Skip to contentSkip to conversation

Make the fetcher expand checksums

PATCH In review Peter Kjellerstedt 1 participant 3 messages Mar 8, 2016

lore
Share & tools
lore
#0 lore raw

cover Make the fetcher expand checksums

We needed a way to override the checksums for a recipe from a configuration file, e.g., local.conf. I first tried the naive:

    SRC_URI_pn-myrecipe[md5sum] = "123abc..."
    SRC_URI_pn-myrecipe[sha256sum] = "abcd1234..."

which of course did not work. Then I modified the recipe as:

    SRC_URI = "http://.../${PN}-${PV}.tar.gz"

    MD5SUM = "123abc..."
    SHA256SUM = "abcd1234..."

    SRC_URI[md5sum] = "${MD5SUM}"
    SRC_URI[sha256sum] = "${SHA256SUM}"

which I had assumed would work, but it did not. Finally I tried:

    MD5SUM = "123abc..."
    SHA256SUM = "abcd1234..."

    SRC_URI = "http://.../${PN}-${PV}.tar.gz;md5sum=${MD5SUM};sha256sum=${SHA256SUM}"

which actually did work.

Looking into why the second solution above did not work it turned out that the fetcher code called d.getVarFlag("SRC_URI", ..., False), i.e., without expanding the checksum values. I cannot see any reason not to expand the values, so the following patch does that.

//Peter

The following changes since commit 5ac3dc76a5afc2ed35b1abfc8e330e0c580eadf0:

image.bbclass: fix incomplete .rootfs customization (2016-03-07 22:10:54 +0000)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib pkj/expand_checksums
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=pkj/expand_checksums

Peter Kjellerstedt (1):
fetch2: Make SRC_URI[md5sum] and SRC_URI[sha256sum] expand their
values

 bitbake/lib/bb/fetch2/__init__.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/1 fetch2: Make SRC_URI[md5sum] and SRC_URI[sha256sum] expand their values

For some reason, the values for SRC_URI[md5sum] and SRC_URI[sha256sum] were not being expanded. That lead to the following code not working as expected:

SRC_URI = "http://.../${PN}-${PV}.tar.gz"

MD5SUM = "123abc..."
SHA256SUM = "abcd1234..."

SRC_URI[md5sum] = "${MD5SUM}"
SRC_URI[sha256sum] = "${SHA256SUM}"

---
 bitbake/lib/bb/fetch2/__init__.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
bitbake/lib/bb/fetch2/__init__.py +2 -2
index e8d3af7..f86014c 100644
@@ -1153,13 +1153,13 @@ class FetchData(object):
         elif self.type not in ["http", "https", "ftp", "ftps", "sftp"]:
             self.md5_expected = None
         else:
-            self.md5_expected = d.getVarFlag("SRC_URI", self.md5_name, False)
+            self.md5_expected = d.getVarFlag("SRC_URI", self.md5_name, True)
         if self.sha256_name in self.parm:
             self.sha256_expected = self.parm[self.sha256_name]
         elif self.type not in ["http", "https", "ftp", "ftps", "sftp"]:
             self.sha256_expected = None
         else:
-            self.sha256_expected = d.getVarFlag("SRC_URI", self.sha256_name, False)
+            self.sha256_expected = d.getVarFlag("SRC_URI", self.sha256_name, True)
         self.ignore_checksums = False
 
         self.names = self.parm.get("name",'default').split(',')
Signature · 1 line
2.1.0
#2 lore raw
In reply to Peter Kjellerstedt
Quoted 7 lines

-----Original Message-----
From: [email protected] [mailto:bitbake- [email protected]] On Behalf Of Peter Kjellerstedt
Sent: den 9 mars 2016 00:54
To: [email protected]
Subject: [bitbake-devel] [PATCH 0/1] Make the fetcher expand checksums

Quoted 7 lines

We needed a way to override the checksums for a recipe from a configuration file, e.g., local.conf. I first tried the naive:

    SRC_URI_pn-myrecipe[md5sum] = "123abc..."
    SRC_URI_pn-myrecipe[sha256sum] = "abcd1234..."

which of course did not work.

Btw, is there any way to do what I tried to do above, i.e., override variable flags from a configuration file? That would have been so much nicer than having to modify the recipe as I do below to be able to override the checksums.

Quoted 43 lines

Then I modified the recipe as:

    SRC_URI = "http://.../${PN}-${PV}.tar.gz"

    MD5SUM = "123abc..."
    SHA256SUM = "abcd1234..."

    SRC_URI[md5sum] = "${MD5SUM}"
    SRC_URI[sha256sum] = "${SHA256SUM}"

which I had assumed would work, but it did not. Finally I tried:

    MD5SUM = "123abc..."
    SHA256SUM = "abcd1234..."

    SRC_URI = "http://.../${PN}-

${PV}.tar.gz;md5sum=${MD5SUM};sha256sum=${SHA256SUM}"

which actually did work.

Looking into why the second solution above did not work it turned out that the fetcher code called d.getVarFlag("SRC_URI", ..., False), i.e., without expanding the checksum values. I cannot see any reason not to expand the values, so the following patch does that.

//Peter

The following changes since commit
5ac3dc76a5afc2ed35b1abfc8e330e0c580eadf0:

image.bbclass: fix incomplete .rootfs customization (2016-03-07
22:10:54 +0000)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib pkj/expand_checksums
http://git.yoctoproject.org/cgit.cgi/poky-
contrib/log/?h=pkj/expand_checksums

Peter Kjellerstedt (1):
fetch2: Make SRC_URI[md5sum] and SRC_URI[sha256sum] expand their
values

Quoted 5 lines
 bitbake/lib/bb/fetch2/__init__.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--
2.1.0

//Peter