十分感谢清华大学做的镜像
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 "you@example.com"
- 修改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代码