summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-03-05 10:51:20 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-03-20 11:27:45 +0000
commitcb4b07838c267a09ebedba6c30ec25bda2cd11be (patch)
treed3c2826f27d23f885631c53dcd6fba4634b4c557
parent221705f0143c9ba4c11180dc9ff1bf29966b23bc (diff)
downloadpoky-cb4b07838c267a09ebedba6c30ec25bda2cd11be.tar.gz
devtool: modify/extract: prevent usage with incompatible recipes
Consolidate code for checking compatible recipes and consider meta and packagegroup recipes as well as package-index and gcc-source to be incompatible. (From OE-Core rev: 4be9bf637583b341a89af1b9924752abc7d49c94) 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/oeqa/selftest/devtool.py24
-rw-r--r--scripts/lib/devtool/standard.py48
2 files changed, 59 insertions, 13 deletions
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py
index a8c339a39f..2574e4bbf4 100644
--- a/meta/lib/oeqa/selftest/devtool.py
+++ b/meta/lib/oeqa/selftest/devtool.py
@@ -227,6 +227,30 @@ class DevtoolTests(oeSelfTest):
227 matches = glob.glob(stampprefix + '*') 227 matches = glob.glob(stampprefix + '*')
228 self.assertFalse(matches, 'Stamp files exist for recipe mdadm that should have been cleaned') 228 self.assertFalse(matches, 'Stamp files exist for recipe mdadm that should have been cleaned')
229 229
230 def test_devtool_modify_invalid(self):
231 # Check preconditions
232 workspacedir = os.path.join(self.builddir, 'workspace')
233 self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory')
234 # Try modifying some recipes
235 tempdir = tempfile.mkdtemp(prefix='devtoolqa')
236 self.track_for_cleanup(tempdir)
237 self.track_for_cleanup(workspacedir)
238 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
239
240 testrecipes = 'perf gcc-source kernel-devsrc package-index core-image-minimal meta-toolchain packagegroup-core-sdk meta-ide-support'.split()
241 for testrecipe in testrecipes:
242 # Check it's a valid recipe
243 bitbake('%s -e' % testrecipe)
244 # devtool extract should fail
245 result = runCmd('devtool extract %s %s' % (testrecipe, os.path.join(tempdir, testrecipe)), ignore_status=True)
246 self.assertNotEqual(result.status, 0, 'devtool extract on %s should have failed' % testrecipe)
247 self.assertNotIn('Fetching ', result.output, 'devtool extract on %s should have errored out before trying to fetch' % testrecipe)
248 self.assertIn('ERROR: ', result.output, 'devtool extract on %s should have given an ERROR' % testrecipe)
249 # devtool modify should fail
250 result = runCmd('devtool modify %s -x %s' % (testrecipe, os.path.join(tempdir, testrecipe)), ignore_status=True)
251 self.assertNotEqual(result.status, 0, 'devtool modify on %s should have failed' % testrecipe)
252 self.assertIn('ERROR: ', result.output, 'devtool modify on %s should have given an ERROR' % testrecipe)
253
230 def test_devtool_modify_git(self): 254 def test_devtool_modify_git(self):
231 # Check preconditions 255 # Check preconditions
232 workspacedir = os.path.join(self.builddir, 'workspace') 256 workspacedir = os.path.join(self.builddir, 'workspace')
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index f9369eeef0..54920b26f8 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -87,6 +87,38 @@ def add(args, config, basepath, workspace):
87 return 0 87 return 0
88 88
89 89
90def _check_compatible_recipe(pn, d):
91 if pn == 'perf':
92 logger.error("The perf recipe does not actually check out source and thus cannot be supported by this tool")
93 return False
94
95 if pn in ['gcc-source', 'kernel-devsrc', 'package-index']:
96 logger.error("The %s recipe is not supported by this tool" % pn)
97 return False
98
99 if bb.data.inherits_class('image', d):
100 logger.error("The %s recipe is an image, and therefore is not supported by this tool" % pn)
101 return False
102
103 if bb.data.inherits_class('populate_sdk', d):
104 logger.error("The %s recipe is an SDK, and therefore is not supported by this tool" % pn)
105 return False
106
107 if bb.data.inherits_class('packagegroup', d):
108 logger.error("The %s recipe is a packagegroup, and therefore is not supported by this tool" % pn)
109 return False
110
111 if bb.data.inherits_class('meta', d):
112 logger.error("The %s recipe is a meta-recipe, and therefore is not supported by this tool" % pn)
113 return False
114
115 if bb.data.inherits_class('externalsrc', d) and d.getVar('EXTERNALSRC', True):
116 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)
117 return False
118
119 return True
120
121
90def _get_recipe_file(cooker, pn): 122def _get_recipe_file(cooker, pn):
91 import oe.recipeutils 123 import oe.recipeutils
92 recipefile = oe.recipeutils.pn_to_recipe(cooker, pn) 124 recipefile = oe.recipeutils.pn_to_recipe(cooker, pn)
@@ -133,16 +165,7 @@ def _extract_source(srctree, keep_temp, devbranch, d):
133 165
134 pn = d.getVar('PN', True) 166 pn = d.getVar('PN', True)
135 167
136 if pn == 'perf': 168 if not _check_compatible_recipe(pn, d):
137 logger.error("The perf recipe does not actually check out source and thus cannot be supported by this tool")
138 return None
139
140 if bb.data.inherits_class('image', d):
141 logger.error("The %s recipe is an image, and therefore is not supported by this tool" % pn)
142 return None
143
144 if bb.data.inherits_class('externalsrc', d) and d.getVar('EXTERNALSRC', True):
145 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)
146 return None 169 return None
147 170
148 if os.path.exists(srctree): 171 if os.path.exists(srctree):
@@ -310,9 +333,8 @@ def modify(args, config, basepath, workspace):
310 return -1 333 return -1
311 rd = oe.recipeutils.parse_recipe(recipefile, tinfoil.config_data) 334 rd = oe.recipeutils.parse_recipe(recipefile, tinfoil.config_data)
312 335
313 if bb.data.inherits_class('image', rd): 336 if not _check_compatible_recipe(args.recipename, rd):
314 logger.error("The %s recipe is an image, and therefore is not supported by this tool" % args.recipename) 337 return -1
315 return None
316 338
317 initial_rev = None 339 initial_rev = None
318 commits = [] 340 commits = []