summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2023-04-29 03:23:29 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-05-25 10:33:15 +0100
commit5b4c7dc600f33f784618c98330d075a38f944fb1 (patch)
tree6916dd507de95c011c967372257cefa133ac6e5d /bitbake/lib/bb
parentddc06f0a30eb4d512aa1c4b41e4a0dd8b9385d20 (diff)
downloadpoky-5b4c7dc600f33f784618c98330d075a38f944fb1.tar.gz
bitbake: fetch2/crate: Correct unpack for a crate that matches the recipe name
The crate fetcher handles a crate with a name that matches the recipe's name specially by placing the unpacked code in the current directory (which typically is ${S}) rather than together with the sources for the other crates. This broke when the URI names for all crates were changed recently to include the version in the name. Correct the crate fetcher to test against ${BP} instead of ${BPN}. Also add a test case to the selftests to avoid this breaking again. [Yocto #15012] (Bitbake rev: 9af52b748357d0c843ce2507ce4d119fd9c37008) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/fetch2/crate.py4
-rw-r--r--bitbake/lib/bb/tests/fetch.py25
2 files changed, 27 insertions, 2 deletions
diff --git a/bitbake/lib/bb/fetch2/crate.py b/bitbake/lib/bb/fetch2/crate.py
index 2b8b6bc7a1..3310ed0050 100644
--- a/bitbake/lib/bb/fetch2/crate.py
+++ b/bitbake/lib/bb/fetch2/crate.py
@@ -98,8 +98,8 @@ class Crate(Wget):
98 save_cwd = os.getcwd() 98 save_cwd = os.getcwd()
99 os.chdir(rootdir) 99 os.chdir(rootdir)
100 100
101 pn = d.getVar('BPN') 101 bp = d.getVar('BP')
102 if pn == ud.parm.get('name'): 102 if bp == ud.parm.get('name'):
103 cmd = "tar -xz --no-same-owner -f %s" % thefile 103 cmd = "tar -xz --no-same-owner -f %s" % thefile
104 else: 104 else:
105 cargo_bitbake = self._cargo_bitbake_path(rootdir) 105 cargo_bitbake = self._cargo_bitbake_path(rootdir)
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 532adb9414..256f0fb788 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -2392,6 +2392,31 @@ class CrateTest(FetcherTest):
2392 self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/glob-0.2.11/src/lib.rs")) 2392 self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/glob-0.2.11/src/lib.rs"))
2393 2393
2394 @skipIfNoNetwork() 2394 @skipIfNoNetwork()
2395 def test_crate_url_matching_recipe(self):
2396
2397 self.d.setVar('BP', 'glob-0.2.11')
2398
2399 uri = "crate://crates.io/glob/0.2.11"
2400 self.d.setVar('SRC_URI', uri)
2401
2402 uris = self.d.getVar('SRC_URI').split()
2403 d = self.d
2404
2405 fetcher = bb.fetch2.Fetch(uris, self.d)
2406 ud = fetcher.ud[fetcher.urls[0]]
2407
2408 self.assertIn("name", ud.parm)
2409 self.assertEqual(ud.parm["name"], "glob-0.2.11")
2410 self.assertIn("downloadfilename", ud.parm)
2411 self.assertEqual(ud.parm["downloadfilename"], "glob-0.2.11.crate")
2412
2413 fetcher.download()
2414 fetcher.unpack(self.tempdir)
2415 self.assertEqual(sorted(os.listdir(self.tempdir)), ['download', 'glob-0.2.11', 'unpacked'])
2416 self.assertEqual(sorted(os.listdir(self.tempdir + "/download")), ['glob-0.2.11.crate', 'glob-0.2.11.crate.done'])
2417 self.assertTrue(os.path.exists(self.tempdir + "/glob-0.2.11/src/lib.rs"))
2418
2419 @skipIfNoNetwork()
2395 def test_crate_url_params(self): 2420 def test_crate_url_params(self):
2396 2421
2397 uri = "crate://crates.io/aho-corasick/0.7.20;name=aho-corasick-renamed" 2422 uri = "crate://crates.io/aho-corasick/0.7.20;name=aho-corasick-renamed"