Skip to content

Commit d289cc8

Browse files
committed
chore: merge SBOM packages and remove old SBOM's
1 parent abdee51 commit d289cc8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

twoliter/embedded/rpm2img

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,19 @@ printf "%s\n" "${INVENTORY_DATA}" >"${ROOT_MOUNT}/usr/share/bottlerocket/applica
256256
# can access the inventory without needed to dig into the generated image.
257257
printf "%s\n" "${INVENTORY_DATA}" >"${OUTPUT_DIR}/application-inventory.json"
258258

259+
# Merge SBOM's into a single json file
260+
KIT_SBOMS_DIR="${ROOT_MOUNT}/usr/share/sboms"
261+
# Only process SBOMs if the directory exists.
262+
if [ -d "${KIT_SBOMS_DIR}" ]; then
263+
IMAGE_SBOM_DIR="${ROOT_MOUNT}/usr/share/bottlerocket/sbom"
264+
mkdir -p "${IMAGE_SBOM_DIR}"
265+
for format in "spdx" "cyclonedx"; do
266+
find "${KIT_SBOMS_DIR}" -name "*-${format}.json" -type f -exec sbomtool merge --output "${IMAGE_SBOM_DIR}/image-${format}.json" {} \+
267+
done
268+
# Clean up old SBOM packages
269+
rm -rf "${KIT_SBOMS_DIR}"
270+
fi
271+
259272
# Regenerate module dependencies, if possible.
260273
KMOD_DIR="${ROOT_MOUNT}/lib/modules"
261274
# First decompress the kernel modules, so they can be recompressed by EROFS.

0 commit comments

Comments
 (0)