diff options
6 files changed, 148 insertions, 23 deletions
diff --git a/meta-selftest/recipes-test/devtool/devtool-upgrade-test3_1.5.3.bb b/meta-selftest/recipes-test/devtool/devtool-upgrade-test3_1.5.3.bb new file mode 100644 index 0000000000..69c0d351ec --- /dev/null +++ b/meta-selftest/recipes-test/devtool/devtool-upgrade-test3_1.5.3.bb | |||
@@ -0,0 +1,16 @@ | |||
1 | SUMMARY = "Pipe viewer test recipe for devtool upgrade test" | ||
2 | LICENSE = "Artistic-2.0" | ||
3 | LIC_FILES_CHKSUM = "file://doc/COPYING;md5=9c50db2589ee3ef10a9b7b2e50ce1d02" | ||
4 | |||
5 | SRC_URI = "http://www.ivarch.com/programs/sources/pv-${PV}.tar.gz" | ||
6 | UPSTREAM_CHECK_URI = "http://www.ivarch.com/programs/pv.shtml" | ||
7 | RECIPE_NO_UPDATE_REASON = "This recipe is used to test devtool upgrade feature" | ||
8 | |||
9 | SRC_URI[md5sum] = "9365d86bd884222b4bf1039b5a9ed1bd" | ||
10 | |||
11 | S = "${WORKDIR}/pv-${PV}" | ||
12 | |||
13 | EXCLUDE_FROM_WORLD = "1" | ||
14 | |||
15 | inherit autotools | ||
16 | |||
diff --git a/meta-selftest/recipes-test/devtool/devtool-upgrade-test3_1.5.3.bb.upgraded b/meta-selftest/recipes-test/devtool/devtool-upgrade-test3_1.5.3.bb.upgraded new file mode 100644 index 0000000000..3ce7e85e10 --- /dev/null +++ b/meta-selftest/recipes-test/devtool/devtool-upgrade-test3_1.5.3.bb.upgraded | |||
@@ -0,0 +1,15 @@ | |||
1 | SUMMARY = "Pipe viewer test recipe for devtool upgrade test" | ||
2 | LICENSE = "Artistic-2.0" | ||
3 | LIC_FILES_CHKSUM = "file://doc/COPYING;md5=9c50db2589ee3ef10a9b7b2e50ce1d02" | ||
4 | |||
5 | SRC_URI[sha256sum] = "9dd45391806b0ed215abee4c5ac1597d018c386fe9c1f5afd2f6bc3b07fd82c3" | ||
6 | SRC_URI = "http://www.ivarch.com/programs/sources/pv-${PV}.tar.gz" | ||
7 | UPSTREAM_CHECK_URI = "http://www.ivarch.com/programs/pv.shtml" | ||
8 | RECIPE_NO_UPDATE_REASON = "This recipe is used to test devtool upgrade feature" | ||
9 | |||
10 | S = "${WORKDIR}/pv-${PV}" | ||
11 | |||
12 | EXCLUDE_FROM_WORLD = "1" | ||
13 | |||
14 | inherit autotools | ||
15 | |||
diff --git a/meta-selftest/recipes-test/devtool/devtool-upgrade-test4_1.5.3.bb b/meta-selftest/recipes-test/devtool/devtool-upgrade-test4_1.5.3.bb new file mode 100644 index 0000000000..9abf80e6ed --- /dev/null +++ b/meta-selftest/recipes-test/devtool/devtool-upgrade-test4_1.5.3.bb | |||
@@ -0,0 +1,22 @@ | |||
1 | SUMMARY = "Pipe viewer test recipe for devtool upgrade test" | ||
2 | LICENSE = "Artistic-2.0" | ||
3 | LIC_FILES_CHKSUM = "file://doc/COPYING;md5=9c50db2589ee3ef10a9b7b2e50ce1d02" | ||
4 | |||
5 | SRC_URI = "http://www.ivarch.com/programs/sources/pv-${PV}.tar.gz" | ||
6 | UPSTREAM_CHECK_URI = "http://www.ivarch.com/programs/pv.shtml" | ||
7 | RECIPE_NO_UPDATE_REASON = "This recipe is used to test devtool upgrade feature" | ||
8 | |||
9 | SRC_URI[md5sum] = "9365d86bd884222b4bf1039b5a9ed1bd" | ||
10 | SRC_URI[sha1sum] = "63a0801350e812541c7f8e9ad74e0d6b629d0b39" | ||
11 | SRC_URI[sha256sum] = "681bcca9784bf3cb2207e68236d1f68e2aa7b80f999b5750dc77dcd756e81fbc" | ||
12 | SRC_URI[sha384sum] = "5fff6390465ff23dbf573fcf39dfad3aed2f92074a35e6c02abe58b7678858d90fa6572ff4cb56df8b3e217c739cdbe3" | ||
13 | SRC_URI[sha512sum] = "32efe7071a363f547afc74e96774f711795edda1d2702823a347d0f9953e859b7d8c45b3e63e18ffb9e0d5ed5910be652d7d727c8676e81b6cb3aed0b13aec00" | ||
14 | |||
15 | PR = "r5" | ||
16 | |||
17 | S = "${WORKDIR}/pv-${PV}" | ||
18 | |||
19 | EXCLUDE_FROM_WORLD = "1" | ||
20 | |||
21 | inherit autotools | ||
22 | |||
diff --git a/meta-selftest/recipes-test/devtool/devtool-upgrade-test4_1.5.3.bb.upgraded b/meta-selftest/recipes-test/devtool/devtool-upgrade-test4_1.5.3.bb.upgraded new file mode 100644 index 0000000000..cd2a0842f4 --- /dev/null +++ b/meta-selftest/recipes-test/devtool/devtool-upgrade-test4_1.5.3.bb.upgraded | |||
@@ -0,0 +1,19 @@ | |||
1 | SUMMARY = "Pipe viewer test recipe for devtool upgrade test" | ||
2 | LICENSE = "Artistic-2.0" | ||
3 | LIC_FILES_CHKSUM = "file://doc/COPYING;md5=9c50db2589ee3ef10a9b7b2e50ce1d02" | ||
4 | |||
5 | SRC_URI = "http://www.ivarch.com/programs/sources/pv-${PV}.tar.gz" | ||
6 | UPSTREAM_CHECK_URI = "http://www.ivarch.com/programs/pv.shtml" | ||
7 | RECIPE_NO_UPDATE_REASON = "This recipe is used to test devtool upgrade feature" | ||
8 | |||
9 | SRC_URI[sha1sum] = "395ce62f4f3e035b86c77038f04b96c5aa233595" | ||
10 | SRC_URI[sha256sum] = "9dd45391806b0ed215abee4c5ac1597d018c386fe9c1f5afd2f6bc3b07fd82c3" | ||
11 | SRC_URI[sha384sum] = "218c8d2d097aeba5310be759bc20573f18ffa0b11701eac6dd2e7e14ddf13c6e0e094ca7ca026eaa05ef92a056402e36" | ||
12 | SRC_URI[sha512sum] = "1cf9d7376fceefcd594d0a8b591afc8e11ce89f7210d10ad74438974ecebe9cc5d9ec4db9cc79e0566bfd2b0278c0cc263c07547803e7536432cd1ffd32d8a45" | ||
13 | |||
14 | S = "${WORKDIR}/pv-${PV}" | ||
15 | |||
16 | EXCLUDE_FROM_WORLD = "1" | ||
17 | |||
18 | inherit autotools | ||
19 | |||
diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py index fd9ac42168..47353dadff 100644 --- a/meta/lib/oeqa/selftest/cases/devtool.py +++ b/meta/lib/oeqa/selftest/cases/devtool.py | |||
@@ -1883,6 +1883,54 @@ class DevtoolUpgradeTests(DevtoolBase): | |||
1883 | self.assertNotIn(recipe, result.output) | 1883 | self.assertNotIn(recipe, result.output) |
1884 | self.assertNotExists(os.path.join(self.workspacedir, 'recipes', recipe), 'Recipe directory should not exist after resetting') | 1884 | self.assertNotExists(os.path.join(self.workspacedir, 'recipes', recipe), 'Recipe directory should not exist after resetting') |
1885 | 1885 | ||
1886 | def test_devtool_upgrade_drop_md5sum(self): | ||
1887 | # Check preconditions | ||
1888 | self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory') | ||
1889 | self.track_for_cleanup(self.workspacedir) | ||
1890 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') | ||
1891 | # For the moment, we are using a real recipe. | ||
1892 | recipe = 'devtool-upgrade-test3' | ||
1893 | version = '1.6.0' | ||
1894 | oldrecipefile = get_bb_var('FILE', recipe) | ||
1895 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') | ||
1896 | self.track_for_cleanup(tempdir) | ||
1897 | # Check upgrade. Code does not check if new PV is older or newer that current PV, so, it may be that | ||
1898 | # we are downgrading instead of upgrading. | ||
1899 | result = runCmd('devtool upgrade %s %s -V %s' % (recipe, tempdir, version)) | ||
1900 | # Check new recipe file is present | ||
1901 | newrecipefile = os.path.join(self.workspacedir, 'recipes', recipe, '%s_%s.bb' % (recipe, version)) | ||
1902 | self.assertExists(newrecipefile, 'Recipe file should exist after upgrade') | ||
1903 | # Check recipe got changed as expected | ||
1904 | with open(oldrecipefile + '.upgraded', 'r') as f: | ||
1905 | desiredlines = f.readlines() | ||
1906 | with open(newrecipefile, 'r') as f: | ||
1907 | newlines = f.readlines() | ||
1908 | self.assertEqual(desiredlines, newlines) | ||
1909 | |||
1910 | def test_devtool_upgrade_all_checksums(self): | ||
1911 | # Check preconditions | ||
1912 | self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory') | ||
1913 | self.track_for_cleanup(self.workspacedir) | ||
1914 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') | ||
1915 | # For the moment, we are using a real recipe. | ||
1916 | recipe = 'devtool-upgrade-test4' | ||
1917 | version = '1.6.0' | ||
1918 | oldrecipefile = get_bb_var('FILE', recipe) | ||
1919 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') | ||
1920 | self.track_for_cleanup(tempdir) | ||
1921 | # Check upgrade. Code does not check if new PV is older or newer that current PV, so, it may be that | ||
1922 | # we are downgrading instead of upgrading. | ||
1923 | result = runCmd('devtool upgrade %s %s -V %s' % (recipe, tempdir, version)) | ||
1924 | # Check new recipe file is present | ||
1925 | newrecipefile = os.path.join(self.workspacedir, 'recipes', recipe, '%s_%s.bb' % (recipe, version)) | ||
1926 | self.assertExists(newrecipefile, 'Recipe file should exist after upgrade') | ||
1927 | # Check recipe got changed as expected | ||
1928 | with open(oldrecipefile + '.upgraded', 'r') as f: | ||
1929 | desiredlines = f.readlines() | ||
1930 | with open(newrecipefile, 'r') as f: | ||
1931 | newlines = f.readlines() | ||
1932 | self.assertEqual(desiredlines, newlines) | ||
1933 | |||
1886 | def test_devtool_layer_plugins(self): | 1934 | def test_devtool_layer_plugins(self): |
1887 | """Test that devtool can use plugins from other layers. | 1935 | """Test that devtool can use plugins from other layers. |
1888 | 1936 | ||
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 | ||
302 | def _add_license_diff_to_recipe(path, diff): | 298 | def _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 | ||
321 | def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, srcsubdir_old, srcsubdir_new, workspace, tinfoil, rd, license_diff, new_licenses, srctree, keep_failure): | 317 | def _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) |