Copy SBOM files of unbundled APKs to dist directory.
Bug: 266726655
Test: CIs
Test: tapas Browser2 Calendar arm userdebug && m dist
Change-Id: I82328dc4916451a99ad0bf6d7bb945c9b98d0bea
diff --git a/tools/sbom/generate-sbom.py b/tools/sbom/generate-sbom.py
index 192061e..d2992c5 100755
--- a/tools/sbom/generate-sbom.py
+++ b/tools/sbom/generate-sbom.py
@@ -397,7 +397,7 @@
creators=['Organization: ' + args.product_mfr])
for installed_file_metadata in reader:
installed_file = installed_file_metadata['installed_file']
- if args.output_file != args.product_out_dir + installed_file + ".spdx":
+ if args.output_file != args.product_out_dir + installed_file + '.spdx.json':
continue
module_path = installed_file_metadata['module_path']
@@ -418,7 +418,10 @@
doc.created = datetime.datetime.now(tz=datetime.timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')
break
- with open(args.output_file, 'w', encoding="utf-8") as file:
+ with open(args.output_file, 'w', encoding='utf-8') as file:
+ sbom_writers.JSONWriter.write(doc, file)
+ fragment_file = args.output_file.removesuffix('.spdx.json') + '-fragment.spdx'
+ with open(fragment_file, 'w', encoding='utf-8') as file:
sbom_writers.TagValueWriter.write(doc, file, fragment=True)