Mirror AOSP Android 15 to Gerrit (Complete History + Tags)

This guide shows how to mirror Android 15 (AOSP android-15.0.0_r30) to your own Gerrit server, preserving full commit history and tags, while keeping the original clone-depth settings in the manifest — so that downstream users can sync with the same behavior as Google’s AOSP repo.


Prerequisites

Install essential tools:

sudo add-apt-repository ppa:git-core/ppa
sudo  apt update
sudo apt install git
mkdir -p ~/bin
curl -o ~/bin/repo https://storage.googleapis.com/git-repo-downloads/repo
chmod +x ~/bin/repo
export PATH=~/bin:$PATH

Add to your shell profile (~/.bashrc, ~/.zshrc, etc.):

export PATH=~/bin:$PATH

Ensure your .gitconfig includes the following:

[user]
        email = your email
        name = your name
[color]
        ui = auto
[url "ssh://maksonlee@gerrit:29418/"]
        insteadof = "git://gerrit/"
        pushinsteadof = "git://gerrit/"

  1. Initialize the AOSP Manifest
mkdir ~/aosp-15 && cd ~/aosp-15
repo init -u https://android.googlesource.com/platform/manifest -b android-15.0.0_r30

This initializes the official manifest, which includes Google’s clone-depth settings.


  1. Remove clone-depth from Manifest
sed -i 's/ clone-depth="[0-9]\+"//g' .repo/manifests/default.xml

This ensures repo sync clones full Git history for all projects, even if the manifest tries to enforce shallow clones.


  1. Sync Repositories
repo sync -c -j8

This synchronizes the repositories with the specified manifest.


  1. Gerrit Server Configuration
  • Permissions

In All-Projects → Access, add following permissions for administrator:

refs/tags/*
Forge Committer Identity
Forge Server Identity
Forge Author Identity

refs/heads/*
Push
Forge Committer Identity
  • Prevent Timeout

In your Gerrit configuration file (gerrit.config), set the receive timeout:

[receive]
        timeout = 30 min
  • Performance Tuning

Adjust the following settings to optimize performance:

[core]
        packedGitWindowSize = 32m            # default is only 8k
        packedGitLimit = 512m                # raise from default 10m
        deltaBaseCacheLimit = 512m           # raise from default 10m
        streamFileThreshold = 20m            # to avoid temp file usage for large blobs
        packedGitUseStrongRefs = true        # more stable memory behavior
        packedGitOpenFiles = 256             # if you have many packfiles (raise ulimit if needed)
[receive]
        checkReferencedObjectsAreReachable = false

  1. Create Projects in Gerrit

Save the following script as create-projects.sh and run it:

#!/bin/bash -e

echo "=== Fetching list of existing projects from Gerrit ==="
ssh -p 29418 maksonlee@gerrit gerrit ls-projects > existing_projects.txt

REPO_ROOT_DIR=$(pwd)

echo "=== Checking and creating missing projects ==="

repo forall -p -v -e -c '
  if grep -q "^$REPO_PROJECT$" "'"$REPO_ROOT_DIR"'/existing_projects.txt"; then
    echo ">>> Project $REPO_PROJECT already exists."
  else
    echo ">>> Project $REPO_PROJECT does not exist. Creating it now..."
    ssh -p 29418 maksonlee@gerrit gerrit create-project "$REPO_PROJECT" --empty-commit
    echo ">>> Project $REPO_PROJECT creation command finished."
  fi
'

echo "=== Project creation phase completed. ==="

Then run:

bash create-projects.sh

  1. Push All Projects to Your Gerrit Server

Push all repositories:

repo forall -p -v -e -c 'git push -o skip-validation --no-tags git://gerrit/$REPO_PROJECT HEAD:refs/heads/android-15.0.0_r30'

  1. Push Tags
repo forall -p -v -e -c 'git push git://gerrit/$REPO_PROJECT refs/tags/android-15.0.0_r30'

  1. Push Manifests
cd .repo/manifests
git checkout default.xml
ssh -p 29418 maksonlee@gerrit gerrit create-project platform/manifest --empty-commit
git push -o skip-validation --tags git://gerrit/platform/manifest HEAD:refs/heads/android-15.0.0_r30

Done!

You now have:

  • A complete mirror of Android 15 AOSP with all history and tags
  • A self-hosted repo source via Gerrit
  • Support for shallow clones on downstream clients — just like Google

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top