十分感謝清華大學做的鏡像
AOSP推薦的方法
安裝 Repo
- 確信在/home目錄下有bin/目錄,並且添加到環境變量中
$ mkdir ~/bin
$ PATH=~/bin:$PATH
- 下載Repo工具,並賦予可執行 權限:
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
各個Repo版本的SHA-1檢驗和如下:
1.21: b8bd1804f432ecf1bab730949c82b93b0fc5fede
1.22: da0514e484f74648a890c0467d61ca415379f791
1.23: ac9d646f6d699f6822a6bc787d3e7338ae7ab6ed
初始化Repo 客戶端
After installing Repo, set up your client to access the Android source repository:
Create an empty directory to hold your working files. If you’re using MacOS, this has to be on a case-sensitive filesystem. Give it any name you like:
- 創建自己的工作目錄:
$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY
- 配置自己的真實名字和email地址(可以忽略)。如果使用Gerrit工具,需要和google account綁定的email地址。
$ git config --global user.name "Your Name"
$ git config --global user.email "[email protected]"
- 修改repo 文件(新加的,不是AOSP的步驟)
將~/bin/repo中:
REPO_URL = 'https://gerrit.googlesource.com/git-repo' 替換爲 REPO_URL = 'https://gerrit-google.tuna.tsinghua.edu.cn/git-repo'
- 運行repo init初始化代碼倉庫
$ repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-7.0.0_r4
下載Android代碼樹
$ repo sync
使用清華每月更新的初始化包
wget https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar # 下載初始化包
tar xf aosp-latest.tar
cd AOSP # 解壓得到的 AOSP 工程目錄
# 這時 ls 的話什麼也看不到,因爲只有一個隱藏的 .repo 目錄
repo sync # 正常同步一遍即可得到完整目錄
# 或 repo sync -l 僅checkout代碼