From acac7d6e9ce77a0e9aedb6ff2429fff5710edfa6 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Mon, 26 Mar 2018 16:59:32 +1300 Subject: [PATCH] rrs_upgrade_history.py: ensure we shut down tinfoil safely Use try...finally to ensure we shut down tinfoil, but since we are potentially dealing with older bitbake releases when importing older upgrades, only call shutdown() if it's actually there (and although it's unlikely, guard against the broken shutdown() in fido as we do in the main layer index update script). Signed-off-by: Paul Eggleton --- rrs/tools/upgrade_history_internal.py | 47 ++++++++++++++------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/rrs/tools/upgrade_history_internal.py b/rrs/tools/upgrade_history_internal.py index fb015d8..82fbe1a 100644 --- a/rrs/tools/upgrade_history_internal.py +++ b/rrs/tools/upgrade_history_internal.py @@ -178,30 +178,33 @@ def generate_history(options, layerbranch_id, commit, logger): (tinfoil, d, recipes) = load_recipes(layerbranch, bitbakepath, fetchdir, settings, logger, recipe_files=fns, nocheckout=True) - - if options.initial: - title = options.initial - info = 'No maintainer;;' + utils.runcmd("git log --format='%ad;%cd' --date=rfc -n 1 " \ - + commit, destdir=repodir, logger=logger) - recordcommit = '' - else: - title = utils.runcmd("git log --format='%s' -n 1 " + commit, - repodir, logger=logger) - info = utils.runcmd("git log --format='%an;%ae;%ad;%cd' --date=rfc -n 1 " \ - + commit, destdir=repodir, logger=logger) - recordcommit = commit - try: - with transaction.atomic(): - for recipe_data in recipes: - _create_upgrade(recipe_data, layerbranch, recordcommit, title, - info, logger, initial=options.initial) - if options.dry_run: - raise DryRunRollbackException - except DryRunRollbackException: - pass - tinfoil.shutdown() + if options.initial: + title = options.initial + info = 'No maintainer;;' + utils.runcmd("git log --format='%ad;%cd' --date=rfc -n 1 " \ + + commit, destdir=repodir, logger=logger) + recordcommit = '' + else: + title = utils.runcmd("git log --format='%s' -n 1 " + commit, + repodir, logger=logger) + info = utils.runcmd("git log --format='%an;%ae;%ad;%cd' --date=rfc -n 1 " \ + + commit, destdir=repodir, logger=logger) + recordcommit = commit + + try: + with transaction.atomic(): + for recipe_data in recipes: + _create_upgrade(recipe_data, layerbranch, recordcommit, title, + info, logger, initial=options.initial) + if options.dry_run: + raise DryRunRollbackException + except DryRunRollbackException: + pass + + finally: + if tinfoil and hasattr(tinfoil, 'shutdown') and (LooseVersion(bb.__version__) > LooseVersion("1.27")): + tinfoil.shutdown() if __name__=="__main__":