diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2015-05-18 12:04:55 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-12-01 21:32:04 +0000 |
commit | 1fbd76093dadd990dcb6ef8bd35659c73950cf7e (patch) | |
tree | ae6f5f9ea817ba02e721cceb9d2dda2227e2258a /scripts | |
parent | 0b850cb231231371b496ae5ee6f7571c3de2f448 (diff) | |
download | poky-1fbd76093dadd990dcb6ef8bd35659c73950cf7e.tar.gz |
lib/oe/recipeutils: refactor patch_recipe_file() to use edit_metadata()
Use bb.utils.edit_metadata() to replace some of the logic in this
function; this avoids us effectively having two implementations of the
same thing. In the process fix the following issues:
* Insert values before any leading comments for the next variable
instead of after them
* Insert overridden variables (e.g. RDEPENDS_${PN}) in the correct place
* Properly handle replacing varflag settings (e.g. SRC_URI[md5sum])
(From OE-Core rev: 0f81b83fc5fd908efa7f6b837137830ca65f6ed6)
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')
-rw-r--r-- | scripts/lib/devtool/upgrade.py | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py index fbffae06fe..e2be38e7af 100644 --- a/scripts/lib/devtool/upgrade.py +++ b/scripts/lib/devtool/upgrade.py | |||
@@ -62,26 +62,6 @@ def _get_checksums(rf): | |||
62 | checksums[cs] = m.group(1) | 62 | checksums[cs] = m.group(1) |
63 | return checksums | 63 | return checksums |
64 | 64 | ||
65 | def _replace_checksums(rf, md5, sha256): | ||
66 | if not md5 and not sha256: | ||
67 | return | ||
68 | checksums = {'md5sum':md5, 'sha256sum':sha256} | ||
69 | with open(rf + ".tmp", "w+") as tmprf: | ||
70 | with open(rf) as f: | ||
71 | for line in f: | ||
72 | m = None | ||
73 | for cs in checksums.keys(): | ||
74 | m = re.match("^SRC_URI\[%s\].*=.*\"(.*)\"" % cs, line) | ||
75 | if m: | ||
76 | if checksums[cs]: | ||
77 | oldcheck = m.group(1) | ||
78 | newcheck = checksums[cs] | ||
79 | line = line.replace(oldcheck, newcheck) | ||
80 | break | ||
81 | tmprf.write(line) | ||
82 | os.rename(rf + ".tmp", rf) | ||
83 | |||
84 | |||
85 | def _remove_patch_dirs(recipefolder): | 65 | def _remove_patch_dirs(recipefolder): |
86 | for root, dirs, files in os.walk(recipefolder): | 66 | for root, dirs, files in os.walk(recipefolder): |
87 | for d in dirs: | 67 | for d in dirs: |
@@ -297,16 +277,14 @@ def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, workspace, tinfoil | |||
297 | if changed: | 277 | if changed: |
298 | newvalues['SRC_URI'] = ' '.join(new_src_uri) | 278 | newvalues['SRC_URI'] = ' '.join(new_src_uri) |
299 | 279 | ||
280 | if md5 and sha256: | ||
281 | newvalues['SRC_URI[md5sum]'] = md5 | ||
282 | newvalues['SRC_URI[sha256sum]'] = sha256 | ||
283 | |||
300 | if newvalues: | 284 | if newvalues: |
301 | rd = oe.recipeutils.parse_recipe(fullpath, None, tinfoil.config_data) | 285 | rd = oe.recipeutils.parse_recipe(fullpath, None, tinfoil.config_data) |
302 | oe.recipeutils.patch_recipe(rd, fullpath, newvalues) | 286 | oe.recipeutils.patch_recipe(rd, fullpath, newvalues) |
303 | 287 | ||
304 | if md5 and sha256: | ||
305 | # Unfortunately, oe.recipeutils.patch_recipe cannot update flags. | ||
306 | # once the latter feature is implemented, we should call patch_recipe | ||
307 | # instead of the following function | ||
308 | _replace_checksums(fullpath, md5, sha256) | ||
309 | |||
310 | return fullpath | 288 | return fullpath |
311 | 289 | ||
312 | def upgrade(args, config, basepath, workspace): | 290 | def upgrade(args, config, basepath, workspace): |