-1

I created a mirrored repo workspace like this:

repo init -u $url -b $branch  -m $manifest --mirror
repo sync

I would like to update the mirror to use a different manifest or an updated manifest and then re-sync to pull down any new or missing changes. If I try to run the same init command, it complains:

fatal: --mirror is only supported when initializing a new workspace.
Either delete the .repo folder in this workspace, or initialize in another location.

I suppose that I could manually fetch within .repo/manifests and then update the symlink, .repo/manifest.xml. I'd like to use the repo tool instead, though, if possible.

Or I could remove the entire .repo directory and then run the init command again. I'm avoiding this because unfortunately my manifest file is inside a 12GB repository. So, re-cloning is time consuming.

Harvey
  • 5,703
  • 1
  • 32
  • 41

1 Answers1

0

I ended up abandoning this idea. Instead, I create a throw-away git repo locally containing the manifest. Then I init from that. The shell functions below will create the temporary manifest repo, create/update the mirror, and then create a working repo for building.

function parameters

  • mirror

    • /path/to/mirror
  • url

    • /path/to/temporary/manifests_repo
  • branch

    • branch name to use.
      This is not strictly necessary, but it makes it easy to label your build directories. I use the hash from our main repo corresponding to the current manifest.xml. Then, I can easily see which revision a build directory is based upon: $ repo info Manifest ... Manifest merge branch: refs/heads/BRANCH_NAME
  • manifest

    • relative/path/to/manifest_file from the current directory
  • build_dir

    • /path/to/new_build_directory

The reason for creating the mirror is to save time fetching as this code was designed for an automated build server. Notice that the build directory does a shallow clone from the mirror and even gets its copy of Google's repo tool from a local bundle allowing for offline building. The sync step uses options to only fetch the changesets required by the manifest and excludes other branches and commits.

function pushd_quiet() {
    pushd "$@" >/dev/null
}

function popd_quiet() {
    popd "$@" >/dev/null
}

function build_android_os_update_mirror() {
    local mirror="$1"
    local url="$2"
    local branch="$3"
    local manifest="$4"

    # Create a temporary manifest repo
    rm -rf "${url}"
    mkdir -p "${url}"
    cp -rf "${manifest}" "${url}"
    pushd_quiet "${url}"
    {
        git init
        git add .
        git commit -m $branch
        git branch -m $branch
        popd_quiet
    }

    # Update mirror
    mkdir -p $mirror
    pushd_quiet $mirror
    {
        rm -rf .repo
        repo init -u $url -b $branch -m $(basename $manifest) --mirror \
             --repo-url ${BUILD_HOME}/tools/git-repo-clone.bundle
        repo sync -c --optimized-fetch -j 16
        popd_quiet
    }
}

function build_android_os_create_build_tree() {
    local build_dir="$1"
    local mirror="$2"
    local url="$3"
    local branch="$4"
    local manifest="$5"

    rm -rf $build_dir
    mkdir -p $build_dir
    pushd_quiet $build_dir
    {
        repo init -u $url -b $branch -m $(basename $manifest) --reference=$mirror --depth=1 \
             --repo-url ${BUILD_HOME}/tools/git-repo-clone.bundle
        repo sync -d -c --optimized-fetch -j 16
        popd_quiet
    }
}
Harvey
  • 5,703
  • 1
  • 32
  • 41