gnychis
gnychis

Reputation: 7555

how to use "repo" to clone minimal android source?

I am able to clone the Android source code by using the "repo" tool. However, what I want to do is clone the source code in a more minimal way than having an 11GB footprint. It seems to download things related to every Android device and every prior release. I tried thought I could reduce this by checking out a specific branch like this:

repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1

However, what ends up happening is that I still get everything involved, just at a specific snapshot (understandable). But is there any way to limit the amount that is cloned?

Upvotes: 8

Views: 5169

Answers (2)

DrChandra
DrChandra

Reputation: 181

There are a number of things you can do. First, "repo sync" with a -c argument will limit the checked-out sandbox to only the "current" branch. The repo sync will not download material for other branches.

You can also edit the .repo/manifests/default.xml manifest. What I do is make a backup of it such as "default.bak" and then strip out the lines from the default.xml file I know I don't need. Because I'm not building on a Macintosh, I know I don't need any of the "darwin" tools, so I remove every line that contains "darwin". Then "repo sync" doesn't download any darwin projects or install the source code in the sandbox.

If you already synched a sandbox, and you want to trim its size, you can strip projects out as above, and then do "repo sync -c -l", and repo sync will only strip the directories that you just removed. The -l flag only does the local part of the sync, which means it only syncs the local git projects with your source tree. The network is not used. See the "-n" flag for the other half of a normal sync, which does the network sync to update the local git projects with the upstream repository.

To also remove the git backing object stores for the unwanted projects (which take up a lot of room) I use this:

for project in `diff ~/android/.repo/manifests/default.xml ~/android/.repo/manifests/default.bak | awk '{print $3}' | grep path | cut -f2 -d\"`; do  rm -rf ~/android/.repo/projects/$project.git ; rm -rf ~/android/.repo/project-objects/$project.git ; done

This finds all the projects that are in your backup manifest, but have been removed from your active manifest, and removes the git projects and all the backing data for them. This recovers a lot of space.

If you remove too much, just recover the project line from your backup manifest, and add it back into your active manifest. Then, a repo sync will get your git projects and your sandbox straight again. You can test the build to see if you've removed too much by doing "mma -B -n" in your project directory. This will try to do a full dependency build on your target, forcing all the targets to build even if they don't need it, and it will do it as a dry run. If the build fails, you removed something your project needs.

You can also set up a local mirror sandbox, and create small, working, reference sandboxes from your mirror. The working sandboxes don't contain git object stores, but refer to the central ones in the mirror. Use "repo init -u ... --mirror" to set up the mirror, and "repo init --reference=~/android-mirror -u ..." to refer to the mirror. The -u flag in the latter allows a real upstream repository to be used as the authority, while the mirror reference is used as a local cache. Local mirrors also avoid the download quota that the AOSP project enforces, and they are faster to sync to.

Upvotes: 4

JesusFreke
JesusFreke

Reputation: 20282

The android source tree is made up of many separate git repositories, which are all managed by repo. You can't really reduce the amount of data that's downloaded for a given git repository.

However, you can only download a subset of the git repos that are available, using repo sync <project>. I.e. if you only wanted the frameworks/base package, you should be able to do repo sync frameworks/base, after doing the initial repo init.

If you are actually wanting to build the source though, you probably want the full thing.

You might be able to save a gig or two by removing the device repositories that you don't need. You can do this by editing <source>/.repo/manifest.xml and removing the repositories for the devices you don't want.

Upvotes: 4

Related Questions