summaryrefslogtreecommitdiffstats
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 18:05:39 +0100
commit677e8c8e97ec377c5919943a9ca7257787b6ab81 (patch)
tree1af3878ca71d1058e84a65bcd5dabfa5b9b18be9
parent48bb9eca790c354eb6505b02ce940398a6efa8a1 (diff)
downloadpoky-677e8c8e97ec377c5919943a9ca7257787b6ab81.tar.gz
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]. (From OE-Core rev: b63fca00c2e24ad0c8b8b3c492d93ee4372fa92d) 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.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 b59db15be4..947d8eecf1 100644
--- a/meta/lib/oeqa/selftest/devtool.py
+++ b/meta/lib/oeqa/selftest/devtool.py
@@ -367,6 +367,36 @@ class DevtoolTests(DevtoolBase):
367 self.assertNotEqual(result.status, 0, 'devtool modify on %s should have failed. devtool output: %s' % (testrecipe, result.output)) 367 self.assertNotEqual(result.status, 0, 'devtool modify on %s should have failed. devtool output: %s' % (testrecipe, result.output))
368 self.assertIn('ERROR: ', result.output, 'devtool modify on %s should have given an ERROR' % testrecipe) 368 self.assertIn('ERROR: ', result.output, 'devtool modify on %s should have given an ERROR' % testrecipe)
369 369
370 def test_devtool_modify_native(self):
371 # Check preconditions
372 workspacedir = os.path.join(self.builddir, 'workspace')
373 self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory')
374 # Try modifying some recipes
375 tempdir = tempfile.mkdtemp(prefix='devtoolqa')
376 self.track_for_cleanup(tempdir)
377 self.track_for_cleanup(workspacedir)
378 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
379
380 bbclassextended = False
381 inheritnative = False
382 testrecipes = 'mtools-native apt-native desktop-file-utils-native'.split()
383 for testrecipe in testrecipes:
384 checkextend = 'native' in (get_bb_var('BBCLASSEXTEND', testrecipe) or '').split()
385 if not bbclassextended:
386 bbclassextended = checkextend
387 if not inheritnative:
388 inheritnative = not checkextend
389 result = runCmd('devtool modify %s -x %s' % (testrecipe, os.path.join(tempdir, testrecipe)))
390 self.assertNotIn('ERROR: ', result.output, 'ERROR in devtool modify output: %s' % result.output)
391 result = runCmd('devtool build %s' % testrecipe)
392 self.assertNotIn('ERROR: ', result.output, 'ERROR in devtool build output: %s' % result.output)
393 result = runCmd('devtool reset %s' % testrecipe)
394 self.assertNotIn('ERROR: ', result.output, 'ERROR in devtool reset output: %s' % result.output)
395
396 self.assertTrue(bbclassextended, 'None of these recipes are BBCLASSEXTENDed to native - need to adjust testrecipes list: %s' % ', '.join(testrecipes))
397 self.assertTrue(inheritnative, 'None of these recipes do "inherit native" - need to adjust testrecipes list: %s' % ', '.join(testrecipes))
398
399
370 @testcase(1165) 400 @testcase(1165)
371 def test_devtool_modify_git(self): 401 def test_devtool_modify_git(self):
372 # Check preconditions 402 # Check preconditions
diff --git a/scripts/devtool b/scripts/devtool
index 1c2243812a..b9d3bb9e85 100755
--- a/scripts/devtool
+++ b/scripts/devtool
@@ -104,15 +104,15 @@ def read_workspace():
104 _enable_workspace_layer(config.workspace_path, config, basepath) 104 _enable_workspace_layer(config.workspace_path, config, basepath)
105 105
106 logger.debug('Reading workspace in %s' % config.workspace_path) 106 logger.debug('Reading workspace in %s' % config.workspace_path)
107 externalsrc_re = re.compile(r'^EXTERNALSRC(_pn-[^ =]+)? =.*$') 107 externalsrc_re = re.compile(r'^EXTERNALSRC(_pn-([^ =]+))? *= *"([^"]*)"$')
108 for fn in glob.glob(os.path.join(config.workspace_path, 'appends', '*.bbappend')): 108 for fn in glob.glob(os.path.join(config.workspace_path, 'appends', '*.bbappend')):
109 pn = os.path.splitext(os.path.basename(fn))[0].split('_')[0]
110 with open(fn, 'r') as f: 109 with open(fn, 'r') as f:
111 for line in f: 110 for line in f:
112 if externalsrc_re.match(line.rstrip()): 111 res = externalsrc_re.match(line.rstrip())
113 splitval = line.split('=', 2) 112 if res:
114 workspace[pn] = splitval[1].strip('" \n\r\t') 113 pn = res.group(2) or os.path.splitext(os.path.basename(fn))[0].split('_')[0]
115 break 114 workspace[pn] = {'srctree': res.group(3),
115 'bbappend': fn}
116 116
117def create_workspace(args, config, basepath, workspace): 117def create_workspace(args, config, basepath, workspace):
118 if args.layerpath: 118 if args.layerpath:
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 658076c048..e85e1ad860 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -430,6 +430,16 @@ def modify(args, config, basepath, workspace):
430 if not rd: 430 if not rd:
431 return 1 431 return 1
432 recipefile = rd.getVar('FILE', True) 432 recipefile = rd.getVar('FILE', True)
433 appendname = os.path.splitext(os.path.basename(recipefile))[0]
434 if args.wildcard:
435 appendname = re.sub(r'_.*', '_%', appendname)
436 appendpath = os.path.join(config.workspace_path, 'appends')
437 appendfile = os.path.join(appendpath, appendname + '.bbappend')
438 if os.path.exists(appendfile):
439 raise DevtoolError("Another variant of recipe %s is already in your "
440 "workspace (only one variant of a recipe can "
441 "currently be worked on at once)"
442 % args.recipename)
433 443
434 _check_compatible_recipe(args.recipename, rd) 444 _check_compatible_recipe(args.recipename, rd)
435 445
@@ -467,14 +477,8 @@ def modify(args, config, basepath, workspace):
467 srcsubdir = os.path.relpath(s, workdir).split(os.sep, 1)[1] 477 srcsubdir = os.path.relpath(s, workdir).split(os.sep, 1)[1]
468 srctree = os.path.join(srctree, srcsubdir) 478 srctree = os.path.join(srctree, srcsubdir)
469 479
470 appendpath = os.path.join(config.workspace_path, 'appends')
471 if not os.path.exists(appendpath): 480 if not os.path.exists(appendpath):
472 os.makedirs(appendpath) 481 os.makedirs(appendpath)
473
474 appendname = os.path.splitext(os.path.basename(recipefile))[0]
475 if args.wildcard:
476 appendname = re.sub(r'_.*', '_%', appendname)
477 appendfile = os.path.join(appendpath, appendname + '.bbappend')
478 with open(appendfile, 'w') as f: 482 with open(appendfile, 'w') as f:
479 f.write('FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n\n') 483 f.write('FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n\n')
480 f.write('inherit externalsrc\n') 484 f.write('inherit externalsrc\n')
@@ -777,7 +781,7 @@ def update_recipe(args, config, basepath, workspace):
777 else: 781 else:
778 mode = args.mode 782 mode = args.mode
779 783
780 srctree = workspace[args.recipename] 784 srctree = workspace[args.recipename]['srctree']
781 785
782 if mode == 'srcrev': 786 if mode == 'srcrev':
783 _update_recipe_srcrev(args, srctree, rd, tinfoil.config_data) 787 _update_recipe_srcrev(args, srctree, rd, tinfoil.config_data)
@@ -793,7 +797,7 @@ def status(args, config, basepath, workspace):
793 """Entry point for the devtool 'status' subcommand""" 797 """Entry point for the devtool 'status' subcommand"""
794 if workspace: 798 if workspace:
795 for recipe, value in workspace.iteritems(): 799 for recipe, value in workspace.iteritems():
796 print("%s: %s" % (recipe, value)) 800 print("%s: %s" % (recipe, value['srctree']))
797 else: 801 else:
798 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') 802 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')
799 return 0 803 return 0