[PATCH] checksum: only split file-checksums entries at right-most colon
Rasmus Villemoes <[email protected]>
| Newsgroups | org.openembedded.lists.bitbake-devel |
|---|---|
| Message-ID | <[email protected]> |
While paths generally do not contain :, it is not forbidden. Even when
ordinary files do not contain : anywhere in the path, there is a
real-world example where the current code ends up emitting a false
warning:
meta-rauc's bundle.bbclass [*] expects the user to set RAUC_KEY_FILE
and RAUC_CERT_FILE to point at the key/certificate used for signing a
RAUC bundle. Since those files are not in SRC_URI but are used
directly in the do_bundle task, they set
do_bundle[file-checksums] += "${RAUC_CERT_FILE}:False ${RAUC_KEY_FILE}:False"
The :False is because they also allow these variables to be pkcs#11
uris. However, in that case, it will be something like
RAUC_KEY_FILE = "pkcs11:object=some-id"
and the file-checksums entry ends up being
"pkcs11:object=some-id:False". So the python code ends up seeing
"object=some-id" as the [1] entry in the split and "pkcs11" as the [0]
entry, and the whole thing ends up doing
WARNING: Unable to get checksum for system-bundle SRC_URI entry pkcs11: [Errno 2] No such file or directory: 'pkcs11'
The code really just wants the right-most, colon-delimited field, with
anything before being the path. So change to use .rsplit(":", 1)
instead. This should make no functional change for items that contain
exactly one :, and matches the change done in a70a7376a ("cache:
correctly handle file names containing colons").
[*] https://github.com/rauc/meta-rauc/blob/master/classes-recipe/bundle.bbclass
Signed-off-by: Rasmus Villemoes <[email protected]>
---
Note: I'm not really sure meta-rauc's use of [file-checksums] in this
way is correct; it seems that the flag should reflect whether the file
actually exists, not whether it is guaranteed to exist. But
regardless, this patch should be correct.
lib/bb/checksum.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/bb/checksum.py b/lib/bb/checksum.py
index 3fb39a303..9490199d4 100644
--- a/lib/bb/checksum.py
+++ b/lib/bb/checksum.py
@@ -118,10 +118,10 @@ class FileChecksumCache(MultiProcessCache):
pth = pth.strip()
if not pth:
continue
- exist = pth.split(":")[1]
+ exist = pth.rsplit(":", 1)[1]
if exist == "False":
continue
- pth = pth.split(":")[0]
+ pth = pth.rsplit(":", 1)[0]
if '*' in pth:
# Handle globs
for f in glob.glob(pth):
--
2.54.0