mirror of
https://git.yoctoproject.org/poky
synced 2026-09-19 00:49:33 +02:00
recipetool: appendsrcfile(s): use params instead of extraline
appendsrc function relies on oe.recipeutils.bbappend_recipe to copy files and add the corresponding entries in SRC_URI. Currently, appendsrc function build itself the new SRC_URI entry to add the correct subdir param, and gives it using the extralines parameter. This has 2 drawbacks: - oe.recipeutils.bbappend_recipe can already do this if we specify the correct params, so we have duplicate code - the duplicated code is not fully functional: for example, it doesn't take into account the -m/--machine parameter So fix this by not using extralines but give correctly formatted params. Also remove the check for already existing entries as oe.recipeutils.bbappend_recipe already implement it The new bbappend file now have the SRC_URI entry after the FILESEXTRAPATHS so fix the selftest. Update test_recipetool_appendsrcfile_existing_in_src_uri_diff_params test because recipetool appendsrcfiles used to not add new src_uri entry if the entry already exist even with different parameters while oe.recipeutils.bbappend_recipe adds it if parameters are different (and remove the old entry) (From OE-Core rev: cd5de8d53849a6f3bb6f82e45fb301e39892c789) Signed-off-by: Julien Stephan <jstephan@baylibre.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
165626f7b9
commit
29dc0d7315
@@ -1108,9 +1108,9 @@ class RecipetoolAppendsrcBase(RecipetoolBase):
|
||||
for uri in src_uri:
|
||||
p = urllib.parse.urlparse(uri)
|
||||
if p.scheme == 'file':
|
||||
return p.netloc + p.path
|
||||
return p.netloc + p.path, uri
|
||||
|
||||
def _test_appendsrcfile(self, testrecipe, filename=None, destdir=None, has_src_uri=True, srcdir=None, newfile=None, options=''):
|
||||
def _test_appendsrcfile(self, testrecipe, filename=None, destdir=None, has_src_uri=True, srcdir=None, newfile=None, remove=None, options=''):
|
||||
if newfile is None:
|
||||
newfile = self.testfile
|
||||
|
||||
@@ -1137,12 +1137,18 @@ class RecipetoolAppendsrcBase(RecipetoolBase):
|
||||
|
||||
expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
|
||||
'\n']
|
||||
|
||||
if remove:
|
||||
for entry in remove:
|
||||
expectedlines.extend(['SRC_URI:remove = "%s"\n' % entry,
|
||||
'\n'])
|
||||
|
||||
if has_src_uri:
|
||||
uri = 'file://%s' % filename
|
||||
if expected_subdir:
|
||||
uri += ';subdir=%s' % expected_subdir
|
||||
expectedlines[0:0] = ['SRC_URI += "%s"\n' % uri,
|
||||
'\n']
|
||||
expectedlines.extend(['SRC_URI += "%s"\n' % uri,
|
||||
'\n'])
|
||||
|
||||
return self._try_recipetool_appendsrcfile(testrecipe, newfile, destpath, options, expectedlines, [filename])
|
||||
|
||||
@@ -1197,18 +1203,17 @@ class RecipetoolAppendsrcTests(RecipetoolAppendsrcBase):
|
||||
|
||||
def test_recipetool_appendsrcfile_existing_in_src_uri(self):
|
||||
testrecipe = 'base-files'
|
||||
filepath = self._get_first_file_uri(testrecipe)
|
||||
filepath,_ = self._get_first_file_uri(testrecipe)
|
||||
self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe)
|
||||
self._test_appendsrcfile(testrecipe, filepath, has_src_uri=False)
|
||||
|
||||
def test_recipetool_appendsrcfile_existing_in_src_uri_diff_params(self):
|
||||
testrecipe = 'base-files'
|
||||
subdir = 'tmp'
|
||||
filepath = self._get_first_file_uri(testrecipe)
|
||||
filepath, srcuri_entry = self._get_first_file_uri(testrecipe)
|
||||
self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe)
|
||||
|
||||
output = self._test_appendsrcfile(testrecipe, filepath, subdir, has_src_uri=False)
|
||||
self.assertTrue(any('with different parameters' in l for l in output))
|
||||
self._test_appendsrcfile(testrecipe, filepath, subdir, remove=[srcuri_entry])
|
||||
|
||||
def test_recipetool_appendsrcfile_replace_file_srcdir(self):
|
||||
testrecipe = 'bash'
|
||||
|
||||
Reference in New Issue
Block a user