[Android Software Development] SHM:
I assume you already have all your build packages installed. This guide is merely showing how to obtain a mirror copy of the android source for local purposes.

I will be using OmniRom for the duration of this guide, but for those who use CM or other projects, the concept should remain the same.

I do not expect this guide to be useful for everyone but there will be many who are going to be thankful that did not initially know this could be done.

Due to the rapid development, I ran into a huge issue pretty quickly when having to nuke/resync the various repos for building. The total space required for a full omni source is roughly 508,334 items, totaling 14.4 GB based on today from branch android-5.1 and requires pulling from a massive number of git repos online. So if bandwidth is an issue then constantly syncing after nuking the source could become an issue for you real quick. Not to mention the time it takes just to pull all of this data from the internet onto your computer.

However, by creating a Mirror of the source and its numerous git repos, the source is roughly 19,696 items, totalling 16.5 GB based on today from branch android-5.1.

Now, for those asking, why do a mirror? It is relatively simple. When using several sources, especially in situations where bandwidth is scarce, it is better to create a local mirror of the entire content, and to sync from that mirror (which requires no network access). The download for a full mirror is smaller than the download of two sources, while containing more information.

These instructions assume that the mirror is created in

/path/to/home

/android/mirror. The first step is to create and sync the mirror itself.

mkdir -p ~/android/mirror

cd ~/android/mirror

repo init -u https://github.com/omnirom/android.git -b android-5.1 [COLOR="Red"]--mirror[/COLOR]

repo sync -j# -f --no-clone-bundle

Basically this allows you to initialize a local mirror of an android repo (--mirror) and then later allow you to point subsequent repo pulls to that local copy which will be explained further into this guide. The mirror looks nothing like the actual source used to make builds.

Once the mirror repo has synced, then we are ready to establish the actual source in another directory that will pull directly from the mirror locally.

mkdir -p ~/android/omni

cd ~/android/omni

repo init -u git://github.com/omnirom/android.git -b android-5.1 [COLOR="Red"]--reference=/path/to/home/android/mirror/[/COLOR]

repo sync -j# -f --no-clone-bundle

Note the use of the ‘–-reference’ parameter. This uses my local mirror of the android sources instead of pulling across the network again.

Now I can pull one of the various repos, using that same ‘--reference’ parameter (pointed at my local omni mirror) and profit!

From here on out, should I want to update the omni source with the latest changes I just go to the mirror directory and run:

repo sync

Then, I switch over to the omni directory and run the same command to pull those changes from the local directory.

Even further, should I nuke something in the omni directory, I can simply delete it and run repo sync to pull from the local mirror to fix the problem and never have to worry about pulling data from the network itself.

Here is an example for a clearer picture:

I make changes in /android/omni/bootable/recovery

I do not like the changes I have made

I delete /android/omni/bootable recursively

I run repo sync to restore /android/omni/bootable

The sync pulls from the local mirror instead of downloading the repo from the internet.

Time for syncing is cut in half if not more

Everything is still intact