mirror of
https://git.yoctoproject.org/poky
synced 2026-04-21 21:32:12 +02:00
devtool/upgrade: correctly clean up when recipe filename isn't yet known
There is a coding error in the second invocation of _upgrade_error: rf is passed into it before it is initialized in the try: block. And so bogus recipes are left behind in the workspace, causing breakage. Instead, rewrite the functions to take the recipe directory name in the workspace layer, which can be calculated in advance. (From OE-Core rev: a7d406dce577192f98d76dbae411c72a8b7f07d4) Signed-off-by: Alexander Kanavin <alex@linutronix.de> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> (cherry picked from commit e653996369c1d2b5ac8367ad85f4816d679b6c98) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
58d3e1b897
commit
53019423e4
@@ -119,20 +119,19 @@ def _write_append(rc, srctree, same_dir, no_same_dir, rev, copied, workspace, d)
|
||||
f.write('# original_files: %s\n' % ' '.join(copied))
|
||||
return af
|
||||
|
||||
def _cleanup_on_error(rf, srctree):
|
||||
rfp = os.path.split(rf)[0] # recipe folder
|
||||
rfpp = os.path.split(rfp)[0] # recipes folder
|
||||
if os.path.exists(rfp):
|
||||
shutil.rmtree(rfp)
|
||||
if not len(os.listdir(rfpp)):
|
||||
os.rmdir(rfpp)
|
||||
def _cleanup_on_error(rd, srctree):
|
||||
rdp = os.path.split(rd)[0] # recipes folder
|
||||
if os.path.exists(rd):
|
||||
shutil.rmtree(rd)
|
||||
if not len(os.listdir(rdp)):
|
||||
os.rmdir(rdp)
|
||||
srctree = os.path.abspath(srctree)
|
||||
if os.path.exists(srctree):
|
||||
shutil.rmtree(srctree)
|
||||
|
||||
def _upgrade_error(e, rf, srctree, keep_failure=False, extramsg=None):
|
||||
if rf and not keep_failure:
|
||||
_cleanup_on_error(rf, srctree)
|
||||
def _upgrade_error(e, rd, srctree, keep_failure=False, extramsg=None):
|
||||
if not keep_failure:
|
||||
_cleanup_on_error(rd, srctree)
|
||||
logger.error(e)
|
||||
if extramsg:
|
||||
logger.error(extramsg)
|
||||
@@ -426,7 +425,7 @@ def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, srcsubdir_old, src
|
||||
try:
|
||||
rd = tinfoil.parse_recipe_file(fullpath, False)
|
||||
except bb.tinfoil.TinfoilCommandFailed as e:
|
||||
_upgrade_error(e, fullpath, srctree, keep_failure, 'Parsing of upgraded recipe failed')
|
||||
_upgrade_error(e, os.path.dirname(fullpath), srctree, keep_failure, 'Parsing of upgraded recipe failed')
|
||||
oe.recipeutils.patch_recipe(rd, fullpath, newvalues)
|
||||
|
||||
return fullpath, copied
|
||||
@@ -568,10 +567,9 @@ def upgrade(args, config, basepath, workspace):
|
||||
new_licenses = _extract_licenses(srctree_s, (rd.getVar('LIC_FILES_CHKSUM') or ""))
|
||||
license_diff = _generate_license_diff(old_licenses, new_licenses)
|
||||
rf, copied = _create_new_recipe(args.version, md5, sha256, args.srcrev, srcbranch, srcsubdir1, srcsubdir2, config.workspace_path, tinfoil, rd, license_diff, new_licenses, srctree, args.keep_failure)
|
||||
except bb.process.CmdError as e:
|
||||
_upgrade_error(e, rf, srctree, args.keep_failure)
|
||||
except DevtoolError as e:
|
||||
_upgrade_error(e, rf, srctree, args.keep_failure)
|
||||
except (bb.process.CmdError, DevtoolError) as e:
|
||||
recipedir = os.path.join(config.workspace_path, 'recipes', rd.getVar('BPN'))
|
||||
_upgrade_error(e, recipedir, srctree, args.keep_failure)
|
||||
standard._add_md5(config, pn, os.path.dirname(rf))
|
||||
|
||||
af = _write_append(rf, srctree_s, args.same_dir, args.no_same_dir, rev2,
|
||||
|
||||
Reference in New Issue
Block a user