diff options
-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: |