搭建 android 代码镜像服务

1. 搭建 git 服务器

git服务器有很多,比如使用android 提供的 gerrit 服务器,安装方法参见 gerrit 环境搭建

2 同步远程库

$ mkdir ~/review_site/git/google
$ cd ~/review_site/git/google
$ repo init -u https://android.googlesource.com/platform/manifest
$ head -n 12 .repo/manifest.xml

<?xml version="1.0" encoding="UTF-8"?>

<manifest> <remote name="aosp" fetch="https://android.googlesource.com/" review="https://android-review.googlesource.com/" /> <default revision="master" remote="aosp" sync-j="4" /> <project path="build" name="platform/build" groups="pdk" > <copyfile src="core/root.mk" dest="Makefile" /> $ repo sync
直接同步(sync)会出现”代码库不存在“错误,是因为使用的repo不支持manifest相对路径。
如果从 http://android.git.kernel.org/repo 下载 repo 就会有这个问题,建议从 https://chromium.googlesource.com/external/repo 下载
需要参照上面修改 .repo/manifest.xml 文件中的 fetch 节点,然后再同步。

3 调整代码库

如果需要对 android 进行二次开发,最好创建自己的分支,方法如下:

3.1 所有项目增加分支

直接在代码库中执行
$ repo forall -c git branch --no-track mybranch master

3.2 manifest 项目增加相应分支

  • 首先,在本地同步 manifest 库
$ cd ~
$ git clone ~/review/git/platform/manifest.git
  • 其次,增加新分支,并对 default.xml 作相应调整
$ cd ~/manifest
$ git checkout -b mybranch origin/master
$ head -12 defalut.xml
<?xml version="1.0" encoding="UTF-8"?>
<manifest>

  <remote  name="myserver"
           fetch=".." />
  <default revision="mybranch "
           remote="myserver"
           sync-j="1" />

  <project path="build" name="platform/build">
    <copyfile src="core/root.mk" dest="Makefile" />
  </project>
  • 推送到代码库中

$ git add defalut.xml
$ git commit -m "modify manifest"
$ git push origin mybranch:mybranch

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Fighting Horse

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值