android源码下载方法 批量下载 基于windows os
- 安装win版的Gitbash, 在这里 http://msysgit.googlecode.com/files/Git-1.6.0.2-preview20080923.exe。 选择默认安装路径(否则后面你要手动修改下载的脚本)。 将C:\Program Files\Git\bin 加进系统路径。Android的源码在这里:http://git.source.android.com/
- 为了省去一些麻烦,目前提供下载的脚本,都是将脚本的路径和将要用来存放源代码的路径写成固定的了。 你需要在F盘腾出至少4G的空间。目前来看至少10GB空间。因为我即将下载完成,已经达到6点几G的大小,占用空间达到近9G。如果磁盘空间不足,git会报错,那就麻烦了,我已经吃了这个苦头了。因为据网上说android的source code的size将近3.8G。在F盘根目录下创建android_source_code目录和download_android-source_script。顾名思义,前者用来存放源代码,后者用来存放下载脚本。
- 到这里 https://www.sugarsync.com/pf/D033416_6684866_66541 下载下载脚本,解压将所有文件放置f:\download_android-source_script\ 目录下,注意:该目录下直接就放这些脚本,不要因为解压的原因,再在这脚本外面套上一些多余的文件夹。就是像这样就可以了:
- 开始-->运行-->cmd-->f:-->cd\ -->cd download_android-source_script-->dlBatchFile.bat 然后就能看到如下图的下载界面,比较慢。
下载的进度结果,就写在存放源码目录下的clone_result.log里。要是遇到网络中断,你可以看看你下载到哪了。然后手工修改dlBatchFile.bat
- 其实这些bat脚本和sh脚本使用python脚本生成的,脚本写的很简陋,随便写下,没用心考究,注释都没写,代码如下:
01importos
02
03fileP=open("git_reps.txt","r");
04
05logFileP=open("2.log","w")
06
07forsingleLineinfileP:
08
09if((notsingleLine.startswith("\t"))and(notsingleLine.startswith("\n"))and(notsingleLine.startswith(" "))and(notsingleLine.startswith("\r\n"))):
10
11logFileP.write(singleLine)
12
13fileP.close();
14
15logFileP.close()
16
17
18
19sourceDir="%android_source_code_path%"
20
21allrepsFileP=open("2.log","r")
22
23dlBatchFileP=open("dlBatchFile.bat","w")
24
25gitRepHead="git clone git://android.git.kernel.org/"
26
27#device/htc/passion-common.git
28
29i=0
30
31forsingleAddinallrepsFileP:
32
33i=i+1
34
35singleAdd
36
37gitScriptFileName="git_script_"+singleAdd.replace("/","_")[:-1]+".sh"
38
39lastDa=singleAdd.rfind("/")
40
41singleDir=singleAdd[0:lastDa]
42
43singleDir=singleDir.replace("/","\\")
44
45singleDir
46
47dlBatchFileP.write("if not exist "+singleDir+" md "+singleDir+"\n")
48
49dlBatchFileP.write("cd "+singleDir+"\n")
50
51dlBatchFileP.write("copy "+"F:\\download_android-source_script\\" + gitScriptFileName + "/y \n")
52
53dlBatchFileP.write("\"C:\\Program Files\\Git\\bin\\sh\" "+gitScriptFileName+"\n")
54
55dlBatchFileP.write("del "+gitScriptFileName+"\n")
56
57dlBatchFileP.write("cd \\" + "\n")
58
59dlBatchFileP.write("cd "+sourceDir+"\n")
60
61dlBatchFileP.write("echo "+str(i)+"---::"+singleDir+" >>clone_result.log \n")
62
63dlBatchFileP.write("\n")
64
65spFileP=open(gitScriptFileName,"w")
66
67spFileP.write(gitRepHead+singleAdd[:-1])
68
69spFileP.close()
70
71dlBatchFileP.close()
72
73allrepsFileP.close()#git_reps.txt中是直接从http://git.source.android.com/复制粘贴过来的。
ps:Su Zhengang兄弟在mail list中提到repo,如下,Fyr。
Su Zhengang
发送至 china-android-.显示详细信息 14:26 (2 小时前)
为什么不用repo呢?
下载repo
Download thereposcript and make sure it is executable:
$ curl http://android.git.kernel.org/repo >~/bin/repo$ chmod a+x ~/bin/repo
下载android代码
$ repo init -u git://android.git.kernel.org/platform/manifest.git
$ repo sync
这些就可以了,具体说明: http://source.android.com/source/download.html



浙公网安备 33010602011771号