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 <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2018-08-06 10:26:09 +02:00
parent 725c7e054c
commit f0fa06d2c0

View File

@ -96,6 +96,10 @@ def main():
fetchdir = settings.LAYER_FETCH_DIR fetchdir = settings.LAYER_FETCH_DIR
bitbakepath = os.path.join(fetchdir, 'bitbake') 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") lockfn = os.path.join(fetchdir, "layerindex.lock")
lockfile = utils.lock_file(lockfn) lockfile = utils.lock_file(lockfn)
if not lockfile: if not lockfile:
@ -103,7 +107,7 @@ def main():
sys.exit(1) sys.exit(1)
try: try:
(tinfoil, tempdir) = recipeparse.init_parser(settings, branch, bitbakepath, True) (tinfoil, tempdir) = recipeparse.init_parser(settings, branch, bitbakepath, True)
try:
changeset = get_changeset(sys.argv[1]) changeset = get_changeset(sys.argv[1])
if not changeset: if not changeset:
sys.stderr.write("Unable to find changeset with id %s\n" % sys.argv[1]) sys.stderr.write("Unable to find changeset with id %s\n" % sys.argv[1])
@ -114,6 +118,7 @@ def main():
outp = generate_patches(tinfoil, fetchdir, changeset, sys.argv[2]) outp = generate_patches(tinfoil, fetchdir, changeset, sys.argv[2])
finally: finally:
tinfoil.shutdown() tinfoil.shutdown()
finally:
utils.unlock_file(lockfile) utils.unlock_file(lockfile)
if outp: if outp: