1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-31 00:39:46 +00:00

devtool: upgrade: fix updating PV and SRCREV

This code was clearly never tested. Fix the following issues:
* Actually set SRCREV if it's been specified
* Enable history tracking and reparse so that we handle if variables are
  set in an inc file next to the recipe
* Use a more accurate check for PV being in the recipe which will work
  if it's in an inc file next to the recipe

(From OE-Core master rev: 8b8f04226ebf464fa61c05ca7af7c6cbda392339)

(From OE-Core rev: 105a7c90dac6f43b7c3d1de92827db2db8419112)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Paul Eggleton
2015-11-23 10:14:44 +13:00
committed by Richard Purdie
parent 3b4f65968e
commit fec97f6fa2
+20 -14
View File
@@ -91,15 +91,13 @@ def _remove_patch_dirs(recipefolder):
for d in dirs: for d in dirs:
shutil.rmtree(os.path.join(root,d)) shutil.rmtree(os.path.join(root,d))
def _recipe_contains(rf, var): def _recipe_contains(rd, var):
import re rf = rd.getVar('FILE', True)
found = False varfiles = oe.recipeutils.get_var_files(rf, [var], rd)
with open(rf) as f: for var, fn in varfiles.iteritems():
for line in f: if fn and fn.startswith(os.path.dirname(rf) + os.sep):
if re.match("^%s.*=.*" % var, line): return True
found = True return False
break
return found
def _rename_recipe_dirs(oldpv, newpv, path): def _rename_recipe_dirs(oldpv, newpv, path):
for root, dirs, files in os.walk(path): for root, dirs, files in os.walk(path):
@@ -257,7 +255,7 @@ def _extract_new_source(newpv, srctree, no_patch, srcrev, branch, keep_temp, tin
return (rev, md5, sha256) return (rev, md5, sha256)
def _create_new_recipe(newpv, md5, sha256, workspace, rd): def _create_new_recipe(newpv, md5, sha256, srcrev, workspace, tinfoil, rd):
"""Creates the new recipe under workspace""" """Creates the new recipe under workspace"""
crd = rd.createCopy() crd = rd.createCopy()
@@ -271,8 +269,16 @@ def _create_new_recipe(newpv, md5, sha256, workspace, rd):
newpv = oldpv newpv = oldpv
fullpath = _rename_recipe_files(bpn, oldpv, newpv, path) fullpath = _rename_recipe_files(bpn, oldpv, newpv, path)
if _recipe_contains(fullpath, 'PV') and newpv != oldpv: newvalues = {}
oe.recipeutils.patch_recipe(d, fullpath, {'PV':newpv}) if _recipe_contains(rd, 'PV') and newpv != oldpv:
newvalues['PV'] = newpv
if srcrev:
newvalues['SRCREV'] = srcrev
if newvalues:
rd = oe.recipeutils.parse_recipe(fullpath, None, tinfoil.config_data)
oe.recipeutils.patch_recipe(rd, fullpath, newvalues)
if md5 and sha256: if md5 and sha256:
# Unfortunately, oe.recipeutils.patch_recipe cannot update flags. # Unfortunately, oe.recipeutils.patch_recipe cannot update flags.
@@ -294,7 +300,7 @@ def upgrade(args, config, basepath, workspace):
if reason: if reason:
raise DevtoolError(reason) raise DevtoolError(reason)
tinfoil = setup_tinfoil(basepath=basepath) tinfoil = setup_tinfoil(basepath=basepath, tracking=True)
rd = parse_recipe(config, tinfoil, args.recipename, True) rd = parse_recipe(config, tinfoil, args.recipename, True)
if not rd: if not rd:
@@ -316,7 +322,7 @@ def upgrade(args, config, basepath, workspace):
rev2, md5, sha256 = _extract_new_source(args.version, args.srctree, args.no_patch, rev2, md5, sha256 = _extract_new_source(args.version, args.srctree, args.no_patch,
args.srcrev, args.branch, args.keep_temp, args.srcrev, args.branch, args.keep_temp,
tinfoil, rd) tinfoil, rd)
rf = _create_new_recipe(args.version, md5, sha256, config.workspace_path, rd) rf = _create_new_recipe(args.version, md5, sha256, args.srcrev, config.workspace_path, tinfoil, rd)
except bb.process.CmdError as e: except bb.process.CmdError as e:
_upgrade_error(e, rf, args.srctree) _upgrade_error(e, rf, args.srctree)
except DevtoolError as e: except DevtoolError as e: