From 2dc0b337bc53c94ca60423dd0a39086bb62d36ef Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Tue, 31 Jul 2012 01:06:23 +0100 Subject: combo-layer: drop to a shell when apply fails during update If applying a patch fails during the update process, drop to a shell instead of exiting; at that point the user can manually apply the patch, do nothing and "exit" to skip it, or "exit 1" to abort the process. (From OE-Core rev: c82b28982c4f630c130c827a7da3ac0454cd93b6) Signed-off-by: Paul Eggleton Signed-off-by: Richard Purdie --- scripts/combo-layer | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'scripts/combo-layer') diff --git a/scripts/combo-layer b/scripts/combo-layer index a93fb9b0e6..4025b72a87 100755 --- a/scripts/combo-layer +++ b/scripts/combo-layer @@ -184,6 +184,19 @@ def check_patch(patchfile): of.close() os.rename(patchfile + '.tmp', patchfile) +def drop_to_shell(workdir=None): + shell = os.environ.get('SHELL', 'bash') + print('Dropping to shell "%s"\n' \ + 'When you are finished, run the following to continue:\n' \ + ' exit -- continue to apply the patches\n' \ + ' exit 1 -- abort\n' % shell); + ret = subprocess.call([shell], cwd=workdir) + if ret != 0: + print "Aborting" + return False + else: + return True + def get_repos(conf, args): repos = [] if len(args) > 1: @@ -295,14 +308,9 @@ def action_update(conf, args): # Step 5: invoke bash for user to edit patch and patch list if conf.interactive: - print 'Edit the patch and patch list in %s\n' \ - 'For example, remove the unwanted patch entry from patchlist-*, so that it will be not applied later\n' \ - 'When you are finished, run the following to continue:\n' \ - ' exit 0 -- exit and continue to apply the patch\n' \ - ' exit 1 -- abort and do not apply the patch\n' % patch_dir - ret = subprocess.call(["bash"], cwd=patch_dir) - if ret != 0: - print "Aborting without applying the patch" + print('You may now edit the patch and patch list in %s\n' \ + 'For example, you can remove unwanted patch entries from patchlist-*, so that they will be not applied later' % patch_dir); + if not drop_to_shell(patch_dir): sys.exit(0) # Step 6: apply the generated and revised patch @@ -328,6 +336,7 @@ def apply_patchlist(conf, repos): for name in repos: repo = conf.repos[name] lastrev = repo["last_revision"] + prevrev = lastrev for line in open(repo['patchlist']): patchfile = line.split()[0] lastrev = line.split()[1] @@ -343,9 +352,12 @@ def apply_patchlist(conf, repos): runcmd("git am --abort") logger.error('"%s" failed' % cmd) logger.info("please manually apply patch %s" % patchfile) - logger.info("After applying, run this tool again to apply the remaining patches") - conf.update(name, "last_revision", lastrev) - sys.exit(0) + logger.info("Note: if you exit and continue applying without manually applying the patch, it will be skipped") + if not drop_to_shell(): + if prevrev != repo['last_revision']: + conf.update(name, "last_revision", prevrev) + sys.exit(0) + prevrev = lastrev if lastrev != repo['last_revision']: conf.update(name, "last_revision", lastrev) -- cgit v1.2.3-54-g00ecf