Reduce the Size of the Android Source Repository .repo Directory

11,192

Solution 1

The -c flag doesn't seem to be supported any more, but here's what you can do.

At the time of writing, repo init -u https://android.googlesource.com/platform/manifest -b android-5.1.0_r5 creates 33GB worth of files.

Adding --depth=1 reduces this to 21GB.

Adding --groups=all,-notdefault,-device,-darwin,-x86,-mips,-exynos5 to exclude devices and components you're not interested in reduces this to 19GB.

For storage only, you could remove the checked-out files for each .git repository inside .repo/ to save even more space, but I'm not sure how to script this. If you did do this, repo sync would check out the "missing" files when needed.

For reference, my complete command line was
repo init -u https://android.googlesource.com/platform/manifest -b android-5.1.0_r5 --depth=1 --groups=all,-notdefault,-device,-darwin,-x86,-mips,-exynos5,mako
so this tree would only work for the Nexus 4. I have not yet tried to build from this tree but there's no reason it wouldn't work.

You could also remove projects you're not using by specifying a local manifest, or even work from a compressed filesystem like btrfs with the right mount options, but I'm unsure of the performance impact.

Solution 2

Untested, but I think you can use the -c switch to only download the branches you currently need.

With that flag, repo will only download the revision (branch) that is specified in the manifest, not all the branches that are on the remote server. It will thus save us quite some space, and again it will take less time to download.

Source and more info: http://xda-university.com/as-a-developer/repo-tips-tricks

Share:
11,192
GrandAdmiral
Author by

GrandAdmiral

Greetings!

Updated on July 30, 2022

Comments

  • GrandAdmiral
    GrandAdmiral almost 2 years

    I have been switching between several branches of the Android source code with the commands like:

    repo init -u https://android.googlesource.com/platform/manifest -b android-4.4_r1.2
    repo sync
    

    The most recent tag was android-5.0.0_r2. I noticed my .repo directory is now 30 GB in size. Is that the expected size? If not, then I'm speculating I have history from the other branches/tags I've used stored in the .repo directory.

    Is there a way to reduce the size of the .repo directory? I would like to limit to only the source/objects/images/etc. I need for the particular branch I'm working on. HDD space is more important to me than download time.

    I see git gc is used on .git repositories, but that doesn't work in this case. Is there an equivalent for .repo repositories?

    Note: I did try repo prune, but that did not reduce the size of the .repo directory.

  • GrandAdmiral
    GrandAdmiral over 9 years
    While that would help minimize the space of a single branch, I don't think that helps if I download multiple branches. I will still end up with extra content in the places where branches don't overlap.
  • Adam Baxter
    Adam Baxter almost 9 years
    I don't think -c is supported any more. There's no reference to it in the current repo source.
  • Padmanabha V
    Padmanabha V over 3 years