1. 程式人生 > >下載android4.4.2原始碼全過程(附已下載的原始碼)

下載android4.4.2原始碼全過程(附已下載的原始碼)

今天在下載andriod原始碼,特來與大家分享一下我的經驗。

當然,網上教下載原始碼的教程較多,本文主要針對在GFW下下載原始碼出現的各種問題的解決方法。

1、首先安裝下載clientgit , curl。

命令例如以下:

sudo apt-get install curl git

2、建立一個bin資料夾,加入到PATH當中。

mkdir ~/bin
PATH=~/bin:$PATH

3、下載repo的指令碼並加入可執行許可權。

curl http://git-repo.googlecode.com/files/repo-1.13 > ~/bin/repo
chmod a+x ~/bin/repo

在這裡。問題就出來了。

自5月底開始,谷歌的相關網站,基本上都已經不能直接訪問了,當然,我一直用goagentFQ,所受影響不大。除了打不開tools.android.com這個網站之外。

在這裡。我假設你已經有代理工具的了(假設沒有,會折騰的用goagent,不會折騰的一個月花幾塊錢買一個)。

以下我們就須要設定curl的代理,方法非常easy。加個引數 -x 代理地址。

比方我的代理server為我在局域網裡的還有一部電腦。IP為192.168.137.1,埠為8087.那麼上面下載 repo指令碼的命令就應該為:

curl -x 192.168.137.1:8087 http://git-repo.googlecode.com/files/repo-1.13 > ~/bin/repo

下載之後,再改動許可權,如上面所看到的。


4、建立原始碼資料夾並進入。

mkdir android4.4.2
cd android4.4.2

5、初始化repo。

repo init -u https://android.googlesource.com/platform/manifest -b android-cts-4.2_r2
在-b後面跟著的是分支名。不出意外,這裡問題又來了。googlesource.com網站被牆。所以這裡不能直接下載,須要設定程式碼。這裡設定程式碼非常easy,設定一下https.proxy的變數就能夠了。

例如以下:

https_proxy=192.168.137.1:8087

後面相應的值記得改回你自己的代理server地址及埠。

