注意:本镜像是 AOSP 镜像,Android SDK 因版权原因,我们不能提供镜像服务。
可访问 https://cs.android.com 或 https://github.com/aosp-mirror 在线搜索及浏览 AOSP 源码。
参考 Google 教程 https://source.android.com/setup/build/downloading,
将 https://android.googlesource.com/ 全部使用如下链接代替即可。
https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/
由于使用 HTTPS 协议更安全,并且更便于我们灵活处理,所以强烈推荐使用 HTTPS 协议同步 AOSP 镜像。
由于 AOSP 镜像造成 CPU/内存负载过重,我们限制了并发数量,因此建议:
- sync 的时候并发数不宜太高,否则会出现 503 错误,即-j后面的数字不能太大,建议选择 4。
- 请尽量选择流量较小时错峰同步。
过程摘录
下载 repo 工具
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
或者使用 git-repo 镜像
使用每月更新的初始化包
参考 AOSP Monthly 镜像
传统初始化方法
建立工作目录:
mkdir WORKING_DIRECTORY
cd WORKING_DIRECTORY
初始化仓库:
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest
如果提示无法连接到 gerrit.googlesource.com,请参照 git-repo 的帮助页面的更新一节。
如果需要某个特定的 Android 版本 (见「说明」中「Android 版本列表」部分):
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-4.0.1_r1
同步源码树(以后只需执行这条命令来同步):
repo sync
建立次级镜像
由于 AOSP 镜像需求量巨大,且 Git 服务占资源较多,部分镜像站服务器因 AOSP 产生的负载已经占主要部分。
如果你是团队用户,我们强烈建议你建立次级镜像,再分享给团队内其他用户,减轻服务器压力。
建立 AOSP 镜像需要占用约 850G 磁盘。
具体步骤为:
下载 repo 工具和建立工作目录(略)
初始化:
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/mirror/manifest --mirror
最后同步源码树:
repo sync
同步完成后,运行:
git daemon --verbose --export-all --base-path=WORKING_DIR WORKING_DIR`
其中 WORKING_DIR 为代码树所在目录。
此后,其他用户使用 git://ip.to.mirror/ 作为镜像即可。
替换已有的 AOSP 源代码的 remote
如果你之前已经通过某种途径获得了 AOSP 的源码 (或者你只是 init 这一步完成后),
你希望以后通过 TUNA 同步 AOSP 部分的代码,只需要修改 .repo/manifests.git/config,将
url = https://android.googlesource.com/platform/manifest
更改为
url = https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest
或者可以不修改文件,而执行
git config --global url.https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/.insteadof https://android.googlesource.com
说明
通用
镜像的是什么?
AOSP 的 git 仓库
Android 版本列表:https://source.android.com/source/build-numbers.html#source-code-tags-and-builds 或 https://source.android.google.cn/source/build-numbers#source-code-tags-and-builds
镜像站 tags 列表(部分镜像站可浏览)
https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest.git/refs/tags/
出现 curl: (22) The requested URL returned error: 404 Not Found Server does not provide clone.bundle; ignoring. 怎么办?
无视即可。
参见:https://github.com/tuna/issues/issues/936
TUNA/BFSU
为何不能通过浏览器访问?
暂时没有 gitweb, 而且反正是 git bare 仓库,没有可以直接看到的内容。
建议访问 https://cs.android.com 或 https://github.com/aosp-mirror 在线搜索及浏览 AOSP 源码。
USTC
USTC 推荐使用 git:// 协议,只有在无法使用 git:// 推荐使用 http://。
由于硬盘 I/O 资源有限,Git 服务器每 IP 限制 5 个并发连接。
repo sync 命令默认使用 4 个并发连接,请勿使用 -j
参数增加并发连接数。
Brillo
Brillo 项目的代码托管在 AOSP 项目中,镜像站镜像的是整个 AOSP
项目,所以自然也能从本镜像下载 Brillo 项目代码。
参考 Brillo 官方文档
https://developers.google.com/brillo/docs/reference/downloads
进行下载,将其中源码 manifest 地址 改为
https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/brillo/manifest
即 repo init 时,使用
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/brillo/manifest -b master
LineageOS 中对于 AOSP 的替换
打开.repo/manifests/default.xml,将
<remote name="aosp"
fetch="https://android.googlesource.com"
改成
<remote name="aosp"
fetch="https://mirrors.tuna.tsinghua.edu.cn/git/AOSP"
评论