summaryrefslogtreecommitdiffstats
path: root/scripts/lib
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2023-12-06 21:55:30 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-12-08 16:58:34 +0000
commitdd2fb8f00acedf758f51a5afa7f04e5bc24ad15f (patch)
tree075f8da4aa59841b9d732f8feb22d287cb0fb714 /scripts/lib
parent45d2f8d4bc2ca7c16379334a93ea172a538a6bb2 (diff)
downloadpoky-dd2fb8f00acedf758f51a5afa7f04e5bc24ad15f.tar.gz
devtool: upgrade: Update all existing checksums for the SRC_URI
In addition to updating the sha256sum and removing the md5sum, update all other existing checksums. If the only existing checksum is md5sum, then replace it with the default expected checksums (currently only sha256sum). (From OE-Core rev: 8ea8827ee49b7f0443b1c4bd47d1344a689d73a3) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/devtool/upgrade.py51
1 files changed, 28 insertions, 23 deletions
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py
index 10827a762b..a98370bc10 100644
--- a/scripts/lib/devtool/upgrade.py
+++ b/scripts/lib/devtool/upgrade.py
@@ -192,8 +192,7 @@ def _extract_new_source(newpv, srctree, no_patch, srcrev, srcbranch, branch, kee
192 __run('git submodule foreach \'git tag -f devtool-base-new\'') 192 __run('git submodule foreach \'git tag -f devtool-base-new\'')
193 (stdout, _) = __run('git submodule --quiet foreach \'echo $sm_path\'') 193 (stdout, _) = __run('git submodule --quiet foreach \'echo $sm_path\'')
194 paths += [os.path.join(srctree, p) for p in stdout.splitlines()] 194 paths += [os.path.join(srctree, p) for p in stdout.splitlines()]
195 md5 = None 195 checksums = {}
196 sha256 = None
197 _, _, _, _, _, params = bb.fetch2.decodeurl(uri) 196 _, _, _, _, _, params = bb.fetch2.decodeurl(uri)
198 srcsubdir_rel = params.get('destsuffix', 'git') 197 srcsubdir_rel = params.get('destsuffix', 'git')
199 if not srcbranch: 198 if not srcbranch:
@@ -226,9 +225,6 @@ def _extract_new_source(newpv, srctree, no_patch, srcrev, srcbranch, branch, kee
226 if ftmpdir and keep_temp: 225 if ftmpdir and keep_temp:
227 logger.info('Fetch temp directory is %s' % ftmpdir) 226 logger.info('Fetch temp directory is %s' % ftmpdir)
228 227
229 md5 = checksums['md5sum']
230 sha256 = checksums['sha256sum']
231
232 tmpsrctree = _get_srctree(tmpdir) 228 tmpsrctree = _get_srctree(tmpdir)
233 srctree = os.path.abspath(srctree) 229 srctree = os.path.abspath(srctree)
234 srcsubdir_rel = os.path.relpath(tmpsrctree, tmpdir) 230 srcsubdir_rel = os.path.relpath(tmpsrctree, tmpdir)
@@ -297,7 +293,7 @@ def _extract_new_source(newpv, srctree, no_patch, srcrev, srcbranch, branch, kee
297 if tmpdir != tmpsrctree: 293 if tmpdir != tmpsrctree:
298 shutil.rmtree(tmpdir) 294 shutil.rmtree(tmpdir)
299 295
300 return (revs, md5, sha256, srcbranch, srcsubdir_rel) 296 return (revs, checksums, srcbranch, srcsubdir_rel)
301 297
302def _add_license_diff_to_recipe(path, diff): 298def _add_license_diff_to_recipe(path, diff):
303 notice_text = """# FIXME: the LIC_FILES_CHKSUM values have been updated by 'devtool upgrade'. 299 notice_text = """# FIXME: the LIC_FILES_CHKSUM values have been updated by 'devtool upgrade'.
@@ -318,7 +314,7 @@ def _add_license_diff_to_recipe(path, diff):
318 f.write("\n#\n\n".encode()) 314 f.write("\n#\n\n".encode())
319 f.write(orig_content) 315 f.write(orig_content)
320 316
321def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, srcsubdir_old, srcsubdir_new, workspace, tinfoil, rd, license_diff, new_licenses, srctree, keep_failure): 317def _create_new_recipe(newpv, checksums, srcrev, srcbranch, srcsubdir_old, srcsubdir_new, workspace, tinfoil, rd, license_diff, new_licenses, srctree, keep_failure):
322 """Creates the new recipe under workspace""" 318 """Creates the new recipe under workspace"""
323 319
324 bpn = rd.getVar('BPN') 320 bpn = rd.getVar('BPN')
@@ -390,30 +386,39 @@ def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, srcsubdir_old, src
390 addnames.append(params['name']) 386 addnames.append(params['name'])
391 # Find what's been set in the original recipe 387 # Find what's been set in the original recipe
392 oldnames = [] 388 oldnames = []
389 oldsums = []
393 noname = False 390 noname = False
394 for varflag in rd.getVarFlags('SRC_URI'): 391 for varflag in rd.getVarFlags('SRC_URI'):
395 if varflag.endswith(('.md5sum', '.sha256sum')): 392 for checksum in checksums:
396 name = varflag.rsplit('.', 1)[0] 393 if varflag.endswith('.' + checksum):
397 if name not in oldnames: 394 name = varflag.rsplit('.', 1)[0]
398 oldnames.append(name) 395 if name not in oldnames:
399 elif varflag in ['md5sum', 'sha256sum']: 396 oldnames.append(name)
400 noname = True 397 oldsums.append(checksum)
398 elif varflag == checksum:
399 noname = True
400 oldsums.append(checksum)
401 # Even if SRC_URI has named entries it doesn't have to actually use the name 401 # Even if SRC_URI has named entries it doesn't have to actually use the name
402 if noname and addnames and addnames[0] not in oldnames: 402 if noname and addnames and addnames[0] not in oldnames:
403 addnames = [] 403 addnames = []
404 # Drop any old names (the name actually might include ${PV}) 404 # Drop any old names (the name actually might include ${PV})
405 for name in oldnames: 405 for name in oldnames:
406 if name not in newnames: 406 if name not in newnames:
407 newvalues['SRC_URI[%s.md5sum]' % name] = None 407 for checksum in oldsums:
408 newvalues['SRC_URI[%s.sha256sum]' % name] = None 408 newvalues['SRC_URI[%s.%s]' % (name, checksum)] = None
409 409
410 if sha256: 410 nameprefix = '%s.' % addnames[0] if addnames else ''
411 if addnames: 411
412 nameprefix = '%s.' % addnames[0] 412 # md5sum is deprecated, remove any traces of it. If it was the only old
413 else: 413 # checksum, then replace it with the default checksums.
414 nameprefix = '' 414 if 'md5sum' in oldsums:
415 newvalues['SRC_URI[%smd5sum]' % nameprefix] = None 415 newvalues['SRC_URI[%smd5sum]' % nameprefix] = None
416 newvalues['SRC_URI[%ssha256sum]' % nameprefix] = sha256 416 oldsums.remove('md5sum')
417 if not oldsums:
418 oldsums = ["%ssum" % s for s in bb.fetch2.SHOWN_CHECKSUM_LIST]
419
420 for checksum in oldsums:
421 newvalues['SRC_URI[%s%s]' % (nameprefix, checksum)] = checksums[checksum]
417 422
418 if srcsubdir_new != srcsubdir_old: 423 if srcsubdir_new != srcsubdir_old:
419 s_subdir_old = os.path.relpath(os.path.abspath(rd.getVar('S')), rd.getVar('WORKDIR')) 424 s_subdir_old = os.path.relpath(os.path.abspath(rd.getVar('S')), rd.getVar('WORKDIR'))
@@ -571,12 +576,12 @@ def upgrade(args, config, basepath, workspace):
571 rev1, srcsubdir1 = standard._extract_source(srctree, False, 'devtool-orig', False, config, basepath, workspace, args.fixed_setup, rd, tinfoil, no_overrides=args.no_overrides) 576 rev1, srcsubdir1 = standard._extract_source(srctree, False, 'devtool-orig', False, config, basepath, workspace, args.fixed_setup, rd, tinfoil, no_overrides=args.no_overrides)
572 old_licenses = _extract_licenses(srctree_s, (rd.getVar('LIC_FILES_CHKSUM') or "")) 577 old_licenses = _extract_licenses(srctree_s, (rd.getVar('LIC_FILES_CHKSUM') or ""))
573 logger.info('Extracting upgraded version source...') 578 logger.info('Extracting upgraded version source...')
574 rev2, md5, sha256, srcbranch, srcsubdir2 = _extract_new_source(args.version, srctree, args.no_patch, 579 rev2, checksums, srcbranch, srcsubdir2 = _extract_new_source(args.version, srctree, args.no_patch,
575 args.srcrev, args.srcbranch, args.branch, args.keep_temp, 580 args.srcrev, args.srcbranch, args.branch, args.keep_temp,
576 tinfoil, rd) 581 tinfoil, rd)
577 new_licenses = _extract_licenses(srctree_s, (rd.getVar('LIC_FILES_CHKSUM') or "")) 582 new_licenses = _extract_licenses(srctree_s, (rd.getVar('LIC_FILES_CHKSUM') or ""))
578 license_diff = _generate_license_diff(old_licenses, new_licenses) 583 license_diff = _generate_license_diff(old_licenses, new_licenses)
579 rf, copied = _create_new_recipe(args.version, md5, sha256, args.srcrev, srcbranch, srcsubdir1, srcsubdir2, config.workspace_path, tinfoil, rd, license_diff, new_licenses, srctree, args.keep_failure) 584 rf, copied = _create_new_recipe(args.version, checksums, args.srcrev, srcbranch, srcsubdir1, srcsubdir2, config.workspace_path, tinfoil, rd, license_diff, new_licenses, srctree, args.keep_failure)
580 except (bb.process.CmdError, DevtoolError) as e: 585 except (bb.process.CmdError, DevtoolError) as e:
581 recipedir = os.path.join(config.workspace_path, 'recipes', rd.getVar('BPN')) 586 recipedir = os.path.join(config.workspace_path, 'recipes', rd.getVar('BPN'))
582 _upgrade_error(e, recipedir, srctree, args.keep_failure) 587 _upgrade_error(e, recipedir, srctree, args.keep_failure)