下載Android源碼

如下操做均是在Ubuntu下操做:

 

1. 安裝git

$ sudo apt-get install git-core

2. 配置git

$ git config --global user.name  "name"
$ git config --global user.email  "email"

3. 下載repo

$ cd ~ #進入home目錄
$ mkdir bin #建立bin目錄用於存放Repo腳本
$ PATH=~/bin:$PATH #將bin目錄加入系統路徑中
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo #curl是一個基於命令
#行的文件傳輸工具,它支持不少協議。這裏利用curl來說repo保存到相應目錄下
$ chmod a+x ~/bin/repo

4. 配置repo

$ mkdir source #用於存放整個項目的源碼
$ cd source
$ repo init -u https://android.googlesource.com/platform/manifest #init命令用於初始化
#repo並獲得近期的版本更新信息。若是你想獲取某個非master分支的代碼,須要在命令最後加上-b選項。如:
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
#完成配置後,repo會有以下提示:repo initialized in /home/android,這時在你的機器home目錄下會有
#一個.repo目錄,用於記錄manifrest等信息。

由於google的服務起連接問題,這裏能夠將上述信息修改成如下內容:android

打開~/bin/repo,並修改此行代碼爲:git

REPO_URL = 'https://gerrit-google.tuna.tsinghua.edu.cn/git-repo'

而後將命令:api

$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1

修改成:bash

$ repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-4.0.1_r1

5. 下載源碼

$ repo sync

 

 

以上鏡像來自清華大學開源軟件鏡像站:https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/curl

相關文章
相關標籤/搜索