使用 repo
管理工程源码及分支,需要对 manfiest.xml
有深入了解,本文记录主要关注点
repo
repo init -u $URL -b $BRANCH -m $MANIFEST
相当于执行如下命令队列
mkdir .repo
cd .repo
git clone https://android.googlesource.com/tools/repo
git clone --bare $URL manifests.git
mkdir -p manifests/.git; cd manifests/.git
for i in ../../manifests.git/*; do ln -s $ı .; done
cd ..
git checkout $BRANCH -- .
cd ..
ln -s manifests/$MANIFEST manifest.xml
manfiest.xml
repo v1.3
<!DOCTYPE manifest [
<!ELEMENT manifest (remote*,
default?,
project*,
add-remote*)>
<!ELEMENT remote (EMPTY)>
<!ATTLIST remote name ID #REQUIRED>
<!ATTLIST remote fetch CDATA #REQUIRED>
<!ATTLIST remote review CDATA #IMPLIED>
<!ATTLIST remote project-name CDATA #IMPLIED>
<!ELEMENT default (EMPTY)>
<!ATTLIST default remote IDREF #IMPLIED>
<!ATTLIST default revision CDATA #IMPLIED>
<!ELEMENT project (remote*)>
<!ATTLIST project name CDATA #REQUIRED>
<!ATTLIST project path CDATA #IMPLIED>
<!ATTLIST project remote IDREF #IMPLIED>
<!ATTLIST project revision CDATA #IMPLIED>
<!ELEMENT add-remote (EMPTY)>
<!ATTLIST add-remote to-project ID #REQUIRED>
<!ATTLIST add-remote name ID #REQUIRED>
<!ATTLIST add-remote fetch CDATA #REQUIRED>
<!ATTLIST add-remote review CDATA #IMPLIED>
<!ATTLIST add-remote project-name CDATA #IMPLIED>
]>
需要关注 remote
、 default
和 project
manfiest
示例
<manifest>
<remote name="aosp"
fetch="https://android.googlesource.com/"/>
<remote name="udinic"
fetch="https://github.com/udinic/"/>
<default revision="master"
remote="aosp"
sync-j="4" />
<project path="art" name="platform/art" />
<project path="bionic" name="platform/bionic" groups="pdk" />
<project path="dalvik" name="platform_dalvik” remote=“udinic”/>
<project path="frameworks/base" name="platform_frameworks_base" remote=“udinic" revision=“statusbar_fixes"/>
<project path="tools/adt/eclipse" name="platform/tools/adt/eclipse" groups="notdefault,tools" />
</manifest>
remote
<remote>
指定 remote
地址,可以有多个,可以使用 name 进行区分
,主要参数如下
name
,必须fetch
,必须,The Git URL prefix for all projects which use this remote.review
,代码评审地址
例如
<remote name="aosp"
fetch="https://android.googlesource.com/"/>
review="https://android.googlesource.com/review"/>
<remote name="udinic"
fetch="https://github.com/udinic/"/>
fetch="https://192.168.110.10/review"/>
<remote name="test"
fetch="https://github.com/test/"/>
default
<default>
为可选项,指定默认 <remote>
,主要设置参数如下:
remote
选择指定<remote>
revision
指定默认revision
,包括branch
或tag
,例如master
、dev
、refs/tags/v1.0.1
等
project
<project>
指定工程,主要参数如下
name
远程相对与remote
地址的路径,必须项path
本地相对路径,不指定的话表示和name
相同remote
选择<remote>
revision
选择指定分支或tag
copyfile
复制文件
将工程下的 make.sh
复制到根目录
<project path="tools" name="test" >
<copyfile src="make.sh" dest="make.sh" />
</project>
Example
实现意图, repo
管理两部分代码,一部分为私有代码,另外一部分为公共代码,位于不同的分支,修改 manfiest.xml
如下
<manifest>
<remote name="aosp"
fetch="https://android.googlesource.com/"/>
<remote name="udinic"
fetch="https://github.com/udinic/"/>
<default revision="master"
remote="aosp"
sync-j="4" />
<project path="art" name="platform/art" />
<project path="bionic" name="platform/bionic" groups="pdk" />
<project path="dalvik" name="platform_dalvik” remote=“udinic”/>
<project path="frameworks/base" name="platform_frameworks_base" remote=“udinic" revision=“statusbar_fixes"/>
<project path="tools/adt/eclipse" name="platform/tools/adt/eclipse" groups="notdefault,tools" />
</manifest>
未指定 revision
的 project
下载 default
指定的 master
分支
建立分支或 tag
repo
管理下建立 branch
或 tag
,主要是管理 manfiest
以及 project
各个仓库
branch
- 管理
manfiest
,克隆git
仓库之后,根据source
建立release
分支,并修改default.xml
跟踪refs/tags/$RELEASE
,推送branch
及tag
到服务器git clone ssh://git@192.168.110.10/manifests.git git co origin/$SOURCE -b $RELEASE sed -i "s/\"$SOURCE\"/\"refs\/tags\/$RELEASE\"/g" ./default.xml git ci -m "$RELEASE" -a git push --all
- 管理
project
,根据SOURCE
迁出代码,然后上传tag
信息git tag $RELEASE git push $SOURCE --tags