]> code.ossystems Code Review - openembedded-core.git/commitdiff
devtool: modify/extract: prevent usage with incompatible recipes
authorPaul Eggleton <paul.eggleton@linux.intel.com>
Thu, 5 Mar 2015 10:51:20 +0000 (10:51 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 20 Mar 2015 11:03:11 +0000 (11:03 +0000)
Consolidate code for checking compatible recipes and consider meta and
packagegroup recipes as well as package-index and gcc-source to be
incompatible.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/lib/oeqa/selftest/devtool.py
scripts/lib/devtool/standard.py

index a8c339a39f28e2c7e52a51ede7a3a2defd2de732..2574e4bbf4d07c04e9a77028902d1bc3ab5ea3ac 100644 (file)
@@ -227,6 +227,30 @@ class DevtoolTests(oeSelfTest):
         matches = glob.glob(stampprefix + '*')
         self.assertFalse(matches, 'Stamp files exist for recipe mdadm that should have been cleaned')
 
+    def test_devtool_modify_invalid(self):
+        # Check preconditions
+        workspacedir = os.path.join(self.builddir, 'workspace')
+        self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory')
+        # Try modifying some recipes
+        tempdir = tempfile.mkdtemp(prefix='devtoolqa')
+        self.track_for_cleanup(tempdir)
+        self.track_for_cleanup(workspacedir)
+        self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
+
+        testrecipes = 'perf gcc-source kernel-devsrc package-index core-image-minimal meta-toolchain packagegroup-core-sdk meta-ide-support'.split()
+        for testrecipe in testrecipes:
+            # Check it's a valid recipe
+            bitbake('%s -e' % testrecipe)
+            # devtool extract should fail
+            result = runCmd('devtool extract %s %s' % (testrecipe, os.path.join(tempdir, testrecipe)), ignore_status=True)
+            self.assertNotEqual(result.status, 0, 'devtool extract on %s should have failed' % testrecipe)
+            self.assertNotIn('Fetching ', result.output, 'devtool extract on %s should have errored out before trying to fetch' % testrecipe)
+            self.assertIn('ERROR: ', result.output, 'devtool extract on %s should have given an ERROR' % testrecipe)
+            # devtool modify should fail
+            result = runCmd('devtool modify %s -x %s' % (testrecipe, os.path.join(tempdir, testrecipe)), ignore_status=True)
+            self.assertNotEqual(result.status, 0, 'devtool modify on %s should have failed' % testrecipe)
+            self.assertIn('ERROR: ', result.output, 'devtool modify on %s should have given an ERROR' % testrecipe)
+
     def test_devtool_modify_git(self):
         # Check preconditions
         workspacedir = os.path.join(self.builddir, 'workspace')
index f9369eeef0f3c69e85fc52a781219424af5857fb..54920b26f89fd73c35b35211440c377214e35206 100644 (file)
@@ -87,6 +87,38 @@ def add(args, config, basepath, workspace):
     return 0
 
 
+def _check_compatible_recipe(pn, d):
+    if pn == 'perf':
+        logger.error("The perf recipe does not actually check out source and thus cannot be supported by this tool")
+        return False
+
+    if pn in ['gcc-source', 'kernel-devsrc', 'package-index']:
+        logger.error("The %s recipe is not supported by this tool" % pn)
+        return False
+
+    if bb.data.inherits_class('image', d):
+        logger.error("The %s recipe is an image, and therefore is not supported by this tool" % pn)
+        return False
+
+    if bb.data.inherits_class('populate_sdk', d):
+        logger.error("The %s recipe is an SDK, and therefore is not supported by this tool" % pn)
+        return False
+
+    if bb.data.inherits_class('packagegroup', d):
+        logger.error("The %s recipe is a packagegroup, and therefore is not supported by this tool" % pn)
+        return False
+
+    if bb.data.inherits_class('meta', d):
+        logger.error("The %s recipe is a meta-recipe, and therefore is not supported by this tool" % pn)
+        return False
+
+    if bb.data.inherits_class('externalsrc', d) and d.getVar('EXTERNALSRC', True):
+        logger.error("externalsrc is currently enabled for the %s recipe. This prevents the normal do_patch task from working. You will need to disable this first." % pn)
+        return False
+
+    return True
+
+
 def _get_recipe_file(cooker, pn):
     import oe.recipeutils
     recipefile = oe.recipeutils.pn_to_recipe(cooker, pn)
@@ -133,16 +165,7 @@ def _extract_source(srctree, keep_temp, devbranch, d):
 
     pn = d.getVar('PN', True)
 
-    if pn == 'perf':
-        logger.error("The perf recipe does not actually check out source and thus cannot be supported by this tool")
-        return None
-
-    if bb.data.inherits_class('image', d):
-        logger.error("The %s recipe is an image, and therefore is not supported by this tool" % pn)
-        return None
-
-    if bb.data.inherits_class('externalsrc', d) and d.getVar('EXTERNALSRC', True):
-        logger.error("externalsrc is currently enabled for the %s recipe. This prevents the normal do_patch task from working. You will need to disable this first." % pn)
+    if not _check_compatible_recipe(pn, d):
         return None
 
     if os.path.exists(srctree):
@@ -310,9 +333,8 @@ def modify(args, config, basepath, workspace):
         return -1
     rd = oe.recipeutils.parse_recipe(recipefile, tinfoil.config_data)
 
-    if bb.data.inherits_class('image', rd):
-        logger.error("The %s recipe is an image, and therefore is not supported by this tool" % args.recipename)
-        return None
+    if not _check_compatible_recipe(args.recipename, rd):
+        return -1
 
     initial_rev = None
     commits = []