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 <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
f558ecf90e
commit
2dc0b337bc
|
@ -184,6 +184,19 @@ def check_patch(patchfile):
|
||||||
of.close()
|
of.close()
|
||||||
os.rename(patchfile + '.tmp', patchfile)
|
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):
|
def get_repos(conf, args):
|
||||||
repos = []
|
repos = []
|
||||||
if len(args) > 1:
|
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
|
# Step 5: invoke bash for user to edit patch and patch list
|
||||||
if conf.interactive:
|
if conf.interactive:
|
||||||
print 'Edit the patch and patch list in %s\n' \
|
print('You may now 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' \
|
'For example, you can remove unwanted patch entries from patchlist-*, so that they will be not applied later' % patch_dir);
|
||||||
'When you are finished, run the following to continue:\n' \
|
if not drop_to_shell(patch_dir):
|
||||||
' 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"
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
# Step 6: apply the generated and revised patch
|
# Step 6: apply the generated and revised patch
|
||||||
|
@ -328,6 +336,7 @@ def apply_patchlist(conf, repos):
|
||||||
for name in repos:
|
for name in repos:
|
||||||
repo = conf.repos[name]
|
repo = conf.repos[name]
|
||||||
lastrev = repo["last_revision"]
|
lastrev = repo["last_revision"]
|
||||||
|
prevrev = lastrev
|
||||||
for line in open(repo['patchlist']):
|
for line in open(repo['patchlist']):
|
||||||
patchfile = line.split()[0]
|
patchfile = line.split()[0]
|
||||||
lastrev = line.split()[1]
|
lastrev = line.split()[1]
|
||||||
|
@ -343,9 +352,12 @@ def apply_patchlist(conf, repos):
|
||||||
runcmd("git am --abort")
|
runcmd("git am --abort")
|
||||||
logger.error('"%s" failed' % cmd)
|
logger.error('"%s" failed' % cmd)
|
||||||
logger.info("please manually apply patch %s" % patchfile)
|
logger.info("please manually apply patch %s" % patchfile)
|
||||||
logger.info("After applying, run this tool again to apply the remaining patches")
|
logger.info("Note: if you exit and continue applying without manually applying the patch, it will be skipped")
|
||||||
conf.update(name, "last_revision", lastrev)
|
if not drop_to_shell():
|
||||||
sys.exit(0)
|
if prevrev != repo['last_revision']:
|
||||||
|
conf.update(name, "last_revision", prevrev)
|
||||||
|
sys.exit(0)
|
||||||
|
prevrev = lastrev
|
||||||
if lastrev != repo['last_revision']:
|
if lastrev != repo['last_revision']:
|
||||||
conf.update(name, "last_revision", lastrev)
|
conf.update(name, "last_revision", lastrev)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue