1. 直接从官方下载
新建一个用于存放下载脚本文件的目录
mkdir ~/bin
PATH=~/bin:$PATH
下载Repo脚本文件
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
创建用于存放Android源代码的目录
mkdir android_source
cd android_source
初始化
repo init -u https://android.googlesource.com/platform/manifest
同步Android源代码
repo sync
2. 从镜像下载
修改repo文件
vim ~/bin/repo
REPO_URL = 'https://gerrit.googlesource.com/git-repo'
改为
REPO_URL = 'https://gerrit-google.tuna.tsinghua.edu.cn/git-repo'
初始化
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
如果需要设置版本,加入参数-b 安卓源码版本号即可。
repo sync -j4
后面-j4表示4个线程进行下载