ubuntu11.10下CyanogenMod刷机文件的编译及打包(for samsung I9100)

昨天刚完成了CyanogenMod刷机包的编译,并在i9100上刷成功。在此记录下过程,以供以后查阅和广大群众们参考。

一、前言篇

在编译之前,我首先把港行的系统刷成了CM 7.1系统,重做了内核。

刷机ROM及相关文件下载地址:http://dl.dbank.com/c0kxb56tek#

包括gapps-gb-20110828-signed.zip,Odin3-v1.85.zip,recovery-clockwork-4.0.1.4-galaxys2.tar,update-cm-7.1.0-GalaxyS2-signed.zip四个文件。

流程完全参照http://bbs.gfan.com/thread-2916412-1-1.html

刷完系统如下:

ubuntu11.10下CyanogenMod刷机文件的编译及打包(for samsung I9100)

不多说,过程都很单一直接照做,下面是Rom编译过程。

 

二、下载CyanogenMod源码

CM wiki:http://wiki.cyanogenmod.com/wiki/Samsung_Galaxy_S_II:_Compile_CyanogenMod_(Linux)

关于获取源码的准备工作(包括初始化repo,安装编译依赖包等),在之前的文章中(http://www.cnblogs.com/dwayne/archive/2011/11/16/2250732.html)已经详细概括了,这里补充一点:

根据CM wiki提供的信息,安装如下包:

For 32-bit & 64-bit systems:

git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.6-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev sun-java6-jdk pngcrush schedtool

针对I9100,下载gingerbread版本

 

$repo init -u git://github.com/CyanogenMod/android.git -b gingerbread

折腾了三天,鉴于破烂的网速 导致下载过程极其惨烈。源码总大小约4G。

Fetching projects: 100% (313/313), done. 
Checking out files: 100% (3863/3863), done.ut files: 9% (377/3863)
Checking out files: 100% (1794/1794), done. out files: 32% (579/1794)
Checking out files: 100% (4679/4679), done.
Checking out files: 100% (4573/4573), done. out files: 20% (941/4573)
Checking out files: 100% (644/644), done.ng out files: 23% (153/644)
Checking out files: 100% (1222/1222), done. out files: 21% (263/1222)
Checking out files: 100% (10012/10012), done.
Checking out files: 100% (12550/12550), done.ut files: 0% (17/12550)
Checking out files: 100% (5192/5192), done. out files: 29% (1519/5192)
Checking out files: 100% (10462/10462), done.ut files: 0% (16/10462)
Checking out files: 100% (1330/1330), done.
Syncing work tree: 100% (312/312), done.

如果下载过程有碰到问题的话,欢迎和wayne一同交流。接下来准备编译 galaxy s2(samsung i9100)对应的系统版本。

 

三、编译CyanogenMod源码及生成刷机包

首先,读取手机上的配置文件

在/device/samsung目录下,发现对应I9100有galaxys2和galaxys2att两个文件夹,后者为美版AT&T定制机。

连接上手机,下载I9100驱动程序及配置文件相关。

需要注意:手机需要先刷好CM系统(You will need to have a Galaxys2 with a working copy of CyanogenMod install and ADB working on the computer.),不然对应的文件结构不一样,后面编译时通不过。

wayne@wayne-pc:~/Android/cyanogenmod/device/samsung/galaxys2$ ./extract-files.sh

这条命令在源码的vendor目录中创建了对应所要编译系统版本的文件夹,用于从手机上获取驱动等设备的配置信息。

2470 KB/s (594465 bytes in 0.234s)
451 KB/s (38376 bytes in 0.083s)
3245 KB/s (2694945 bytes in 0.811s)
908 KB/s (78024 bytes in 0.083s)
547 KB/s (55132 bytes in 0.098s)
771 KB/s (73996 bytes in 0.093s)
2772 KB/s (905356 bytes in 0.318s)
436 KB/s (36756 bytes in 0.082s)
460 KB/s (40968 bytes in 0.086s)
464 KB/s (22220 bytes in 0.046s)
176 KB/s (14028 bytes in 0.077s)
457 KB/s (21616 bytes in 0.046s)

注意:此处不应有错误。

接下来需要下载一些CyanogenMod需要的一些文件,包括RomManager以及Google提供的一些apk。

wayne@wayne-pc:~/Android/cyanogenmod/vendor/cyanogen$ ./get-rommanager

get-rommanager文件内容如下:

mkdir -p `dirname $0`/proprietary
curl -L -o `dirname $0`/proprietary/RomManager.apk -O -L http://download.clockworkmod.com/recoveries/RomManager.apk

此命令用于下载RomManager.apk这个包主要是刷rom用。

下载网站的连接性很不好,我下载了好多次都没能成功……

如果下载速度不行的话就跟wayne一样直接从网站上下载下来,放在/proprietary目录下。

继续,从手机中拷贝一些google开发的apk包,放在proprietary目录下。

wayne@wayne-pc:~/Android/cyanogenmod/vendor/cyanogen$ ./extract-google-files 
2317 KB/s (305096 bytes in 0.128s)
remote object '/system/app/CarHomeLauncher.apk' does not exist
remote object '/system/app/Facebook.apk' does not exist
2352 KB/s (679951 bytes in 0.282s)
remote object '/system/app/Gmail.apk' does not exist
413 KB/s (36561 bytes in 0.086s)
1044 KB/s (113455 bytes in 0.106s)
1070 KB/s (125406 bytes in 0.114s)
1154 KB/s (78790 bytes in 0.066s)
596 KB/s (55212 bytes in 0.090s)
2151 KB/s (471689 bytes in 0.214s)
2961 KB/s (2238785 bytes in 0.738s)
remote object '/system/app/HtcCopyright.apk' does not exist
remote object '/system/app/HtcEmailPolicy.apk' does not exist
remote object '/system/app/HtcSettings.apk' does not exist
remote object '/system/app/LatinImeGoogle.apk' does not exist
873 KB/s (91439 bytes in 0.102s)
remote object '/system/app/Maps.apk' does not exist
90 KB/s (7244 bytes in 0.078s)
1718 KB/s (270892 bytes in 0.153s)
1007 KB/s (109533 bytes in 0.106s)
89 KB/s (7186 bytes in 0.078s)
remote object '/system/app/PassionQuickOffice.apk' does not exist
2537 KB/s (448428 bytes in 0.172s)
remote object '/system/app/Street.apk' does not exist
2707 KB/s (611357 bytes in 0.220s)
remote object '/system/app/Twitter.apk' does not exist
3051 KB/s (3369731 bytes in 1.078s)
remote object '/system/app/VoiceSearch.apk' does not exist
remote object '/system/app/YouTube.apk' does not exist
remote object '/system/app/googlevoice.apk' does not exist
remote object '/system/app/kickback.apk' does not exist
remote object '/system/app/soundback.apk' does not exist
remote object '/system/app/talkback.apk' does not exist
10 KB/s (816 bytes in 0.078s)
10 KB/s (840 bytes in 0.077s)
1292 KB/s (166648 bytes in 0.125s)
remote object '/system/lib/libspeech.so' does not exist

这里有些软件找不到,没什么关系,不用管它们。

下面开始初始化脚本并编译:

wayne@wayne-pc:~/Android/cyanogenmod$ source build/envsetup.sh 
including device/advent/vega/vendorsetup.sh
including device/bn/encore/vendorsetup.sh
including device/geeksphone/one/vendorsetup.sh
including device/htc/ace/vendorsetup.sh
including device/htc/bravoc/vendorsetup.sh
including device/htc/bravo/vendorsetup.sh
including device/htc/buzz/vendorsetup.sh
including device/htc/click/vendorsetup.sh
including device/htc/desirec/vendorsetup.sh

接下来lunch我们所要编译的版本

wayne@wayne-pc:~/Android/cyanogenmod$ lunch cyanogen_galaxys2-eng

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.3.7
TARGET_PRODUCT=cyanogen_galaxys2
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=GINGERBREAD
============================================

开始编译

wayne@wayne-pc:~/Android/cyanogenmod$ make -j2 CYANOGEN_WITH_GOOGLE=trueotapackage

Attention:wayne在快编译完时,出现error(推荐大家直接用下面解决的方法编译):

Checking API: checkapi-last
Checking API: checkapi-current
(unknown): error 13: Class android.app.Profile changed final qualifier
(unknown): error 13: Class android.app.ProfileGroup changed final qualifier
(unknown): error 24: Method android.app.ProfileManager.getProfile has changed deprecation state
(unknown): error 24: Method android.app.ProfileManager.setActiveProfile has changed deprecation state
(unknown): error 3: Added class MultiSelectListPreference to package android.preference
(unknown): error 4: Added public method android.app.Profile.getProfileGroup
(unknown): error 4: Added public method android.app.Profile.getStatusBarIndicator
(unknown): error 4: Added public method android.app.Profile.getUuid
(unknown): error 4: Added public method android.app.Profile.setStatusBarIndicator
(unknown): error 4: Added public method android.app.ProfileGroup.getUuid
(unknown): error 4: Added public method android.app.ProfileManager.getProfile
(unknown): error 4: Added public method android.app.ProfileManager.profileExists
(unknown): error 4: Added public method android.app.ProfileManager.setActiveProfile
(unknown): error 4: Added public method android.telephony.TelephonyManager.isDormancyRejected
(unknown): error 4: Added public method android.telephony.TelephonyManager.setDormancyRejected
(unknown): error 5: Added public field android.Manifest.permission.RAW_AUDIO
(unknown): error 9: Removed public method android.app.Profile.getProfileGroup
(unknown): error 9: Removed public method android.app.ProfileGroup.getName

******************************
You have tried to change the API from what has been previously approved.

To make these errors go away, you have two choices:
1) You can add "@hide" javadoc comments to the methods, etc. listed in the
errors above.

