本文主要记录了在下载slim源码时遇到的一些问题。
1.找到slim在github的地址:https://github.com/SlimRoms。找到仓库platform_manifest点击进去,就能够看到下载源码的方法了。
$ repo init -u git://github.com/SlimRoms/platform_manifest.git -b jb4.3
$ repo sync
2、下载repo。
因为android代码过于庞大,所以google发明了repo来分仓库下载源码。所以我们需要先下载repo。在官方的网站上google已经给出了repo的下载地址http://source.android.com/source/downloading.html,但是由于在国内,很多情况下像google这种不正经的网站是会被和谐的,反正我是从来没有成功通过官方地址下载repo过,这种概率比我上某些网上还低,由此可见上级对我们的精神文明建设是多么地重视啊。言归正转,repo只是一个工具,所以我们完全可以从其他网站下载,如执行一下命令就可以下载:
curl http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo > ~/bin/repo 但我在执行时报找不到curl,于是执行
sudo apt-get install curl
报如下错误:
error:
E: 未发现软件包 git
这是未更新软件源的缘故,执行
sudo apt-get update 更新完成后重新安装curl成功。
重新下载repo:
curl http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo > ~/bin/repo 更改repo权限:
chmod a+x ~/bin/repo 更改~/.bashrc,添加repo到系统目录,在文件尾添加:
PATH=/home/username/bin/:$PATH
source ~/.bashrc
现在终于可以执行repo了。
3、下载slim对应的的repo
执行命令:
repo init -u git://github.com/SlimRoms/platform_manifest.git -b jb4.3
如果顺利的话能够成功init。但一般不会顺利,尤其之前没有下载过源码,
首先出现如下错误:
Traceback (most recent call last):
File "/home/helei/bin/repo", line 603, in
main(sys.argv[1:])
File "/home/helei/bin/repo", line 570, in main
_Init(args)
File "/home/helei/bin/repo", line 184, in _Init
_CheckGitVersion()
File "/home/helei/bin/repo", line 213, in _CheckGitVersion
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
File "/usr/lib/python2.6/subprocess.py", line 623, in __init__
errread, errwrite)
File "/usr/lib/python2.6/subprocess.py", line 1141, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory 这是由于没有安装git,安装git:
sudo apt-get install git
sudo apt-get install git-core
安装完git再次init,出现如下 错误:
fatal: unable to auto-detect email address (got 'sheldon@username-MS-7699.(none)') 按照错误提示添加自己的邮箱和name,随便填一个有效的邮箱即可:
git config --global user.email "you@example.com"
git config --global user.name "Your Name" 再次重新init,显示init成功,执行ls -l会发现多了一个隐藏目录.repo。
4、下载代码。
终于到了最后一步,胜利就在前方了,按照官方的步骤,潇洒地敲下
repo sync
如果顺利能够看到开始下载的文件,但是一般不会顺利,
如果报无法访问googlesource的错误,那是因为下载过程中会频繁访问google网站,google为防止攻击而拒绝访问,可以通过google网站获取到key后继续下载,具体方法请查找其他文章。
如果你的界面一直卡在如下界面
Initializing project platform/abi/cpp ... 那是因为国内很难访问到google网站,你可以从其他网站下载代码。具体做法如下:
打开.repo/manifest.xml。找到下面一段:
fetch="https://android.googlesource.com/" /> 更改为: fetch="git://Android.git.linaro.org/"/> 保存后重新sync,这下应该能够看到进度了,接下来就是漫长的等待了。 因为代码过大,下载过程中会出现错误。可以做一个自动下载的脚本: #!/bin/sh echo "***********************begin to sync***********************" repo sync while [ $? -ne 0 ] do echo "*********************sync failed, sync again***************" repo sync done 接下来就等待代码下载下来吧。。。