android源码下载相关
1. 安装相关
sudo apt-get install git-core curl
2.下载repo
比如:curl "http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo" > '/home/用户/bin/repo'
即将http网址上的repo文件传送到本地,也可以用其它方法下载repo。
给repo赋可执行权限:chmod a+x '/home/用户/bin/repo'
3.修改可用的host,因为很多下载网址不能正常访问
在/etc/hosts 中添加如下两行
可用ip android.googlesource.com
可用ip gerrit.googlesource.com
如何获取可用ip,可以参考http://www.williamlong.info/archives/3983.html
笔者当时用79.101.110.148是可以使用的。
4.新建一个文件夹,比如android5.0
cd到android5.0
repo init -u https://android.googlesource.com/platform/manifest -b android-5.0.0_r2
通过ctrl+h查看隐藏文件夹,可以看到android5.0/.repo/manifest.xml,
修改fetch=".."成fetch="git://Android.git.linaro.org/"
否则,在repo sync时会出现“fatal: '../platform/abi/cpp.git' does not appear to be a git repository”的错误。
5. repo sync
运行repo sync时,有时因为网络问题,会中断下载。
可以在android5.0目录下写一个shell脚本比如download.sh:
#!/bin/sh
repo sync -j16
while [ $? -ne 0 ]
do
repo sync -j16
done
虽然不是断点续传,但也可以解决反复执行repo sync所带来的耗时耗力以及.repo文件夹越来越大的问题。
执行download.sh这个脚本
6.如果想切换分支
如:/android5.0/.repo/manifests$ git branch -a | cut -d / -f 3
* default看到有个android-5.1.1_r1分支
想切换过去:
android5.0/.repo/manifests$ repo init -b android-5.1.1_r1
error: .repo/manifests/: contains uncommitted changes,出错了。
是因为上面第4步修改了fetch了。现在修改回来fetch=".."。
再运行repo init -b android-5.1.1_r1,看到成功了。
现在,又改回来fetch="git://Android.git.linaro.org/"
同步代码:/android5.0/.repo/manifests$ repo sync -j16
最后,查看一下现在的分支:repo branches