2) You can update current.xml by executing the following command:
make update-api

To submit the revised current.xml to the main Android repository,
you will need approval.
******************************



make: *** [out/target/common/obj/PACKAGING/checkapi-current-timestamp] Error 38
make: *** Waiting for unfinished jobs....
htmlDir not a directory: out/target/common/docs/gen
DroidDoc took 369 sec. to write docs to out/target/common/docs/doc-comment-check

安装提示解决方法,更新current.xml

wayne@wayne-pc:~/Android/cyanogenmod$ make update-api
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.3.7
TARGET_PRODUCT=cyanogen_galaxys2
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=GINGERBREAD
============================================

>>>
No private recovery resources for TARGET_DEVICE galaxys2
Install: out/host/linux-x86/framework/apicheck.jar
Install: out/host/linux-x86/framework/clearsilver.jar
Install: out/host/linux-x86/framework/droiddoc.jar
Install: out/host/linux-x86/lib/libneo_util.so
Install: out/host/linux-x86/lib/libneo_cs.so
Install: out/host/linux-x86/lib/libneo_cgi.so
Install: out/host/linux-x86/lib/libclearsilver-jni.so
Copying: out/target/common/obj/JAVA_LIBRARIES/core_intermediates/emma_out/lib/classes-jarjar.jar
Install: out/host/linux-x86/framework/dx.jar
Install: out/host/linux-x86/bin/dx
Install: out/host/linux-x86/bin/aapt
Copying: out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/emma_out/lib/classes-jarjar.jar
Copying: out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/emma_out/lib/classes-jarjar.jar
Install: out/host/linux-x86/bin/aidl
Copying: out/target/common/obj/JAVA_LIBRARIES/core-junit_intermediates/emma_out/lib/classes-jarjar.jar
Copying: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/emma_out/lib/classes-jarjar.jar
Copying current.xml

