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 <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2018-03-26 16:59:32 +13:00
parent ba27f9fee0
commit acac7d6e9c

View File

@ -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__":