repo是用於管理android的git倉庫的工具。
之前想將android的代碼放在github上面,並通過repo進行管理。但一直不知道怎么添加進去,那么多的git倉庫,難道都要手動建立嗎?
直到看到有人在github上面部署成功,分析一下他的manifest.xml才知道是怎么部署。
參考鏈接
http://blog.csdn.net/billpig/article/details/7604828
http://blog.csdn.net/shift_wwx/article/details/19557031
manifest.xml
分析的manifest.xml文件來源:
https://github.com/CyanogenMod/android
分析其中的default.xml,如下:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="github" // 遠程服務器名稱是“github”,后面用github表示fetch
fetch=".." // 獲取數據的位置是"..",上一級目錄
review="review.cyanogenmod.org" /> // gerrit審核的位置
<remote name="private" // 遠程服務器名稱“private”
fetch="ssh://git@github.com" /> // 從”ssh://git@github.com下載代碼
<remote name="aosp" // aosp
fetch="https://android.googlesource.com" // 代碼下載地址
review="android-review.googlesource.com"
revision="refs/tags/android-7.1.1_r6" /> // 默認的git分支
// 默認的下載地址,如果沒有指定remote的話。
<default revision="refs/heads/cm-14.1" // 默認的代碼下載地址
remote="github" // github,表示上面的remote設置的name="github"的一項,那么下載的地址fetch就是”..“
sync-c="true" // 只同步指定的分支
sync-j="4" /> // repo sync 默認的並行數目
<!-- AOSP Projects -->
// path:將代碼下載到本地的build目錄中
// name:${remote fetch}/${project name}.git
// remote 沒有指定,那么久采用default地址,name=github,從”.."上一層目錄下載。
// 結合name的值,就從../CyanogenMod/android_build.git這個倉庫下載地址。查看作者github倉庫,就能找到android_build這個倉庫。
<project path="build" name="CyanogenMod/android_build" groups="pdk,tradefed">
<copyfile src="core/root.mk" dest="Makefile" />
</project>
// 將代碼下載到本地的build/blueprint目錄,從remote="aosp“下載,也就是https://android.googlesource.com
// 在結合project的name,下載的倉庫地址就是https://android.googlesource.com/platform/build/blueprint
<project path="build/blueprint" name="platform/build/blueprint" groups="pdk,tradefed" remote="aosp" />
// 從android_buld_kati.git倉庫下載,放到本地的build/kati目錄。
<project path="build/kati" name="CyanogenMod/android_build_kati" groups="pdk,tradefed" />
<project path="build/soong" name="platform/build/soong" groups="pdk,tradefed" remote="aosp" >
<linkfile src="root.bp" dest="Android.bp" />
<linkfile src="bootstrap.bash" dest="bootstrap.bash" />
</project>
<project path="abi/cpp" name="platform/abi/cpp" groups="pdk" remote="aosp" />
<project path="art" name="CyanogenMod/android_art" groups="pdk" />
<project path="bionic" name="CyanogenMod/android_bionic" groups="pdk" />
<project path="bootable/recovery" name="CyanogenMod/android_bootable_recovery" groups="pdk" />
<project path="cts" name="platform/cts" groups="cts,pdk-cw-fs,pdk-fs" remote="aosp" />
<project path="dalvik" name="CyanogenMod/android_dalvik" groups="pdk-cw-fs,pdk-fs" />
<project path="developers/build" name="platform/developers/build" remote="aosp" />
<project path="development" name="CyanogenMod/android_development" groups="pdk-cw-fs,pdk-fs" />
<project path="device/common" name="device/common" groups="pdk-cw-fs,pdk-fs" remote="aosp" />```
...
通過分析可以看出,作者將android的代碼放在github上,並通過repo進行管理。
-
自己需要改動的代碼就建立倉庫,放在自己的github上。
-
不改動的代碼就引用google原生的代碼,這樣就不需要在github上面建立倉庫。
如果android的源碼托管在github上的話可以采用這種方式,建立倉庫的數量。一個android里面的git倉庫接近500個。建立倉庫,保存改動的代碼,是個不錯的方法。
當然也有很多人在自己的私有服務器搭建git倉庫,放置android源碼。
Tony Liu
2017-2-22, Shenzhen