diff options
-rw-r--r-- | meta/lib/oeqa/selftest/devtool.py | 29 | ||||
-rw-r--r-- | scripts/lib/devtool/standard.py | 52 |
2 files changed, 62 insertions, 19 deletions
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index 932d6b9ec2..a8c339a39f 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py | |||
@@ -384,3 +384,32 @@ class DevtoolTests(oeSelfTest): | |||
384 | result = runCmd('devtool extract remake %s' % tempdir) | 384 | result = runCmd('devtool extract remake %s' % tempdir) |
385 | self.assertTrue(os.path.exists(os.path.join(tempdir, 'Makefile.am')), 'Extracted source could not be found') | 385 | self.assertTrue(os.path.exists(os.path.join(tempdir, 'Makefile.am')), 'Extracted source could not be found') |
386 | self.assertTrue(os.path.isdir(os.path.join(tempdir, '.git')), 'git repository for external source tree not found') | 386 | self.assertTrue(os.path.isdir(os.path.join(tempdir, '.git')), 'git repository for external source tree not found') |
387 | |||
388 | def test_devtool_reset_all(self): | ||
389 | # Check preconditions | ||
390 | workspacedir = os.path.join(self.builddir, 'workspace') | ||
391 | self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory') | ||
392 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') | ||
393 | self.track_for_cleanup(tempdir) | ||
394 | self.track_for_cleanup(workspacedir) | ||
395 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') | ||
396 | testrecipe1 = 'mdadm' | ||
397 | testrecipe2 = 'cronie' | ||
398 | result = runCmd('devtool modify -x %s %s' % (testrecipe1, os.path.join(tempdir, testrecipe1))) | ||
399 | result = runCmd('devtool modify -x %s %s' % (testrecipe2, os.path.join(tempdir, testrecipe2))) | ||
400 | result = runCmd('devtool build %s' % testrecipe1) | ||
401 | result = runCmd('devtool build %s' % testrecipe2) | ||
402 | stampprefix1 = get_bb_var('STAMP', testrecipe1) | ||
403 | self.assertTrue(stampprefix1, 'Unable to get STAMP value for recipe %s' % testrecipe1) | ||
404 | stampprefix2 = get_bb_var('STAMP', testrecipe2) | ||
405 | self.assertTrue(stampprefix2, 'Unable to get STAMP value for recipe %s' % testrecipe2) | ||
406 | result = runCmd('devtool reset -a') | ||
407 | self.assertIn(testrecipe1, result.output) | ||
408 | self.assertIn(testrecipe2, result.output) | ||
409 | result = runCmd('devtool status') | ||
410 | self.assertNotIn(testrecipe1, result.output) | ||
411 | self.assertNotIn(testrecipe2, result.output) | ||
412 | matches1 = glob.glob(stampprefix1 + '*') | ||
413 | self.assertFalse(matches1, 'Stamp files exist for recipe %s that should have been cleaned' % testrecipe1) | ||
414 | matches2 = glob.glob(stampprefix2 + '*') | ||
415 | self.assertFalse(matches2, 'Stamp files exist for recipe %s that should have been cleaned' % testrecipe2) | ||
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py index 435878cef9..32fb3b656b 100644 --- a/scripts/lib/devtool/standard.py +++ b/scripts/lib/devtool/standard.py | |||
@@ -556,28 +556,42 @@ def status(args, config, basepath, workspace): | |||
556 | 556 | ||
557 | def reset(args, config, basepath, workspace): | 557 | def reset(args, config, basepath, workspace): |
558 | import bb.utils | 558 | import bb.utils |
559 | if not args.recipename in workspace: | 559 | if args.recipename: |
560 | logger.error("no recipe named %s in your workspace" % args.recipename) | 560 | if args.all: |
561 | logger.error("Recipe cannot be specified if -a/--all is used") | ||
562 | return -1 | ||
563 | elif not args.recipename in workspace: | ||
564 | logger.error("no recipe named %s in your workspace" % args.recipename) | ||
565 | return -1 | ||
566 | elif not args.all: | ||
567 | logger.error("Recipe must be specified, or specify -a/--all to reset all recipes") | ||
561 | return -1 | 568 | return -1 |
562 | 569 | ||
563 | if not args.no_clean: | 570 | if args.all: |
564 | logger.info('Cleaning sysroot for recipe %s...' % args.recipename) | 571 | recipes = workspace |
565 | exec_build_env_command(config.init_path, basepath, 'bitbake -c clean %s' % args.recipename) | 572 | else: |
573 | recipes = [args.recipename] | ||
574 | |||
575 | for pn in recipes: | ||
576 | if not args.no_clean: | ||
577 | logger.info('Cleaning sysroot for recipe %s...' % pn) | ||
578 | exec_build_env_command(config.init_path, basepath, 'bitbake -c clean %s' % pn) | ||
566 | 579 | ||
567 | _check_preserve(config, args.recipename) | 580 | _check_preserve(config, pn) |
568 | 581 | ||
569 | preservepath = os.path.join(config.workspace_path, 'attic', args.recipename) | 582 | preservepath = os.path.join(config.workspace_path, 'attic', pn) |
570 | def preservedir(origdir): | 583 | def preservedir(origdir): |
571 | if os.path.exists(origdir): | 584 | if os.path.exists(origdir): |
572 | for fn in os.listdir(origdir): | 585 | for fn in os.listdir(origdir): |
573 | logger.warn('Preserving %s in %s' % (fn, preservepath)) | 586 | logger.warn('Preserving %s in %s' % (fn, preservepath)) |
574 | bb.utils.mkdirhier(preservepath) | 587 | bb.utils.mkdirhier(preservepath) |
575 | shutil.move(os.path.join(origdir, fn), os.path.join(preservepath, fn)) | 588 | shutil.move(os.path.join(origdir, fn), os.path.join(preservepath, fn)) |
576 | os.rmdir(origdir) | 589 | os.rmdir(origdir) |
590 | |||
591 | preservedir(os.path.join(config.workspace_path, 'recipes', pn)) | ||
592 | # We don't automatically create this dir next to appends, but the user can | ||
593 | preservedir(os.path.join(config.workspace_path, 'appends', pn)) | ||
577 | 594 | ||
578 | preservedir(os.path.join(config.workspace_path, 'recipes', args.recipename)) | ||
579 | # We don't automatically create this dir next to appends, but the user can | ||
580 | preservedir(os.path.join(config.workspace_path, 'appends', args.recipename)) | ||
581 | return 0 | 595 | return 0 |
582 | 596 | ||
583 | 597 | ||
@@ -644,7 +658,7 @@ def register_commands(subparsers, context): | |||
644 | parser_reset = subparsers.add_parser('reset', help='Remove a recipe from your workspace', | 658 | parser_reset = subparsers.add_parser('reset', help='Remove a recipe from your workspace', |
645 | description='Removes the specified recipe from your workspace (resetting its state)', | 659 | description='Removes the specified recipe from your workspace (resetting its state)', |
646 | formatter_class=argparse.ArgumentDefaultsHelpFormatter) | 660 | formatter_class=argparse.ArgumentDefaultsHelpFormatter) |
647 | parser_reset.add_argument('recipename', help='Recipe to reset') | 661 | parser_reset.add_argument('recipename', nargs='?', help='Recipe to reset') |
662 | parser_reset.add_argument('--all', '-a', action="store_true", help='Reset all recipes (clear workspace)') | ||
648 | parser_reset.add_argument('--no-clean', '-n', action="store_true", help='Don\'t clean the sysroot to remove recipe output') | 663 | parser_reset.add_argument('--no-clean', '-n', action="store_true", help='Don\'t clean the sysroot to remove recipe output') |
649 | parser_reset.set_defaults(func=reset) | 664 | parser_reset.set_defaults(func=reset) |
650 | |||