From f0fa06d2c0319f0432bae8fc54ebd05ee3b04e65 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Mon, 6 Aug 2018 10:26:09 +0200 Subject: [PATCH] bulkchange: make script more robust * Check if bitbake directory can be found before trying to do anything with the repo * Split try..finally into two so we don't try to shut down a nonexistent tinfoil when we failed to gain a lock. Signed-off-by: Paul Eggleton --- layerindex/bulkchange.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/layerindex/bulkchange.py b/layerindex/bulkchange.py index c06acce..be57130 100644 --- a/layerindex/bulkchange.py +++ b/layerindex/bulkchange.py @@ -96,6 +96,10 @@ def main(): fetchdir = settings.LAYER_FETCH_DIR bitbakepath = os.path.join(fetchdir, 'bitbake') + if not os.path.exists(bitbakepath): + sys.stderr.write("Unable to find bitbake checkout at %s" % bitbakepath) + sys.exit(1) + lockfn = os.path.join(fetchdir, "layerindex.lock") lockfile = utils.lock_file(lockfn) if not lockfile: @@ -103,17 +107,18 @@ def main(): sys.exit(1) try: (tinfoil, tempdir) = recipeparse.init_parser(settings, branch, bitbakepath, True) + try: + changeset = get_changeset(sys.argv[1]) + if not changeset: + sys.stderr.write("Unable to find changeset with id %s\n" % sys.argv[1]) + sys.exit(1) - changeset = get_changeset(sys.argv[1]) - if not changeset: - sys.stderr.write("Unable to find changeset with id %s\n" % sys.argv[1]) - sys.exit(1) + utils.setup_core_layer_sys_path(settings, branch.name) - utils.setup_core_layer_sys_path(settings, branch.name) - - outp = generate_patches(tinfoil, fetchdir, changeset, sys.argv[2]) + outp = generate_patches(tinfoil, fetchdir, changeset, sys.argv[2]) + finally: + tinfoil.shutdown() finally: - tinfoil.shutdown() utils.unlock_file(lockfile) if outp: