From 3b4fecb217f29b3668dedda487542d3c956340f0 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Mon, 16 Jan 2017 11:09:42 +1300 Subject: update: fix logic for updating layer dependencies at the end * We were passing the incorrect path (to the top of the layer repo) if the layer had a subdirectory, so this doesn't seem to have been able to work for such layers previously. * Doing this update in the main update.py script meant that this could never work across branches requiring a python version change (using PythonEnvironment records) since the code was running within the same environment in which update.py was launched - the entire point of the separation of the two scripts. Move the checking to update_layer.py and call it separately to perform these updates, splitting out some common code in order to do so. Signed-off-by: Paul Eggleton --- layerindex/update_layer.py | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'layerindex/update_layer.py') diff --git a/layerindex/update_layer.py b/layerindex/update_layer.py index 3497ac5a90..66337cf069 100644 --- a/layerindex/update_layer.py +++ b/layerindex/update_layer.py @@ -20,6 +20,7 @@ from distutils.version import LooseVersion import itertools import utils import recipeparse +import layerconfparse import warnings warnings.filterwarnings("ignore", category=DeprecationWarning) @@ -170,6 +171,9 @@ def main(): parser.add_option("-n", "--dry-run", help = "Don't write any data back to the database", action="store_true", dest="dryrun") + parser.add_option("", "--update-dependencies", + help = "Update layer dependencies only", + action="store_true", dest="updatedeps") parser.add_option("", "--nocheckout", help = "Don't check out branches", action="store_true", dest="nocheckout") @@ -238,6 +242,30 @@ def main(): branchname = layerbranch.actual_branch branchdesc = "%s (%s)" % (options.branch, branchname) + if options.updatedeps: + # Update layer dependencies only + if not layerbranch: + logger.debug('Skipping dependency update for layer %s on branch %s - no layerbranch record' % (layer, branchdesc)) + sys.exit(0) + if not options.nocheckout: + utils.checkout_layer_branch(layerbranch, repodir, logger=logger) + layerdir = os.path.join(repodir, layerbranch.vcs_subdir) + if not os.path.exists(layerdir): + # If this happens it was already flagged during the main update, so ignore it + logger.debug('Skipping dependency update for layer %s on branch %s - layer directory not found' % (layer, branchdesc)) + sys.exit(0) + + layerconfparser = layerconfparse.LayerConfParse(logger=logger, bitbakepath=bitbakepath, tinfoil=tinfoil) + config_data = layerconfparser.parse_layer(layerbranch, layerdir) + if not config_data: + logger.debug("Layer %s does not appear to be valid for branch %s" % (layer.name, branchdesc)) + sys.exit(0) + + utils.add_dependencies(layerbranch, config_data, logger=logger) + utils.add_recommends(layerbranch, config_data, logger=logger) + + sys.exit(0) + # Collect repo info repo = git.Repo(repodir) assert repo.bare == False @@ -300,8 +328,7 @@ def main(): if layerbranch.vcs_last_rev != topcommit.hexsha or options.reload: # Check out appropriate branch if not options.nocheckout: - out = utils.runcmd("git checkout origin/%s" % branchname, repodir, logger=logger) - out = utils.runcmd("git clean -f -x", repodir, logger=logger) + utils.checkout_layer_branch(layerbranch, repodir, logger=logger) if layerbranch.vcs_subdir and not os.path.exists(layerdir): if newbranch: @@ -316,8 +343,7 @@ def main(): logger.info("Collecting data for layer %s on branch %s" % (layer.name, branchdesc)) - from layerconfparse import LayerConfParse - layerconfparser = LayerConfParse(logger=logger, tinfoil=tinfoil) + layerconfparser = layerconfparse.LayerConfParse(logger=logger, tinfoil=tinfoil) layer_config_data = layerconfparser.parse_layer(layerbranch, layerdir) if not layer_config_data: logger.info("Skipping update of layer %s for branch %s - conf/layer.conf may have parse issues" % (layer.name, branchdesc)) -- cgit 1.2.3-korg