到这里,wayne打包没能成功,提示错误:

wayne@wayne-pc:~/Android/cyanogenmod$ ./vendor/cyanogen/tools/squisher 
/home/wayne/Android/cyanogenmod/out/target/product/galaxys2/cyanogen_galaxys2-ota-eng.wayne.zip doesn't exist!

Google了半天没有找到解决方法,只好跑到CyanogenMod网站上去查看官方编译流程。

准备重新编译,make clean后执行

$. build/envsetup.sh && brunch galaxys2

两小时的等待过后,终于成功打包!

Sanitizing environment...
Unpacking /home/wayne/Android/cyanogenmod/out/target/product/galaxys2/cyanogen_galaxys2-ota-eng.wayne.zip...
Optimizing framework-res.apk...
Optimizing SoundRecorder.apk...


Zipping package...
Signing package...
Cleaning up...

Package complete: /home/wayne/Android/cyanogenmod/out/target/product/galaxys2/update-cm-7.2.0-RC0-GalaxyS2-KANG-signed.zip
1ac405ca21cf130e216ecd782e992d77 update-cm-7.2.0-RC0-GalaxyS2-KANG-signed.zip

在/out/target/product/galaxys2目录下生成了ROM文件cyanogen_galaxys2-ota-eng.wayne.zip和update-cm-7.2.0-RC0-GalaxyS2-KANG-signed.zip 后者是在前者的基础上优化后的。

接下来,使用update-cm-7.2.0-RC0-GalaxyS2-KANG-signed.zip进行刷机即可。

步骤前言篇,完成后,系统信息如下图

ubuntu11.10下CyanogenMod刷机文件的编译及打包(for samsung I9100)

到此,ubuntu11.10下CyanogenMod刷机文件的编译及打包就在Galaxy SII上实验成功了,终于可以在真机上调试修改源码了,后续wayne就开始源码修改了。还是一样,欢迎交流指正!

 

你可能感兴趣的:(ubuntu)