From 1fbd76093dadd990dcb6ef8bd35659c73950cf7e Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Mon, 18 May 2015 12:04:55 +0100 Subject: 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 Signed-off-by: Ross Burton Signed-off-by: Richard Purdie --- scripts/lib/devtool/upgrade.py | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) (limited to 'scripts/lib/devtool') 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): checksums[cs] = m.group(1) return checksums -def _replace_checksums(rf, md5, sha256): - if not md5 and not sha256: - return - checksums = {'md5sum':md5, 'sha256sum':sha256} - with open(rf + ".tmp", "w+") as tmprf: - with open(rf) as f: - for line in f: - m = None - for cs in checksums.keys(): - m = re.match("^SRC_URI\[%s\].*=.*\"(.*)\"" % cs, line) - if m: - if checksums[cs]: - oldcheck = m.group(1) - newcheck = checksums[cs] - line = line.replace(oldcheck, newcheck) - break - tmprf.write(line) - os.rename(rf + ".tmp", rf) - - def _remove_patch_dirs(recipefolder): for root, dirs, files in os.walk(recipefolder): for d in dirs: @@ -297,16 +277,14 @@ def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, workspace, tinfoil if changed: newvalues['SRC_URI'] = ' '.join(new_src_uri) + if md5 and sha256: + newvalues['SRC_URI[md5sum]'] = md5 + newvalues['SRC_URI[sha256sum]'] = sha256 + if newvalues: rd = oe.recipeutils.parse_recipe(fullpath, None, tinfoil.config_data) oe.recipeutils.patch_recipe(rd, fullpath, newvalues) - if md5 and sha256: - # Unfortunately, oe.recipeutils.patch_recipe cannot update flags. - # once the latter feature is implemented, we should call patch_recipe - # instead of the following function - _replace_checksums(fullpath, md5, sha256) - return fullpath def upgrade(args, config, basepath, workspace): -- cgit v1.2.3-54-g00ecf