summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2018-04-06 17:19:22 +1200
committerPaul Eggleton <paul.eggleton@linux.intel.com>2018-05-04 23:57:53 +1200
commit3a3c9f3d02d01238f8e9177102c11e21f34b7946 (patch)
treee1c64108593acf82b678746823b981cbfcf2e504
parent7343484695f264d68d5b5ed8900a0786d755a2ff (diff)
downloadopenembedded-core-contrib-3a3c9f3d02d01238f8e9177102c11e21f34b7946.tar.gz
openembedded-core-contrib-3a3c9f3d02d01238f8e9177102c11e21f34b7946.tar.bz2
openembedded-core-contrib-3a3c9f3d02d01238f8e9177102c11e21f34b7946.zip
rrs_upgrade_history: improve checkout logic
* Consolidate the code for checking out a repository, using the newly added utils.checkout_repo() function * Check out a layer's dependencies, not just the layer itself * Only check out if the desired revision isn't already checked out (mostly useful for bitbake which we would otherwise be checking out much more frequently than necessary since it may not have changed even if we've moved to a new commit in the layer). Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
-rw-r--r--rrs/tools/upgrade_history_internal.py37
1 files changed, 29 insertions, 8 deletions
diff --git a/rrs/tools/upgrade_history_internal.py b/rrs/tools/upgrade_history_internal.py
index 15d4671b1f..d58a79d639 100644
--- a/rrs/tools/upgrade_history_internal.py
+++ b/rrs/tools/upgrade_history_internal.py
@@ -153,6 +153,32 @@ def _get_recipes_filenames(ct, repodir, layerdir, logger):
return ct_files
+def checkout_layer_deps(layerbranch, commit, fetchdir, logger):
+ """ Check out the repositories for a layer and its dependencies """
+ # Some layers will be in the same repository, so we only want to check those out once
+ done_repos = []
+ def checkout_layer(lb, lcommit=None, lcommitdate=None, force=False):
+ urldir = str(lb.layer.get_fetch_dir())
+ repodir = os.path.join(fetchdir, urldir)
+ if not repodir in done_repos:
+ if not lcommit:
+ lcommit = utils.runcmd('git rev-list -1 --before="%s" origin/master' % lcommitdate, repodir, logger=logger).strip()
+ utils.checkout_repo(repodir, lcommit, logger, force)
+ done_repos.append(repodir)
+
+ # We "force" here because it's almost certain we'll be checking out a
+ # different revision for the layer itself
+ checkout_layer(layerbranch, commit, force=True)
+ layer_urldir = str(layerbranch.layer.get_fetch_dir())
+ layer_repodir = os.path.join(fetchdir, layer_urldir)
+ commitdate = utils.runcmd("git show -s --format=%ci", layer_repodir, logger=logger)
+
+ for dep in layerbranch.get_recursive_dependencies():
+ checkout_layer(dep, lcommitdate=commitdate)
+
+ return commitdate
+
+
def generate_history(options, layerbranch_id, commit, logger):
from layerindex.models import LayerBranch
from rrs.models import Release
@@ -168,9 +194,7 @@ def generate_history(options, layerbranch_id, commit, logger):
repodir = os.path.join(fetchdir, urldir)
layerdir = os.path.join(repodir, str(layerbranch.vcs_subdir))
- utils.runcmd("git checkout %s" % commit,
- repodir, logger=logger)
- utils.runcmd("git clean -dfx", repodir, logger=logger)
+ commitdate = checkout_layer_deps(layerbranch, commit, fetchdir, logger)
if options.initial:
fns = None
@@ -187,11 +211,8 @@ def generate_history(options, layerbranch_id, commit, logger):
# Branch name, need to check out detached
bitbake_rev = 'origin/%s' % bitbake_rev
else:
- commitdate = utils.runcmd("git show -s --format=%ci", repodir, logger=logger)
- bitbake_rev = '`git rev-list -1 --before="%s" origin/master`' % commitdate
- utils.runcmd('git checkout %s' % bitbake_rev,
- bitbakepath, logger=logger)
- utils.runcmd("git clean -dfx", bitbakepath, logger=logger)
+ bitbake_rev = utils.runcmd('git rev-list -1 --before="%s" origin/master' % commitdate, bitbakepath, logger=logger).strip()
+ utils.checkout_repo(bitbakepath, bitbake_rev, logger)
sys.path.insert(0, os.path.join(bitbakepath, 'lib'))
(tinfoil, d, recipes, tempdir) = load_recipes(layerbranch, bitbakepath,