Friday, April 12, 2013

How to Mirror Cyanogenmod Repo

As you may known, a repo is a list of git. Mirror a repo equal to mirror all git in this list.
There are several ways to mirror a repo:

1. It's simple to mirror it if it's aosp repo that support mirror already. That's guided by Google:
# Create a local mirror
$ mkdir -p /usr/local/mirror-aosp
$ cd /usr/local/mirror-aosp
$ repo init -u https://android.googlesource.com/mirror/manifest --mirror
$ repo sync
# Clone from your local mirror
$ mkdir aosp
$ cd aosp
$ repo init -u /usr/local/mirror-aosp/platform/manifest.git
# Update local mirror
$ cd /usr/local/mirror-aosp
$ repo sync

2. It's still simple if the repo also provide gitweb. As an example below for case of omapzoom
# Getting the tool
$ wget https://raw.github.com/ndechesne/git-mirror/master/git-mirror;
$ chmod +x git-mirror
# Create a local mirror
$ ./git-mirror -o /path/to/local-mirror/ -s http://git.omapzoom.org -g git://git.omapzoom.org
# Clone from your local mirror
$ mkdir omapzoom
$ cd omapzoom
$ repo init -u /path/to/local-mirror/git.omapzoom.org/platform/manifest.git
# Run again to update it
$ ./git-mirror -o /path/to/local-mirror/ -s http://git.omapzoom.org -g git://git.omapzoom.org

3. It's not simple if the repo does not support repo mirror like aosp also does not provide gitweb. It's CyanogenMod. So, to mirror it
Step1: getting list of git of CyanogenMod repo
Step2: mirror all git in this list
I made a helper sript to do that, please use if you like.
do-mirror-cyanogenmod

Usage:
$ chmod +x do-mirror-cyanogenmod
$ ./do-mirror-cyanogenmod NUMBER_CONCURRENT_DOWNLOAD

Example:
# Create a local mirror
$ mkdir mirror-cyanogenmod
$ cd mirror-cyanogenmod
$ ./do-mirror-cyanogenmod 8
# Clone from local mirror
$ repo init -u /path/to/mirror-cyanogenmod/android.git
# Update local mirror
$ cd /path/to/mirror-cyanogenmod/
$ ./do-mirror-cyanogenmod 8

NOTE: manifest of cyanogenmod usually includes several remotes, you may need to revise it accordingly

Reference:
[Setup git mirror]
http://www.omappedia.com/wiki/Setup_git_mirror
[Downloading the Source Tree]
http://source.android.com/source/downloading.html





1 comment:

Saiimons said...

There are now 32 pages in the github repo list, so if you don't want to miss anything, change 30 to 32 in the script !

Also, I had to perform a little call to :
mkdir ../CyanogenMod; for line in $(find -name "*.git"); do ln -s $PWD/${line:2} ../CyanogenMod/${line:2}; done
in order to get the sync to work