aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-08-17 11:10:13 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-19 17:57:54 +0100
commitb63fca00c2e24ad0c8b8b3c492d93ee4372fa92d (patch)
tree0303010a44cf81f163292b6a7d7cf10e73147fe6
parent2062c88726400e09599aff51af95799a866b90c9 (diff)
downloadopenembedded-core-contrib-b63fca00c2e24ad0c8b8b3c492d93ee4372fa92d.tar.gz
openembedded-core-contrib-b63fca00c2e24ad0c8b8b3c492d93ee4372fa92d.tar.bz2
openembedded-core-contrib-b63fca00c2e24ad0c8b8b3c492d93ee4372fa92d.zip
devtool: fix handling of BBCLASSEXTENDed recipes
If a recipe is BBCLASSEXTENDed (e.g. to -native), its PN value and the name of the bbappend will be different; we were assuming them to be the same when reading in the workspace, leading to us seeing the base recipe name everywhere afterwards. Also add a test so we ensure this doesn't regress in future. Fixes [YOCTO #8157]. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
-rw-r--r--meta/lib/oeqa/selftest/devtool.py30
-rwxr-xr-xscripts/devtool12
-rw-r--r--scripts/lib/devtool/standard.py20
3 files changed, 48 insertions, 14 deletions
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py
index b59db15be43..947d8eecf1f 100644
--- a/meta/lib/oeqa/selftest/devtool.py
+++ b/meta/lib/oeqa/selftest/devtool.py
@@ -367,6 +367,36 @@ class DevtoolTests(DevtoolBase):
self.assertNotEqual(result.status, 0, 'devtool modify on %s should have failed. devtool output: %s' % (testrecipe, result.output))
self.assertIn('ERROR: ', result.output, 'devtool modify on %s should have given an ERROR' % testrecipe)
+ def test_devtool_modify_native(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')
+
+ bbclassextended = False
+ inheritnative = False
+ testrecipes = 'mtools-native apt-native desktop-file-utils-native'.split()
+ for testrecipe in testrecipes:
+ checkextend = 'native' in (get_bb_var('BBCLASSEXTEND', testrecipe) or '').split()
+ if not bbclassextended:
+ bbclassextended = checkextend
+ if not inheritnative:
+ inheritnative = not checkextend
+ result = runCmd('devtool modify %s -x %s' % (testrecipe, os.path.join(tempdir, testrecipe)))
+ self.assertNotIn('ERROR: ', result.output, 'ERROR in devtool modify output: %s' % result.output)
+ result = runCmd('devtool build %s' % testrecipe)
+ self.assertNotIn('ERROR: ', result.output, 'ERROR in devtool build output: %s' % result.output)
+ result = runCmd('devtool reset %s' % testrecipe)
+ self.assertNotIn('ERROR: ', result.output, 'ERROR in devtool reset output: %s' % result.output)
+
+ self.assertTrue(bbclassextended, 'None of these recipes are BBCLASSEXTENDed to native - need to adjust testrecipes list: %s' % ', '.join(testrecipes))
+ self.assertTrue(inheritnative, 'None of these recipes do "inherit native" - need to adjust testrecipes list: %s' % ', '.join(testrecipes))
+
+
@testcase(1165)
def test_devtool_modify_git(self):
# Check preconditions
diff --git a/scripts/devtool b/scripts/devtool
index 1c2243812a8..b9d3bb9e85e 100755
--- a/scripts/devtool
+++ b/scripts/devtool
@@ -104,15 +104,15 @@ def read_workspace():
_enable_workspace_layer(config.workspace_path, config, basepath)
logger.debug('Reading workspace in %s' % config.workspace_path)
- externalsrc_re = re.compile(r'^EXTERNALSRC(_pn-[^ =]+)? =.*$')
+ externalsrc_re = re.compile(r'^EXTERNALSRC(_pn-([^ =]+))? *= *"([^"]*)"$')
for fn in glob.glob(os.path.join(config.workspace_path, 'appends', '*.bbappend')):
- pn = os.path.splitext(os.path.basename(fn))[0].split('_')[0]
with open(fn, 'r') as f:
for line in f:
- if externalsrc_re.match(line.rstrip()):
- splitval = line.split('=', 2)
- workspace[pn] = splitval[1].strip('" \n\r\t')
- break
+ res = externalsrc_re.match(line.rstrip())
+ if res:
+ pn = res.group(2) or os.path.splitext(os.path.basename(fn))[0].split('_')[0]
+ workspace[pn] = {'srctree': res.group(3),
+ 'bbappend': fn}
def create_workspace(args, config, basepath, workspace):
if args.layerpath:
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 658076c0480..e85e1ad8605 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -430,6 +430,16 @@ def modify(args, config, basepath, workspace):
if not rd:
return 1
recipefile = rd.getVar('FILE', True)
+ appendname = os.path.splitext(os.path.basename(recipefile))[0]
+ if args.wildcard:
+ appendname = re.sub(r'_.*', '_%', appendname)
+ appendpath = os.path.join(config.workspace_path, 'appends')
+ appendfile = os.path.join(appendpath, appendname + '.bbappend')
+ if os.path.exists(appendfile):
+ raise DevtoolError("Another variant of recipe %s is already in your "
+ "workspace (only one variant of a recipe can "
+ "currently be worked on at once)"
+ % args.recipename)
_check_compatible_recipe(args.recipename, rd)
@@ -467,14 +477,8 @@ def modify(args, config, basepath, workspace):
srcsubdir = os.path.relpath(s, workdir).split(os.sep, 1)[1]
srctree = os.path.join(srctree, srcsubdir)
- appendpath = os.path.join(config.workspace_path, 'appends')
if not os.path.exists(appendpath):
os.makedirs(appendpath)
-
- appendname = os.path.splitext(os.path.basename(recipefile))[0]
- if args.wildcard:
- appendname = re.sub(r'_.*', '_%', appendname)
- appendfile = os.path.join(appendpath, appendname + '.bbappend')
with open(appendfile, 'w') as f:
f.write('FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n\n')
f.write('inherit externalsrc\n')
@@ -777,7 +781,7 @@ def update_recipe(args, config, basepath, workspace):
else:
mode = args.mode
- srctree = workspace[args.recipename]
+ srctree = workspace[args.recipename]['srctree']
if mode == 'srcrev':
_update_recipe_srcrev(args, srctree, rd, tinfoil.config_data)
@@ -793,7 +797,7 @@ def status(args, config, basepath, workspace):
"""Entry point for the devtool 'status' subcommand"""
if workspace:
for recipe, value in workspace.iteritems():
- print("%s: %s" % (recipe, value))
+ print("%s: %s" % (recipe, value['srctree']))
else:
logger.info('No recipes currently in your workspace - you can use "devtool modify" to work on an existing recipe or "devtool add" to add a new one')
return 0