CyanogenMod Source Code Download

env ubuntu 14.04 64

mkdir CyanogenMod && cd CyanogenMod
下载repo
curl http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo > ./repo
chmod 755 ./repo
初始化:
./repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0
同步源码:
./repo sync -j4

  • [new tag] android-wear-5.1.0_r1 -> android-wear-5.1.0_r1
  • [new tag] android-wear-5.1.1_r1 -> android-wear-5.1.1_r1
    Fetching projects: 100% (477/477), done.
    Checking out files: 100% (44267/44267), done. files: 22% (10167/44267)
    Checking out files: 100% (6686/6686), done.out files: 24% (1636/6686)
    Checking out files: 100% (9389/9389), done.out files: 32% (3007/9389)
    Checking out files: 100% (50822/50822), done.t files: 3% (1619/50822)
    Checking out files: 100% (10083/10083), done.
    Checking out files: 100% (4307/4307), done.out files: 2% (110/4307)
    Checking out files: 100% (4082/4082), done.out files: 24% (987/4082)
    Checking out files: 100% (3494/3494), done.out files: 10% (376/3494)
    Checking out files: 100% (7954/7954), done.
    Checking out files: 100% (4098/4098), done. out files: 20% (826/4098)
    Checking out files: 100% (11685/11685), done.ut files: 19% (2317/11685)
    Checking out files: 100% (4093/4093), done. out files: 29% (1193/4093)
    Checking out files: 100% (1654/1654), done. out files: 30% (510/1654)
    Checking out files: 100% (23588/23588), done.ut files: 0% (149/23588)
    Checking out files: 100% (4629/4629), done. out files: 34% (1592/4629)
    Checking out files: 100% (8597/8597), done.
    Checking out files: 100% (1765/1765), done. out files: 0% (12/1765)
    Checking out files: 100% (575/575), done.ng out files: 21% (123/575)
    Checking out files: 100% (431/431), done.ng out files: 10% (47/431)
    Checking out files: 100% (181/181), done.ng out files: 48% (87/181)
    Checking out files: 100% (2407/2407), done. out files: 33% (795/2407)
    Checking out files: 100% (2482/2482), done.
    Checking out files: 100% (177/177), done.ng out files: 10% (19/177)
    Checking out files: 100% (182/182), done.
    Checking out files: 100% (50299/50299), done.ut files: 16% (8475/50299)
    Checking out files: 100% (4864/4864), done.
    Checking out files: 100% (182/182), done.ng out files: 7% (14/182)
    Checking out files: 100% (1256/1256), done.
    Checking out files: 100% (53361/53361), done.ut files: 2% (1108/53361)
    Checking out files: 100% (126/126), done.
    Syncing work tree: 100% (477/477), done.

看到最后的 “Syncing work tree: 100% (477/477), done.” 代表代码同步完成。 由于同步代码会比较耗时,且网络不好断开时,没有同步完成的代码会以 tmppack_xxx 的形式保存在.repo/projects/仓库名/objects/pack/tmp_pack_XXX 目录下面,再次同步时会从头开始,若多次断开就会在该目录下存在多个tmp_pack_XXX的临时文件并占用大量空间,该文件会在代码同步完成后被删除,也可以手动删除 find ./ -name tmp_pack* -exec rm -rf {} \;

同步代码时为了防止断网导致同步中断可以用一个shell脚本来循环执行repo sync的操作直到成功:

./repo sync -j16
while [ $? != 0 ]
do
    ### maybe disconnect, try again
    sleep 1
    ./repo sync -j16
done

下面是代码同步完成后的目录结构:

.
├── abi
├── android
├── art
├── bionic
├── bootable
├── build
├── cts
├── dalvik
├── developers
├── development
├── device
├── docs
├── external
├── frameworks
├── hardware
├── kernel
├── libcore
├── libnativehelper
├── Makefile
├── ndk
├── packages
├── pdk
├── prebuilt
├── prebuilts
├── repo
├── sdk
├── sync.sh
├── system
├── tools
└── vendor

来看下整个仓库的大小:

45M    ./developers
118M./development
46M    ./libcore
12M    ./system
4.2G./prebuilts
1.2G./frameworks
11M    ./build
8.0K./kernel
33M    ./sdk
13M    ./art
88M    ./hardware
3.2G./external
12M    ./device
424M./cts
42M    ./dalvik
9.1M./docs
12M    ./bootable
19M    ./bionic
971M./tools
18G    ./.repo
120K./abi
72K    ./android
196K./libnativehelper
260M./prebuilt
89M    ./vendor
382M./packages
916K./pdk
77M    ./ndk
29G.

29G,.repo就占了18G,可见仓库的历史记录占用了很大的空间。代码同步完成就可以开始进行编译定制自己的rom了。