recipetool/devtool: calculate source paths relative to UNPACKDIR

Now that recipes default to S in UNPACKDIR, recipetool and devtool should
do the same.

There was some discussion about changing devtool to simply setting
UNPACKDIR via bbappend to a workspace and running unpack task directly;
currently it has a bunch of convoluted path calculations, substitutions,
moving source trees around and and special casing (devtool-source.bbclass
in particular is an unpleasant hack).

This should definitely be done; but right now we can simply tweak existing
code which at least doesn't make it worse.

(From OE-Core rev: c326ca8aeb2bf0f7719e43921d10efd5dedc7b2a)

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Alexander Kanavin
2025-06-16 11:49:57 +02:00
committed by Richard Purdie
parent efb0410d38
commit 4547232c71
8 changed files with 31 additions and 31 deletions

View File

@@ -92,9 +92,9 @@ python devtool_post_unpack() {
for fname in local_files:
f.write('%s\n' % fname)
if os.path.dirname(srcsubdir) != workdir:
if srcsubdir.startswith(unpackdir) and os.path.dirname(srcsubdir) != unpackdir:
# Handle if S is set to a subdirectory of the source
srcsubdir = os.path.join(workdir, os.path.relpath(srcsubdir, workdir).split(os.sep)[0])
srcsubdir = os.path.normpath(os.path.join(unpackdir, os.path.relpath(srcsubdir, unpackdir).split(os.sep)[0]))
scriptutils.git_convert_standalone_clone(srcsubdir)

View File

@@ -565,7 +565,7 @@ class DevtoolAddTests(DevtoolBase):
recipefile = get_bb_var('FILE', testrecipe)
self.assertIn('%s_%s.bb' % (testrecipe, testver), recipefile, 'Recipe file incorrectly named')
checkvars = {}
checkvars['S'] = '${WORKDIR}/MarkupSafe-${PV}'
checkvars['S'] = '${UNPACKDIR}/MarkupSafe-${PV}'
checkvars['SRC_URI'] = url.replace(testver, '${PV}')
self._test_recipe_contents(recipefile, checkvars, [])
# Try with version specified
@@ -582,7 +582,7 @@ class DevtoolAddTests(DevtoolBase):
recipefile = get_bb_var('FILE', testrecipe)
self.assertIn('%s_%s.bb' % (testrecipe, fakever), recipefile, 'Recipe file incorrectly named')
checkvars = {}
checkvars['S'] = '${WORKDIR}/MarkupSafe-%s' % testver
checkvars['S'] = '${UNPACKDIR}/MarkupSafe-%s' % testver
checkvars['SRC_URI'] = url
self._test_recipe_contents(recipefile, checkvars, [])
@@ -1627,12 +1627,12 @@ class DevtoolUpdateTests(DevtoolBase):
# Check preconditions
testrecipe = 'dos2unix'
self.append_config('ERROR_QA:remove:pn-dos2unix = "patch-status"\n')
bb_vars = get_bb_vars(['SRC_URI', 'S', 'WORKDIR', 'FILE', 'BB_GIT_DEFAULT_DESTSUFFIX'], testrecipe)
bb_vars = get_bb_vars(['SRC_URI', 'S', 'UNPACKDIR', 'FILE', 'BB_GIT_DEFAULT_DESTSUFFIX'], testrecipe)
self.assertIn('git://', bb_vars['SRC_URI'], 'This test expects the %s recipe to be a git recipe' % testrecipe)
workdir_git = '%s/%s/' % (bb_vars['WORKDIR'], bb_vars['BB_GIT_DEFAULT_DESTSUFFIX'])
if not bb_vars['S'].startswith(workdir_git):
unpackdir_git = '%s/%s/' % (bb_vars['UNPACKDIR'], bb_vars['BB_GIT_DEFAULT_DESTSUFFIX'])
if not bb_vars['S'].startswith(unpackdir_git):
self.fail('This test expects the %s recipe to be building from a subdirectory of the git repo' % testrecipe)
subdir = bb_vars['S'].split(workdir_git, 1)[1]
subdir = bb_vars['S'].split(unpackdir_git, 1)[1]
# Clean up anything in the workdir/sysroot/sstate cache
bitbake('%s -c cleansstate' % testrecipe)
# Try modifying a recipe
@@ -2414,7 +2414,7 @@ class DevtoolUpgradeTests(DevtoolBase):
newsrctree = os.path.join(self.workspacedir, 'sources', newrecipename)
self.assertExists(newsrctree, 'Source directory not renamed')
checkvars = {}
checkvars['S'] = '${WORKDIR}/%s-%s' % (recipename, recipever)
checkvars['S'] = '${UNPACKDIR}/%s-%s' % (recipename, recipever)
checkvars['SRC_URI'] = url
self._test_recipe_contents(newrecipefile, checkvars, [])
# Try again - change just name this time
@@ -2426,7 +2426,7 @@ class DevtoolUpgradeTests(DevtoolBase):
self.assertNotExists(os.path.join(self.workspacedir, 'recipes', recipename), 'Old recipe directory still exists')
self.assertExists(os.path.join(self.workspacedir, 'sources', newrecipename), 'Source directory not renamed')
checkvars = {}
checkvars['S'] = '${WORKDIR}/%s-${PV}' % recipename
checkvars['S'] = '${UNPACKDIR}/%s-${PV}' % recipename
checkvars['SRC_URI'] = url.replace(recipever, '${PV}')
self._test_recipe_contents(newrecipefile, checkvars, [])
# Try again - change just version this time
@@ -2437,7 +2437,7 @@ class DevtoolUpgradeTests(DevtoolBase):
self.assertExists(newrecipefile, 'Recipe file not renamed')
self.assertExists(os.path.join(self.workspacedir, 'sources', recipename), 'Source directory no longer exists')
checkvars = {}
checkvars['S'] = '${WORKDIR}/${BPN}-%s' % recipever
checkvars['S'] = '${UNPACKDIR}/${BPN}-%s' % recipever
checkvars['SRC_URI'] = url
self._test_recipe_contents(newrecipefile, checkvars, [])

View File

@@ -1144,10 +1144,10 @@ class RecipetoolAppendsrcTests(RecipetoolAppendsrcBase):
def test_recipetool_appendsrcfile_srcdir_basic(self):
testrecipe = 'bash'
bb_vars = get_bb_vars(['S', 'WORKDIR'], testrecipe)
bb_vars = get_bb_vars(['S', 'UNPACKDIR'], testrecipe)
srcdir = bb_vars['S']
workdir = bb_vars['WORKDIR']
subdir = os.path.relpath(srcdir, workdir)
unpackdir = bb_vars['UNPACKDIR']
subdir = os.path.relpath(srcdir, unpackdir)
self._test_appendsrcfile(testrecipe, 'a-file', srcdir=subdir)
def test_recipetool_appendsrcfile_existing_in_src_uri(self):
@@ -1196,10 +1196,10 @@ class RecipetoolAppendsrcTests(RecipetoolAppendsrcBase):
def test_recipetool_appendsrcfile_replace_file_srcdir(self):
testrecipe = 'bash'
filepath = 'Makefile.in'
bb_vars = get_bb_vars(['S', 'WORKDIR'], testrecipe)
bb_vars = get_bb_vars(['S', 'UNPACKDIR'], testrecipe)
srcdir = bb_vars['S']
workdir = bb_vars['WORKDIR']
subdir = os.path.relpath(srcdir, workdir)
unpackdir = bb_vars['UNPACKDIR']
subdir = os.path.relpath(srcdir, unpackdir)
self._test_appendsrcfile(testrecipe, filepath, srcdir=subdir)
bitbake('%s:do_unpack' % testrecipe)