Android 本地版本库建立(Using a local mirror)

1. 安装repo

    $ mkdir ~/bin
    $ echo "export PATH=~/bin:$PATH" >> ~/.bashrc
    $ source ~/.bashrc

获取repo并赋予可执行权限(或者参考google官方网站

    $ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    $ chmod a+x ~/bin/repo

2. 建立本地版本库

    $ mkdir -p /work/git/android
    $ cd /work/git/android
    $ repo init -u https://android.googlesource.com/mirror/manifest --mirror
    $ repo sync -j8

3. 建立本地版本库git访问方式

安装git-daemon

    $sudo apt-get install git-daemon-run

修改配置

    $sudo vi /etc/sv/git-daemon/run
将文件中的最后一行:
    "$(git --exec-path)"/git-daemon --verbose --base-path=/var/cache /var/cache/git
修改为:
    "$(git --exec-path)"/git-daemon --verbose --export-all --base-path=/work/git/ /work/git/
最终效果如下:
    #!/bin/sh
    exec 2>&1
    echo 'git-daemon starting.'
    exec chpst -ugitdaemon 
      "$(git --exec-path)"/git-daemon --verbose --export-all --base-path=/work/git/ /work/git/ 
    #  "$(git --exec-path)"/git-daemon --verbose --base-path=/var/cache /var/cache/git

重启git-daemon服务

    $sudo sv stop git-daemon
    $sudo sv start git-daemon 

查看服务是否启动

    $sudo ps aux | grep "git"

4. 使用本地版本库(服务器地址为192.168.1.183)

通过git访问使用(默认你已经自行安装配置好repo):

    $ repo init -u git://192.168.1.183/android/platform/manifest.git --repo-url=git://192.168.1.183/android/tools/repo.git
或指定版本
    $ repo init -u git://192.168.1.183/android/platform/manifest.git -b android-4.1.1_r2 --repo-url=git://192.168.1.183/android/tools/repo.git

在192.168.1.183上本地目录访问:

    repo init -u /work/git/android/platform/manifest.git --repo-url=/work/git/android/tools/repo.git
或指定版本
    repo init -u /work/git/android/platform/manifest.git  -b android-4.1.1_r2 --repo-url=/work/git/android/tools/repo.git

可参考google官方网站

By Leslie Guan

原文地址:https://www.cnblogs.com/GMCisMarkdownCraftsman/p/3769704.html