Android (AOSP) 源测试上线。Android (AOSP) 镜像使用帮助

每天凌晨 04:30 同步一次。

目前 AOSP 源提供 git 和 http 两种同步方式,推荐使用 git 同步。

为方便墙内用户访问 repo 工具所在的 storage.googleapis.comgerrit.googlesource.com,我们提供了代理,具体用法见 Android (AOSP) 镜像使用帮助

为了不引入额外的 git daemon,目前仅提供 HTTP 服务,同步过程中不会显示进度,而且由于不支持 --depth 选项,部分项目可能同步失败。

如果发现某些项目同步失败,可以使用 repo sync -f 强制同步。我们会修复此问题。


以下供镜像维护者阅读。

mirrors 从官方同步每个 git 仓库后,由于我们是 dumb http server 而非 git daemon,需要运行 git update-server-info 生成仓库内容列表文件。修改 .repo/repo/subcmds/sync.py(repo sync 命令的实现)如下:

diff --git a/subcmds/sync.py b/subcmds/sync.py
index b1945d5..5c59534 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -275,6 +275,8 @@ later is required to fix a server side protocol bug.
           no_tags=opt.no_tags, archive=self.manifest.IsArchive)
         self._fetch_times.Set(project, time.time() - start)

+        os.system('cd %s; git update-server-info' % project.gitdir)
+
         # Lock around all the rest of the code, since printing, updating a set
         # and Progress.update() are not thread safe.
         lock.acquire()

由于 manifest 文件中的路径是不带 .git 后缀的,而文件系统中都是 bare 仓库(从而有 .git 后缀),需要让带 .git 和不带 .git 后缀的都能访问。修改 nginx 配置如下:

    ## AOSP rewrite abc/def/info/refs => abc/def.git/info/refs
    location /aosp {
        rewrite ^/aosp/(.+)\.git/(.*)$ /aosp/$1.git/$2 break; # path including .git keep as it is
        rewrite ^/aosp/(.+?)/(branches|hooks|info|objects|refs)(/.*)?$ /aosp/$1.git/$2$3 break;
        rewrite ^/aosp/(.+?)/(config|description|HEAD|packed-refs)$ /aosp/$1.git/$2 break;
        rewrite ^/aosp/(.*?)/+$ /aosp/$2 break; # remove trailing slashes
        ## note: try_files is executed after all rewrites
        try_files $uri $uri/ $uri.git/ =404;
    }

其中有点 tricky 的是,git 目录中有 info/refsobjects/info/ 这样的文件和目录,如果 ^/aosp/(.+)/(branches|hooks|info|objects|refs) 使用贪婪匹配,就会把路径变成 /aosp/example/info.git/refs 这样,显然是不对的。因此要对 (.+) 部分使用懒惰匹配,即 (.+?)

Git 服务的配置和搭建看这里