yocto-autobuilder-helper/scripts/prepare-shared-repos
Richard Purdie 5dc0559cc8 prepare-shared-repo/utils: Limit HEAD clones to shallow depth to save time/space
By not syncing all the history is is possible to save some time/space
in the checkout process since we never use this data. This reduces data
from 650MB to 400MB or with the tarball, 416MB to 55MB.

The logic for the commands needs to be tweaked to handle this and as
written it can't work in non-HEAD revision case but that isn't a commonly
used situation.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-10-31 13:03:22 +00:00

1.4 KiB
Executable File

#!/usr/bin/env python3

Iterate over a set of repositories in a json file and setup a shared directory containing them

import json import os import sys import subprocess import errno import tempfile

import utils

parser = utils.ArgParser(description='Iterates over a set of repositories in a json file and sets up a shared directory containing them.')

parser.add_argument('repojson', help="The json file containing the repositories to use") parser.add_argument('sharedsrcdir', help="The shared directory where the repos are to be transferred") parser.add_argument('-p', '--publish-dir', action='store', help="Where to publish artefacts to (optional)")

args = parser.parse_args()

ourconfig = utils.loadconfig()

with open(args.repojson) as f: repos = json.load(f)

stashdir = utils.getconfig("REPO_STASH_DIR", ourconfig)

with tempfile.TemporaryDirectory(prefix="shared-repo-temp-", dir="/home/pokybuild/tmp") as tempdir: for repo in sorted(repos.keys()): utils.printheader("Intially fetching repo %s" % repo) utils.fetchgitrepo(tempdir, repo, repos[repo], stashdir, depth=1) if args.publish_dir: utils.publishrepo(tempdir, repo, args.publish_dir)

utils.printheader("Running rsync")
subprocess.check_call("rsync -a " + tempdir + "/* " + args.sharedsrcdir, shell=True)