Initial implementation of layoutlib SBOM generation.
1) Build/dist build.prop, resource files
2) Generate layoutlib SBOM that includes build.prop, resource files,
font files and font configuration files
3) Generate SBOM of framework_res.jar with placeholders for substitution
in release_layoutlib.sh
Bug: 303903787
Bug: 303904046
Bug: 303904808
Bug: 303905932
Bug: 303906000
Bug: 303906275
Test: lunch sdk_phone64_arm64-userdebug && m layoutlib dist
Change-Id: Ib004e199e740ccc901e93b11201db2477464be1d
diff --git a/tools/sbom/sbom_data.py b/tools/sbom/sbom_data.py
index 71f8660..b5ac8a5 100644
--- a/tools/sbom/sbom_data.py
+++ b/tools/sbom/sbom_data.py
@@ -138,3 +138,16 @@
h = hashlib.sha1()
h.update(''.join(checksums).encode(encoding='utf-8'))
package.verification_code = h.hexdigest()
+
+def encode_for_spdxid(s):
+ """Simple encode for string values used in SPDXID which uses the charset of A-Za-Z0-9.-"""
+ result = ''
+ for c in s:
+ if c.isalnum() or c in '.-':
+ result += c
+ elif c in '_@/':
+ result += '-'
+ else:
+ result += '0x' + c.encode('utf-8').hex()
+
+ return result.lstrip('-')
\ No newline at end of file