diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2015-11-23 10:14:44 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-12-01 21:32:03 +0000 |
commit | 9a704441b7a40e93626af606cb51c282a8f66850 (patch) | |
tree | 251784f36ee3e0299054c2aa74424b9e456079f8 /scripts/lib | |
parent | 6a52c738ba0734f0f37b45af7e6836b2fe06fe8a (diff) | |
download | poky-9a704441b7a40e93626af606cb51c282a8f66850.tar.gz |
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 rev: 8b8f04226ebf464fa61c05ca7af7c6cbda392339)
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>
Diffstat (limited to 'scripts/lib')
-rw-r--r-- | scripts/lib/devtool/upgrade.py | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py index 5410c9dd02..14eff665b6 100644 --- a/scripts/lib/devtool/upgrade.py +++ b/scripts/lib/devtool/upgrade.py | |||
@@ -91,15 +91,13 @@ def _remove_patch_dirs(recipefolder): | |||
91 | for d in dirs: | 91 | for d in dirs: |
92 | shutil.rmtree(os.path.join(root,d)) | 92 | shutil.rmtree(os.path.join(root,d)) |
93 | 93 | ||
94 | def _recipe_contains(rf, var): | 94 | def _recipe_contains(rd, var): |
95 | import re | 95 | rf = rd.getVar('FILE', True) |
96 | found = False | 96 | varfiles = oe.recipeutils.get_var_files(rf, [var], rd) |
97 | with open(rf) as f: | 97 | for var, fn in varfiles.iteritems(): |
98 | for line in f: | 98 | if fn and fn.startswith(os.path.dirname(rf) + os.sep): |
99 | if re.match("^%s.*=.*" % var, line): | 99 | return True |
100 | found = True | 100 | return False |
101 | break | ||
102 | return found | ||
103 | 101 | ||
104 | def _rename_recipe_dirs(oldpv, newpv, path): | 102 | def _rename_recipe_dirs(oldpv, newpv, path): |
105 | for root, dirs, files in os.walk(path): | 103 | 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 | |||
257 | 255 | ||
258 | return (rev, md5, sha256) | 256 | return (rev, md5, sha256) |
259 | 257 | ||
260 | def _create_new_recipe(newpv, md5, sha256, workspace, rd): | 258 | def _create_new_recipe(newpv, md5, sha256, srcrev, workspace, tinfoil, rd): |
261 | """Creates the new recipe under workspace""" | 259 | """Creates the new recipe under workspace""" |
262 | crd = rd.createCopy() | 260 | crd = rd.createCopy() |
263 | 261 | ||
@@ -271,8 +269,16 @@ def _create_new_recipe(newpv, md5, sha256, workspace, rd): | |||
271 | newpv = oldpv | 269 | newpv = oldpv |
272 | fullpath = _rename_recipe_files(bpn, oldpv, newpv, path) | 270 | fullpath = _rename_recipe_files(bpn, oldpv, newpv, path) |
273 | 271 | ||
274 | if _recipe_contains(fullpath, 'PV') and newpv != oldpv: | 272 | newvalues = {} |
275 | oe.recipeutils.patch_recipe(d, fullpath, {'PV':newpv}) | 273 | if _recipe_contains(rd, 'PV') and newpv != oldpv: |
274 | newvalues['PV'] = newpv | ||
275 | |||
276 | if srcrev: | ||
277 | newvalues['SRCREV'] = srcrev | ||
278 | |||
279 | if newvalues: | ||
280 | rd = oe.recipeutils.parse_recipe(fullpath, None, tinfoil.config_data) | ||
281 | oe.recipeutils.patch_recipe(rd, fullpath, newvalues) | ||
276 | 282 | ||
277 | if md5 and sha256: | 283 | if md5 and sha256: |
278 | # Unfortunately, oe.recipeutils.patch_recipe cannot update flags. | 284 | # Unfortunately, oe.recipeutils.patch_recipe cannot update flags. |
@@ -294,7 +300,7 @@ def upgrade(args, config, basepath, workspace): | |||
294 | if reason: | 300 | if reason: |
295 | raise DevtoolError(reason) | 301 | raise DevtoolError(reason) |
296 | 302 | ||
297 | tinfoil = setup_tinfoil(basepath=basepath) | 303 | tinfoil = setup_tinfoil(basepath=basepath, tracking=True) |
298 | 304 | ||
299 | rd = parse_recipe(config, tinfoil, args.recipename, True) | 305 | rd = parse_recipe(config, tinfoil, args.recipename, True) |
300 | if not rd: | 306 | if not rd: |
@@ -316,7 +322,7 @@ def upgrade(args, config, basepath, workspace): | |||
316 | rev2, md5, sha256 = _extract_new_source(args.version, args.srctree, args.no_patch, | 322 | rev2, md5, sha256 = _extract_new_source(args.version, args.srctree, args.no_patch, |
317 | args.srcrev, args.branch, args.keep_temp, | 323 | args.srcrev, args.branch, args.keep_temp, |
318 | tinfoil, rd) | 324 | tinfoil, rd) |
319 | rf = _create_new_recipe(args.version, md5, sha256, config.workspace_path, rd) | 325 | rf = _create_new_recipe(args.version, md5, sha256, args.srcrev, config.workspace_path, tinfoil, rd) |
320 | except bb.process.CmdError as e: | 326 | except bb.process.CmdError as e: |
321 | _upgrade_error(e, rf, args.srctree) | 327 | _upgrade_error(e, rf, args.srctree) |
322 | except DevtoolError as e: | 328 | except DevtoolError as e: |