@@ -138,7 +138,7 @@ class BuildSystem(object):
# (because of externalsrc, the workspace bbappends will interfere with the
# locked signatures if present, and we don't need them anyway)
image_bbappend = os.path.splitext(os.path.basename(self.d.getVar('FILE')))[0] + '.bbappend'
- appenddir = os.path.join(layerdestpath, 'appends')
+ appenddir = os.path.join(layerdestpath, 'recipes-appends')
if os.path.isdir(appenddir):
for fn in os.listdir(appenddir):
if fn == image_bbappend:
@@ -157,7 +157,10 @@ class BuildSystem(object):
for line in origlines:
if line.startswith('#'):
continue
- line = line.replace('workspacelayer', workspace_newname)
+ # LAYERNAME must be unique, so rename the original workspace layer
+ if re.match(r'^LAYERNAME\s*=', line):
+ line = 'LAYERNAME = "%s"\n' % workspace_newname
+ line = line.replace('_workspace ', '_' + workspace_newname + ' ')
f.write(line)
# meta-skeleton layer is added as part of the build system
@@ -37,8 +37,7 @@ def setUpModule():
bblayers_conf = os.path.join(os.environ['BUILDDIR'], 'conf', 'bblayers.conf')
edited_layers = []
# make sure user doesn't have a local workspace
- result = runCmd('bitbake-layers show-layers')
- assert "workspacelayer" not in result.output, "Devtool test suite cannot be run with a local workspace directory"
+ assert not get_bb_var('LAYERDIR_workspace'), "Devtool test suite cannot be run with a local workspace directory"
# We need to take a copy of the meta layer so we can modify it and not
# have any races against other tests that might be running in parallel
@@ -795,7 +794,7 @@ class DevtoolModifyTests(DevtoolBase):
result = runCmd('devtool modify mdadm -x %s' % tempdir)
self.assertExists(os.path.join(tempdir, 'Makefile'), 'Extracted source could not be found')
self.assertExists(os.path.join(self.workspacedir, 'conf', 'layer.conf'), 'Workspace directory not created')
- matches = glob.glob(os.path.join(self.workspacedir, 'appends', 'mdadm_*.bbappend'))
+ matches = glob.glob(os.path.join(self.workspacedir, 'recipes-appends', 'mdadm_*.bbappend'))
self.assertTrue(matches, 'bbappend not created %s' % result.output)
# Test devtool status
@@ -857,7 +856,7 @@ class DevtoolModifyTests(DevtoolBase):
oe.path.join(self.workspacedir, 'conf', 'layer.conf'),
'Workspace directory not created'
)
- matches = glob.glob(oe.path.join(self.workspacedir, 'appends', 'go-helloworld_*.bbappend'))
+ matches = glob.glob(oe.path.join(self.workspacedir, 'recipes-appends', 'go-helloworld_*.bbappend'))
self.assertTrue(matches, 'bbappend not created %s' % result.output)
def test_devtool_buildclean(self):
@@ -988,7 +987,7 @@ class DevtoolModifyTests(DevtoolBase):
result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir))
srcfile = os.path.join(tempdir, 'share/dot.bashrc')
self.assertExists(srcfile, 'Extracted source could not be found')
- matches = glob.glob(os.path.join(self.workspacedir, 'appends', '%s_*.bbappend' % testrecipe))
+ matches = glob.glob(os.path.join(self.workspacedir, 'recipes-appends', '%s_*.bbappend' % testrecipe))
self.assertTrue(matches, 'bbappend not created')
# Test devtool status
result = runCmd('devtool status')
@@ -1013,7 +1012,7 @@ class DevtoolModifyTests(DevtoolBase):
result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir))
self.assertExists(os.path.join(tempdir, 'Makefile.am'), 'Extracted source could not be found')
self.assertExists(os.path.join(self.workspacedir, 'conf', 'layer.conf'), 'Workspace directory not created. devtool output: %s' % result.output)
- matches = glob.glob(os.path.join(self.workspacedir, 'appends', 'psplash_*.bbappend'))
+ matches = glob.glob(os.path.join(self.workspacedir, 'recipes-appends', 'psplash_*.bbappend'))
self.assertTrue(matches, 'bbappend not created')
# Test devtool status
result = runCmd('devtool status')
@@ -1039,7 +1038,7 @@ class DevtoolModifyTests(DevtoolBase):
self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
result = runCmd('git clone https://git.yoctoproject.org/psplash %s && devtool modify -n %s %s' % (tempdir, testrecipe, tempdir))
self.assertExists(os.path.join(self.workspacedir, 'conf', 'layer.conf'), 'Workspace directory not created. devtool output: %s' % result.output)
- matches = glob.glob(os.path.join(self.workspacedir, 'appends', 'psplash_*.bbappend'))
+ matches = glob.glob(os.path.join(self.workspacedir, 'recipes-appends', 'psplash_*.bbappend'))
self.assertTrue(matches, 'bbappend not created')
# Test devtool status
result = runCmd('devtool status')
@@ -1087,7 +1086,7 @@ class DevtoolModifyTests(DevtoolBase):
result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir))
self.assertExists(os.path.join(tempdir, 'Cargo.toml'), 'Extracted source could not be found')
self.assertExists(os.path.join(self.workspacedir, 'conf', 'layer.conf'), 'Workspace directory not created. devtool output: %s' % result.output)
- matches = glob.glob(os.path.join(self.workspacedir, 'appends', '%s_*.bbappend' % testrecipe))
+ matches = glob.glob(os.path.join(self.workspacedir, 'recipes-appends', '%s_*.bbappend' % testrecipe))
self.assertTrue(matches, 'bbappend not created')
# Test devtool status
result = runCmd('devtool status')
@@ -1161,7 +1160,7 @@ class DevtoolModifyTests(DevtoolBase):
result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir))
self.assertExists(os.path.join(tempdir, 'configure.ac'), 'Extracted source could not be found')
self.assertExists(os.path.join(self.workspacedir, 'conf', 'layer.conf'), 'Workspace directory not created')
- matches = glob.glob(os.path.join(self.workspacedir, 'appends', '%s_*.bbappend' % testrecipe))
+ matches = glob.glob(os.path.join(self.workspacedir, 'recipes-appends', '%s_*.bbappend' % testrecipe))
self.assertTrue(matches, 'bbappend not created')
# Test devtool status
result = runCmd('devtool status')
@@ -1248,7 +1247,7 @@ class DevtoolModifyTests(DevtoolBase):
result = runCmd('devtool modify %s -x %s' % (virtrecipe, tempdir))
self.assertExists(os.path.join(tempdir, 'Makefile.am'), 'Extracted source could not be found')
self.assertExists(os.path.join(self.workspacedir, 'conf', 'layer.conf'), 'Workspace directory not created')
- matches = glob.glob(os.path.join(self.workspacedir, 'appends', '%s_*.bbappend' % realrecipe))
+ matches = glob.glob(os.path.join(self.workspacedir, 'recipes-appends', '%s_*.bbappend' % realrecipe))
self.assertTrue(matches, 'bbappend not created %s' % result.output)
# Test devtool status
result = runCmd('devtool status')
@@ -3170,7 +3169,7 @@ class DevtoolIdeSdkTests(DevtoolBase):
self.assertExists(os.path.join(self.workspacedir, 'conf',
'layer.conf'), 'Workspace directory not created')
matches = glob.glob(os.path.join(self.workspacedir,
- 'appends', recipe_name + '.bbappend'))
+ 'recipes-appends', recipe_name + '.bbappend'))
self.assertTrue(matches, 'bbappend not created %s' % result.output)
# Test devtool status
@@ -3540,7 +3539,7 @@ class DevtoolIdeSdkTests(DevtoolBase):
def _verify_slirp_bbappend(self, testimage):
"""Verify update_qb_slirp_opt() wrote the SSH port-forward to the image bbappend."""
- bbappend = os.path.join(self.workspacedir, 'appends', testimage + '.bbappend')
+ bbappend = os.path.join(self.workspacedir, 'recipes-appends', testimage + '.bbappend')
self.assertExists(bbappend, 'Image bbappend not created at %s' % bbappend)
with open(bbappend) as f:
bbappend_content = f.read()
@@ -3608,7 +3607,7 @@ class DevtoolIdeSdkTests(DevtoolBase):
self.assertIn('exec runqemu ', helper)
self.assertIn(nfs_rootfs, helper)
- bbappend = os.path.join(self.workspacedir, 'appends', testimage + '.bbappend')
+ bbappend = os.path.join(self.workspacedir, 'recipes-appends', testimage + '.bbappend')
with open(bbappend) as append_file:
self.assertRegex(
append_file.read(),
@@ -4385,7 +4384,7 @@ class DevtoolIdeSdkKernelTests(DevtoolIdeSdkTests):
self.assertExists(os.path.join(self.workspacedir, 'conf', 'layer.conf'),
'Workspace directory not created')
matches = glob.glob(os.path.join(
- self.workspacedir, 'appends', recipe_name + '.bbappend'))
+ self.workspacedir, 'recipes-appends', recipe_name + '.bbappend'))
self.assertTrue(matches, 'bbappend not created %s' % result.output)
# Test devtool status
@@ -24,6 +24,7 @@ scripts_path = os.path.dirname(os.path.realpath(__file__))
lib_path = scripts_path + '/lib'
sys.path = sys.path + [lib_path]
from devtool import DevtoolError, setup_tinfoil
+from devtool import WORKSPACE_LAYERNAME, WORKSPACE_LAYERDEPENDS, get_workspace_appends_dir
import scriptutils
import argparse_oe
logger = scriptutils.logger_create('devtool')
@@ -101,7 +102,7 @@ def read_workspace(basepath, context):
logger.debug('Reading workspace in %s' % context.config.workspace_path)
externalsrc_re = re.compile(r'^EXTERNALSRC(:pn-([^ =]+))? *= *"([^"]*)"$')
- for fn in glob.glob(os.path.join(context.config.workspace_path, 'appends', '*.bbappend')):
+ for fn in glob.glob(os.path.join(get_workspace_appends_dir(context.config.workspace_path), '*.bbappend')):
with open(fn, 'r') as f:
pnvalues = {}
pn = None
@@ -162,16 +163,7 @@ def _create_workspace(workspacedir, basepath, layerseries=None):
# Add a config file
bb.utils.mkdirhier(confdir)
- with open(os.path.join(confdir, 'layer.conf'), 'w') as f:
- f.write('# ### workspace layer auto-generated by devtool ###\n')
- f.write('BBPATH =. "$' + '{LAYERDIR}:"\n')
- f.write('BBFILES += "$' + '{LAYERDIR}/recipes/*/*.bb \\\n')
- f.write(' $' + '{LAYERDIR}/appends/*.bbappend"\n')
- f.write('BBFILE_COLLECTIONS += "workspacelayer"\n')
- f.write('BBFILE_PATTERN_workspacelayer = "^$' + '{LAYERDIR}/"\n')
- f.write('BBFILE_PATTERN_IGNORE_EMPTY_workspacelayer = "1"\n')
- f.write('BBFILE_PRIORITY_workspacelayer = "99"\n')
- f.write('LAYERSERIES_COMPAT_workspacelayer = "%s"\n' % layerseries)
+ _write_workspace_layerconf(os.path.join(confdir, 'layer.conf'), layerseries)
# Add a README file
with open(os.path.join(workspacedir, 'README'), 'w') as f:
f.write('This layer was created by the OpenEmbedded devtool utility in order to\n')
@@ -190,6 +182,21 @@ def _create_workspace(workspacedir, basepath, layerseries=None):
f.write('layer. If you prefer it to be elsewhere you can specify the source\n')
f.write('tree path on the command line.\n')
+WORKSPACE_LAYERCONF_HEADER = '# ### workspace layer auto-generated by devtool ###'
+
+def _write_workspace_layerconf(layerconf, layerseries, extralines=None):
+ # BBPATH and BBFILES are constructed automatically by bitbake from the
+ # layer's location and its recipes* subdirectories, so only the layer
+ # metadata needs to be set here.
+ with open(layerconf, 'w') as f:
+ f.write(WORKSPACE_LAYERCONF_HEADER + '\n')
+ f.write('LAYERNAME = "%s"\n' % WORKSPACE_LAYERNAME)
+ f.write('LAYERDEPENDS = "%s"\n' % WORKSPACE_LAYERDEPENDS)
+ f.write('LAYERSERIES_COMPAT = "%s"\n' % layerseries)
+ for line in extralines or []:
+ f.write(line)
+
+
def _enable_workspace_layer(workspacedir, config, basepath):
"""Ensure the workspace layer is in bblayers.conf"""
import bb.utils
@@ -17,6 +17,19 @@ import codecs
logger = logging.getLogger('devtool')
+# LAYERNAME used for the auto-generated workspace layer
+WORKSPACE_LAYERNAME = 'workspace'
+# Layer(s) the workspace layer depends upon (LAYERDEPENDS)
+WORKSPACE_LAYERDEPENDS = 'oe-core'
+# Subdirectory of the workspace layer holding bbappends. Bitbake constructs
+# BBFILES automatically from a layer's recipes* directories, so this needs
+# to match that pattern.
+WORKSPACE_APPENDS_DIR = 'recipes-appends'
+
+def get_workspace_appends_dir(workspace_path):
+ """Return the directory within the workspace layer holding bbappends"""
+ return os.path.join(workspace_path, WORKSPACE_APPENDS_DIR)
+
class DevtoolError(Exception):
"""Exception for handling devtool errors"""
def __init__(self, message, exitcode=1):
@@ -286,7 +299,7 @@ def recipe_to_append(recipefile, config, wildcard=False):
appendname = os.path.splitext(os.path.basename(recipefile))[0]
if wildcard:
appendname = re.sub(r'_.*', '_%', appendname)
- appendpath = os.path.join(config.workspace_path, 'appends')
+ appendpath = get_workspace_appends_dir(config.workspace_path)
appendfile = os.path.join(appendpath, appendname + '.bbappend')
return appendfile
@@ -12,7 +12,7 @@ import errno
import logging
from bb.process import ExecutionError
-from devtool import exec_build_env_command, setup_tinfoil, parse_recipe, DevtoolError
+from devtool import exec_build_env_command, setup_tinfoil, parse_recipe, DevtoolError, get_workspace_appends_dir
logger = logging.getLogger('devtool')
@@ -67,7 +67,7 @@ def build_image_task(config, basepath, workspace, image, add_packages=None, task
# break because of it
target_basename = config.get('SDK', 'target_basename', '')
if target_basename:
- appendfile = os.path.join(config.workspace_path, 'appends',
+ appendfile = os.path.join(get_workspace_appends_dir(config.workspace_path),
'%s.bbappend' % target_basename)
try:
os.unlink(appendfile)
@@ -90,7 +90,7 @@ def build_image_task(config, basepath, workspace, image, add_packages=None, task
config.set('SDK', 'target_basename', target_basename)
config.write()
- appendfile = os.path.join(config.workspace_path, 'appends',
+ appendfile = os.path.join(get_workspace_appends_dir(config.workspace_path),
'%s.bbappend' % target_basename)
outputdir = None
old mode 100755
new mode 100644
@@ -22,7 +22,7 @@ from pathlib import Path
import scriptutils
import bb
-from devtool import exec_build_env_command, setup_tinfoil, check_workspace_recipe, DevtoolError, parse_recipe
+from devtool import exec_build_env_command, setup_tinfoil, check_workspace_recipe, DevtoolError, parse_recipe, get_workspace_appends_dir
from devtool.standard import get_real_srctree
from devtool.deploy import parse_packages_arg
from devtool.ide_plugins import BuildTool, DebuggerCrossConfig, LOOPBACK_HOSTS, is_loopback_target
@@ -243,7 +243,7 @@ class RecipeImage:
that have a bbappend, to be passed on to the RecipeImage constructor.
"""
originals = {}
- appends_dir = os.path.join(config.workspace_path, 'appends')
+ appends_dir = get_workspace_appends_dir(config.workspace_path)
for name in recipe_names:
bbappend = os.path.join(appends_dir, name + '.bbappend')
if not os.path.exists(bbappend):
@@ -259,7 +259,7 @@ class RecipeImage:
return originals
def initialize(self, config, tinfoil, nfs=None):
- appends_dir = os.path.join(config.workspace_path, 'appends')
+ appends_dir = get_workspace_appends_dir(config.workspace_path)
self._bbappend = os.path.join(appends_dir, self.name + '.bbappend')
# strip_bbappend_sections() ran before the tinfoil session started, so
@@ -897,7 +897,7 @@ class RecipeModified:
original recipe content and only non standard flags can be bbappended later.
"""
originals = {}
- appends_dir = os.path.join(config.workspace_path, 'appends')
+ appends_dir = get_workspace_appends_dir(config.workspace_path)
for name in recipe_names:
bbappend = os.path.join(appends_dir, name + '.bbappend')
if not os.path.exists(bbappend):
@@ -1795,7 +1795,7 @@ def ide_setup(args, config, basepath, workspace):
invalid_params = True
if DevtoolIdeMode.modified in modes:
if not recipes_modified_names:
- appends_dir = os.path.join(config.workspace_path, 'appends')
+ appends_dir = get_workspace_appends_dir(config.workspace_path)
recipes_modified_names = sorted(
bb.parse.vars_from_file(path, None)[0]
for path in glob.glob(os.path.join(appends_dir, '*.bbappend'))
@@ -1815,7 +1815,7 @@ def ide_setup(args, config, basepath, workspace):
if not recipes_modified_names:
logger.error(
"At least one modified recipe is required or must be guessable from %s." %
- os.path.join(config.workspace_path, 'appends'))
+ get_workspace_appends_dir(config.workspace_path))
invalid_params = True
for modified_recipe_name in recipes_modified_names:
if modified_recipe_name.startswith('nativesdk-') or modified_recipe_name.endswith('-native'):
@@ -2066,7 +2066,7 @@ def register_commands(subparsers, context):
'recipenames', nargs='+', help='Generate an IDE configuration suitable to work on the given recipes.\n'
'Depending on the --mode parameter different types of SDKs and IDE configurations are generated.\n'
'In modified mode at least the image recipe is required; if no modified recipe is passed, '
- 'all modified recipes are taken from <workspace>/appends/*.bbappend.')
+ 'all modified recipes are taken from <workspace>/recipes-appends/*.bbappend.')
parser_ide_sdk.add_argument(
'-m', '--mode', type=DevtoolIdeMode, action='append',
help='Different SDK types are supported. Repeat --mode to generate both:\n'
@@ -14,6 +14,7 @@ import json
import fnmatch
from devtool import standard, setup_tinfoil, replace_from_file, DevtoolError
+from devtool import WORKSPACE_APPENDS_DIR
from devtool import export
logger = logging.getLogger('devtool')
@@ -45,12 +46,15 @@ def devimport(args, config, basepath, workspace):
members = tar.getmembers()
+ def is_append(name):
+ return name == WORKSPACE_APPENDS_DIR or name.startswith(WORKSPACE_APPENDS_DIR + '/')
+
# Get appends and recipes from the exported archive, these
# will be needed to find out those appends without corresponding
# recipe pair
append_fns, recipe_fns = set(), set()
for member in members:
- if member.name.startswith('appends'):
+ if is_append(member.name):
append_fns.add(get_pn(member.name))
elif member.name.startswith('recipes'):
recipe_fns.add(get_pn(member.name))
@@ -82,7 +86,7 @@ def devimport(args, config, basepath, workspace):
for nonimp in non_importables:
pn = nonimp.split('_')[0]
# do not extract data from non-importable recipes or metadata
- if member.name.startswith('appends/%s' % nonimp) or \
+ if member.name.startswith('%s/%s' % (WORKSPACE_APPENDS_DIR, nonimp)) or \
member.name.startswith('recipes/%s' % nonimp) or \
member.name.startswith('sources/%s' % pn):
break
@@ -102,7 +106,7 @@ def devimport(args, config, basepath, workspace):
tar.extract(member, path=config.workspace_path)
# Update EXTERNALSRC and the devtool md5 file
- if member.name.startswith('appends'):
+ if is_append(member.name):
if export_workspace_path:
# appends created by 'devtool modify' just need to update the workspace
replace_from_file(path, export_workspace_path, config.workspace_path)
@@ -21,7 +21,7 @@ import glob
from collections import OrderedDict
from devtool import exec_build_env_command, setup_tinfoil, check_workspace_recipe, use_external_build, setup_git_repo, recipe_to_append, get_bbclassextend_targets, update_unlockedsigs, check_prerelease_version, check_git_repo_dirty, check_git_repo_op, DevtoolError
-from devtool import parse_recipe
+from devtool import parse_recipe, get_workspace_appends_dir
import bb.utils
@@ -2042,7 +2042,7 @@ def _reset(recipes, no_clean, remove_work, config, basepath, workspace):
# This should always be true if recipefile is set, but just in case
preservedir(os.path.dirname(recipefile))
# We don't automatically create this dir next to appends, but the user can
- preservedir(os.path.join(config.workspace_path, 'appends', pn))
+ preservedir(os.path.join(get_workspace_appends_dir(config.workspace_path), pn))
srctreebase = workspace[pn]['srctreebase']
if os.path.isdir(srctreebase):
@@ -26,7 +26,7 @@ sys.path = sys.path + [devtool_path]
import oe.recipeutils
from devtool import standard
-from devtool import exec_build_env_command, setup_tinfoil, DevtoolError, parse_recipe, use_external_build, update_unlockedsigs, check_prerelease_version
+from devtool import exec_build_env_command, setup_tinfoil, DevtoolError, parse_recipe, use_external_build, update_unlockedsigs, check_prerelease_version, get_workspace_appends_dir
logger = logging.getLogger('devtool')
@@ -138,7 +138,7 @@ def _write_append(rc, srctreebase, srctree, same_dir, no_same_dir, revs, copied,
if not os.path.exists(rc):
raise DevtoolError("bbappend not created because %s does not exist" % rc)
- appendpath = os.path.join(workspace, 'appends')
+ appendpath = get_workspace_appends_dir(workspace)
if not os.path.exists(appendpath):
bb.utils.mkdirhier(appendpath)
This updates devtool's workspace handling to: - Set a LAYERNAME (workspace) - Use the new core name for LAYERDEPENDS - Stop adding BBFILES, BBPATH and BBFILE variables - Store appends in /recipes-appends/ instead of /appends/ Tests are updated to match the changes. AI-Generated: Uses Claude Opus 5.5 Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> --- meta/lib/oe/copy_buildsystem.py | 7 ++++-- meta/lib/oeqa/selftest/cases/devtool.py | 27 +++++++++++------------ scripts/devtool | 29 +++++++++++++++---------- scripts/lib/devtool/__init__.py | 15 ++++++++++++- scripts/lib/devtool/build_image.py | 6 ++--- scripts/lib/devtool/ide_sdk.py | 14 ++++++------ scripts/lib/devtool/import.py | 10 ++++++--- scripts/lib/devtool/standard.py | 4 ++-- scripts/lib/devtool/upgrade.py | 4 ++-- 9 files changed, 71 insertions(+), 45 deletions(-) mode change 100755 => 100644 scripts/lib/devtool/ide_sdk.py