|
|
|
@ -37,6 +37,10 @@ create_empty_disk_image() {
|
|
|
|
|
create_manifest() {
|
|
|
|
|
local chroot_root=${1}
|
|
|
|
|
local target_file=${2}
|
|
|
|
|
local base_default_sbom_name="ubuntu-cloud-image-$(grep "VERSION_ID" $chroot_root/etc/os-release | cut --delimiter "=" --field 2 | tr -d '"')-${ARCH}-$(date +%Y%m%dT%H:%M:%S)"
|
|
|
|
|
local sbom_file_name=${3:-"${base_default_sbom_name}.spdx"}
|
|
|
|
|
local sbom_document_name=${4:-"${base_default_sbom_name}"}
|
|
|
|
|
local sbom_log=${sbom_document_name}.log
|
|
|
|
|
echo "create_manifest chroot_root: ${chroot_root}"
|
|
|
|
|
dpkg-query --show --admindir="${chroot_root}/var/lib/dpkg" > ${target_file}
|
|
|
|
|
echo "create_manifest call to dpkg-query finished."
|
|
|
|
@ -45,7 +49,23 @@ create_manifest() {
|
|
|
|
|
if [ "$PROJECT" = ubuntu-cpc ]; then
|
|
|
|
|
echo "create_manifest creating file listing."
|
|
|
|
|
local target_filelist=${2%.manifest}.filelist
|
|
|
|
|
(cd "${chroot_root}" && find -xdev) > "${target_filelist}"
|
|
|
|
|
(cd "${chroot_root}" && find -xdev) | sort > "${target_filelist}"
|
|
|
|
|
# only creating sboms for CPC project at this time
|
|
|
|
|
if [[ ! $(which cpc-sbom) ]]; then
|
|
|
|
|
# ensure the tool is installed
|
|
|
|
|
sudo snap install --classic --edge cpc-sbom
|
|
|
|
|
fi
|
|
|
|
|
# generate the SBOM
|
|
|
|
|
cpc-sbom --rootdir ${chroot_root} --ignore-copyright-parsing-errors --ignore-copyright-file-not-found-errors --document-name ${sbom_document_name} >"${sbom_file_name}" 2>"${sbom_log}"
|
|
|
|
|
SBOM_GENERATION_EXIT_CODE=$?
|
|
|
|
|
if [[ ${SBOM_GENERATION_EXIT_CODE} != "0" ]]; then
|
|
|
|
|
# check for failure and print log
|
|
|
|
|
echo "ERROR: SBOM generation failed. See ${sbom_log}"
|
|
|
|
|
cat "$sbom_log"
|
|
|
|
|
exit 1
|
|
|
|
|
else
|
|
|
|
|
echo "SBOM generation succeeded. see ${sbom_log} for details"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
echo "create_manifest finished"
|
|
|
|
|
}
|
|
|
|
|