summaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2017-10-03 16:36:19 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-11-11 12:14:27 +0000
commitb5c72fe5844eb334a86ab53bd7238c7da9781562 (patch)
tree3702401248985a33bf0cb13f22b3a1c75a525b4b /scripts/lib/devtool
parentff1efda2af1027421cb27a398484b4b4e4798646 (diff)
downloadpoky-b5c72fe5844eb334a86ab53bd7238c7da9781562.tar.gz
devtool: upgrade: handle recipes that use named SRC_URI checksums
devtool upgrade did not properly handle setting SRC_URI checksums for recipes that use named SRC_URI entries and also use those names in the SRC_URI checksums. A further complication was where the name contained an expression that changed with the version e.g. ${PV} (probably quite rare, but the dnsmasq recipe in meta-networking is currently one such recipe.) All of these are now handled properly. Additionally, drop the _get_checksums() function that wasn't being called from anywhere in the code. Note that this now turns nowrap_vars in recipeutils.py to be a list of regexes, hence things such as [ and ] need to be appropriately escaped. (From OE-Core rev: c914a5e1ad6d96e316746222e5d42f2ba9110060) 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/devtool')
-rw-r--r--scripts/lib/devtool/upgrade.py53
1 files changed, 40 insertions, 13 deletions
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py
index ab7acd16c6..6d51958d51 100644
--- a/scripts/lib/devtool/upgrade.py
+++ b/scripts/lib/devtool/upgrade.py
@@ -55,17 +55,6 @@ def _copy_source_code(orig, dest):
55 dest_path = os.path.join(dest, path) 55 dest_path = os.path.join(dest, path)
56 shutil.move(os.path.join(orig, path), dest_path) 56 shutil.move(os.path.join(orig, path), dest_path)
57 57
58def _get_checksums(rf):
59 import re
60 checksums = {}
61 with open(rf) as f:
62 for line in f:
63 for cs in ['md5sum', 'sha256sum']:
64 m = re.match("^SRC_URI\[%s\].*=.*\"(.*)\"" % cs, line)
65 if m:
66 checksums[cs] = m.group(1)
67 return checksums
68
69def _remove_patch_dirs(recipefolder): 58def _remove_patch_dirs(recipefolder):
70 for root, dirs, files in os.walk(recipefolder): 59 for root, dirs, files in os.walk(recipefolder):
71 for d in dirs: 60 for d in dirs:
@@ -353,9 +342,47 @@ def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, workspace, tinfoil
353 342
354 newvalues['PR'] = None 343 newvalues['PR'] = None
355 344
345 # Work out which SRC_URI entries have changed in case the entry uses a name
346 crd = rd.createCopy()
347 crd.setVar('PV', newpv)
348 for var, value in newvalues.items():
349 crd.setVar(var, value)
350 old_src_uri = (rd.getVar('SRC_URI') or '').split()
351 new_src_uri = (crd.getVar('SRC_URI') or '').split()
352 newnames = []
353 addnames = []
354 for newentry in new_src_uri:
355 _, _, _, _, _, params = bb.fetch2.decodeurl(newentry)
356 if 'name' in params:
357 newnames.append(params['name'])
358 if newentry not in old_src_uri:
359 addnames.append(params['name'])
360 # Find what's been set in the original recipe
361 oldnames = []
362 noname = False
363 for varflag in rd.getVarFlags('SRC_URI'):
364 if varflag.endswith(('.md5sum', '.sha256sum')):
365 name = varflag.rsplit('.', 1)[0]
366 if name not in oldnames:
367 oldnames.append(name)
368 elif varflag in ['md5sum', 'sha256sum']:
369 noname = True
370 # Even if SRC_URI has named entries it doesn't have to actually use the name
371 if noname and addnames and addnames[0] not in oldnames:
372 addnames = []
373 # Drop any old names (the name actually might include ${PV})
374 for name in oldnames:
375 if name not in newnames:
376 newvalues['SRC_URI[%s.md5sum]' % name] = None
377 newvalues['SRC_URI[%s.sha256sum]' % name] = None
378
356 if md5 and sha256: 379 if md5 and sha256:
357 newvalues['SRC_URI[md5sum]'] = md5 380 if addnames:
358 newvalues['SRC_URI[sha256sum]'] = sha256 381 nameprefix = '%s.' % addnames[0]
382 else:
383 nameprefix = ''
384 newvalues['SRC_URI[%smd5sum]' % nameprefix] = md5
385 newvalues['SRC_URI[%ssha256sum]' % nameprefix] = sha256
359 386
360 rd = tinfoil.parse_recipe_file(fullpath, False) 387 rd = tinfoil.parse_recipe_file(fullpath, False)
361 oe.recipeutils.patch_recipe(rd, fullpath, newvalues) 388 oe.recipeutils.patch_recipe(rd, fullpath, newvalues)