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 <[email protected]> --- scripts/prepare-shared-repos | 2 +- scripts/utils.py | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/scripts/prepare-shared-repos b/scripts/prepare-shared-repos index c221e69..f34ba99 100755 --- a/scripts/prepare-shared-repos +++ b/scripts/prepare-shared-repos @@ -35,7 +35,7 @@ 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) + utils.fetchgitrepo(tempdir, repo, repos[repo], stashdir, depth=1) if args.publish_dir: utils.publishrepo(tempdir, repo, args.publish_dir) diff --git a/scripts/utils.py b/scripts/utils.py index 4c73f81..3c2622f 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -228,26 +228,34 @@ def runcmd(cmd): return subprocess.check_output(cmd, stderr=subprocess.STDOUT) -def fetchgitrepo(clonedir, repo, params, stashdir): +def fetchgitrepo(clonedir, repo, params, stashdir, depth=None): sharedrepo = "%s/%s" % (clonedir, repo) branch = params["branch"] revision = params["revision"] + if revision != "HEAD": + depth = None + fetchopt = [] + depthopt = [] + if depth: + fetchopt = ["--depth", str(depth), branch + ":origin/" + branch] + depthopt = ["--depth", str(depth), "--branch", branch] print("Checking for stash at: " + stashdir + "/" + repo) flush() if os.path.exists(stashdir + "/" + repo): print("Cloning from stash to %s..." % sharedrepo) flush() - subprocess.check_call(["git", "clone", "file://%s/%s" % (stashdir, repo), "%s/%s" % (clonedir, repo)]) + subprocess.check_call(["git", "clone", "file://%s/%s" % (stashdir, repo), "%s/%s" % (clonedir, repo)] + depthopt) subprocess.check_call(["git", "remote", "rm", "origin"], cwd=sharedrepo) subprocess.check_call(["git", "remote", "add", "origin", params["url"]], cwd=sharedrepo) print("Updating from origin...") flush() - subprocess.check_call(["git", "fetch", "origin"], cwd=sharedrepo) - subprocess.check_call(["git", "fetch", "origin", "-t"], cwd=sharedrepo) + subprocess.check_call(["git", "fetch", "origin"] + fetchopt, cwd=sharedrepo) + if not depth: + subprocess.check_call(["git", "fetch", "origin", "-t"], cwd=sharedrepo) else: print("Cloning from origin to %s..." % sharedrepo) flush() - subprocess.check_call(["git", "clone", params["url"], sharedrepo]) + subprocess.check_call(["git", "clone", params["url"], sharedrepo] + depthopt) print("Updating checkout...") flush() -- 2.32.0
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#55197): https://lists.yoctoproject.org/g/yocto/message/55197 Mute This Topic: https://lists.yoctoproject.org/mt/86716909/21656 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