(補述,http的代理也要設定 。後面下載程式碼會用到,方法同上。設定一下http_proxy變數。

然後我們再執行初始化。這時。問題又來了。控制檯輸出:

Get https://code.google.com/p/git-repo/
error: server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none while accessing https://code.google.com/p/git-repo/info/refs
fatal: HTTP request failed
顯示是證書問題。匯入證書我不知道怎麼整,只是我找到了還有一種方法,就是取消GIT的SSL驗證。命令例如以下:

export GIT_SSL_NO_VERIFY=1

然後我們再執行初始化,這時成功了(假設網路斷開請多試一試)。

6、下載原始碼。

最後,執行repo sync就可以。

7、關於獲取原始碼清單

以下說一下怎樣獲取各個版本號的分支名。

首先。沒有設定代理的要先設定GIT的代理,例如以下:

export https_proxy=192.168.137.1:8087
export https_proxy=192.168.137.1:8087
export GIT_SSL_NO_VERIFY=1
當中第一、二行各自是設定http及https的代理server。後面的值改動為你自己的取代server的地址。

第三行是取消SSL驗證,不然會出現SSL驗證問題。

然後執行以下命令克隆該git 倉庫。

 git clone https://android.googlesource.com/platform/manifest
接著執行git branch -a,就可以得到各分支名,例如以下:
[email protected]:~/code/A/manifest$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/android-1.6_r1
  remotes/origin/android-1.6_r1.1
  remotes/origin/android-1.6_r1.2
  remotes/origin/android-1.6_r1.3
  remotes/origin/android-1.6_r1.4
  remotes/origin/android-1.6_r1.5
  remotes/origin/android-1.6_r2
  remotes/origin/android-2.0.1_r1
  remotes/origin/android-2.0_r1
  remotes/origin/android-2.1_r1
  remotes/origin/android-2.1_r2
  remotes/origin/android-2.1_r2.1p
  remotes/origin/android-2.1_r2.1p2
  remotes/origin/android-2.1_r2.1s
  remotes/origin/android-2.2.1_r1
  remotes/origin/android-2.2.1_r2
  remotes/origin/android-2.2.2_r1
  remotes/origin/android-2.2.3_r1
  remotes/origin/android-2.2.3_r2
  remotes/origin/android-2.2.3_r2.1
  remotes/origin/android-2.2_r1
  remotes/origin/android-2.2_r1.1
  remotes/origin/android-2.2_r1.2
  remotes/origin/android-2.2_r1.3
  remotes/origin/android-2.3.1_r1
  remotes/origin/android-2.3.2_r1
  remotes/origin/android-2.3.3_r1
  remotes/origin/android-2.3.3_r1.1
  remotes/origin/android-2.3.4_r0.9
  remotes/origin/android-2.3.4_r1
  remotes/origin/android-2.3.5_r1
  remotes/origin/android-2.3.6_r0.9
  remotes/origin/android-2.3.6_r1
  remotes/origin/android-2.3.7_r1
  remotes/origin/android-2.3_r1
  remotes/origin/android-4.0.1_r1
  remotes/origin/android-4.0.1_r1.1
  remotes/origin/android-4.0.1_r1.2
  remotes/origin/android-4.0.2_r1
  remotes/origin/android-4.0.3_r1
  remotes/origin/android-4.0.3_r1.1
  remotes/origin/android-4.0.4_r1
  remotes/origin/android-4.0.4_r1.1
  remotes/origin/android-4.0.4_r1.2
  remotes/origin/android-4.0.4_r2
  remotes/origin/android-4.0.4_r2.1
  remotes/origin/android-4.1.1_r1
  remotes/origin/android-4.1.1_r1.1
  remotes/origin/android-4.1.1_r2
  remotes/origin/android-4.1.1_r3
  remotes/origin/android-4.1.1_r4
  remotes/origin/android-4.1.1_r5
  remotes/origin/android-4.1.1_r6
  remotes/origin/android-4.1.1_r6.1
  remotes/origin/android-4.1.2_r1
  remotes/origin/android-4.1.2_r2
  remotes/origin/android-4.1.2_r2.1
  remotes/origin/android-4.2.1_r1
  remotes/origin/android-4.2.1_r1.1
  remotes/origin/android-4.2.1_r1.2
  remotes/origin/android-4.2.2_r1
  remotes/origin/android-4.2.2_r1.1
  remotes/origin/android-4.2.2_r1.2
  remotes/origin/android-4.2.2_r1.2b
  remotes/origin/android-4.2_r1
  remotes/origin/android-4.3.1_r1
  remotes/origin/android-4.3_r0.9
  remotes/origin/android-4.3_r0.9.1
  remotes/origin/android-4.3_r1
  remotes/origin/android-4.3_r1.1
  remotes/origin/android-4.3_r2
  remotes/origin/android-4.3_r2.1
  remotes/origin/android-4.3_r2.2
  remotes/origin/android-4.3_r2.2-cts
  remotes/origin/android-4.3_r2.3
  remotes/origin/android-4.3_r3
  remotes/origin/android-4.3_r3.1
  remotes/origin/android-4.4.1_r1
  remotes/origin/android-4.4.2_r1
  remotes/origin/android-4.4.2_r2
  remotes/origin/android-4.4.3_r1
  remotes/origin/android-4.4.3_r1.1
  remotes/origin/android-4.4.4_r1
  remotes/origin/android-4.4_r1
  remotes/origin/android-4.4_r1.1
  remotes/origin/android-4.4_r1.2
  remotes/origin/android-cts-2.2_r8
  remotes/origin/android-cts-2.3_r10
  remotes/origin/android-cts-2.3_r11
  remotes/origin/android-cts-2.3_r12
  remotes/origin/android-cts-4.0.3_r1
  remotes/origin/android-cts-4.0.3_r2
  remotes/origin/android-cts-4.0_r1
  remotes/origin/android-cts-4.1_r1
  remotes/origin/android-cts-4.1_r2
  remotes/origin/android-cts-4.1_r4
  remotes/origin/android-cts-4.2_r2
  remotes/origin/android-cts-verifier-4.0.3_r1
  remotes/origin/android-cts-verifier-4.0_r1
  remotes/origin/android-sdk-4.0.3-tools_r1
  remotes/origin/android-sdk-4.0.3_r1
  remotes/origin/android-sdk-4.4.2_r1
  remotes/origin/android-sdk-adt_r16.0.1
  remotes/origin/android-sdk-adt_r20
  remotes/origin/android-sdk-support_r11
  remotes/origin/chromium-dev
  remotes/origin/froyo
  remotes/origin/gingerbread
  remotes/origin/gingerbread-release
  remotes/origin/ics-mr0
  remotes/origin/ics-mr1
  remotes/origin/ics-plus-aosp
  remotes/origin/idea133
  remotes/origin/idea133-weekly-release
  remotes/origin/jb-dev
  remotes/origin/jb-mr1-dev
  remotes/origin/jb-mr1-dev-plus-aosp
  remotes/origin/jb-mr1.1-dev
  remotes/origin/jb-mr1.1-dev-plus-aosp
  remotes/origin/jb-mr2-dev
  remotes/origin/jumper-stable
  remotes/origin/kitkat-cts-dev
  remotes/origin/kitkat-dev
  remotes/origin/l-preview
  remotes/origin/master
  remotes/origin/master-art
  remotes/origin/master-art-host
  remotes/origin/master-dalvik
  remotes/origin/master-dalvik-host
  remotes/origin/tools-canary-release
  remotes/origin/tools_ndk_r9d
  remotes/origin/tools_r20
  remotes/origin/tools_r21
  remotes/origin/tools_r21.1
  remotes/origin/tools_r22
  remotes/origin/tools_r22.2
  remotes/origin/tools_r22.6
  remotes/origin/tradefed
  remotes/origin/ub-tools-idea133
  remotes/origin/ub-tools-idea133-milestone
  remotes/origin/ub-tools-idea133-release
  remotes/origin/ub-tools-master




最後。附上我已經下載好的原始碼:http://zdz.la/KN8Nai

我下載的東西,事實上有51G左右,當中.repo佔了約42G。下載原始碼請留夠硬碟