2012年12月14日 星期五

mirror android source to an internal git/gerrit server

花了好長一段時間 目前看來終於有初步結果了
就以git://github.com/MIPS/ 為例子

步驟一:
首先創建一個 mirror的參考project, 重點是把相關的access control permission設好, 之後要mirror的project都繼承自該project, 或者是去修改ALL-Projects 的 access permission, 至於要設哪些permission其實我還不是很清楚, 反正我就幾乎全開了XD,  如下:


Rights Inherit From:
Reference:
refs/for/*
Push

Push Merge Commit

Reference:
refs/heads/*
Read


Create Reference

Forge Author Identity

Forge Committer Identity

Forge Server Identity

Push

Push Merge Commit

Push Annotated Tag

Label Code-Review
 
 
Rebase

Submit

Reference:
refs/meta/config
Read

Create Reference

Forge Author Identity

Forge Committer Identity

Forge Server Identity

Push

Push Merge Commit

Push Annotated Tag

Submit

Reference:
refs/tags/*
Read

Create Reference

Forge Author Identity

Forge Committer Identity

Forge Server Identity

Push

Push Merge Commit

Push Annotated Tag

Submit

步驟二:
1. mkdir mirror-folder
2. repo init -u git://github.com/MIPS/manifests.git --mirror
3. repo sync -j4
4. repo forall -c 'ssh -p PORT ACCOUNT@SERVER gerrit create-project PROJECT_ROOT/$REPO_PROJECT;  \
    ssh -p PORT ACCOUNT@SERVER gerrit set-project-parent --parent mirror-project-permission-base PROJECT_ROOT/$REPO_PROJECT; \
    git push ssh://ACCOUNT@SERVER:PORT/PROJECT_ROOT/$REPO_PROJECT 'refs/heads/*' 'refs/tags/*' 'refs/notes/*''


note: 紅色字的部份很重要, 這是試了好多種方式後目前可行的方式

步驟三:
1. 接下來就先去 git clone 其manifests的project的下來 修改其xml file, 使其fetch/review的url能對應到internal server

1. git clone ssh://ACCOUNT@SERVER:PORT/PROJECT_ROOT/manifests
2. 將default.xml 的fetch and review URLs改成internal server, 例如
             fetch="git://github.com/MIPS"
             remote="mips"
             sync-j="4"
==>  
           fetch="ssh://SERVER:PORT/PROJECT_ROOT"
           review="SERVER:PORT"
           remote="mips"
           sync-j="4"

然後push回server

步驟四:
接下來就可以照repo init & repo sync的動作來將整包source tree 都 checkout回來, 如
1. repo init -u ssh://ACCOUNT@SERVER:PORT/PROJECT_ROOT/manifests
2. repo sync

Reference:
https://groups.google.com/forum/?fromgroups=#!topic/repo-discuss/zpqpPpHAwSM
https://wiki.linaro.org/Platform/Infrastructure/GerritNotes
https://groups.google.com/forum/?fromgroups=#!topic/repo-discuss/qXBILfjVV04
https://groups.google.com/forum/?fromgroups=#!msg/repo-discuss/F8wQCreKv4c/L3DOAPPiQpMJ

2 則留言:

  1. Hi, 謝謝你的資訊, 節省我很多時間。

    想請教一下你自己的repo init -u ssh://ACCOUNT@SERVER:PORT/PROJECT_ROOT/manifests 這邊需要什麼特殊設定嗎? 我這邊的狀況是這步會有問題。

    repo init -u ssh://account@127.0.0.1:29418/android/platform/manifest

    會出現

    IOError: [Errno 2] No such file or directory: '/home/tmp/.repo/manifests/.git/HEAD'

    不知道您有沒有遇過?

    回覆刪除