summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/recipetool.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/recipetool.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/recipetool.py873
1 files changed, 775 insertions, 98 deletions
diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py
index 9d56e9e1e3..126906df50 100644
--- a/meta/lib/oeqa/selftest/cases/recipetool.py
+++ b/meta/lib/oeqa/selftest/cases/recipetool.py
@@ -1,7 +1,10 @@
1# 1#
2# Copyright OpenEmbedded Contributors
3#
2# SPDX-License-Identifier: MIT 4# SPDX-License-Identifier: MIT
3# 5#
4 6
7import errno
5import os 8import os
6import shutil 9import shutil
7import tempfile 10import tempfile
@@ -25,7 +28,17 @@ def tearDownModule():
25 runCmd('rm -rf %s' % templayerdir) 28 runCmd('rm -rf %s' % templayerdir)
26 29
27 30
28class RecipetoolBase(devtool.DevtoolBase): 31def needTomllib(test):
32 # This test require python 3.11 or above for the tomllib module or tomli module to be installed
33 try:
34 import tomllib
35 except ImportError:
36 try:
37 import tomli
38 except ImportError:
39 test.skipTest('Test requires python 3.11 or above for tomllib module or tomli module')
40
41class RecipetoolBase(devtool.DevtoolTestCase):
29 42
30 def setUpLocal(self): 43 def setUpLocal(self):
31 super(RecipetoolBase, self).setUpLocal() 44 super(RecipetoolBase, self).setUpLocal()
@@ -35,6 +48,8 @@ class RecipetoolBase(devtool.DevtoolBase):
35 self.testfile = os.path.join(self.tempdir, 'testfile') 48 self.testfile = os.path.join(self.tempdir, 'testfile')
36 with open(self.testfile, 'w') as f: 49 with open(self.testfile, 'w') as f:
37 f.write('Test file\n') 50 f.write('Test file\n')
51 config = 'BBMASK += "meta-poky/recipes-core/base-files/base-files_%.bbappend"\n'
52 self.append_config(config)
38 53
39 def tearDownLocal(self): 54 def tearDownLocal(self):
40 runCmd('rm -rf %s/recipes-*' % self.templayerdir) 55 runCmd('rm -rf %s/recipes-*' % self.templayerdir)
@@ -68,17 +83,16 @@ class RecipetoolBase(devtool.DevtoolBase):
68 return bbappendfile, result.output 83 return bbappendfile, result.output
69 84
70 85
71class RecipetoolTests(RecipetoolBase): 86class RecipetoolAppendTests(RecipetoolBase):
72 87
73 @classmethod 88 @classmethod
74 def setUpClass(cls): 89 def setUpClass(cls):
75 super(RecipetoolTests, cls).setUpClass() 90 super(RecipetoolAppendTests, cls).setUpClass()
76 # Ensure we have the right data in shlibs/pkgdata 91 # Ensure we have the right data in shlibs/pkgdata
77 cls.logger.info('Running bitbake to generate pkgdata') 92 cls.logger.info('Running bitbake to generate pkgdata')
78 bitbake('-c packagedata base-files coreutils busybox selftest-recipetool-appendfile') 93 bitbake('-c packagedata base-files coreutils busybox selftest-recipetool-appendfile')
79 bb_vars = get_bb_vars(['COREBASE', 'BBPATH']) 94 bb_vars = get_bb_vars(['COREBASE'])
80 cls.corebase = bb_vars['COREBASE'] 95 cls.corebase = bb_vars['COREBASE']
81 cls.bbpath = bb_vars['BBPATH']
82 96
83 def _try_recipetool_appendfile(self, testrecipe, destfile, newfile, options, expectedlines, expectedfiles): 97 def _try_recipetool_appendfile(self, testrecipe, destfile, newfile, options, expectedlines, expectedfiles):
84 cmd = 'recipetool appendfile %s %s %s %s' % (self.templayerdir, destfile, newfile, options) 98 cmd = 'recipetool appendfile %s %s %s %s' % (self.templayerdir, destfile, newfile, options)
@@ -94,7 +108,7 @@ class RecipetoolTests(RecipetoolBase):
94 108
95 def test_recipetool_appendfile_basic(self): 109 def test_recipetool_appendfile_basic(self):
96 # Basic test 110 # Basic test
97 expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', 111 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
98 '\n'] 112 '\n']
99 _, output = self._try_recipetool_appendfile('base-files', '/etc/motd', self.testfile, '', expectedlines, ['motd']) 113 _, output = self._try_recipetool_appendfile('base-files', '/etc/motd', self.testfile, '', expectedlines, ['motd'])
100 self.assertNotIn('WARNING: ', output) 114 self.assertNotIn('WARNING: ', output)
@@ -106,23 +120,29 @@ class RecipetoolTests(RecipetoolBase):
106 self._try_recipetool_appendfile_fail('/dev/console', self.testfile, ['ERROR: /dev/console cannot be handled by this tool']) 120 self._try_recipetool_appendfile_fail('/dev/console', self.testfile, ['ERROR: /dev/console cannot be handled by this tool'])
107 121
108 def test_recipetool_appendfile_alternatives(self): 122 def test_recipetool_appendfile_alternatives(self):
123 lspath = '/bin/ls'
124 dirname = "base_bindir"
125 if "usrmerge" in get_bb_var('DISTRO_FEATURES'):
126 lspath = '/usr/bin/ls'
127 dirname = "bindir"
128
109 # Now try with a file we know should be an alternative 129 # Now try with a file we know should be an alternative
110 # (this is very much a fake example, but one we know is reliably an alternative) 130 # (this is very much a fake example, but one we know is reliably an alternative)
111 self._try_recipetool_appendfile_fail('/bin/ls', self.testfile, ['ERROR: File /bin/ls is an alternative possibly provided by the following recipes:', 'coreutils', 'busybox']) 131 self._try_recipetool_appendfile_fail(lspath, self.testfile, ['ERROR: File %s is an alternative possibly provided by the following recipes:' % lspath, 'coreutils', 'busybox'])
112 # Need a test file - should be executable 132 # Need a test file - should be executable
113 testfile2 = os.path.join(self.corebase, 'oe-init-build-env') 133 testfile2 = os.path.join(self.corebase, 'oe-init-build-env')
114 testfile2name = os.path.basename(testfile2) 134 testfile2name = os.path.basename(testfile2)
115 expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', 135 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
116 '\n', 136 '\n',
117 'SRC_URI += "file://%s"\n' % testfile2name, 137 'SRC_URI += "file://%s"\n' % testfile2name,
118 '\n', 138 '\n',
119 'do_install_append() {\n', 139 'do_install:append() {\n',
120 ' install -d ${D}${base_bindir}\n', 140 ' install -d ${D}${%s}\n' % dirname,
121 ' install -m 0755 ${WORKDIR}/%s ${D}${base_bindir}/ls\n' % testfile2name, 141 ' install -m 0755 ${WORKDIR}/%s ${D}${%s}/ls\n' % (testfile2name, dirname),
122 '}\n'] 142 '}\n']
123 self._try_recipetool_appendfile('coreutils', '/bin/ls', testfile2, '-r coreutils', expectedlines, [testfile2name]) 143 self._try_recipetool_appendfile('coreutils', lspath, testfile2, '-r coreutils', expectedlines, [testfile2name])
124 # Now try bbappending the same file again, contents should not change 144 # Now try bbappending the same file again, contents should not change
125 bbappendfile, _ = self._try_recipetool_appendfile('coreutils', '/bin/ls', self.testfile, '-r coreutils', expectedlines, [testfile2name]) 145 bbappendfile, _ = self._try_recipetool_appendfile('coreutils', lspath, self.testfile, '-r coreutils', expectedlines, [testfile2name])
126 # But file should have 146 # But file should have
127 copiedfile = os.path.join(os.path.dirname(bbappendfile), 'coreutils', testfile2name) 147 copiedfile = os.path.join(os.path.dirname(bbappendfile), 'coreutils', testfile2name)
128 result = runCmd('diff -q %s %s' % (testfile2, copiedfile), ignore_status=True) 148 result = runCmd('diff -q %s %s' % (testfile2, copiedfile), ignore_status=True)
@@ -138,11 +158,11 @@ class RecipetoolTests(RecipetoolBase):
138 158
139 def test_recipetool_appendfile_add(self): 159 def test_recipetool_appendfile_add(self):
140 # Try arbitrary file add to a recipe 160 # Try arbitrary file add to a recipe
141 expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', 161 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
142 '\n', 162 '\n',
143 'SRC_URI += "file://testfile"\n', 163 'SRC_URI += "file://testfile"\n',
144 '\n', 164 '\n',
145 'do_install_append() {\n', 165 'do_install:append() {\n',
146 ' install -d ${D}${datadir}\n', 166 ' install -d ${D}${datadir}\n',
147 ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/something\n', 167 ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/something\n',
148 '}\n'] 168 '}\n']
@@ -151,13 +171,13 @@ class RecipetoolTests(RecipetoolBase):
151 # (so we're testing that, plus modifying an existing bbappend) 171 # (so we're testing that, plus modifying an existing bbappend)
152 testfile2 = os.path.join(self.corebase, 'oe-init-build-env') 172 testfile2 = os.path.join(self.corebase, 'oe-init-build-env')
153 testfile2name = os.path.basename(testfile2) 173 testfile2name = os.path.basename(testfile2)
154 expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', 174 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
155 '\n', 175 '\n',
156 'SRC_URI += "file://testfile \\\n', 176 'SRC_URI += "file://testfile \\\n',
157 ' file://%s \\\n' % testfile2name, 177 ' file://%s \\\n' % testfile2name,
158 ' "\n', 178 ' "\n',
159 '\n', 179 '\n',
160 'do_install_append() {\n', 180 'do_install:append() {\n',
161 ' install -d ${D}${datadir}\n', 181 ' install -d ${D}${datadir}\n',
162 ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/something\n', 182 ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/something\n',
163 ' install -m 0755 ${WORKDIR}/%s ${D}${datadir}/scriptname\n' % testfile2name, 183 ' install -m 0755 ${WORKDIR}/%s ${D}${datadir}/scriptname\n' % testfile2name,
@@ -166,11 +186,11 @@ class RecipetoolTests(RecipetoolBase):
166 186
167 def test_recipetool_appendfile_add_bindir(self): 187 def test_recipetool_appendfile_add_bindir(self):
168 # Try arbitrary file add to a recipe, this time to a location such that should be installed as executable 188 # Try arbitrary file add to a recipe, this time to a location such that should be installed as executable
169 expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', 189 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
170 '\n', 190 '\n',
171 'SRC_URI += "file://testfile"\n', 191 'SRC_URI += "file://testfile"\n',
172 '\n', 192 '\n',
173 'do_install_append() {\n', 193 'do_install:append() {\n',
174 ' install -d ${D}${bindir}\n', 194 ' install -d ${D}${bindir}\n',
175 ' install -m 0755 ${WORKDIR}/testfile ${D}${bindir}/selftest-recipetool-testbin\n', 195 ' install -m 0755 ${WORKDIR}/testfile ${D}${bindir}/selftest-recipetool-testbin\n',
176 '}\n'] 196 '}\n']
@@ -179,13 +199,13 @@ class RecipetoolTests(RecipetoolBase):
179 199
180 def test_recipetool_appendfile_add_machine(self): 200 def test_recipetool_appendfile_add_machine(self):
181 # Try arbitrary file add to a recipe, this time to a location such that should be installed as executable 201 # Try arbitrary file add to a recipe, this time to a location such that should be installed as executable
182 expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', 202 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
183 '\n', 203 '\n',
184 'PACKAGE_ARCH = "${MACHINE_ARCH}"\n', 204 'PACKAGE_ARCH = "${MACHINE_ARCH}"\n',
185 '\n', 205 '\n',
186 'SRC_URI_append_mymachine = " file://testfile"\n', 206 'SRC_URI:append:mymachine = " file://testfile"\n',
187 '\n', 207 '\n',
188 'do_install_append_mymachine() {\n', 208 'do_install:append:mymachine() {\n',
189 ' install -d ${D}${datadir}\n', 209 ' install -d ${D}${datadir}\n',
190 ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/something\n', 210 ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/something\n',
191 '}\n'] 211 '}\n']
@@ -194,32 +214,32 @@ class RecipetoolTests(RecipetoolBase):
194 214
195 def test_recipetool_appendfile_orig(self): 215 def test_recipetool_appendfile_orig(self):
196 # A file that's in SRC_URI and in do_install with the same name 216 # A file that's in SRC_URI and in do_install with the same name
197 expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', 217 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
198 '\n'] 218 '\n']
199 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-orig', self.testfile, '', expectedlines, ['selftest-replaceme-orig']) 219 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-orig', self.testfile, '', expectedlines, ['selftest-replaceme-orig'])
200 self.assertNotIn('WARNING: ', output) 220 self.assertNotIn('WARNING: ', output)
201 221
202 def test_recipetool_appendfile_todir(self): 222 def test_recipetool_appendfile_todir(self):
203 # A file that's in SRC_URI and in do_install with destination directory rather than file 223 # A file that's in SRC_URI and in do_install with destination directory rather than file
204 expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', 224 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
205 '\n'] 225 '\n']
206 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-todir', self.testfile, '', expectedlines, ['selftest-replaceme-todir']) 226 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-todir', self.testfile, '', expectedlines, ['selftest-replaceme-todir'])
207 self.assertNotIn('WARNING: ', output) 227 self.assertNotIn('WARNING: ', output)
208 228
209 def test_recipetool_appendfile_renamed(self): 229 def test_recipetool_appendfile_renamed(self):
210 # A file that's in SRC_URI with a different name to the destination file 230 # A file that's in SRC_URI with a different name to the destination file
211 expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', 231 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
212 '\n'] 232 '\n']
213 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-renamed', self.testfile, '', expectedlines, ['file1']) 233 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-renamed', self.testfile, '', expectedlines, ['file1'])
214 self.assertNotIn('WARNING: ', output) 234 self.assertNotIn('WARNING: ', output)
215 235
216 def test_recipetool_appendfile_subdir(self): 236 def test_recipetool_appendfile_subdir(self):
217 # A file that's in SRC_URI in a subdir 237 # A file that's in SRC_URI in a subdir
218 expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', 238 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
219 '\n', 239 '\n',
220 'SRC_URI += "file://testfile"\n', 240 'SRC_URI += "file://testfile"\n',
221 '\n', 241 '\n',
222 'do_install_append() {\n', 242 'do_install:append() {\n',
223 ' install -d ${D}${datadir}\n', 243 ' install -d ${D}${datadir}\n',
224 ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/selftest-replaceme-subdir\n', 244 ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/selftest-replaceme-subdir\n',
225 '}\n'] 245 '}\n']
@@ -228,25 +248,25 @@ class RecipetoolTests(RecipetoolBase):
228 248
229 def test_recipetool_appendfile_inst_glob(self): 249 def test_recipetool_appendfile_inst_glob(self):
230 # A file that's in do_install as a glob 250 # A file that's in do_install as a glob
231 expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', 251 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
232 '\n'] 252 '\n']
233 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-inst-globfile', self.testfile, '', expectedlines, ['selftest-replaceme-inst-globfile']) 253 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-inst-globfile', self.testfile, '', expectedlines, ['selftest-replaceme-inst-globfile'])
234 self.assertNotIn('WARNING: ', output) 254 self.assertNotIn('WARNING: ', output)
235 255
236 def test_recipetool_appendfile_inst_todir_glob(self): 256 def test_recipetool_appendfile_inst_todir_glob(self):
237 # A file that's in do_install as a glob with destination as a directory 257 # A file that's in do_install as a glob with destination as a directory
238 expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', 258 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
239 '\n'] 259 '\n']
240 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-inst-todir-globfile', self.testfile, '', expectedlines, ['selftest-replaceme-inst-todir-globfile']) 260 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-inst-todir-globfile', self.testfile, '', expectedlines, ['selftest-replaceme-inst-todir-globfile'])
241 self.assertNotIn('WARNING: ', output) 261 self.assertNotIn('WARNING: ', output)
242 262
243 def test_recipetool_appendfile_patch(self): 263 def test_recipetool_appendfile_patch(self):
244 # A file that's added by a patch in SRC_URI 264 # A file that's added by a patch in SRC_URI
245 expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', 265 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
246 '\n', 266 '\n',
247 'SRC_URI += "file://testfile"\n', 267 'SRC_URI += "file://testfile"\n',
248 '\n', 268 '\n',
249 'do_install_append() {\n', 269 'do_install:append() {\n',
250 ' install -d ${D}${sysconfdir}\n', 270 ' install -d ${D}${sysconfdir}\n',
251 ' install -m 0644 ${WORKDIR}/testfile ${D}${sysconfdir}/selftest-replaceme-patched\n', 271 ' install -m 0644 ${WORKDIR}/testfile ${D}${sysconfdir}/selftest-replaceme-patched\n',
252 '}\n'] 272 '}\n']
@@ -260,11 +280,11 @@ class RecipetoolTests(RecipetoolBase):
260 280
261 def test_recipetool_appendfile_script(self): 281 def test_recipetool_appendfile_script(self):
262 # Now, a file that's in SRC_URI but installed by a script (so no mention in do_install) 282 # Now, a file that's in SRC_URI but installed by a script (so no mention in do_install)
263 expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', 283 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
264 '\n', 284 '\n',
265 'SRC_URI += "file://testfile"\n', 285 'SRC_URI += "file://testfile"\n',
266 '\n', 286 '\n',
267 'do_install_append() {\n', 287 'do_install:append() {\n',
268 ' install -d ${D}${datadir}\n', 288 ' install -d ${D}${datadir}\n',
269 ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/selftest-replaceme-scripted\n', 289 ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/selftest-replaceme-scripted\n',
270 '}\n'] 290 '}\n']
@@ -273,7 +293,7 @@ class RecipetoolTests(RecipetoolBase):
273 293
274 def test_recipetool_appendfile_inst_func(self): 294 def test_recipetool_appendfile_inst_func(self):
275 # A file that's installed from a function called by do_install 295 # A file that's installed from a function called by do_install
276 expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', 296 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
277 '\n'] 297 '\n']
278 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-inst-func', self.testfile, '', expectedlines, ['selftest-replaceme-inst-func']) 298 _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-inst-func', self.testfile, '', expectedlines, ['selftest-replaceme-inst-func'])
279 self.assertNotIn('WARNING: ', output) 299 self.assertNotIn('WARNING: ', output)
@@ -283,11 +303,11 @@ class RecipetoolTests(RecipetoolBase):
283 # First try without specifying recipe 303 # First try without specifying recipe
284 self._try_recipetool_appendfile_fail('/usr/share/selftest-replaceme-postinst', self.testfile, ['File /usr/share/selftest-replaceme-postinst may be written out in a pre/postinstall script of the following recipes:', 'selftest-recipetool-appendfile']) 304 self._try_recipetool_appendfile_fail('/usr/share/selftest-replaceme-postinst', self.testfile, ['File /usr/share/selftest-replaceme-postinst may be written out in a pre/postinstall script of the following recipes:', 'selftest-recipetool-appendfile'])
285 # Now specify recipe 305 # Now specify recipe
286 expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', 306 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
287 '\n', 307 '\n',
288 'SRC_URI += "file://testfile"\n', 308 'SRC_URI += "file://testfile"\n',
289 '\n', 309 '\n',
290 'do_install_append() {\n', 310 'do_install:append() {\n',
291 ' install -d ${D}${datadir}\n', 311 ' install -d ${D}${datadir}\n',
292 ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/selftest-replaceme-postinst\n', 312 ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/selftest-replaceme-postinst\n',
293 '}\n'] 313 '}\n']
@@ -332,6 +352,9 @@ class RecipetoolTests(RecipetoolBase):
332 filename = try_appendfile_wc('-w') 352 filename = try_appendfile_wc('-w')
333 self.assertEqual(filename, recipefn.split('_')[0] + '_%.bbappend') 353 self.assertEqual(filename, recipefn.split('_')[0] + '_%.bbappend')
334 354
355
356class RecipetoolCreateTests(RecipetoolBase):
357
335 def test_recipetool_create(self): 358 def test_recipetool_create(self):
336 # Try adding a recipe 359 # Try adding a recipe
337 tempsrc = os.path.join(self.tempdir, 'srctree') 360 tempsrc = os.path.join(self.tempdir, 'srctree')
@@ -341,14 +364,13 @@ class RecipetoolTests(RecipetoolBase):
341 result = runCmd('recipetool create -o %s %s -x %s' % (recipefile, srcuri, tempsrc)) 364 result = runCmd('recipetool create -o %s %s -x %s' % (recipefile, srcuri, tempsrc))
342 self.assertTrue(os.path.isfile(recipefile)) 365 self.assertTrue(os.path.isfile(recipefile))
343 checkvars = {} 366 checkvars = {}
344 checkvars['LICENSE'] = 'GPLv2' 367 checkvars['LICENSE'] = 'GPL-2.0-only'
345 checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263' 368 checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263'
346 checkvars['SRC_URI'] = 'https://github.com/logrotate/logrotate/releases/download/${PV}/logrotate-${PV}.tar.xz' 369 checkvars['SRC_URI'] = 'https://github.com/logrotate/logrotate/releases/download/${PV}/logrotate-${PV}.tar.xz'
347 checkvars['SRC_URI[md5sum]'] = 'a560c57fac87c45b2fc17406cdf79288'
348 checkvars['SRC_URI[sha256sum]'] = '2e6a401cac9024db2288297e3be1a8ab60e7401ba8e91225218aaf4a27e82a07' 370 checkvars['SRC_URI[sha256sum]'] = '2e6a401cac9024db2288297e3be1a8ab60e7401ba8e91225218aaf4a27e82a07'
349 self._test_recipe_contents(recipefile, checkvars, []) 371 self._test_recipe_contents(recipefile, checkvars, [])
350 372
351 def test_recipetool_create_git(self): 373 def test_recipetool_create_autotools(self):
352 if 'x11' not in get_bb_var('DISTRO_FEATURES'): 374 if 'x11' not in get_bb_var('DISTRO_FEATURES'):
353 self.skipTest('Test requires x11 as distro feature') 375 self.skipTest('Test requires x11 as distro feature')
354 # Ensure we have the right data in shlibs/pkgdata 376 # Ensure we have the right data in shlibs/pkgdata
@@ -357,15 +379,15 @@ class RecipetoolTests(RecipetoolBase):
357 tempsrc = os.path.join(self.tempdir, 'srctree') 379 tempsrc = os.path.join(self.tempdir, 'srctree')
358 os.makedirs(tempsrc) 380 os.makedirs(tempsrc)
359 recipefile = os.path.join(self.tempdir, 'libmatchbox.bb') 381 recipefile = os.path.join(self.tempdir, 'libmatchbox.bb')
360 srcuri = 'git://git.yoctoproject.org/libmatchbox' 382 srcuri = 'git://git.yoctoproject.org/libmatchbox;protocol=https'
361 result = runCmd(['recipetool', 'create', '-o', recipefile, srcuri + ";rev=9f7cf8895ae2d39c465c04cc78e918c157420269", '-x', tempsrc]) 383 result = runCmd(['recipetool', 'create', '-o', recipefile, srcuri + ";rev=9f7cf8895ae2d39c465c04cc78e918c157420269", '-x', tempsrc])
362 self.assertTrue(os.path.isfile(recipefile), 'recipetool did not create recipe file; output:\n%s' % result.output) 384 self.assertTrue(os.path.isfile(recipefile), 'recipetool did not create recipe file; output:\n%s' % result.output)
363 checkvars = {} 385 checkvars = {}
364 checkvars['LICENSE'] = 'LGPLv2.1' 386 checkvars['LICENSE'] = 'LGPL-2.1-only'
365 checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING;md5=7fbc338309ac38fefcd64b04bb903e34' 387 checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING;md5=7fbc338309ac38fefcd64b04bb903e34'
366 checkvars['S'] = '${WORKDIR}/git' 388 checkvars['S'] = '${WORKDIR}/git'
367 checkvars['PV'] = '1.11+git${SRCPV}' 389 checkvars['PV'] = '1.11+git'
368 checkvars['SRC_URI'] = srcuri 390 checkvars['SRC_URI'] = srcuri + ';branch=master'
369 checkvars['DEPENDS'] = set(['libcheck', 'libjpeg-turbo', 'libpng', 'libx11', 'libxext', 'pango']) 391 checkvars['DEPENDS'] = set(['libcheck', 'libjpeg-turbo', 'libpng', 'libx11', 'libxext', 'pango'])
370 inherits = ['autotools', 'pkgconfig'] 392 inherits = ['autotools', 'pkgconfig']
371 self._test_recipe_contents(recipefile, checkvars, inherits) 393 self._test_recipe_contents(recipefile, checkvars, inherits)
@@ -374,8 +396,8 @@ class RecipetoolTests(RecipetoolBase):
374 # Try adding a recipe 396 # Try adding a recipe
375 temprecipe = os.path.join(self.tempdir, 'recipe') 397 temprecipe = os.path.join(self.tempdir, 'recipe')
376 os.makedirs(temprecipe) 398 os.makedirs(temprecipe)
377 pv = '1.7.3.0' 399 pv = '1.7.4.1'
378 srcuri = 'http://www.dest-unreach.org/socat/download/socat-%s.tar.bz2' % pv 400 srcuri = 'http://www.dest-unreach.org/socat/download/Archive/socat-%s.tar.bz2' % pv
379 result = runCmd('recipetool create %s -o %s' % (srcuri, temprecipe)) 401 result = runCmd('recipetool create %s -o %s' % (srcuri, temprecipe))
380 dirlist = os.listdir(temprecipe) 402 dirlist = os.listdir(temprecipe)
381 if len(dirlist) > 1: 403 if len(dirlist) > 1:
@@ -384,7 +406,7 @@ class RecipetoolTests(RecipetoolBase):
384 self.fail('recipetool did not create recipe file; output:\n%s\ndirlist:\n%s' % (result.output, str(dirlist))) 406 self.fail('recipetool did not create recipe file; output:\n%s\ndirlist:\n%s' % (result.output, str(dirlist)))
385 self.assertEqual(dirlist[0], 'socat_%s.bb' % pv, 'Recipe file incorrectly named') 407 self.assertEqual(dirlist[0], 'socat_%s.bb' % pv, 'Recipe file incorrectly named')
386 checkvars = {} 408 checkvars = {}
387 checkvars['LICENSE'] = set(['Unknown', 'GPLv2']) 409 checkvars['LICENSE'] = set(['Unknown', 'GPL-2.0-only'])
388 checkvars['LIC_FILES_CHKSUM'] = set(['file://COPYING.OpenSSL;md5=5c9bccc77f67a8328ef4ebaf468116f4', 'file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263']) 410 checkvars['LIC_FILES_CHKSUM'] = set(['file://COPYING.OpenSSL;md5=5c9bccc77f67a8328ef4ebaf468116f4', 'file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263'])
389 # We don't check DEPENDS since they are variable for this recipe depending on what's in the sysroot 411 # We don't check DEPENDS since they are variable for this recipe depending on what's in the sysroot
390 checkvars['S'] = None 412 checkvars['S'] = None
@@ -400,9 +422,8 @@ class RecipetoolTests(RecipetoolBase):
400 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri)) 422 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
401 self.assertTrue(os.path.isfile(recipefile)) 423 self.assertTrue(os.path.isfile(recipefile))
402 checkvars = {} 424 checkvars = {}
403 checkvars['LICENSE'] = set(['LGPLv2.1', 'MPL-1.1']) 425 checkvars['LICENSE'] = set(['LGPL-2.1-only', 'MPL-1.1-only'])
404 checkvars['SRC_URI'] = 'http://taglib.github.io/releases/taglib-${PV}.tar.gz' 426 checkvars['SRC_URI'] = 'http://taglib.github.io/releases/taglib-${PV}.tar.gz'
405 checkvars['SRC_URI[md5sum]'] = 'cee7be0ccfc892fa433d6c837df9522a'
406 checkvars['SRC_URI[sha256sum]'] = 'b6d1a5a610aae6ff39d93de5efd0fdc787aa9e9dc1e7026fa4c961b26563526b' 427 checkvars['SRC_URI[sha256sum]'] = 'b6d1a5a610aae6ff39d93de5efd0fdc787aa9e9dc1e7026fa4c961b26563526b'
407 checkvars['DEPENDS'] = set(['boost', 'zlib']) 428 checkvars['DEPENDS'] = set(['boost', 'zlib'])
408 inherits = ['cmake'] 429 inherits = ['cmake']
@@ -424,77 +445,271 @@ class RecipetoolTests(RecipetoolBase):
424 checkvars = {} 445 checkvars = {}
425 checkvars['SUMMARY'] = 'Node Server Example' 446 checkvars['SUMMARY'] = 'Node Server Example'
426 checkvars['HOMEPAGE'] = 'https://github.com/savoirfairelinux/node-server-example#readme' 447 checkvars['HOMEPAGE'] = 'https://github.com/savoirfairelinux/node-server-example#readme'
427 checkvars['LICENSE'] = set(['MIT', 'ISC', 'Unknown']) 448 checkvars['LICENSE'] = 'BSD-3-Clause & ISC & MIT & Unknown'
428 urls = [] 449 urls = []
429 urls.append('npm://registry.npmjs.org/;package=@savoirfairelinux/node-server-example;version=${PV}') 450 urls.append('npm://registry.npmjs.org/;package=@savoirfairelinux/node-server-example;version=${PV}')
430 urls.append('npmsw://${THISDIR}/${BPN}/npm-shrinkwrap.json') 451 urls.append('npmsw://${THISDIR}/${BPN}/npm-shrinkwrap.json')
431 checkvars['SRC_URI'] = set(urls) 452 checkvars['SRC_URI'] = set(urls)
432 checkvars['S'] = '${WORKDIR}/npm' 453 checkvars['S'] = '${WORKDIR}/npm'
433 checkvars['LICENSE_${PN}'] = 'MIT' 454 checkvars['LICENSE:${PN}'] = 'MIT'
434 checkvars['LICENSE_${PN}-base64'] = 'Unknown' 455 checkvars['LICENSE:${PN}-base64'] = 'Unknown'
435 checkvars['LICENSE_${PN}-accepts'] = 'MIT' 456 checkvars['LICENSE:${PN}-accepts'] = 'MIT'
436 checkvars['LICENSE_${PN}-inherits'] = 'ISC' 457 checkvars['LICENSE:${PN}-inherits'] = 'ISC'
437 inherits = ['npm'] 458 inherits = ['npm']
438 self._test_recipe_contents(recipefile, checkvars, inherits) 459 self._test_recipe_contents(recipefile, checkvars, inherits)
439 460
440 def test_recipetool_create_github(self): 461 def test_recipetool_create_github(self):
441 # Basic test to see if github URL mangling works 462 # Basic test to see if github URL mangling works. Deliberately use an
463 # older release of Meson at present so we don't need a toml parser.
442 temprecipe = os.path.join(self.tempdir, 'recipe') 464 temprecipe = os.path.join(self.tempdir, 'recipe')
443 os.makedirs(temprecipe) 465 os.makedirs(temprecipe)
444 recipefile = os.path.join(temprecipe, 'meson_git.bb') 466 recipefile = os.path.join(temprecipe, 'python3-meson_git.bb')
445 srcuri = 'https://github.com/mesonbuild/meson;rev=0.32.0' 467 srcuri = 'https://github.com/mesonbuild/meson;rev=0.52.1'
446 result = runCmd(['recipetool', 'create', '-o', temprecipe, srcuri]) 468 cmd = ['recipetool', 'create', '-o', temprecipe, srcuri]
447 self.assertTrue(os.path.isfile(recipefile)) 469 result = runCmd(cmd)
470 self.assertTrue(os.path.isfile(recipefile), msg="recipe %s not created for command %s, output %s" % (recipefile, " ".join(cmd), result.output))
448 checkvars = {} 471 checkvars = {}
449 checkvars['LICENSE'] = set(['Apache-2.0']) 472 checkvars['LICENSE'] = set(['Apache-2.0', "Unknown"])
450 checkvars['SRC_URI'] = 'git://github.com/mesonbuild/meson;protocol=https' 473 checkvars['SRC_URI'] = 'git://github.com/mesonbuild/meson;protocol=https;branch=0.52'
451 inherits = ['setuptools3'] 474 inherits = ['setuptools3']
452 self._test_recipe_contents(recipefile, checkvars, inherits) 475 self._test_recipe_contents(recipefile, checkvars, inherits)
453 476
454 def test_recipetool_create_python3_setuptools(self): 477 def test_recipetool_create_python3_setuptools(self):
455 # Test creating python3 package from tarball (using setuptools3 class) 478 # Test creating python3 package from tarball (using setuptools3 class)
479 # Use the --no-pypi switch to avoid creating a pypi enabled recipe and
480 # and check the created recipe as if it was a more general tarball
456 temprecipe = os.path.join(self.tempdir, 'recipe') 481 temprecipe = os.path.join(self.tempdir, 'recipe')
457 os.makedirs(temprecipe) 482 os.makedirs(temprecipe)
458 pn = 'python-magic' 483 pn = 'python-magic'
459 pv = '0.4.15' 484 pv = '0.4.15'
460 recipefile = os.path.join(temprecipe, '%s_%s.bb' % (pn, pv)) 485 recipefile = os.path.join(temprecipe, '%s_%s.bb' % (pn, pv))
461 srcuri = 'https://files.pythonhosted.org/packages/84/30/80932401906eaf787f2e9bd86dc458f1d2e75b064b4c187341f29516945c/python-magic-%s.tar.gz' % pv 486 srcuri = 'https://files.pythonhosted.org/packages/84/30/80932401906eaf787f2e9bd86dc458f1d2e75b064b4c187341f29516945c/python-magic-%s.tar.gz' % pv
462 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri)) 487 result = runCmd('recipetool create --no-pypi -o %s %s' % (temprecipe, srcuri))
463 self.assertTrue(os.path.isfile(recipefile)) 488 self.assertTrue(os.path.isfile(recipefile))
464 checkvars = {} 489 checkvars = {}
465 checkvars['LICENSE'] = set(['MIT']) 490 checkvars['LICENSE'] = set(['MIT'])
466 checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=16a934f165e8c3245f241e77d401bb88' 491 checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=16a934f165e8c3245f241e77d401bb88'
467 checkvars['SRC_URI'] = 'https://files.pythonhosted.org/packages/84/30/80932401906eaf787f2e9bd86dc458f1d2e75b064b4c187341f29516945c/python-magic-${PV}.tar.gz' 492 checkvars['SRC_URI'] = 'https://files.pythonhosted.org/packages/84/30/80932401906eaf787f2e9bd86dc458f1d2e75b064b4c187341f29516945c/python-magic-${PV}.tar.gz'
468 checkvars['SRC_URI[md5sum]'] = 'e384c95a47218f66c6501cd6dd45ff59'
469 checkvars['SRC_URI[sha256sum]'] = 'f3765c0f582d2dfc72c15f3b5a82aecfae9498bd29ca840d72f37d7bd38bfcd5' 493 checkvars['SRC_URI[sha256sum]'] = 'f3765c0f582d2dfc72c15f3b5a82aecfae9498bd29ca840d72f37d7bd38bfcd5'
470 inherits = ['setuptools3'] 494 inherits = ['setuptools3']
471 self._test_recipe_contents(recipefile, checkvars, inherits) 495 self._test_recipe_contents(recipefile, checkvars, inherits)
472 496
473 def test_recipetool_create_python3_distutils(self): 497 def test_recipetool_create_python3_setuptools_pypi_tarball(self):
474 # Test creating python3 package from tarball (using distutils3 class) 498 # Test creating python3 package from tarball (using setuptools3 and pypi classes)
499 temprecipe = os.path.join(self.tempdir, 'recipe')
500 os.makedirs(temprecipe)
501 pn = 'python-magic'
502 pv = '0.4.15'
503 recipefile = os.path.join(temprecipe, '%s_%s.bb' % (pn, pv))
504 srcuri = 'https://files.pythonhosted.org/packages/84/30/80932401906eaf787f2e9bd86dc458f1d2e75b064b4c187341f29516945c/python-magic-%s.tar.gz' % pv
505 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
506 self.assertTrue(os.path.isfile(recipefile))
507 checkvars = {}
508 checkvars['LICENSE'] = set(['MIT'])
509 checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=16a934f165e8c3245f241e77d401bb88'
510 checkvars['SRC_URI[sha256sum]'] = 'f3765c0f582d2dfc72c15f3b5a82aecfae9498bd29ca840d72f37d7bd38bfcd5'
511 checkvars['PYPI_PACKAGE'] = pn
512 inherits = ['setuptools3', 'pypi']
513 self._test_recipe_contents(recipefile, checkvars, inherits)
514
515 def test_recipetool_create_python3_setuptools_pypi(self):
516 # Test creating python3 package from pypi url (using setuptools3 and pypi classes)
517 # Intentionnaly using setuptools3 class here instead of any of the pep517 class
518 # to avoid the toml dependency and allows this test to run on host autobuilders
519 # with older version of python
475 temprecipe = os.path.join(self.tempdir, 'recipe') 520 temprecipe = os.path.join(self.tempdir, 'recipe')
476 os.makedirs(temprecipe) 521 os.makedirs(temprecipe)
477 pn = 'docutils' 522 pn = 'python-magic'
478 pv = '0.14' 523 pv = '0.4.15'
479 recipefile = os.path.join(temprecipe, '%s_%s.bb' % (pn, pv)) 524 recipefile = os.path.join(temprecipe, '%s_%s.bb' % (pn, pv))
480 srcuri = 'https://files.pythonhosted.org/packages/84/f4/5771e41fdf52aabebbadecc9381d11dea0fa34e4759b4071244fa094804c/docutils-%s.tar.gz' % pv 525 # First specify the required version in the url
526 srcuri = 'https://pypi.org/project/%s/%s' % (pn, pv)
527 runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
528 self.assertTrue(os.path.isfile(recipefile))
529 checkvars = {}
530 checkvars['LICENSE'] = set(['MIT'])
531 checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=16a934f165e8c3245f241e77d401bb88'
532 checkvars['SRC_URI[sha256sum]'] = 'f3765c0f582d2dfc72c15f3b5a82aecfae9498bd29ca840d72f37d7bd38bfcd5'
533 checkvars['PYPI_PACKAGE'] = pn
534 inherits = ['setuptools3', "pypi"]
535 self._test_recipe_contents(recipefile, checkvars, inherits)
536
537 # Now specify the version as a recipetool parameter
538 runCmd('rm -rf %s' % recipefile)
539 self.assertFalse(os.path.isfile(recipefile))
540 srcuri = 'https://pypi.org/project/%s' % pn
541 runCmd('recipetool create -o %s %s --version %s' % (temprecipe, srcuri, pv))
542 self.assertTrue(os.path.isfile(recipefile))
543 checkvars = {}
544 checkvars['LICENSE'] = set(['MIT'])
545 checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=16a934f165e8c3245f241e77d401bb88'
546 checkvars['SRC_URI[sha256sum]'] = 'f3765c0f582d2dfc72c15f3b5a82aecfae9498bd29ca840d72f37d7bd38bfcd5'
547 checkvars['PYPI_PACKAGE'] = pn
548 inherits = ['setuptools3', "pypi"]
549 self._test_recipe_contents(recipefile, checkvars, inherits)
550
551 # Now, try to grab latest version of the package, so we cannot guess the name of the recipe,
552 # unless hardcoding the latest version but it means we will need to update the test for each release,
553 # so use a regexp
554 runCmd('rm -rf %s' % recipefile)
555 self.assertFalse(os.path.isfile(recipefile))
556 recipefile_re = r'%s_(.*)\.bb' % pn
557 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
558 dirlist = os.listdir(temprecipe)
559 if len(dirlist) > 1:
560 self.fail('recipetool created more than just one file; output:\n%s\ndirlist:\n%s' % (result.output, str(dirlist)))
561 if len(dirlist) < 1 or not os.path.isfile(os.path.join(temprecipe, dirlist[0])):
562 self.fail('recipetool did not create recipe file; output:\n%s\ndirlist:\n%s' % (result.output, str(dirlist)))
563 import re
564 match = re.match(recipefile_re, dirlist[0])
565 self.assertTrue(match)
566 latest_pv = match.group(1)
567 self.assertTrue(latest_pv != pv)
568 recipefile = os.path.join(temprecipe, '%s_%s.bb' % (pn, latest_pv))
569 # Do not check LIC_FILES_CHKSUM and SRC_URI checksum here to avoid having updating the test on each release
570 checkvars = {}
571 checkvars['LICENSE'] = set(['MIT'])
572 checkvars['PYPI_PACKAGE'] = pn
573 inherits = ['setuptools3', "pypi"]
574 self._test_recipe_contents(recipefile, checkvars, inherits)
575
576 def test_recipetool_create_python3_pep517_setuptools_build_meta(self):
577 # This test require python 3.11 or above for the tomllib module or tomli module to be installed
578 needTomllib(self)
579
580 # Test creating python3 package from tarball (using setuptools.build_meta class)
581 temprecipe = os.path.join(self.tempdir, 'recipe')
582 os.makedirs(temprecipe)
583 pn = 'webcolors'
584 pv = '1.13'
585 recipefile = os.path.join(temprecipe, 'python3-%s_%s.bb' % (pn, pv))
586 srcuri = 'https://files.pythonhosted.org/packages/a1/fb/f95560c6a5d4469d9c49e24cf1b5d4d21ffab5608251c6020a965fb7791c/%s-%s.tar.gz' % (pn, pv)
587 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
588 self.assertTrue(os.path.isfile(recipefile))
589 checkvars = {}
590 checkvars['SUMMARY'] = 'A library for working with the color formats defined by HTML and CSS.'
591 checkvars['LICENSE'] = set(['BSD-3-Clause'])
592 checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=702b1ef12cf66832a88f24c8f2ee9c19'
593 checkvars['SRC_URI[sha256sum]'] = 'c225b674c83fa923be93d235330ce0300373d02885cef23238813b0d5668304a'
594 inherits = ['python_setuptools_build_meta', 'pypi']
595
596 self._test_recipe_contents(recipefile, checkvars, inherits)
597
598 def test_recipetool_create_python3_pep517_poetry_core_masonry_api(self):
599 # This test require python 3.11 or above for the tomllib module or tomli module to be installed
600 needTomllib(self)
601
602 # Test creating python3 package from tarball (using poetry.core.masonry.api class)
603 temprecipe = os.path.join(self.tempdir, 'recipe')
604 os.makedirs(temprecipe)
605 pn = 'iso8601'
606 pv = '2.1.0'
607 recipefile = os.path.join(temprecipe, 'python3-%s_%s.bb' % (pn, pv))
608 srcuri = 'https://files.pythonhosted.org/packages/b9/f3/ef59cee614d5e0accf6fd0cbba025b93b272e626ca89fb70a3e9187c5d15/%s-%s.tar.gz' % (pn, pv)
609 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
610 self.assertTrue(os.path.isfile(recipefile))
611 checkvars = {}
612 checkvars['SUMMARY'] = 'Simple module to parse ISO 8601 dates'
613 checkvars['LICENSE'] = set(['MIT'])
614 checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=aab31f2ef7ba214a5a341eaa47a7f367'
615 checkvars['SRC_URI[sha256sum]'] = '6b1d3829ee8921c4301998c909f7829fa9ed3cbdac0d3b16af2d743aed1ba8df'
616 inherits = ['python_poetry_core', 'pypi']
617
618 self._test_recipe_contents(recipefile, checkvars, inherits)
619
620 def test_recipetool_create_python3_pep517_flit_core_buildapi(self):
621 # This test require python 3.11 or above for the tomllib module or tomli module to be installed
622 needTomllib(self)
623
624 # Test creating python3 package from tarball (using flit_core.buildapi class)
625 temprecipe = os.path.join(self.tempdir, 'recipe')
626 os.makedirs(temprecipe)
627 pn = 'typing-extensions'
628 pv = '4.8.0'
629 recipefile = os.path.join(temprecipe, 'python3-%s_%s.bb' % (pn, pv))
630 srcuri = 'https://files.pythonhosted.org/packages/1f/7a/8b94bb016069caa12fc9f587b28080ac33b4fbb8ca369b98bc0a4828543e/typing_extensions-%s.tar.gz' % pv
631 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
632 self.assertTrue(os.path.isfile(recipefile))
633 checkvars = {}
634 checkvars['SUMMARY'] = 'Backported and Experimental Type Hints for Python 3.8+'
635 checkvars['LICENSE'] = set(['PSF-2.0'])
636 checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=fcf6b249c2641540219a727f35d8d2c2'
637 checkvars['SRC_URI[sha256sum]'] = 'df8e4339e9cb77357558cbdbceca33c303714cf861d1eef15e1070055ae8b7ef'
638 inherits = ['python_flit_core', 'pypi']
639
640 self._test_recipe_contents(recipefile, checkvars, inherits)
641
642 def test_recipetool_create_python3_pep517_hatchling(self):
643 # This test require python 3.11 or above for the tomllib module or tomli module to be installed
644 needTomllib(self)
645
646 # Test creating python3 package from tarball (using hatchling class)
647 temprecipe = os.path.join(self.tempdir, 'recipe')
648 os.makedirs(temprecipe)
649 pn = 'jsonschema'
650 pv = '4.19.1'
651 recipefile = os.path.join(temprecipe, 'python3-%s_%s.bb' % (pn, pv))
652 srcuri = 'https://files.pythonhosted.org/packages/e4/43/087b24516db11722c8687e0caf0f66c7785c0b1c51b0ab951dfde924e3f5/jsonschema-%s.tar.gz' % pv
653 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
654 self.assertTrue(os.path.isfile(recipefile))
655 checkvars = {}
656 checkvars['SUMMARY'] = 'An implementation of JSON Schema validation for Python'
657 checkvars['HOMEPAGE'] = 'https://github.com/python-jsonschema/jsonschema'
658 checkvars['LICENSE'] = set(['MIT'])
659 checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING;md5=7a60a81c146ec25599a3e1dabb8610a8 file://json/LICENSE;md5=9d4de43111d33570c8fe49b4cb0e01af'
660 checkvars['SRC_URI[sha256sum]'] = 'ec84cc37cfa703ef7cd4928db24f9cb31428a5d0fa77747b8b51a847458e0bbf'
661 inherits = ['python_hatchling', 'pypi']
662
663 self._test_recipe_contents(recipefile, checkvars, inherits)
664
665 def test_recipetool_create_python3_pep517_maturin(self):
666 # This test require python 3.11 or above for the tomllib module or tomli module to be installed
667 needTomllib(self)
668
669 # Test creating python3 package from tarball (using maturin class)
670 temprecipe = os.path.join(self.tempdir, 'recipe')
671 os.makedirs(temprecipe)
672 pn = 'pydantic-core'
673 pv = '2.14.5'
674 recipefile = os.path.join(temprecipe, 'python3-%s_%s.bb' % (pn, pv))
675 srcuri = 'https://files.pythonhosted.org/packages/64/26/cffb93fe9c6b5a91c497f37fae14a4b073ecbc47fc36a9979c7aa888b245/pydantic_core-%s.tar.gz' % pv
676 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
677 self.assertTrue(os.path.isfile(recipefile))
678 checkvars = {}
679 checkvars['HOMEPAGE'] = 'https://github.com/pydantic/pydantic-core'
680 checkvars['LICENSE'] = set(['MIT'])
681 checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=ab599c188b4a314d2856b3a55030c75c'
682 checkvars['SRC_URI[sha256sum]'] = '6d30226dfc816dd0fdf120cae611dd2215117e4f9b124af8c60ab9093b6e8e71'
683 inherits = ['python_maturin', 'pypi']
684
685 self._test_recipe_contents(recipefile, checkvars, inherits)
686
687 def test_recipetool_create_python3_pep517_mesonpy(self):
688 # This test require python 3.11 or above for the tomllib module or tomli module to be installed
689 needTomllib(self)
690
691 # Test creating python3 package from tarball (using mesonpy class)
692 temprecipe = os.path.join(self.tempdir, 'recipe')
693 os.makedirs(temprecipe)
694 pn = 'siphash24'
695 pv = '1.4'
696 recipefile = os.path.join(temprecipe, 'python3-%s_%s.bb' % (pn, pv))
697 srcuri = 'https://files.pythonhosted.org/packages/c2/32/b934a70592f314afcfa86c7f7e388804a8061be65b822e2aa07e573b6477/%s-%s.tar.gz' % (pn, pv)
481 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri)) 698 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
482 self.assertTrue(os.path.isfile(recipefile)) 699 self.assertTrue(os.path.isfile(recipefile))
483 checkvars = {} 700 checkvars = {}
484 checkvars['LICENSE'] = set(['PSF', '&', 'BSD', 'GPL']) 701 checkvars['SRC_URI[sha256sum]'] = '7fd65e39b2a7c8c4ddc3a168a687f4610751b0ac2ebb518783c0cdfc30bec4a0'
485 checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING.txt;md5=35a23d42b615470583563132872c97d6' 702 inherits = ['python_mesonpy', 'pypi']
486 checkvars['SRC_URI'] = 'https://files.pythonhosted.org/packages/84/f4/5771e41fdf52aabebbadecc9381d11dea0fa34e4759b4071244fa094804c/docutils-${PV}.tar.gz' 703
487 checkvars['SRC_URI[md5sum]'] = 'c53768d63db3873b7d452833553469de'
488 checkvars['SRC_URI[sha256sum]'] = '51e64ef2ebfb29cae1faa133b3710143496eca21c530f3f71424d77687764274'
489 inherits = ['distutils3']
490 self._test_recipe_contents(recipefile, checkvars, inherits) 704 self._test_recipe_contents(recipefile, checkvars, inherits)
491 705
492 def test_recipetool_create_github_tarball(self): 706 def test_recipetool_create_github_tarball(self):
493 # Basic test to ensure github URL mangling doesn't apply to release tarballs 707 # Basic test to ensure github URL mangling doesn't apply to release tarballs.
708 # Deliberately use an older release of Meson at present so we don't need a toml parser.
494 temprecipe = os.path.join(self.tempdir, 'recipe') 709 temprecipe = os.path.join(self.tempdir, 'recipe')
495 os.makedirs(temprecipe) 710 os.makedirs(temprecipe)
496 pv = '0.32.0' 711 pv = '0.52.1'
497 recipefile = os.path.join(temprecipe, 'meson_%s.bb' % pv) 712 recipefile = os.path.join(temprecipe, 'python3-meson_%s.bb' % pv)
498 srcuri = 'https://github.com/mesonbuild/meson/releases/download/%s/meson-%s.tar.gz' % (pv, pv) 713 srcuri = 'https://github.com/mesonbuild/meson/releases/download/%s/meson-%s.tar.gz' % (pv, pv)
499 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri)) 714 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
500 self.assertTrue(os.path.isfile(recipefile)) 715 self.assertTrue(os.path.isfile(recipefile))
@@ -504,27 +719,302 @@ class RecipetoolTests(RecipetoolBase):
504 inherits = ['setuptools3'] 719 inherits = ['setuptools3']
505 self._test_recipe_contents(recipefile, checkvars, inherits) 720 self._test_recipe_contents(recipefile, checkvars, inherits)
506 721
507 def test_recipetool_create_git_http(self): 722 def _test_recipetool_create_git(self, srcuri, branch=None):
508 # Basic test to check http git URL mangling works 723 # Basic test to check http git URL mangling works
509 temprecipe = os.path.join(self.tempdir, 'recipe') 724 temprecipe = os.path.join(self.tempdir, 'recipe')
510 os.makedirs(temprecipe) 725 os.makedirs(temprecipe)
511 recipefile = os.path.join(temprecipe, 'matchbox-terminal_git.bb') 726 name = srcuri.split(';')[0].split('/')[-1]
512 srcuri = 'http://git.yoctoproject.org/git/matchbox-terminal' 727 recipefile = os.path.join(temprecipe, name + '_git.bb')
513 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri)) 728 options = ' -B %s' % branch if branch else ''
729 result = runCmd('recipetool create -o %s%s "%s"' % (temprecipe, options, srcuri))
514 self.assertTrue(os.path.isfile(recipefile)) 730 self.assertTrue(os.path.isfile(recipefile))
515 checkvars = {} 731 checkvars = {}
516 checkvars['LICENSE'] = set(['GPLv2']) 732 checkvars['SRC_URI'] = srcuri
517 checkvars['SRC_URI'] = 'git://git.yoctoproject.org/git/matchbox-terminal;protocol=http' 733 for scheme in ['http', 'https']:
518 inherits = ['pkgconfig', 'autotools'] 734 if srcuri.startswith(scheme + ":"):
735 checkvars['SRC_URI'] = 'git%s;protocol=%s' % (srcuri[len(scheme):], scheme)
736 if ';branch=' not in srcuri:
737 checkvars['SRC_URI'] += ';branch=' + (branch or 'master')
738 self._test_recipe_contents(recipefile, checkvars, [])
739
740 def test_recipetool_create_git_http(self):
741 self._test_recipetool_create_git('http://git.yoctoproject.org/git/matchbox-keyboard')
742
743 def test_recipetool_create_git_srcuri_master(self):
744 self._test_recipetool_create_git('git://git.yoctoproject.org/matchbox-keyboard;branch=master;protocol=https')
745
746 def test_recipetool_create_git_srcuri_branch(self):
747 self._test_recipetool_create_git('git://git.yoctoproject.org/matchbox-keyboard;branch=matchbox-keyboard-0-1;protocol=https')
748
749 def test_recipetool_create_git_srcbranch(self):
750 self._test_recipetool_create_git('git://git.yoctoproject.org/matchbox-keyboard;protocol=https', 'matchbox-keyboard-0-1')
751
752 def _go_urifiy(self, url, version, modulepath = None, pathmajor = None, subdir = None):
753 modulepath = ",path='%s'" % modulepath if len(modulepath) else ''
754 pathmajor = ",pathmajor='%s'" % pathmajor if len(pathmajor) else ''
755 subdir = ",subdir='%s'" % subdir if len(subdir) else ''
756 return "${@go_src_uri('%s','%s'%s%s%s)}" % (url, version, modulepath, pathmajor, subdir)
757
758 def test_recipetool_create_go(self):
759 # Basic test to check go recipe generation
760 temprecipe = os.path.join(self.tempdir, 'recipe')
761 os.makedirs(temprecipe)
762
763 recipefile = os.path.join(temprecipe, 'edgex-go_git.bb')
764 deps_require_file = os.path.join(temprecipe, 'edgex-go', 'edgex-go-modules.inc')
765 lics_require_file = os.path.join(temprecipe, 'edgex-go', 'edgex-go-licenses.inc')
766 modules_txt_file = os.path.join(temprecipe, 'edgex-go', 'modules.txt')
767
768 srcuri = 'https://github.com/edgexfoundry/edgex-go.git'
769 srcrev = "v3.0.0"
770 srcbranch = "main"
771
772 result = runCmd('recipetool create -o %s %s -S %s -B %s' % (temprecipe, srcuri, srcrev, srcbranch))
773
774 self.maxDiff = None
775 inherits = ['go-vendor']
776
777 checkvars = {}
778 checkvars['GO_IMPORT'] = "github.com/edgexfoundry/edgex-go"
779 checkvars['SRC_URI'] = {'git://${GO_IMPORT};destsuffix=git/src/${GO_IMPORT};nobranch=1;name=${BPN};protocol=https',
780 'file://modules.txt'}
781 checkvars['LIC_FILES_CHKSUM'] = {'file://src/${GO_IMPORT}/LICENSE;md5=8f8bc924cf73f6a32381e5fd4c58d603'}
782
783 self.assertTrue(os.path.isfile(recipefile))
519 self._test_recipe_contents(recipefile, checkvars, inherits) 784 self._test_recipe_contents(recipefile, checkvars, inherits)
520 785
786 checkvars = {}
787 checkvars['VENDORED_LIC_FILES_CHKSUM'] = set(
788 ['file://src/${GO_IMPORT}/vendor/github.com/Microsoft/go-winio/LICENSE;md5=69205ff73858f2c22b2ca135b557e8ef',
789 'file://src/${GO_IMPORT}/vendor/github.com/armon/go-metrics/LICENSE;md5=d2d77030c0183e3d1e66d26dc1f243be',
790 'file://src/${GO_IMPORT}/vendor/github.com/cenkalti/backoff/LICENSE;md5=1571d94433e3f3aa05267efd4dbea68b',
791 'file://src/${GO_IMPORT}/vendor/github.com/davecgh/go-spew/LICENSE;md5=c06795ed54b2a35ebeeb543cd3a73e56',
792 'file://src/${GO_IMPORT}/vendor/github.com/eclipse/paho.mqtt.golang/LICENSE;md5=dcdb33474b60c38efd27356d8f2edec7',
793 'file://src/${GO_IMPORT}/vendor/github.com/eclipse/paho.mqtt.golang/edl-v10;md5=3adfcc70f5aeb7a44f3f9b495aa1fbf3',
794 'file://src/${GO_IMPORT}/vendor/github.com/edgexfoundry/go-mod-bootstrap/v3/LICENSE;md5=0d6dae39976133b2851fba4c1e1275ff',
795 'file://src/${GO_IMPORT}/vendor/github.com/edgexfoundry/go-mod-configuration/v3/LICENSE;md5=0d6dae39976133b2851fba4c1e1275ff',
796 'file://src/${GO_IMPORT}/vendor/github.com/edgexfoundry/go-mod-core-contracts/v3/LICENSE;md5=0d6dae39976133b2851fba4c1e1275ff',
797 'file://src/${GO_IMPORT}/vendor/github.com/edgexfoundry/go-mod-messaging/v3/LICENSE;md5=0d6dae39976133b2851fba4c1e1275ff',
798 'file://src/${GO_IMPORT}/vendor/github.com/edgexfoundry/go-mod-registry/v3/LICENSE;md5=0d6dae39976133b2851fba4c1e1275ff',
799 'file://src/${GO_IMPORT}/vendor/github.com/edgexfoundry/go-mod-secrets/v3/LICENSE;md5=f9fa2f4f8e0ef8cc7b5dd150963eb457',
800 'file://src/${GO_IMPORT}/vendor/github.com/fatih/color/LICENSE.md;md5=316e6d590bdcde7993fb175662c0dd5a',
801 'file://src/${GO_IMPORT}/vendor/github.com/fxamacker/cbor/v2/LICENSE;md5=827f5a2fa861382d35a3943adf9ebb86',
802 'file://src/${GO_IMPORT}/vendor/github.com/go-jose/go-jose/v3/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57',
803 'file://src/${GO_IMPORT}/vendor/github.com/go-jose/go-jose/v3/json/LICENSE;md5=591778525c869cdde0ab5a1bf283cd81',
804 'file://src/${GO_IMPORT}/vendor/github.com/go-kit/log/LICENSE;md5=5b7c15ad5fffe2ff6e9d58a6c161f082',
805 'file://src/${GO_IMPORT}/vendor/github.com/go-logfmt/logfmt/LICENSE;md5=98e39517c38127f969de33057067091e',
806 'file://src/${GO_IMPORT}/vendor/github.com/go-playground/locales/LICENSE;md5=3ccbda375ee345400ad1da85ba522301',
807 'file://src/${GO_IMPORT}/vendor/github.com/go-playground/universal-translator/LICENSE;md5=2e2b21ef8f61057977d27c727c84bef1',
808 'file://src/${GO_IMPORT}/vendor/github.com/go-playground/validator/v10/LICENSE;md5=a718a0f318d76f7c5d510cbae84f0b60',
809 'file://src/${GO_IMPORT}/vendor/github.com/go-redis/redis/v7/LICENSE;md5=58103aa5ea1ee9b7a369c9c4a95ef9b5',
810 'file://src/${GO_IMPORT}/vendor/github.com/golang/protobuf/LICENSE;md5=939cce1ec101726fa754e698ac871622',
811 'file://src/${GO_IMPORT}/vendor/github.com/gomodule/redigo/LICENSE;md5=2ee41112a44fe7014dce33e26468ba93',
812 'file://src/${GO_IMPORT}/vendor/github.com/google/uuid/LICENSE;md5=88073b6dd8ec00fe09da59e0b6dfded1',
813 'file://src/${GO_IMPORT}/vendor/github.com/gorilla/mux/LICENSE;md5=33fa1116c45f9e8de714033f99edde13',
814 'file://src/${GO_IMPORT}/vendor/github.com/gorilla/websocket/LICENSE;md5=c007b54a1743d596f46b2748d9f8c044',
815 'file://src/${GO_IMPORT}/vendor/github.com/hashicorp/consul/api/LICENSE;md5=b8a277a612171b7526e9be072f405ef4',
816 'file://src/${GO_IMPORT}/vendor/github.com/hashicorp/errwrap/LICENSE;md5=b278a92d2c1509760384428817710378',
817 'file://src/${GO_IMPORT}/vendor/github.com/hashicorp/go-cleanhttp/LICENSE;md5=65d26fcc2f35ea6a181ac777e42db1ea',
818 'file://src/${GO_IMPORT}/vendor/github.com/hashicorp/go-hclog/LICENSE;md5=ec7f605b74b9ad03347d0a93a5cc7eb8',
819 'file://src/${GO_IMPORT}/vendor/github.com/hashicorp/go-immutable-radix/LICENSE;md5=65d26fcc2f35ea6a181ac777e42db1ea',
820 'file://src/${GO_IMPORT}/vendor/github.com/hashicorp/go-multierror/LICENSE;md5=d44fdeb607e2d2614db9464dbedd4094',
821 'file://src/${GO_IMPORT}/vendor/github.com/hashicorp/go-rootcerts/LICENSE;md5=65d26fcc2f35ea6a181ac777e42db1ea',
822 'file://src/${GO_IMPORT}/vendor/github.com/hashicorp/golang-lru/LICENSE;md5=f27a50d2e878867827842f2c60e30bfc',
823 'file://src/${GO_IMPORT}/vendor/github.com/hashicorp/serf/LICENSE;md5=b278a92d2c1509760384428817710378',
824 'file://src/${GO_IMPORT}/vendor/github.com/leodido/go-urn/LICENSE;md5=8f50db5538ec1148a9b3d14ed96c3418',
825 'file://src/${GO_IMPORT}/vendor/github.com/mattn/go-colorable/LICENSE;md5=24ce168f90aec2456a73de1839037245',
826 'file://src/${GO_IMPORT}/vendor/github.com/mattn/go-isatty/LICENSE;md5=f509beadd5a11227c27b5d2ad6c9f2c6',
827 'file://src/${GO_IMPORT}/vendor/github.com/mitchellh/consulstructure/LICENSE;md5=96ada10a9e51c98c4656f2cede08c673',
828 'file://src/${GO_IMPORT}/vendor/github.com/mitchellh/copystructure/LICENSE;md5=56da355a12d4821cda57b8f23ec34bc4',
829 'file://src/${GO_IMPORT}/vendor/github.com/mitchellh/go-homedir/LICENSE;md5=3f7765c3d4f58e1f84c4313cecf0f5bd',
830 'file://src/${GO_IMPORT}/vendor/github.com/mitchellh/mapstructure/LICENSE;md5=3f7765c3d4f58e1f84c4313cecf0f5bd',
831 'file://src/${GO_IMPORT}/vendor/github.com/mitchellh/reflectwalk/LICENSE;md5=3f7765c3d4f58e1f84c4313cecf0f5bd',
832 'file://src/${GO_IMPORT}/vendor/github.com/nats-io/nats.go/LICENSE;md5=86d3f3a95c324c9479bd8986968f4327',
833 'file://src/${GO_IMPORT}/vendor/github.com/nats-io/nkeys/LICENSE;md5=86d3f3a95c324c9479bd8986968f4327',
834 'file://src/${GO_IMPORT}/vendor/github.com/nats-io/nuid/LICENSE;md5=86d3f3a95c324c9479bd8986968f4327',
835 'file://src/${GO_IMPORT}/vendor/github.com/pmezard/go-difflib/LICENSE;md5=e9a2ebb8de779a07500ddecca806145e',
836 'file://src/${GO_IMPORT}/vendor/github.com/rcrowley/go-metrics/LICENSE;md5=1bdf5d819f50f141366dabce3be1460f',
837 'file://src/${GO_IMPORT}/vendor/github.com/spiffe/go-spiffe/v2/LICENSE;md5=86d3f3a95c324c9479bd8986968f4327',
838 'file://src/${GO_IMPORT}/vendor/github.com/stretchr/objx/LICENSE;md5=d023fd31d3ca39ec61eec65a91732735',
839 'file://src/${GO_IMPORT}/vendor/github.com/stretchr/testify/LICENSE;md5=188f01994659f3c0d310612333d2a26f',
840 'file://src/${GO_IMPORT}/vendor/github.com/x448/float16/LICENSE;md5=de8f8e025d57fe7ee0b67f30d571323b',
841 'file://src/${GO_IMPORT}/vendor/github.com/zeebo/errs/LICENSE;md5=84914ab36fc0eb48edbaa53e66e8d326',
842 'file://src/${GO_IMPORT}/vendor/golang.org/x/crypto/LICENSE;md5=5d4950ecb7b26d2c5e4e7b4e0dd74707',
843 'file://src/${GO_IMPORT}/vendor/golang.org/x/mod/LICENSE;md5=5d4950ecb7b26d2c5e4e7b4e0dd74707',
844 'file://src/${GO_IMPORT}/vendor/golang.org/x/net/LICENSE;md5=5d4950ecb7b26d2c5e4e7b4e0dd74707',
845 'file://src/${GO_IMPORT}/vendor/golang.org/x/sync/LICENSE;md5=5d4950ecb7b26d2c5e4e7b4e0dd74707',
846 'file://src/${GO_IMPORT}/vendor/golang.org/x/sys/LICENSE;md5=5d4950ecb7b26d2c5e4e7b4e0dd74707',
847 'file://src/${GO_IMPORT}/vendor/golang.org/x/text/LICENSE;md5=5d4950ecb7b26d2c5e4e7b4e0dd74707',
848 'file://src/${GO_IMPORT}/vendor/golang.org/x/tools/LICENSE;md5=5d4950ecb7b26d2c5e4e7b4e0dd74707',
849 'file://src/${GO_IMPORT}/vendor/google.golang.org/genproto/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57',
850 'file://src/${GO_IMPORT}/vendor/google.golang.org/grpc/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57',
851 'file://src/${GO_IMPORT}/vendor/google.golang.org/protobuf/LICENSE;md5=02d4002e9171d41a8fad93aa7faf3956',
852 'file://src/${GO_IMPORT}/vendor/gopkg.in/eapache/queue.v1/LICENSE;md5=1bfd4408d3de090ef6b908b0cc45a316',
853 'file://src/${GO_IMPORT}/vendor/gopkg.in/yaml.v3/LICENSE;md5=3c91c17266710e16afdbb2b6d15c761c'])
854
855 self.assertTrue(os.path.isfile(lics_require_file))
856 self._test_recipe_contents(lics_require_file, checkvars, [])
857
858 dependencies = \
859 [ ('github.com/eclipse/paho.mqtt.golang','v1.4.2', '', '', ''),
860 ('github.com/edgexfoundry/go-mod-bootstrap','v3.0.1','github.com/edgexfoundry/go-mod-bootstrap/v3','/v3', ''),
861 ('github.com/edgexfoundry/go-mod-configuration','v3.0.0','github.com/edgexfoundry/go-mod-configuration/v3','/v3', ''),
862 ('github.com/edgexfoundry/go-mod-core-contracts','v3.0.0','github.com/edgexfoundry/go-mod-core-contracts/v3','/v3', ''),
863 ('github.com/edgexfoundry/go-mod-messaging','v3.0.0','github.com/edgexfoundry/go-mod-messaging/v3','/v3', ''),
864 ('github.com/edgexfoundry/go-mod-secrets','v3.0.1','github.com/edgexfoundry/go-mod-secrets/v3','/v3', ''),
865 ('github.com/fxamacker/cbor','v2.4.0','github.com/fxamacker/cbor/v2','/v2', ''),
866 ('github.com/gomodule/redigo','v1.8.9', '', '', ''),
867 ('github.com/google/uuid','v1.3.0', '', '', ''),
868 ('github.com/gorilla/mux','v1.8.0', '', '', ''),
869 ('github.com/rcrowley/go-metrics','v0.0.0-20201227073835-cf1acfcdf475', '', '', ''),
870 ('github.com/spiffe/go-spiffe','v2.1.4','github.com/spiffe/go-spiffe/v2','/v2', ''),
871 ('github.com/stretchr/testify','v1.8.2', '', '', ''),
872 ('go.googlesource.com/crypto','v0.8.0','golang.org/x/crypto', '', ''),
873 ('gopkg.in/eapache/queue.v1','v1.1.0', '', '', ''),
874 ('gopkg.in/yaml.v3','v3.0.1', '', '', ''),
875 ('github.com/microsoft/go-winio','v0.6.0','github.com/Microsoft/go-winio', '', ''),
876 ('github.com/hashicorp/go-metrics','v0.3.10','github.com/armon/go-metrics', '', ''),
877 ('github.com/cenkalti/backoff','v2.2.1+incompatible', '', '', ''),
878 ('github.com/davecgh/go-spew','v1.1.1', '', '', ''),
879 ('github.com/edgexfoundry/go-mod-registry','v3.0.0','github.com/edgexfoundry/go-mod-registry/v3','/v3', ''),
880 ('github.com/fatih/color','v1.9.0', '', '', ''),
881 ('github.com/go-jose/go-jose','v3.0.0','github.com/go-jose/go-jose/v3','/v3', ''),
882 ('github.com/go-kit/log','v0.2.1', '', '', ''),
883 ('github.com/go-logfmt/logfmt','v0.5.1', '', '', ''),
884 ('github.com/go-playground/locales','v0.14.1', '', '', ''),
885 ('github.com/go-playground/universal-translator','v0.18.1', '', '', ''),
886 ('github.com/go-playground/validator','v10.13.0','github.com/go-playground/validator/v10','/v10', ''),
887 ('github.com/go-redis/redis','v7.3.0','github.com/go-redis/redis/v7','/v7', ''),
888 ('github.com/golang/protobuf','v1.5.2', '', '', ''),
889 ('github.com/gorilla/websocket','v1.4.2', '', '', ''),
890 ('github.com/hashicorp/consul','v1.20.0','github.com/hashicorp/consul/api', '', 'api'),
891 ('github.com/hashicorp/errwrap','v1.0.0', '', '', ''),
892 ('github.com/hashicorp/go-cleanhttp','v0.5.1', '', '', ''),
893 ('github.com/hashicorp/go-hclog','v0.14.1', '', '', ''),
894 ('github.com/hashicorp/go-immutable-radix','v1.3.0', '', '', ''),
895 ('github.com/hashicorp/go-multierror','v1.1.1', '', '', ''),
896 ('github.com/hashicorp/go-rootcerts','v1.0.2', '', '', ''),
897 ('github.com/hashicorp/golang-lru','v0.5.4', '', '', ''),
898 ('github.com/hashicorp/serf','v0.10.1', '', '', ''),
899 ('github.com/leodido/go-urn','v1.2.3', '', '', ''),
900 ('github.com/mattn/go-colorable','v0.1.12', '', '', ''),
901 ('github.com/mattn/go-isatty','v0.0.14', '', '', ''),
902 ('github.com/mitchellh/consulstructure','v0.0.0-20190329231841-56fdc4d2da54', '', '', ''),
903 ('github.com/mitchellh/copystructure','v1.2.0', '', '', ''),
904 ('github.com/mitchellh/go-homedir','v1.1.0', '', '', ''),
905 ('github.com/mitchellh/mapstructure','v1.5.0', '', '', ''),
906 ('github.com/mitchellh/reflectwalk','v1.0.2', '', '', ''),
907 ('github.com/nats-io/nats.go','v1.25.0', '', '', ''),
908 ('github.com/nats-io/nkeys','v0.4.4', '', '', ''),
909 ('github.com/nats-io/nuid','v1.0.1', '', '', ''),
910 ('github.com/pmezard/go-difflib','v1.0.0', '', '', ''),
911 ('github.com/stretchr/objx','v0.5.0', '', '', ''),
912 ('github.com/x448/float16','v0.8.4', '', '', ''),
913 ('github.com/zeebo/errs','v1.3.0', '', '', ''),
914 ('go.googlesource.com/mod','v0.8.0','golang.org/x/mod', '', ''),
915 ('go.googlesource.com/net','v0.9.0','golang.org/x/net', '', ''),
916 ('go.googlesource.com/sync','v0.1.0','golang.org/x/sync', '', ''),
917 ('go.googlesource.com/sys','v0.7.0','golang.org/x/sys', '', ''),
918 ('go.googlesource.com/text','v0.9.0','golang.org/x/text', '', ''),
919 ('go.googlesource.com/tools','v0.6.0','golang.org/x/tools', '', ''),
920 ('github.com/googleapis/go-genproto','v0.0.0-20230223222841-637eb2293923','google.golang.org/genproto', '', ''),
921 ('github.com/grpc/grpc-go','v1.53.0','google.golang.org/grpc', '', ''),
922 ('go.googlesource.com/protobuf','v1.28.1','google.golang.org/protobuf', '', ''),
923 ]
924
925 src_uri = set()
926 for d in dependencies:
927 src_uri.add(self._go_urifiy(*d))
928
929 checkvars = {}
930 checkvars['GO_DEPENDENCIES_SRC_URI'] = src_uri
931
932 self.assertTrue(os.path.isfile(deps_require_file))
933 self._test_recipe_contents(deps_require_file, checkvars, [])
934
935 def test_recipetool_create_go_replace_modules(self):
936 # Check handling of replaced modules
937 temprecipe = os.path.join(self.tempdir, 'recipe')
938 os.makedirs(temprecipe)
939
940 recipefile = os.path.join(temprecipe, 'openapi-generator_git.bb')
941 deps_require_file = os.path.join(temprecipe, 'openapi-generator', 'go-modules.inc')
942 lics_require_file = os.path.join(temprecipe, 'openapi-generator', 'go-licenses.inc')
943 modules_txt_file = os.path.join(temprecipe, 'openapi-generator', 'modules.txt')
944
945 srcuri = 'https://github.com/OpenAPITools/openapi-generator.git'
946 srcrev = "v7.2.0"
947 srcbranch = "master"
948 srcsubdir = "samples/openapi3/client/petstore/go"
949
950 result = runCmd('recipetool create -o %s %s -S %s -B %s --src-subdir %s' % (temprecipe, srcuri, srcrev, srcbranch, srcsubdir))
951
952 self.maxDiff = None
953 inherits = ['go-vendor']
954
955 checkvars = {}
956 checkvars['GO_IMPORT'] = "github.com/OpenAPITools/openapi-generator/samples/openapi3/client/petstore/go"
957 checkvars['SRC_URI'] = {'git://${GO_IMPORT};destsuffix=git/src/${GO_IMPORT};nobranch=1;name=${BPN};protocol=https',
958 'file://modules.txt'}
959
960 self.assertNotIn('Traceback', result.output)
961 self.assertIn('No license file was detected for the main module', result.output)
962 self.assertTrue(os.path.isfile(recipefile))
963 self._test_recipe_contents(recipefile, checkvars, inherits)
964
965 # make sure that dependencies don't mention local directory ./go-petstore
966 dependencies = \
967 [ ('github.com/stretchr/testify','v1.8.4', '', '', ''),
968 ('go.googlesource.com/oauth2','v0.10.0','golang.org/x/oauth2', '', ''),
969 ('github.com/davecgh/go-spew','v1.1.1', '', '', ''),
970 ('github.com/golang/protobuf','v1.5.3', '', '', ''),
971 ('github.com/kr/pretty','v0.3.0', '', '', ''),
972 ('github.com/pmezard/go-difflib','v1.0.0', '', '', ''),
973 ('github.com/rogpeppe/go-internal','v1.9.0', '', '', ''),
974 ('go.googlesource.com/net','v0.12.0','golang.org/x/net', '', ''),
975 ('github.com/golang/appengine','v1.6.7','google.golang.org/appengine', '', ''),
976 ('go.googlesource.com/protobuf','v1.31.0','google.golang.org/protobuf', '', ''),
977 ('gopkg.in/check.v1','v1.0.0-20201130134442-10cb98267c6c', '', '', ''),
978 ('gopkg.in/yaml.v3','v3.0.1', '', '', ''),
979 ]
980
981 src_uri = set()
982 for d in dependencies:
983 src_uri.add(self._go_urifiy(*d))
984
985 checkvars = {}
986 checkvars['GO_DEPENDENCIES_SRC_URI'] = src_uri
987
988 self.assertTrue(os.path.isfile(deps_require_file))
989 self._test_recipe_contents(deps_require_file, checkvars, [])
990
991class RecipetoolTests(RecipetoolBase):
992
993 @classmethod
994 def setUpClass(cls):
995 import sys
996
997 super(RecipetoolTests, cls).setUpClass()
998 bb_vars = get_bb_vars(['BBPATH'])
999 cls.bbpath = bb_vars['BBPATH']
1000 libpath = os.path.join(get_bb_var('COREBASE'), 'scripts', 'lib', 'recipetool')
1001 sys.path.insert(0, libpath)
1002
521 def _copy_file_with_cleanup(self, srcfile, basedstdir, *paths): 1003 def _copy_file_with_cleanup(self, srcfile, basedstdir, *paths):
522 dstdir = basedstdir 1004 dstdir = basedstdir
523 self.assertTrue(os.path.exists(dstdir)) 1005 self.assertTrue(os.path.exists(dstdir))
524 for p in paths: 1006 for p in paths:
525 dstdir = os.path.join(dstdir, p) 1007 dstdir = os.path.join(dstdir, p)
526 if not os.path.exists(dstdir): 1008 if not os.path.exists(dstdir):
527 os.makedirs(dstdir) 1009 try:
1010 os.makedirs(dstdir)
1011 except PermissionError:
1012 return False
1013 except OSError as e:
1014 if e.errno == errno.EROFS:
1015 return False
1016 else:
1017 raise e
528 if p == "lib": 1018 if p == "lib":
529 # Can race with other tests 1019 # Can race with other tests
530 self.add_command_to_tearDown('rmdir --ignore-fail-on-non-empty %s' % dstdir) 1020 self.add_command_to_tearDown('rmdir --ignore-fail-on-non-empty %s' % dstdir)
@@ -532,8 +1022,12 @@ class RecipetoolTests(RecipetoolBase):
532 self.track_for_cleanup(dstdir) 1022 self.track_for_cleanup(dstdir)
533 dstfile = os.path.join(dstdir, os.path.basename(srcfile)) 1023 dstfile = os.path.join(dstdir, os.path.basename(srcfile))
534 if srcfile != dstfile: 1024 if srcfile != dstfile:
535 shutil.copy(srcfile, dstfile) 1025 try:
1026 shutil.copy(srcfile, dstfile)
1027 except PermissionError:
1028 return False
536 self.track_for_cleanup(dstfile) 1029 self.track_for_cleanup(dstfile)
1030 return True
537 1031
538 def test_recipetool_load_plugin(self): 1032 def test_recipetool_load_plugin(self):
539 """Test that recipetool loads only the first found plugin in BBPATH.""" 1033 """Test that recipetool loads only the first found plugin in BBPATH."""
@@ -547,20 +1041,147 @@ class RecipetoolTests(RecipetoolBase):
547 plugincontent = fh.readlines() 1041 plugincontent = fh.readlines()
548 try: 1042 try:
549 self.assertIn('meta-selftest', srcfile, 'wrong bbpath plugin found') 1043 self.assertIn('meta-selftest', srcfile, 'wrong bbpath plugin found')
550 for path in searchpath: 1044 searchpath = [
551 self._copy_file_with_cleanup(srcfile, path, 'lib', 'recipetool') 1045 path for path in searchpath
1046 if self._copy_file_with_cleanup(srcfile, path, 'lib', 'recipetool')
1047 ]
552 result = runCmd("recipetool --quiet count") 1048 result = runCmd("recipetool --quiet count")
553 self.assertEqual(result.output, '1') 1049 self.assertEqual(result.output, '1')
554 result = runCmd("recipetool --quiet multiloaded") 1050 result = runCmd("recipetool --quiet multiloaded")
555 self.assertEqual(result.output, "no") 1051 self.assertEqual(result.output, "no")
556 for path in searchpath: 1052 for path in searchpath:
557 result = runCmd("recipetool --quiet bbdir") 1053 result = runCmd("recipetool --quiet bbdir")
558 self.assertEqual(result.output, path) 1054 self.assertEqual(os.path.realpath(result.output), os.path.realpath(path))
559 os.unlink(os.path.join(result.output, 'lib', 'recipetool', 'bbpath.py')) 1055 os.unlink(os.path.join(result.output, 'lib', 'recipetool', 'bbpath.py'))
560 finally: 1056 finally:
561 with open(srcfile, 'w') as fh: 1057 with open(srcfile, 'w') as fh:
562 fh.writelines(plugincontent) 1058 fh.writelines(plugincontent)
563 1059
1060 def test_recipetool_handle_license_vars(self):
1061 from create import handle_license_vars
1062 from unittest.mock import Mock
1063
1064 commonlicdir = get_bb_var('COMMON_LICENSE_DIR')
1065
1066 class DataConnectorCopy(bb.tinfoil.TinfoilDataStoreConnector):
1067 pass
1068
1069 d = DataConnectorCopy
1070 d.getVar = Mock(return_value=commonlicdir)
1071
1072 srctree = tempfile.mkdtemp(prefix='recipetoolqa')
1073 self.track_for_cleanup(srctree)
1074
1075 # Multiple licenses
1076 licenses = ['MIT', 'ISC', 'BSD-3-Clause', 'Apache-2.0']
1077 for licence in licenses:
1078 shutil.copy(os.path.join(commonlicdir, licence), os.path.join(srctree, 'LICENSE.' + licence))
1079 # Duplicate license
1080 shutil.copy(os.path.join(commonlicdir, 'MIT'), os.path.join(srctree, 'LICENSE'))
1081
1082 extravalues = {
1083 # Duplicate and missing licenses
1084 'LICENSE': 'Zlib & BSD-2-Clause & Zlib',
1085 'LIC_FILES_CHKSUM': [
1086 'file://README.md;md5=0123456789abcdef0123456789abcd'
1087 ]
1088 }
1089 lines_before = []
1090 handled = []
1091 licvalues = handle_license_vars(srctree, lines_before, handled, extravalues, d)
1092 expected_lines_before = [
1093 '# WARNING: the following LICENSE and LIC_FILES_CHKSUM values are best guesses - it is',
1094 '# your responsibility to verify that the values are complete and correct.',
1095 '# NOTE: Original package / source metadata indicates license is: BSD-2-Clause & Zlib',
1096 '#',
1097 '# NOTE: multiple licenses have been detected; they have been separated with &',
1098 '# in the LICENSE value for now since it is a reasonable assumption that all',
1099 '# of the licenses apply. If instead there is a choice between the multiple',
1100 '# licenses then you should change the value to separate the licenses with |',
1101 '# instead of &. If there is any doubt, check the accompanying documentation',
1102 '# to determine which situation is applicable.',
1103 'LICENSE = "Apache-2.0 & BSD-2-Clause & BSD-3-Clause & ISC & MIT & Zlib"',
1104 'LIC_FILES_CHKSUM = "file://LICENSE;md5=0835ade698e0bcf8506ecda2f7b4f302 \\\n'
1105 ' file://LICENSE.Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10 \\\n'
1106 ' file://LICENSE.BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9 \\\n'
1107 ' file://LICENSE.ISC;md5=f3b90e78ea0cffb20bf5cca7947a896d \\\n'
1108 ' file://LICENSE.MIT;md5=0835ade698e0bcf8506ecda2f7b4f302 \\\n'
1109 ' file://README.md;md5=0123456789abcdef0123456789abcd"',
1110 ''
1111 ]
1112 self.assertEqual(lines_before, expected_lines_before)
1113 expected_licvalues = [
1114 ('MIT', 'LICENSE', '0835ade698e0bcf8506ecda2f7b4f302'),
1115 ('Apache-2.0', 'LICENSE.Apache-2.0', '89aea4e17d99a7cacdbeed46a0096b10'),
1116 ('BSD-3-Clause', 'LICENSE.BSD-3-Clause', '550794465ba0ec5312d6919e203a55f9'),
1117 ('ISC', 'LICENSE.ISC', 'f3b90e78ea0cffb20bf5cca7947a896d'),
1118 ('MIT', 'LICENSE.MIT', '0835ade698e0bcf8506ecda2f7b4f302')
1119 ]
1120 self.assertEqual(handled, [('license', expected_licvalues)])
1121 self.assertEqual(extravalues, {})
1122 self.assertEqual(licvalues, expected_licvalues)
1123
1124
1125 def test_recipetool_split_pkg_licenses(self):
1126 from create import split_pkg_licenses
1127 licvalues = [
1128 # Duplicate licenses
1129 ('BSD-2-Clause', 'x/COPYING', None),
1130 ('BSD-2-Clause', 'x/LICENSE', None),
1131 # Multiple licenses
1132 ('MIT', 'x/a/LICENSE.MIT', None),
1133 ('ISC', 'x/a/LICENSE.ISC', None),
1134 # Alternative licenses
1135 ('(MIT | ISC)', 'x/b/LICENSE', None),
1136 # Alternative licenses without brackets
1137 ('MIT | BSD-2-Clause', 'x/c/LICENSE', None),
1138 # Multi licenses with alternatives
1139 ('MIT', 'x/d/COPYING', None),
1140 ('MIT | BSD-2-Clause', 'x/d/LICENSE', None),
1141 # Multi licenses with alternatives and brackets
1142 ('Apache-2.0 & ((MIT | ISC) & BSD-3-Clause)', 'x/e/LICENSE', None)
1143 ]
1144 packages = {
1145 '${PN}': '',
1146 'a': 'x/a',
1147 'b': 'x/b',
1148 'c': 'x/c',
1149 'd': 'x/d',
1150 'e': 'x/e',
1151 'f': 'x/f',
1152 'g': 'x/g',
1153 }
1154 fallback_licenses = {
1155 # Ignored
1156 'a': 'BSD-3-Clause',
1157 # Used
1158 'f': 'BSD-3-Clause'
1159 }
1160 outlines = []
1161 outlicenses = split_pkg_licenses(licvalues, packages, outlines, fallback_licenses)
1162 expected_outlicenses = {
1163 '${PN}': ['BSD-2-Clause'],
1164 'a': ['ISC', 'MIT'],
1165 'b': ['(ISC | MIT)'],
1166 'c': ['(BSD-2-Clause | MIT)'],
1167 'd': ['(BSD-2-Clause | MIT)', 'MIT'],
1168 'e': ['(ISC | MIT)', 'Apache-2.0', 'BSD-3-Clause'],
1169 'f': ['BSD-3-Clause'],
1170 'g': ['Unknown']
1171 }
1172 self.assertEqual(outlicenses, expected_outlicenses)
1173 expected_outlines = [
1174 'LICENSE:${PN} = "BSD-2-Clause"',
1175 'LICENSE:a = "ISC & MIT"',
1176 'LICENSE:b = "(ISC | MIT)"',
1177 'LICENSE:c = "(BSD-2-Clause | MIT)"',
1178 'LICENSE:d = "(BSD-2-Clause | MIT) & MIT"',
1179 'LICENSE:e = "(ISC | MIT) & Apache-2.0 & BSD-3-Clause"',
1180 'LICENSE:f = "BSD-3-Clause"',
1181 'LICENSE:g = "Unknown"'
1182 ]
1183 self.assertEqual(outlines, expected_outlines)
1184
564 1185
565class RecipetoolAppendsrcBase(RecipetoolBase): 1186class RecipetoolAppendsrcBase(RecipetoolBase):
566 def _try_recipetool_appendsrcfile(self, testrecipe, newfile, destfile, options, expectedlines, expectedfiles): 1187 def _try_recipetool_appendsrcfile(self, testrecipe, newfile, destfile, options, expectedlines, expectedfiles):
@@ -593,9 +1214,9 @@ class RecipetoolAppendsrcBase(RecipetoolBase):
593 for uri in src_uri: 1214 for uri in src_uri:
594 p = urllib.parse.urlparse(uri) 1215 p = urllib.parse.urlparse(uri)
595 if p.scheme == 'file': 1216 if p.scheme == 'file':
596 return p.netloc + p.path 1217 return p.netloc + p.path, uri
597 1218
598 def _test_appendsrcfile(self, testrecipe, filename=None, destdir=None, has_src_uri=True, srcdir=None, newfile=None, options=''): 1219 def _test_appendsrcfile(self, testrecipe, filename=None, destdir=None, has_src_uri=True, srcdir=None, newfile=None, remove=None, machine=None , options=''):
599 if newfile is None: 1220 if newfile is None:
600 newfile = self.testfile 1221 newfile = self.testfile
601 1222
@@ -620,14 +1241,42 @@ class RecipetoolAppendsrcBase(RecipetoolBase):
620 else: 1241 else:
621 destpath = '.' + os.sep 1242 destpath = '.' + os.sep
622 1243
623 expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', 1244 expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
624 '\n'] 1245 '\n']
1246
1247 override = ""
1248 if machine:
1249 options += ' -m %s' % machine
1250 override = ':append:%s' % machine
1251 expectedlines.extend(['PACKAGE_ARCH = "${MACHINE_ARCH}"\n',
1252 '\n'])
1253
1254 if remove:
1255 for entry in remove:
1256 if machine:
1257 entry_remove_line = 'SRC_URI:remove:%s = " %s"\n' % (machine, entry)
1258 else:
1259 entry_remove_line = 'SRC_URI:remove = "%s"\n' % entry
1260
1261 expectedlines.extend([entry_remove_line,
1262 '\n'])
1263
625 if has_src_uri: 1264 if has_src_uri:
626 uri = 'file://%s' % filename 1265 uri = 'file://%s' % filename
627 if expected_subdir: 1266 if expected_subdir:
628 uri += ';subdir=%s' % expected_subdir 1267 uri += ';subdir=%s' % expected_subdir
629 expectedlines[0:0] = ['SRC_URI += "%s"\n' % uri, 1268 if machine:
630 '\n'] 1269 src_uri_line = 'SRC_URI%s = " %s"\n' % (override, uri)
1270 else:
1271 src_uri_line = 'SRC_URI += "%s"\n' % uri
1272
1273 expectedlines.extend([src_uri_line, '\n'])
1274
1275 with open("/tmp/tmp.txt", "w") as file:
1276 print(expectedlines, file=file)
1277
1278 if machine:
1279 filename = '%s/%s' % (machine, filename)
631 1280
632 return self._try_recipetool_appendsrcfile(testrecipe, newfile, destpath, options, expectedlines, [filename]) 1281 return self._try_recipetool_appendsrcfile(testrecipe, newfile, destpath, options, expectedlines, [filename])
633 1282
@@ -682,18 +1331,46 @@ class RecipetoolAppendsrcTests(RecipetoolAppendsrcBase):
682 1331
683 def test_recipetool_appendsrcfile_existing_in_src_uri(self): 1332 def test_recipetool_appendsrcfile_existing_in_src_uri(self):
684 testrecipe = 'base-files' 1333 testrecipe = 'base-files'
685 filepath = self._get_first_file_uri(testrecipe) 1334 filepath,_ = self._get_first_file_uri(testrecipe)
686 self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe) 1335 self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe)
687 self._test_appendsrcfile(testrecipe, filepath, has_src_uri=False) 1336 self._test_appendsrcfile(testrecipe, filepath, has_src_uri=False)
688 1337
689 def test_recipetool_appendsrcfile_existing_in_src_uri_diff_params(self): 1338 def test_recipetool_appendsrcfile_existing_in_src_uri_diff_params(self, machine=None):
690 testrecipe = 'base-files' 1339 testrecipe = 'base-files'
691 subdir = 'tmp' 1340 subdir = 'tmp'
692 filepath = self._get_first_file_uri(testrecipe) 1341 filepath, srcuri_entry = self._get_first_file_uri(testrecipe)
693 self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe) 1342 self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe)
694 1343
695 output = self._test_appendsrcfile(testrecipe, filepath, subdir, has_src_uri=False) 1344 self._test_appendsrcfile(testrecipe, filepath, subdir, machine=machine, remove=[srcuri_entry])
696 self.assertTrue(any('with different parameters' in l for l in output)) 1345
1346 def test_recipetool_appendsrcfile_machine(self):
1347 # A very basic test
1348 self._test_appendsrcfile('base-files', 'a-file', machine='mymachine')
1349
1350 # Force cleaning the output of previous test
1351 self.tearDownLocal()
1352
1353 # A more complex test: existing entry in src_uri with different param
1354 self.test_recipetool_appendsrcfile_existing_in_src_uri_diff_params(machine='mymachine')
1355
1356 def test_recipetool_appendsrcfile_update_recipe_basic(self):
1357 testrecipe = "mtd-utils-selftest"
1358 recipefile = get_bb_var('FILE', testrecipe)
1359 self.assertIn('meta-selftest', recipefile, 'This test expect %s recipe to be in meta-selftest')
1360 cmd = 'recipetool appendsrcfile -W -u meta-selftest %s %s' % (testrecipe, self.testfile)
1361 result = runCmd(cmd)
1362 self.assertNotIn('Traceback', result.output)
1363 self.add_command_to_tearDown('cd %s; rm -f %s/%s; git checkout .' % (os.path.dirname(recipefile), testrecipe, os.path.basename(self.testfile)))
1364
1365 expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)),
1366 ('??', '.*/%s/%s$' % (testrecipe, os.path.basename(self.testfile)))]
1367 self._check_repo_status(os.path.dirname(recipefile), expected_status)
1368 result = runCmd('git diff %s' % os.path.basename(recipefile), cwd=os.path.dirname(recipefile))
1369 removelines = []
1370 addlines = [
1371 'file://%s \\\\' % os.path.basename(self.testfile),
1372 ]
1373 self._check_diff(result.output, addlines, removelines)
697 1374
698 def test_recipetool_appendsrcfile_replace_file_srcdir(self): 1375 def test_recipetool_appendsrcfile_replace_file_srcdir(self):
699 testrecipe = 'bash' 1376 testrecipe = 'bash'