diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2015-10-14 19:19:23 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-10-21 22:56:03 +0100 |
commit | db55d31dc2cc5336c09d379e5da5d2d67cc2619a (patch) | |
tree | 6367222d6efa600a7b7f417987bffe0d878b7e60 | |
parent | 8578bc17b54da97d42b257b3c8f398ac52b91a9f (diff) | |
download | poky-db55d31dc2cc5336c09d379e5da5d2d67cc2619a.tar.gz |
devtool: handle virtual providers
For modify / extract / upgrade, if the specified "recipe" is not
actually a recipe but a virtual target such as virtual/kernel, map it
correctly to the actual recipe and make sure we use that name within the
workspace. Thanks to Chris Larson for reminding me this was still broken
and for a hint on how to fix it.
(From OE-Core rev: 1f7752282ffb47d2621030ddb2fa42a5e491d6d2)
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>
-rw-r--r-- | meta/lib/oe/recipeutils.py | 6 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/devtool.py | 32 | ||||
-rw-r--r-- | scripts/lib/devtool/standard.py | 24 | ||||
-rw-r--r-- | scripts/lib/devtool/upgrade.py | 12 |
4 files changed, 64 insertions, 10 deletions
diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py index 207c300667..119a68821b 100644 --- a/meta/lib/oe/recipeutils.py +++ b/meta/lib/oe/recipeutils.py | |||
@@ -31,9 +31,13 @@ def pn_to_recipe(cooker, pn): | |||
31 | import bb.providers | 31 | import bb.providers |
32 | 32 | ||
33 | if pn in cooker.recipecache.pkg_pn: | 33 | if pn in cooker.recipecache.pkg_pn: |
34 | filenames = cooker.recipecache.pkg_pn[pn] | ||
35 | best = bb.providers.findBestProvider(pn, cooker.data, cooker.recipecache, cooker.recipecache.pkg_pn) | 34 | best = bb.providers.findBestProvider(pn, cooker.data, cooker.recipecache, cooker.recipecache.pkg_pn) |
36 | return best[3] | 35 | return best[3] |
36 | elif pn in cooker.recipecache.providers: | ||
37 | filenames = cooker.recipecache.providers[pn] | ||
38 | eligible, foundUnique = bb.providers.filterProviders(filenames, pn, cooker.expanded_data, cooker.recipecache) | ||
39 | filename = eligible[0] | ||
40 | return filename | ||
37 | else: | 41 | else: |
38 | return None | 42 | return None |
39 | 43 | ||
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index baa56d6dc1..e4de309e72 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py | |||
@@ -466,6 +466,28 @@ class DevtoolTests(DevtoolBase): | |||
466 | # Try building | 466 | # Try building |
467 | bitbake(testrecipe) | 467 | bitbake(testrecipe) |
468 | 468 | ||
469 | def test_devtool_modify_virtual(self): | ||
470 | # Try modifying a virtual recipe | ||
471 | virtrecipe = 'virtual/libx11' | ||
472 | realrecipe = 'libx11' | ||
473 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') | ||
474 | self.track_for_cleanup(tempdir) | ||
475 | self.track_for_cleanup(self.workspacedir) | ||
476 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') | ||
477 | result = runCmd('devtool modify %s -x %s' % (virtrecipe, tempdir)) | ||
478 | self.assertTrue(os.path.exists(os.path.join(tempdir, 'Makefile.am')), 'Extracted source could not be found') | ||
479 | self.assertTrue(os.path.exists(os.path.join(self.workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created') | ||
480 | matches = glob.glob(os.path.join(self.workspacedir, 'appends', '%s_*.bbappend' % realrecipe)) | ||
481 | self.assertTrue(matches, 'bbappend not created %s' % result.output) | ||
482 | # Test devtool status | ||
483 | result = runCmd('devtool status') | ||
484 | self.assertNotIn(virtrecipe, result.output) | ||
485 | self.assertIn(realrecipe, result.output) | ||
486 | # Check git repo | ||
487 | self._check_src_repo(tempdir) | ||
488 | # This is probably sufficient | ||
489 | |||
490 | |||
469 | @testcase(1169) | 491 | @testcase(1169) |
470 | def test_devtool_update_recipe(self): | 492 | def test_devtool_update_recipe(self): |
471 | # Check preconditions | 493 | # Check preconditions |
@@ -805,6 +827,16 @@ class DevtoolTests(DevtoolBase): | |||
805 | self.assertTrue(os.path.exists(os.path.join(tempdir, 'Makefile.am')), 'Extracted source could not be found') | 827 | self.assertTrue(os.path.exists(os.path.join(tempdir, 'Makefile.am')), 'Extracted source could not be found') |
806 | self._check_src_repo(tempdir) | 828 | self._check_src_repo(tempdir) |
807 | 829 | ||
830 | def test_devtool_extract_virtual(self): | ||
831 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') | ||
832 | # Try devtool extract | ||
833 | self.track_for_cleanup(tempdir) | ||
834 | self.track_for_cleanup(self.workspacedir) | ||
835 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') | ||
836 | result = runCmd('devtool extract virtual/libx11 %s' % tempdir) | ||
837 | self.assertTrue(os.path.exists(os.path.join(tempdir, 'Makefile.am')), 'Extracted source could not be found') | ||
838 | self._check_src_repo(tempdir) | ||
839 | |||
808 | @testcase(1168) | 840 | @testcase(1168) |
809 | def test_devtool_reset_all(self): | 841 | def test_devtool_reset_all(self): |
810 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') | 842 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') |
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py index 5d7e903670..1285974d44 100644 --- a/scripts/lib/devtool/standard.py +++ b/scripts/lib/devtool/standard.py | |||
@@ -45,6 +45,10 @@ def add(args, config, basepath, workspace): | |||
45 | if reason: | 45 | if reason: |
46 | raise DevtoolError(reason) | 46 | raise DevtoolError(reason) |
47 | 47 | ||
48 | # FIXME this ought to be in validate_pn but we're using that in other contexts | ||
49 | if '/' in args.recipename: | ||
50 | raise DevtoolError('"/" is not a valid character in recipe names') | ||
51 | |||
48 | srctree = os.path.abspath(args.srctree) | 52 | srctree = os.path.abspath(args.srctree) |
49 | if os.path.exists(srctree): | 53 | if os.path.exists(srctree): |
50 | if args.fetch: | 54 | if args.fetch: |
@@ -514,6 +518,14 @@ def modify(args, config, basepath, workspace): | |||
514 | rd = parse_recipe(config, tinfoil, args.recipename, True) | 518 | rd = parse_recipe(config, tinfoil, args.recipename, True) |
515 | if not rd: | 519 | if not rd: |
516 | return 1 | 520 | return 1 |
521 | |||
522 | pn = rd.getVar('PN', True) | ||
523 | if pn != args.recipename: | ||
524 | logger.info('Mapping %s to %s' % (args.recipename, pn)) | ||
525 | if pn in workspace: | ||
526 | raise DevtoolError("recipe %s is already in your workspace" % | ||
527 | pn) | ||
528 | |||
517 | recipefile = rd.getVar('FILE', True) | 529 | recipefile = rd.getVar('FILE', True) |
518 | appendname = os.path.splitext(os.path.basename(recipefile))[0] | 530 | appendname = os.path.splitext(os.path.basename(recipefile))[0] |
519 | if args.wildcard: | 531 | if args.wildcard: |
@@ -524,9 +536,9 @@ def modify(args, config, basepath, workspace): | |||
524 | raise DevtoolError("Another variant of recipe %s is already in your " | 536 | raise DevtoolError("Another variant of recipe %s is already in your " |
525 | "workspace (only one variant of a recipe can " | 537 | "workspace (only one variant of a recipe can " |
526 | "currently be worked on at once)" | 538 | "currently be worked on at once)" |
527 | % args.recipename) | 539 | % pn) |
528 | 540 | ||
529 | _check_compatible_recipe(args.recipename, rd) | 541 | _check_compatible_recipe(pn, rd) |
530 | 542 | ||
531 | initial_rev = None | 543 | initial_rev = None |
532 | commits = [] | 544 | commits = [] |
@@ -574,11 +586,11 @@ def modify(args, config, basepath, workspace): | |||
574 | 586 | ||
575 | f.write('\ninherit externalsrc\n') | 587 | f.write('\ninherit externalsrc\n') |
576 | f.write('# NOTE: We use pn- overrides here to avoid affecting multiple variants in the case where the recipe uses BBCLASSEXTEND\n') | 588 | f.write('# NOTE: We use pn- overrides here to avoid affecting multiple variants in the case where the recipe uses BBCLASSEXTEND\n') |
577 | f.write('EXTERNALSRC_pn-%s = "%s"\n' % (args.recipename, srctree)) | 589 | f.write('EXTERNALSRC_pn-%s = "%s"\n' % (pn, srctree)) |
578 | 590 | ||
579 | b_is_s = use_external_build(args.same_dir, args.no_same_dir, rd) | 591 | b_is_s = use_external_build(args.same_dir, args.no_same_dir, rd) |
580 | if b_is_s: | 592 | if b_is_s: |
581 | f.write('EXTERNALSRC_BUILD_pn-%s = "%s"\n' % (args.recipename, srctree)) | 593 | f.write('EXTERNALSRC_BUILD_pn-%s = "%s"\n' % (pn, srctree)) |
582 | 594 | ||
583 | if bb.data.inherits_class('kernel', rd): | 595 | if bb.data.inherits_class('kernel', rd): |
584 | f.write('SRCTREECOVEREDTASKS = "do_validate_branches do_kernel_checkout do_fetch do_unpack"\n') | 596 | f.write('SRCTREECOVEREDTASKS = "do_validate_branches do_kernel_checkout do_fetch do_unpack"\n') |
@@ -587,9 +599,9 @@ def modify(args, config, basepath, workspace): | |||
587 | for commit in commits: | 599 | for commit in commits: |
588 | f.write('# commit: %s\n' % commit) | 600 | f.write('# commit: %s\n' % commit) |
589 | 601 | ||
590 | _add_md5(config, args.recipename, appendfile) | 602 | _add_md5(config, pn, appendfile) |
591 | 603 | ||
592 | logger.info('Recipe %s now set up to build from %s' % (args.recipename, srctree)) | 604 | logger.info('Recipe %s now set up to build from %s' % (pn, srctree)) |
593 | 605 | ||
594 | return 0 | 606 | return 0 |
595 | 607 | ||
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py index 4f850cf0e4..d38762373e 100644 --- a/scripts/lib/devtool/upgrade.py +++ b/scripts/lib/devtool/upgrade.py | |||
@@ -300,7 +300,13 @@ def upgrade(args, config, basepath, workspace): | |||
300 | if not rd: | 300 | if not rd: |
301 | return 1 | 301 | return 1 |
302 | 302 | ||
303 | standard._check_compatible_recipe(args.recipename, rd) | 303 | pn = rd.getVar('PN', True) |
304 | if pn != args.recipename: | ||
305 | logger.info('Mapping %s to %s' % (args.recipename, pn)) | ||
306 | if pn in workspace: | ||
307 | raise DevtoolError("recipe %s is already in your workspace" % pn) | ||
308 | |||
309 | standard._check_compatible_recipe(pn, rd) | ||
304 | if rd.getVar('PV', True) == args.version and rd.getVar('SRCREV', True) == args.srcrev: | 310 | if rd.getVar('PV', True) == args.version and rd.getVar('SRCREV', True) == args.srcrev: |
305 | raise DevtoolError("Current and upgrade versions are the same version" % version) | 311 | raise DevtoolError("Current and upgrade versions are the same version" % version) |
306 | 312 | ||
@@ -315,11 +321,11 @@ def upgrade(args, config, basepath, workspace): | |||
315 | _upgrade_error(e, rf, args.srctree) | 321 | _upgrade_error(e, rf, args.srctree) |
316 | except DevtoolError as e: | 322 | except DevtoolError as e: |
317 | _upgrade_error(e, rf, args.srctree) | 323 | _upgrade_error(e, rf, args.srctree) |
318 | standard._add_md5(config, args.recipename, os.path.dirname(rf)) | 324 | standard._add_md5(config, pn, os.path.dirname(rf)) |
319 | 325 | ||
320 | af = _write_append(rf, args.srctree, args.same_dir, args.no_same_dir, rev2, | 326 | af = _write_append(rf, args.srctree, args.same_dir, args.no_same_dir, rev2, |
321 | config.workspace_path, rd) | 327 | config.workspace_path, rd) |
322 | standard._add_md5(config, args.recipename, af) | 328 | standard._add_md5(config, pn, af) |
323 | logger.info('Upgraded source extracted to %s' % args.srctree) | 329 | logger.info('Upgraded source extracted to %s' % args.srctree) |
324 | return 0 | 330 | return 0 |
325 | 331 | ||