Skip to contentSkip to conversation

utils/generate-cyclonedx: fix hash_file location

PATCH Applied Thomas Perale via buildroot 1 participant 3 messages Jun 1 – Jun 12

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 utils/generate-cyclonedx: fix hash_file location

The 'show-info' output always the location relative to the Buildroot root directory.
When running 'generate-cyclonedx' outside of the Buildroot root directory the hash file locations are not correct. Only using the 'hash_file' variable coming from 'show-info' doesn't guarantee the script to succeed.

Use the 'brpath' variable to correctly reference the absolute path.

Fixes 1791b79422 utils/generate-cyclonedx: add hashes from .hash files to externalReferences
---
 utils/generate-cyclonedx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/generate-cyclonedx +1 -1
index 11edc05d80..bade018cd4 100755
@@ -302,7 +302,7 @@ def cyclonedx_source_hashes(comp, source):
 
     hashes = []
     for hash_file in comp.get("hashes", []):
-        with Path(hash_file).open() as f:
+        with (brpath / hash_file).open() as f:
             for line in f:
                 line = line.strip()
                 if not line.startswith("#") and line.endswith(f" {source}"):
Signature · 6 lines
2.54.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 11 lines · Thomas Perale via buildroot

The 'show-info' output always the location relative to the Buildroot root directory.
When running 'generate-cyclonedx' outside of the Buildroot root directory the hash file locations are not correct. Only using the 'hash_file' variable coming from 'show-info' doesn't guarantee the script to succeed.

Use the 'brpath' variable to correctly reference the absolute path.

Fixes 1791b79422 utils/generate-cyclonedx: add hashes from .hash files to externalReferences

Applied to master, thanks.

Perhaps test_generate_cyclonedx can be updated to check out-of-tree calls?

Regards,
Arnout

Quoted 9 lines
---
  utils/generate-cyclonedx | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
utils/generate-cyclonedx +0 -0
index 11edc05d80..bade018cd4 100755

utils/generate-cyclonedx def cyclonedx_source_hashes(comp, source): · line 308

Quoted 8 lines
utils/generate-cyclonedx +1 -1
@@ -302,7 +302,7 @@ def cyclonedx_source_hashes(comp, source):
 
      hashes = []
      for hash_file in comp.get("hashes", []):
-        with Path(hash_file).open() as f:
+        with (brpath / hash_file).open() as f:
              for line in f:
                  line = line.strip()
                  if not line.startswith("#") and line.endswith(f" {source}"):

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw
In reply to Thomas Perale via buildroot

In reply of:

Quoted 11 lines

The 'show-info' output always the location relative to the Buildroot root directory.
When running 'generate-cyclonedx' outside of the Buildroot root directory the hash file locations are not correct. Only using the 'hash_file' variable coming from 'show-info' doesn't guarantee the script to succeed.

Use the 'brpath' variable to correctly reference the absolute path.

Fixes 1791b79422 utils/generate-cyclonedx: add hashes from .hash files to externalReferences

Applied to 2025.02.x & 2026.02.x. Thanks

Quoted 24 lines
---
 utils/generate-cyclonedx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/generate-cyclonedx +1 -1
index 11edc05d80..bade018cd4 100755
@@ -302,7 +302,7 @@ def cyclonedx_source_hashes(comp, source):
 
     hashes = []
     for hash_file in comp.get("hashes", []):
-        with Path(hash_file).open() as f:
+        with (brpath / hash_file).open() as f:
             for line in f:
                 line = line.strip()
                 if not line.startswith("#") and line.endswith(f" {source}"):
Signature · 6 lines
2.54.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot