fetch2: Add checksum capability for crate fetcher
PATCH v2 1/3 fetch2: Add checksum capability for crate fetcher
From: Frederic Martinsons <[email protected]>
This change brings checksum verification of each crate in a recipe, e.g
| SRC_URI += " \ | crate://crates.io/aho-corasick/0.7.20 \ | crate://crates.io/atomic-waker/1.1.0 \ | crate://crates.io/cc/1.0.79 \ | " | | SRC_URI[aho-corasick.sha256sum] = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" | SRC_URI[atomic-waker.sha256sum] = "debc29dde2e69f9e47506b525f639ed42300fc014a3e007832592448fa8e4599" | SRC_URI[cc.sha256sum] = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
That will require to move the checksum initialization after the possible call to urldata_init method in order for the crate fetcher to parse the url.
Another way of doing could have been implementing a decodeurl method that would have been specific for each fetcher class.
--- lib/bb/fetch2/__init__.py | 12 ++++++------ lib/bb/tests/fetch.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-)
lib/bb/fetch2/__init__.py +6 -6
@@ -1291,18 +1291,13 @@ class FetchData(object): if checksum_name in self.parm: checksum_expected = self.parm[checksum_name] - elif self.type not in ["http", "https", "ftp", "ftps", "sftp", "s3", "az"]: + elif self.type not in ["http", "https", "ftp", "ftps", "sftp", "s3", "az", "crate"]: checksum_expected = None else: checksum_expected = d.getVarFlag("SRC_URI", checksum_name) setattr(self, "%s_expected" % checksum_id, checksum_expected) - for checksum_id in CHECKSUM_LIST: - configure_checksum(checksum_id) - - self.ignore_checksums = False - self.names = self.parm.get("name",'default').split(',') self.method = None
@@ -1324,6 +1319,11 @@ class FetchData(object): if hasattr(self.method, "urldata_init"): self.method.urldata_init(self, d) + for checksum_id in CHECKSUM_LIST: + configure_checksum(checksum_id) + + self.ignore_checksums = False + if "localpath" in self.parm: # if user sets localpath for file, use it instead. self.localpath = self.parm["localpath"]
lib/bb/tests/fetch.py +32 -0
@@ -2377,6 +2377,13 @@ class CrateTest(FetcherTest): d = self.d fetcher = bb.fetch2.Fetch(uris, self.d) + ud = fetcher.ud[fetcher.urls[0]] + + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "glob") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"], "glob-0.2.11.crate") + fetcher.download() fetcher.unpack(self.tempdir) self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home', 'download' , 'unpacked'])
@@ -2394,6 +2401,19 @@ class CrateTest(FetcherTest): d = self.d fetcher = bb.fetch2.Fetch(uris, self.d) + ud = fetcher.ud[fetcher.urls[0]] + + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "glob") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"], "glob-0.2.11.crate") + + ud = fetcher.ud[fetcher.urls[1]] + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "time") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"], "time-0.1.35.crate") + fetcher.download() fetcher.unpack(self.tempdir) self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home', 'download' , 'unpacked'])
@@ -2403,6 +2423,18 @@ class CrateTest(FetcherTest): self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/.cargo-checksum.json")) self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/src/lib.rs")) + @skipIfNoNetwork() + def test_crate_incorrect_cksum(self): + uri = "crate://crates.io/aho-corasick/0.7.20" + self.d.setVar('SRC_URI', uri) + self.d.setVarFlag("SRC_URI", "aho-corasick.sha256sum", hashlib.sha256("Invalid".encode("utf-8")).hexdigest()) + + uris = self.d.getVar('SRC_URI').split() + + fetcher = bb.fetch2.Fetch(uris, self.d) + with self.assertRaisesRegexp(bb.fetch2.FetchError, "Fetcher failure for URL"): + fetcher.download() + class NPMTest(FetcherTest): def skipIfNoNpm(): import shutil
Signature · 1 line
2.34.1
PATCH v2 2/3 crate.py: make checksum verification mandatory
From: Frederic Martinsons <[email protected]>
--- lib/bb/fetch2/crate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/fetch2/crate.py +1 -1
@@ -33,7 +33,7 @@ class Crate(Wget): return ud.type in ['crate'] def recommends_checksum(self, urldata): - return False + return True def urldata_init(self, ud, d): """
Signature · 1 line
2.34.1
PATCH v2 3/3 crate.py: authorize crate url with parameters
In reply to [email protected]From: Frederic Martinsons <[email protected]>
This allow to have classic fetch parameters (like destsuffix, sha256, name ...) not being considered by crate fetcher itself (and so mess up its download)
Moreover, it allow to overload the name of the downloaded crate (maybe usefull if there is a naming clash between two crates coming from different repositories)
--- lib/bb/fetch2/crate.py | 9 ++++++--- lib/bb/tests/fetch.py | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-)
lib/bb/fetch2/crate.py +6 -3
@@ -56,8 +56,10 @@ class Crate(Wget): if len(parts) < 5: raise bb.fetch2.ParameterError("Invalid URL: Must be crate://HOST/NAME/VERSION", ud.url) - # last field is version - version = parts[len(parts) - 1] + # version is expected to be the last token + # but ignore possible url parameters which will be used + # by the top fetcher class + version, _, _ = parts[len(parts) -1].partition(";") # second to last field is name name = parts[len(parts) - 2] # host (this is to allow custom crate registries to be specified
@@ -69,7 +71,8 @@ class Crate(Wget): ud.url = "https://%s/%s/%s/download" % (host, name, version) ud.parm['downloadfilename'] = "%s-%s.crate" % (name, version) - ud.parm['name'] = name + if 'name' not in ud.parm: + ud.parm['name'] = name logger.debug2("Fetching %s to %s" % (ud.url, ud.parm['downloadfilename']))
lib/bb/tests/fetch.py +24 -0
@@ -2423,6 +2423,30 @@ class CrateTest(FetcherTest): self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/.cargo-checksum.json")) self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/src/lib.rs")) + @skipIfNoNetwork() + def test_crate_url_params(self): + + uri = "crate://crates.io/aho-corasick/0.7.20;name=aho-corasick-renamed" + self.d.setVar('SRC_URI', uri) + + uris = self.d.getVar('SRC_URI').split() + d = self.d + + fetcher = bb.fetch2.Fetch(uris, self.d) + ud = fetcher.ud[fetcher.urls[0]] + + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "aho-corasick-renamed") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"], "aho-corasick-0.7.20.crate") + + fetcher.download() + fetcher.unpack(self.tempdir) + self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home', 'download' , 'unpacked']) + self.assertEqual(sorted(os.listdir(self.tempdir + "/download")), ['aho-corasick-0.7.20.crate', 'aho-corasick-0.7.20.crate.done']) + self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/aho-corasick-0.7.20/.cargo-checksum.json")) + self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/aho-corasick-0.7.20/src/lib.rs")) + @skipIfNoNetwork() def test_crate_incorrect_cksum(self): uri = "crate://crates.io/aho-corasick/0.7.20"
Signature · 1 line
2.34.1
RE: [bitbake-devel][PATCH v2 3/3] crate.py: authorize crate url with parameters
Please cherry-pick this to Kirkstone and Langdale so that they can read updated recipes that use crate:// URIs with parameters.
I assume it should be ok to cherry-pick part one of this series too, as long as you do not cherry-pick part two, as it would be a breaking change.
//Peter
Quoted 88 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Frederic Martinsons
Sent: den 17 mars 2023 09:19
To: [email protected]
Cc: Frederic Martinsons <[email protected]>
Subject: [bitbake-devel][PATCH v2 3/3]crate.py: authorize crate url with parametersFrom: Frederic Martinsons <[email protected]>
This allow to have classic fetch parameters
(like destsuffix, sha256, name ...) not being
considered by crate fetcher itself (and so mess
up its download)Moreover, it allow to overload the name of the downloaded crate (maybe usefull if there is a naming clash between two crates coming from different repositories)
Signed-off-by Frederic Martinsons <[email protected]>--- lib/bb/fetch2/crate.py | 9 ++++++--- lib/bb/tests/fetch.py | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-)lib/bb/fetch2/crate.py +6
-3@@ -56,8 +56,10 @@ class Crate(Wget): if len(parts) < 5: raise bb.fetch2.ParameterError("Invalid URL: Must be crate://HOST/NAME/VERSION", ud.url) - # last field is version - version = parts[len(parts) - 1] + # version is expected to be the last token + # but ignore possible url parameters which will be used + # by the top fetcher class + version, _, _ = parts[len(parts) -1].partition(";") # second to last field is name name = parts[len(parts) - 2] # host (this is to allow custom crate registries to be specified@@ -69,7 +71,8 @@ class Crate(Wget): ud.url = "https://%s/%s/%s/download" % (host, name, version) ud.parm['downloadfilename'] = "%s-%s.crate" % (name, version) - ud.parm['name'] = name + if 'name' not in ud.parm: + ud.parm['name'] = name logger.debug2("Fetching %s to %s" % (ud.url, ud.parm['downloadfilename']))lib/bb/tests/fetch.py +24
-1@@ -2423,6 +2423,30 @@ class CrateTest(FetcherTest): self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/.cargo-checksum.json")) self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/src/lib.rs")) + @skipIfNoNetwork() + def test_crate_url_params(self): + + uri = "crate://crates.io/aho-corasick/0.7.20;name=aho-corasick-renamed" + self.d.setVar('SRC_URI', uri) + + uris = self.d.getVar('SRC_URI').split() + d = self.d + + fetcher = bb.fetch2.Fetch(uris, self.d) + ud = fetcher.ud[fetcher.urls[0]] + + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "aho-corasick-renamed") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"], "aho-corasick-0.7.20.crate") + + fetcher.download() + fetcher.unpack(self.tempdir) + self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home', 'download' , 'unpacked']) + self.assertEqual(sorted(os.listdir(self.tempdir + "/download")), ['aho-corasick-0.7.20.crate', 'aho-corasick-0.7.20.crate.done']) + self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/aho-corasick-0.7.20/.cargo-checksum.json")) + self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/aho-corasick-0.7.20/src/lib.rs")) + @skipIfNoNetwork() def test_crate_incorrect_cksum(self): uri = "crate://crates.io/aho-corasick/0.7.20" --2.34.1
Re: [bitbake-devel][PATCH v2 3/3] crate.py: authorize crate url with parameters
Quoted 5 lines · Peter Kjellerstedt
Please cherry-pick this to Kirkstone and Langdale so that they can read updated recipes that use crate:// URIs with parameters.
I assume it should be ok to cherry-pick part one of this series too, as long as you do not cherry-pick part two, as it would be a breaking change.
If we do this does this mean we're committing to forwards compatibility? I'm not sure I like that precedent...
Cheers,
Richard
RE: [bitbake-devel][PATCH v2 3/3] crate.py: authorize crate url with parameters
Quoted 14 lines
-----Original Message-----
From: Richard Purdie <[email protected]>
Sent: den 6 april 2023 10:43
To: Peter Kjellerstedt <[email protected]>; Steve Sakoman <[email protected]>
Cc: Frederic Martinsons <[email protected]>; bitbake- [email protected]
Subject: Re: [bitbake-devel][PATCH v2 3/3]crate.py: authorize crate url with parametersQuoted 3 lines · Peter Kjellerstedt
Please cherry-pick this to Kirkstone and Langdale so that they can read updated recipes that use crate:// URIs with parameters.
Quoted 6 lines
Quoted 2 lines
I assume it should be ok to cherry-pick part one of this series too, as long as you do not cherry-pick part two, as it would be a breaking
change.
If we do this does this mean we're committing to forwards compatibility? I'm not sure I like that precedent...
While not a requirement, I sure hope we can strive for forward compatibility where it does not impact the older branches negatively. At least in cases where it affects parsability or involves parts that are hard to override in a higher layer.
The problem for me in this case is that Mickledore now requires that all URIs have a checksum, which basically requires that parameters are used for the crate:// URIs since it is quite common that recipes depend on multiple versions of the same crate and thus requires the name= parameter. At the same time the crate fetcher in Kirkstone and Langdale will fail if any parameters are specified for the URIs. This means it is not possible to use the same version of the generated crates.inc files, which causes a lot of maintenance burden.
It is also very hard to modify the crate fetcher without actually modifying OE-Core. At least I find my Python-fu lacking in regards to how I can monkeypatch the fetcher to use a modified version of crate.py.
On the other, it is trivial for you to backport this patch to the two branches in OE-Core. And as long as the second patch in the series (which requires that checksums are used) is not backported, I cannot see that it should have any negative impact.
Quoted 4 lines
Cheers,
Richard
//Peter
Re: [bitbake-devel][PATCH v2 3/3] crate.py: authorize crate url with parameters
Quoted 18 lines · Peter Kjellerstedt
Quoted 18 lines
-----Original Message-----
From: Richard Purdie <[email protected]>
Sent: den 6 april 2023 10:43
To: Peter Kjellerstedt <[email protected]>; Steve Sakoman <[email protected]>
Cc: Frederic Martinsons <[email protected]>; bitbake- [email protected]
Subject: Re: [bitbake-devel][PATCH v2 3/3]crate.py: authorize crate url with parametersQuoted 5 lines · Peter Kjellerstedt
Please cherry-pick this to Kirkstone and Langdale so that they can read updated recipes that use crate:// URIs with parameters.
I assume it should be ok to cherry-pick part one of this series too, as long as you do not cherry-pick part two, as it would be a breaking
change.
Quoted 7 lines
Quoted 2 lines
If we do this does this mean we're committing to forwards compatibility? I'm not sure I like that precedent...
While not a requirement, I sure hope we can strive for forward compatibility where it does not impact the older branches negatively. At least in cases where it affects parsability or involves parts that are hard to override in a higher layer.
The trouble is I take this patch, then next time something breaks you tell me "in the past such changes were only made so that this didn't break things" and quote it as precedent.
I worry a lot about people relying upon us doing this as it isn't a guarantee we've ever made.
Quoted 8 lines
The problem for me in this case is that Mickledore now requires that all URIs have a checksum, which basically requires that parameters are used for the crate:// URIs since it is quite common that recipes depend on multiple versions of the same crate and thus requires the name= parameter. At the same time the crate fetcher in Kirkstone and Langdale will fail if any parameters are specified for the URIs. This means it is not possible to use the same version of the generated crates.inc files, which causes a lot of maintenance burden.
I understand the problem but you're effectively asking we would always do this going forward too :/.
Quoted 8 lines
It is also very hard to modify the crate fetcher without actually modifying OE-Core. At least I find my Python-fu lacking in regards to how I can monkeypatch the fetcher to use a modified version of
crate.py.On the other, it is trivial for you to backport this patch to the two branches in OE-Core. And as long as the second patch in the series (which requires that checksums are used) is not backported, I cannot see that it should have any negative impact.
This change alone is fine. The behaviour where people expect older layers to always work with newer code changes is what worries me, a lot. We have done things to make this happen before and I'm not sure it is good to continue the expectation.
Cheers,
Richard
Hello,
Should I verify something more for this series?
I understood that it is a useful development to have in bitbake fetcher (but will break things if series in oe-core and meta-oe are not applied after this one) and I'm wondering if something block the review / apply ?
Please tell me, I'll do all my best to secure this.
Have a good day.
Quoted 136 lines · Le ven. 17 mars 2023, 09:19, <[email protected]> a écrit :
From: Frederic Martinsons <[email protected]>
This change brings checksum verification of each crate in a recipe, e.g
| SRC_URI += " \ | crate://crates.io/aho-corasick/0.7.20 \ | crate://crates.io/atomic-waker/1.1.0 \ | crate://crates.io/cc/1.0.79 \ | " | | SRC_URI[aho-corasick.sha256sum] ="
cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" | SRC_URI[atomic-waker.sha256sum] = "debc29dde2e69f9e47506b525f639ed42300fc014a3e007832592448fa8e4599" | SRC_URI[cc.sha256sum] = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"That will require to move the checksum initialization after the possible call to
urldata_initmethod in order for the crate fetcher to parse the url.Another way of doing could have been implementing a decodeurl method that would have been specific for each fetcher class.
Signed-off-by Frederic Martinsons <[email protected]>--- lib/bb/fetch2/__init__.py | 12 ++++++------ lib/bb/tests/fetch.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-)lib/bb/fetch2/__init__.py +0
-1@@ -1291,18 +1291,13 @@ class FetchData(object): if checksum_name in self.parm: checksum_expected = self.parm[checksum_name] - elif self.type not in ["http", "https", "ftp", "ftps","sftp", "s3", "az"]:
+ elif self.type not in ["http", "https", "ftp", "ftps",
"sftp", "s3", "az", "crate"]:
checksum_expected= None
else:
checksum_expected=d.getVarFlag("SRC_URI", checksum_name)
setattr(self, "%s_expected" % checksum_id, checksum_expected)lib/bb/fetch2/__init__.py +5
-5- for checksum_id in CHECKSUM_LIST: - configure_checksum(checksum_id) - - self.ignore_checksums = False - self.names = self.parm.get("name",'default').split(',') self.method = None@@ -1324,6 +1319,11 @@ class FetchData(object): if hasattr(self.method, "urldata_init"): self.method.urldata_init(self, d) + for checksum_id in CHECKSUM_LIST: + configure_checksum(checksum_id) + + self.ignore_checksums = False + if "localpath" in self.parm: # if user sets localpath for file, use it instead. self.localpath = self.parm["localpath"]lib/bb/tests/fetch.py +7
-0@@ -2377,6 +2377,13 @@ class CrateTest(FetcherTest): d = self.d fetcher = bb.fetch2.Fetch(uris, self.d) + ud = fetcher.ud[fetcher.urls[0]] + + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "glob") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"], "glob-0.2.11.crate") + fetcher.download() fetcher.unpack(self.tempdir) self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home','download' , 'unpacked'])
lib/bb/tests/fetch.py +13
-0@@ -2394,6 +2401,19 @@ class CrateTest(FetcherTest): d = self.d fetcher = bb.fetch2.Fetch(uris, self.d) + ud = fetcher.ud[fetcher.urls[0]] + + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "glob") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"], "glob-0.2.11.crate") + + ud = fetcher.ud[fetcher.urls[1]] + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "time") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"], "time-0.1.35.crate") + fetcher.download() fetcher.unpack(self.tempdir) self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home','download' , 'unpacked'])
lib/bb/tests/fetch.py +10
-0@@ -2403,6 +2423,18 @@ class CrateTest(FetcherTest): self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/.cargo-checksum.json")) self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/src/lib.rs")) + @skipIfNoNetwork() + def test_crate_incorrect_cksum(self): + uri = "crate://crates.io/aho-corasick/0.7.20" + self.d.setVar('SRC_URI', uri) + self.d.setVarFlag("SRC_URI", "aho-corasick.sha256sum", hashlib.sha256("Invalid".encode("utf-8")).hexdigest()) + + uris = self.d.getVar('SRC_URI').split() + + fetcher = bb.fetch2.Fetch(uris, self.d) + with self.assertRaisesRegexp(bb.fetch2.FetchError, "Fetcherfailure for URL"):
lib/bb/tests/fetch.py +2
-1+ fetcher.download() + class NPMTest(FetcherTest): def skipIfNoNpm(): import shutil --2.34.1
If dependencies between bitbake and other layers is an issue, I can suppress the patch n2 of this
series to disable the verification of the checksum, and wait for all patches (bitbake, meta-oe and oe-core)
to be applied.
Finally, I would issue a new patch to make the checksum verification mandatory.
Quoted 153 lines · Frédéric Martinsons
Hello,
Should I verify something more for this series?
I understood that it is a useful development to have in bitbake fetcher (but will break things if series in oe-core and meta-oe are not applied after this one) and I'm wondering if something block the review / apply ?Please tell me, I'll do all my best to secure this.
Have a good day.
Quoted 140 lines · Le ven. 17 mars 2023, 09:19, <[email protected]> a écrit :
From: Frederic Martinsons <[email protected]>
This change brings checksum verification of each crate in a recipe, e.g
| SRC_URI += " \ | crate://crates.io/aho-corasick/0.7.20 \ | crate://crates.io/atomic-waker/1.1.0 \ | crate://crates.io/cc/1.0.79 \ | " | | SRC_URI[aho-corasick.sha256sum] ="
cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" | SRC_URI[atomic-waker.sha256sum] = "debc29dde2e69f9e47506b525f639ed42300fc014a3e007832592448fa8e4599" | SRC_URI[cc.sha256sum] = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"That will require to move the checksum initialization after the possible call to
urldata_initmethod in order for the crate fetcher to parse the url.Another way of doing could have been implementing a decodeurl method that would have been specific for each fetcher class.
Signed-off-by Frederic Martinsons <[email protected]>--- lib/bb/fetch2/__init__.py | 12 ++++++------ lib/bb/tests/fetch.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-)lib/bb/fetch2/__init__.py +0
-1@@ -1291,18 +1291,13 @@ class FetchData(object): if checksum_name in self.parm: checksum_expected = self.parm[checksum_name] - elif self.type not in ["http", "https", "ftp", "ftps","sftp", "s3", "az"]:
+ elif self.type not in ["http", "https", "ftp", "ftps",
"sftp", "s3", "az", "crate"]:
checksum_expected= None
else:
checksum_expected= d.getVarFlag("SRC_URI",checksum_name)
setattr(self, "%s_expected" % checksum_id, checksum_expected)lib/bb/fetch2/__init__.py +5
-5- for checksum_id in CHECKSUM_LIST: - configure_checksum(checksum_id) - - self.ignore_checksums = False - self.names = self.parm.get("name",'default').split(',') self.method = None@@ -1324,6 +1319,11 @@ class FetchData(object): if hasattr(self.method, "urldata_init"): self.method.urldata_init(self, d) + for checksum_id in CHECKSUM_LIST: + configure_checksum(checksum_id) + + self.ignore_checksums = False + if "localpath" in self.parm: # if user sets localpath for file, use it instead. self.localpath = self.parm["localpath"]lib/bb/tests/fetch.py +7
-0@@ -2377,6 +2377,13 @@ class CrateTest(FetcherTest): d = self.d fetcher = bb.fetch2.Fetch(uris, self.d) + ud = fetcher.ud[fetcher.urls[0]] + + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "glob") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"], "glob-0.2.11.crate") + fetcher.download() fetcher.unpack(self.tempdir)self.assertEqual(sorted(os.listdir(self.tempdir)),
['cargo_home', 'download' , 'unpacked'])lib/bb/tests/fetch.py +13
-0@@ -2394,6 +2401,19 @@ class CrateTest(FetcherTest): d = self.d fetcher = bb.fetch2.Fetch(uris, self.d) + ud = fetcher.ud[fetcher.urls[0]] + + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "glob") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"], "glob-0.2.11.crate") + + ud = fetcher.ud[fetcher.urls[1]] + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "time") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"], "time-0.1.35.crate") + fetcher.download()
fetcher.unpack(self.tempdir)self.assertEqual(sorted(os.listdir(self.tempdir)),
['cargo_home', 'download' , 'unpacked'])lib/bb/tests/fetch.py +10
-0@@ -2403,6 +2423,18 @@ class CrateTest(FetcherTest): self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/.cargo-checksum.json")) self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/src/lib.rs")) + @skipIfNoNetwork() + def test_crate_incorrect_cksum(self): + uri = "crate://crates.io/aho-corasick/0.7.20" + self.d.setVar('SRC_URI', uri) + self.d.setVarFlag("SRC_URI", "aho-corasick.sha256sum", hashlib.sha256("Invalid".encode("utf-8")).hexdigest()) + + uris = self.d.getVar('SRC_URI').split() + + fetcher = bb.fetch2.Fetch(uris, self.d) + with self.assertRaisesRegexp(bb.fetch2.FetchError, "Fetcherfailure for URL"):
lib/bb/tests/fetch.py +2
-1+ fetcher.download() + class NPMTest(FetcherTest): def skipIfNoNpm(): import shutil --2.34.1
I believe all the patches are now in abelloni's staging branch:
https://git.yoctoproject.org/poky-contrib/log/?h=abelloni/master-next
If they need a rework, or otherwise aren't suitable, you'll get feedback.
Note that we're in the feature freeze now; while this is a comparatively low risk change (in my view), it may have to wait until after mickledore's out.
Alex
Quoted 152 lines · Frederic Martinsons
If dependencies between bitbake and other layers is an issue, I can suppress the patch n2 of this series to disable the verification of the checksum, and wait for all patches (bitbake, meta-oe and oe-core) to be applied.
Finally, I would issue a new patch to make the checksum verification mandatory.Quoted 128 lines · Frédéric Martinsons
Hello,
Should I verify something more for this series?
I understood that it is a useful development to have in bitbake fetcher (but will break things if series in oe-core and meta-oe are not applied after this one) and I'm wondering if something block the review / apply ?Please tell me, I'll do all my best to secure this.
Have a good day.
Quoted 117 lines · Le ven. 17 mars 2023, 09:19, <[email protected]> a écrit :
From: Frederic Martinsons <[email protected]>
This change brings checksum verification of each crate in a recipe, e.g
| SRC_URI += " \ | crate://crates.io/aho-corasick/0.7.20 \ | crate://crates.io/atomic-waker/1.1.0 \ | crate://crates.io/cc/1.0.79 \ | " | | SRC_URI[aho-corasick.sha256sum] = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" | SRC_URI[atomic-waker.sha256sum] = "debc29dde2e69f9e47506b525f639ed42300fc014a3e007832592448fa8e4599" | SRC_URI[cc.sha256sum] = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"That will require to move the checksum initialization after the possible call to
urldata_initmethod in order for the crate fetcher to parse the url.Another way of doing could have been implementing a decodeurl method that would have been specific for each fetcher class.
Signed-off-by Frederic Martinsons <[email protected]>--- lib/bb/fetch2/__init__.py | 12 ++++++------ lib/bb/tests/fetch.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-)lib/bb/fetch2/__init__.py +6
-6@@ -1291,18 +1291,13 @@ class FetchData(object): if checksum_name in self.parm: checksum_expected = self.parm[checksum_name] - elif self.type not in ["http", "https", "ftp", "ftps", "sftp", "s3", "az"]: + elif self.type not in ["http", "https", "ftp", "ftps", "sftp", "s3", "az", "crate"]: checksum_expected = None else: checksum_expected = d.getVarFlag("SRC_URI", checksum_name) setattr(self, "%s_expected" % checksum_id, checksum_expected) - for checksum_id in CHECKSUM_LIST: - configure_checksum(checksum_id) - - self.ignore_checksums = False - self.names = self.parm.get("name",'default').split(',') self.method = None@@ -1324,6 +1319,11 @@ class FetchData(object): if hasattr(self.method, "urldata_init"): self.method.urldata_init(self, d) + for checksum_id in CHECKSUM_LIST: + configure_checksum(checksum_id) + + self.ignore_checksums = False + if "localpath" in self.parm: # if user sets localpath for file, use it instead. self.localpath = self.parm["localpath"]lib/bb/tests/fetch.py +30
-0@@ -2377,6 +2377,13 @@ class CrateTest(FetcherTest): d = self.d fetcher = bb.fetch2.Fetch(uris, self.d) + ud = fetcher.ud[fetcher.urls[0]] + + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "glob") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"], "glob-0.2.11.crate") + fetcher.download() fetcher.unpack(self.tempdir) self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home', 'download' , 'unpacked'])@@ -2394,6 +2401,19 @@ class CrateTest(FetcherTest): d = self.d fetcher = bb.fetch2.Fetch(uris, self.d) + ud = fetcher.ud[fetcher.urls[0]] + + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "glob") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"], "glob-0.2.11.crate") + + ud = fetcher.ud[fetcher.urls[1]] + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "time") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"], "time-0.1.35.crate") + fetcher.download() fetcher.unpack(self.tempdir) self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home', 'download' , 'unpacked'])@@ -2403,6 +2423,18 @@ class CrateTest(FetcherTest): self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/.cargo-checksum.json")) self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/src/lib.rs")) + @skipIfNoNetwork() + def test_crate_incorrect_cksum(self): + uri = "crate://crates.io/aho-corasick/0.7.20" + self.d.setVar('SRC_URI', uri) + self.d.setVarFlag("SRC_URI", "aho-corasick.sha256sum", hashlib.sha256("Invalid".encode("utf-8")).hexdigest()) + + uris = self.d.getVar('SRC_URI').split() + + fetcher = bb.fetch2.Fetch(uris, self.d) + with self.assertRaisesRegexp(bb.fetch2.FetchError, "Fetcher failure for URL"):Quoted 8 lines
Quoted 8 lines
lib/bb/tests/fetch.py +2
-1+ fetcher.download() + class NPMTest(FetcherTest): def skipIfNoNpm(): import shutil --2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#14609): https://lists.openembedded.org/g/bitbake-devel/message/14609
Mute This Topic: https://lists.openembedded.org/mt/97668729/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
I'm asking because I had a feedback from abelloni about the patch series to update
openembedded-core concerning a build failure (
https://lists.openembedded.org/g/bitbake-devel/topic/97648804#14600)
and I think there was a misunderstanding about the "applicability" of some of bitbake's patches that
was required to compile. And I don't know if I managed to clarify that (and if I understood well).
Anyway, I wasn't aware that there is a feature freeze now, I'll wait for feedback then.
Thanks Alex.
Le mar. 21 mars 2023, 19:35, Alexander Kanavin <[email protected]> a écrit :
Quoted 190 lines
I believe all the patches are now in abelloni's staging branch:
https://git.yoctoproject.org/poky-contrib/log/?h=abelloni/master-nextIf they need a rework, or otherwise aren't suitable, you'll get feedback.
Note that we're in the feature freeze now; while this is a comparatively low risk change (in my view), it may have to wait until after mickledore's out.
Alex
Quoted 2 lines · Frederic Martinsons
If dependencies between bitbake and other layers is an issue, I can
suppress the patch n2 of this
Quoted 1 line
series to disable the verification of the checksum, and wait for all
patches (bitbake, meta-oe and oe-core)
Quoted 2 lines
to be applied.
Finally, I would issue a new patch to make the checksum verificationmandatory.
Quoted 2 lines
On Tue, 21 Mar 2023 at 18:02, Frédéric Martinsons <
Quoted 5 lines · [email protected]> wrote:
Quoted 5 lines
Hello,
Should I verify something more for this series?
I understood that it is a useful development to have in bitbake fetcher(but will break things if series in oe-core and meta-oe are not applied after this one) and I'm wondering if something block the review / apply ?
Quoted 12 lines
Quoted 12 lines
Please tell me, I'll do all my best to secure this.
Have a good day.
Quoted 6 lines · Le ven. 17 mars 2023, 09:19, <[email protected]> a écrit :
From: Frederic Martinsons <[email protected]>
This change brings checksum verification of each crate in a recipe, e.g
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
| SRC_URI += " \ | crate://crates.io/aho-corasick/0.7.20 \ | crate://crates.io/atomic-waker/1.1.0 \ | crate://crates.io/cc/1.0.79 \ | " | | SRC_URI[aho-corasick.sha256sum] ="
cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"Quoted 1 line
Quoted 1 line
Quoted 1 line
| SRC_URI[atomic-waker.sha256sum] =
"
debc29dde2e69f9e47506b525f639ed42300fc014a3e007832592448fa8e4599"Quoted 1 line
Quoted 1 line
Quoted 1 line
| SRC_URI[cc.sha256sum] =
"
50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
That will require to move the checksum initialization after the possible call to
urldata_initmethod in order for the crate fetcher to parse the url.Another way of doing could have been implementing a decodeurl method that would have been specific for each fetcher class.
Signed-off-by Frederic Martinsons <[email protected]>--- lib/bb/fetch2/__init__.py | 12 ++++++------ lib/bb/tests/fetch.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-)lib/bb/fetch2/__init__.py +0
-0@@ -1291,18 +1291,13 @@ class FetchData(object):Quoted 3 lines
Quoted 3 lines
lib/bb/fetch2/__init__.py class FetchData(object):
Quoted 3 lines
lib/bb/fetch2/__init__.py +0
-1if checksum_name in self.parm: checksum_expected = self.parm[checksum_name] - elif self.type not in ["http", "https", "ftp", "ftps","sftp", "s3", "az"]:
Quoted 1 line
Quoted 1 line
lib/bb/fetch2/__init__.py class FetchData(object): · line 1294
Quoted 1 line
lib/bb/fetch2/__init__.py +1
-0+ elif self.type not in ["http", "https", "ftp", "ftps","sftp", "s3", "az", "crate"]:
Quoted 3 lines
Quoted 3 lines
lib/bb/fetch2/__init__.py class FetchData(object):
Quoted 3 lines
lib/bb/fetch2/__init__.py +0
-0checksum_expected = None else: checksum_expected = d.getVarFlag("SRC_URI",
checksum_name)Quoted 2 lines
Quoted 2 lines
lib/bb/fetch2/__init__.py class FetchData(object): · line 1298
Quoted 2 lines
lib/bb/fetch2/__init__.py +0
-0setattr(self, "%s_expected" % checksum_id,
checksum_expected)Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
lib/bb/fetch2/__init__.py +5
-5- for checksum_id in CHECKSUM_LIST: - configure_checksum(checksum_id) - - self.ignore_checksums = False - self.names = self.parm.get("name",'default').split(',') self.method = None@@ -1324,6 +1319,11 @@ class FetchData(object): if hasattr(self.method, "urldata_init"): self.method.urldata_init(self, d) + for checksum_id in CHECKSUM_LIST: + configure_checksum(checksum_id) + + self.ignore_checksums = False + if "localpath" in self.parm: # if user sets localpath for file, use it instead. self.localpath = self.parm["localpath"]lib/bb/tests/fetch.py +0
-0@@ -2377,6 +2377,13 @@ class CrateTest(FetcherTest): d = self.dQuoted 7 lines
Quoted 7 lines
lib/bb/tests/fetch.py class CrateTest(FetcherTest):
Quoted 7 lines
lib/bb/tests/fetch.py +6
-0fetcher = bb.fetch2.Fetch(uris, self.d) + ud = fetcher.ud[fetcher.urls[0]] + + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "glob") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"],"glob-0.2.11.crate")
Quoted 4 lines
Quoted 4 lines
lib/bb/tests/fetch.py class CrateTest(FetcherTest):
Quoted 4 lines
lib/bb/tests/fetch.py +1
-0+ fetcher.download() fetcher.unpack(self.tempdir) self.assertEqual(sorted(os.listdir(self.tempdir)),['
cargo_home', 'download' , 'unpacked'])Quoted 10 lines
Quoted 10 lines
lib/bb/tests/fetch.py class CrateTest(FetcherTest): · line 2409
Quoted 10 lines
lib/bb/tests/fetch.py +6
-0@@ -2394,6 +2401,19 @@ class CrateTest(FetcherTest): d = self.d fetcher = bb.fetch2.Fetch(uris, self.d) + ud = fetcher.ud[fetcher.urls[0]] + + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "glob") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"],"glob-0.2.11.crate")
Quoted 6 lines
Quoted 6 lines
lib/bb/tests/fetch.py class CrateTest(FetcherTest):
Quoted 6 lines
lib/bb/tests/fetch.py +6
-0+ + ud = fetcher.ud[fetcher.urls[1]] + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "time") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"],"time-0.1.35.crate")
Quoted 4 lines
Quoted 4 lines
lib/bb/tests/fetch.py class CrateTest(FetcherTest):
Quoted 4 lines
lib/bb/tests/fetch.py +1
-0+ fetcher.download() fetcher.unpack(self.tempdir) self.assertEqual(sorted(os.listdir(self.tempdir)),['
cargo_home', 'download' , 'unpacked'])Quoted 2 lines
Quoted 2 lines
lib/bb/tests/fetch.py class CrateTest(FetcherTest): · line 2423
Quoted 2 lines
lib/bb/tests/fetch.py +0
-0@@ -2403,6 +2423,18 @@ class CrateTest(FetcherTest): self.assertTrue(os.path.exists(self.tempdir +"/cargo_home/bitbake/time-0.1.35/.cargo-checksum.json"))
Quoted 1 line
Quoted 1 line
lib/bb/tests/fetch.py class CrateTest(FetcherTest): · line 2424
Quoted 1 line
lib/bb/tests/fetch.py +0
-0self.assertTrue(os.path.exists(self.tempdir +"/cargo_home/bitbake/time-0.1.35/src/lib.rs"))
Quoted 6 lines
Quoted 6 lines
lib/bb/tests/fetch.py class CrateTest(FetcherTest):
Quoted 6 lines
lib/bb/tests/fetch.py +5
-0+ @skipIfNoNetwork() + def test_crate_incorrect_cksum(self): + uri = "crate://crates.io/aho-corasick/0.7.20" + self.d.setVar('SRC_URI', uri) + self.d.setVarFlag("SRC_URI", "aho-corasick.sha256sum",hashlib.sha256("Invalid".encode("utf-8")).hexdigest())
Quoted 5 lines
Quoted 5 lines
lib/bb/tests/fetch.py class CrateTest(FetcherTest):
Quoted 5 lines
lib/bb/tests/fetch.py +5
-0+ + uris = self.d.getVar('SRC_URI').split() + + fetcher = bb.fetch2.Fetch(uris, self.d) + with self.assertRaisesRegexp(bb.fetch2.FetchError, "Fetcherfailure for URL"):
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
lib/bb/tests/fetch.py +2
-1+ fetcher.download() + class NPMTest(FetcherTest): def skipIfNoNpm(): import shutil --2.34.1
Quoted 3 lines
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#14609):https://lists.openembedded.org/g/bitbake-devel/message/14609
Quoted 3 lines
Mute This Topic: https://lists.openembedded.org/mt/97668729/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [Quoted 2 lines
-=-=-=-=-=-=-=-=-=-=-=-