diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-06-03 17:44:27 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-06-05 16:42:17 +0100 |
commit | 20a3a36547831349d5d8b429cb35f1415a856bda (patch) | |
tree | 5a8ae41a8fa09237f0f5c67079be2bab68bd4943 /scripts/combo-layer | |
parent | ffd9a4bad8a08e23c421b1ce467f0a59249efe10 (diff) | |
download | poky-20a3a36547831349d5d8b429cb35f1415a856bda.tar.gz |
scripts/combo-layer: Fix exit codes and tty handling
If combo-layer is called from a non-interactive context we should exit
with a correct error code rather than try and drop to a shell.
This patch cleans up a few error case exit codes as well as
detecting and handling non-interactive usage.
(From OE-Core rev: 3b1d89a51445cf526ca84eb5b53de434f9585d6e)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/combo-layer')
-rwxr-xr-x | scripts/combo-layer | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/scripts/combo-layer b/scripts/combo-layer index 698d3e3baa..4029d2bff8 100755 --- a/scripts/combo-layer +++ b/scripts/combo-layer | |||
@@ -502,6 +502,10 @@ def check_patch(patchfile): | |||
502 | os.rename(patchfile + '.tmp', patchfile) | 502 | os.rename(patchfile + '.tmp', patchfile) |
503 | 503 | ||
504 | def drop_to_shell(workdir=None): | 504 | def drop_to_shell(workdir=None): |
505 | if not sys.stdin.isatty(): | ||
506 | print "Not a TTY so can't drop to shell for resolution, exiting." | ||
507 | return False | ||
508 | |||
505 | shell = os.environ.get('SHELL', 'bash') | 509 | shell = os.environ.get('SHELL', 'bash') |
506 | print('Dropping to shell "%s"\n' \ | 510 | print('Dropping to shell "%s"\n' \ |
507 | 'When you are finished, run the following to continue:\n' \ | 511 | 'When you are finished, run the following to continue:\n' \ |
@@ -547,7 +551,7 @@ def get_repos(conf, repo_names): | |||
547 | for repo in repos: | 551 | for repo in repos: |
548 | if not repo in conf.repos: | 552 | if not repo in conf.repos: |
549 | logger.error("Specified component '%s' not found in configuration" % repo) | 553 | logger.error("Specified component '%s' not found in configuration" % repo) |
550 | sys.exit(0) | 554 | sys.exit(1) |
551 | 555 | ||
552 | if not repos: | 556 | if not repos: |
553 | repos = conf.repos | 557 | repos = conf.repos |
@@ -695,7 +699,7 @@ def action_update(conf, args): | |||
695 | print('You may now edit the patch and patch list in %s\n' \ | 699 | print('You may now edit the patch and patch list in %s\n' \ |
696 | 'For example, you can remove unwanted patch entries from patchlist-*, so that they will be not applied later' % patch_dir); | 700 | 'For example, you can remove unwanted patch entries from patchlist-*, so that they will be not applied later' % patch_dir); |
697 | if not drop_to_shell(patch_dir): | 701 | if not drop_to_shell(patch_dir): |
698 | sys.exit(0) | 702 | sys.exit(1) |
699 | 703 | ||
700 | # Step 6: apply the generated and revised patch | 704 | # Step 6: apply the generated and revised patch |
701 | apply_patchlist(conf, repos) | 705 | apply_patchlist(conf, repos) |
@@ -761,7 +765,7 @@ def apply_patchlist(conf, repos): | |||
761 | if not drop_to_shell(): | 765 | if not drop_to_shell(): |
762 | if prevrev != repo['last_revision']: | 766 | if prevrev != repo['last_revision']: |
763 | conf.update(name, "last_revision", prevrev) | 767 | conf.update(name, "last_revision", prevrev) |
764 | sys.exit(0) | 768 | sys.exit(1) |
765 | prevrev = lastrev | 769 | prevrev = lastrev |
766 | i += 1 | 770 | i += 1 |
767 | # Once all patches are applied, we should update | 771 | # Once all patches are applied, we should update |