源码下载
下载 repo 工具:
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
建立工作目录:
mkdir WORKING_DIRECTORY
cd WORKING_DIRECTORY
初始化仓库:
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
# 或 repo init -u git://aosp.tuna.tsinghua.edu.cn/aosp/platform/manifest
## 如果提示无法连接到 gerrit.googlesource.com,可以编辑 ~/bin/repo,把 REPO_URL 一行替换成下面的:
REPO_URL = 'https://gerrit-google.tuna.tsinghua.edu.cn/git-repo'
如果需要某个特定的 Android 版本(列表):
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-6.0.1_r16 #android-6.0.1_r16为版本号,可替换!
同步源码树(以后只需执行这条命令来同步):
repo sync
使用每月更新的初始化包
由于首次同步需要下载 37GB 数据,过程中任何网络故障都可能造成同步失败,因此你可以选择使用每月更新的初始化包。
首先到 http://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/ 选择合适自己的构建包,aosp-latest.tar.xz 经过了 xz 压缩, 相对 aosp-latest.tar 小一些,但是解压的时间也要考虑进来,27G的压缩包呢!(如果CPU核多可以使用pxz解压)
使用方法如下:
wget http://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar # 下载初始化包
tar xf aosp-latest.tar
cd AOSP # 解压得到的 AOSP 工程目录
repo sync # 正常同步
建立次级镜像
由于 AOSP 镜像需求量巨大,且 Git 服务占资源较多,TUNA 服务器因 AOSP 产生的负载已经占主要部分。 如果你是团队用户,我们强烈建议你通过 TUNA 建立次级镜像,再分享给团队内其他用户,减轻 TUNA 服务器压力。 建立 AOSP 镜像需要占用约 80G 磁盘。
具体步骤为:
下载 repo 工具和建立工作目录(略)
初始化:
repo init -u https://aosp.tuna.tsinghua.edu.cn/mirror/manifest --mirror
同步源码树:
repo sync
同步完成后,运行 git daemon –verbose –export-all –base-path=WORKING_DIR WORKING_DIR (WORKING_DIR为代码树所在目录) 。
此后,其他用户使用 git://ip.to.mirror/ 作为镜像即可。