rrs/tools: handle dry-run properly

In the case of dry-run a couple of the scripts were breaking out after
one layerbranch had been processed due to the code structure. Handle the
exception within the block for the layerbranch to avoid this.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2018-09-04 15:28:39 +12:00
parent 0201a86f0d
commit 9d0e048ded
2 changed files with 61 additions and 60 deletions

View File

@ -112,9 +112,7 @@ if __name__=="__main__":
logger.debug("Starting recipe distros update ...") logger.debug("Starting recipe distros update ...")
try:
origsyspath = sys.path origsyspath = sys.path
with transaction.atomic():
for maintplan in maintplans: for maintplan in maintplans:
for item in maintplan.maintenanceplanlayerbranch_set.all(): for item in maintplan.maintenanceplanlayerbranch_set.all():
layerbranch = item.layerbranch layerbranch = item.layerbranch
@ -125,6 +123,8 @@ if __name__=="__main__":
if not recipes: if not recipes:
continue continue
try:
with transaction.atomic():
utils.setup_core_layer_sys_path(settings, layerbranch.branch.name) utils.setup_core_layer_sys_path(settings, layerbranch.branch.name)
from oe import distro_check from oe import distro_check
@ -153,10 +153,10 @@ if __name__=="__main__":
recipedistro.save() recipedistro.save()
logger.debug('%s: layer branch %s, add distro %s alias %s' % (pn, logger.debug('%s: layer branch %s, add distro %s alias %s' % (pn,
str(layerbranch), distro, alias)) str(layerbranch), distro, alias))
finally:
tinfoil.shutdown()
shutil.rmtree(tempdir)
if options.dry_run: if options.dry_run:
raise DryRunRollbackException raise DryRunRollbackException
except DryRunRollbackException: except DryRunRollbackException:
pass pass
finally:
tinfoil.shutdown()
shutil.rmtree(tempdir)

View File

@ -178,6 +178,7 @@ if __name__=="__main__":
for maintplan in maintplans: for maintplan in maintplans:
for item in maintplan.maintenanceplanlayerbranch_set.all(): for item in maintplan.maintenanceplanlayerbranch_set.all():
layerbranch = item.layerbranch layerbranch = item.layerbranch
try:
with transaction.atomic(): with transaction.atomic():
sys.path = origsyspath sys.path = origsyspath