mirror of
https://git.launchpad.net/livecd-rootfs
synced 2026-03-02 13:53:31 +00:00
Merge branch 'CPC-8952-make-sbom-optional' into ubuntu/master
This commit is contained in:
commit
2579dc30cb
@ -44,6 +44,7 @@ create_manifest() {
|
|||||||
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 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_file_name=${3:-"${base_default_sbom_name}.spdx"}
|
||||||
local sbom_document_name=${4:-"${base_default_sbom_name}"}
|
local sbom_document_name=${4:-"${base_default_sbom_name}"}
|
||||||
|
local should_include_sbom=${5:-"true"}
|
||||||
local sbom_log=${sbom_document_name}.log
|
local sbom_log=${sbom_document_name}.log
|
||||||
echo "create_manifest chroot_root: ${chroot_root}"
|
echo "create_manifest chroot_root: ${chroot_root}"
|
||||||
dpkg-query --show --admindir="${chroot_root}/var/lib/dpkg" > ${target_file}
|
dpkg-query --show --admindir="${chroot_root}/var/lib/dpkg" > ${target_file}
|
||||||
@ -54,21 +55,25 @@ create_manifest() {
|
|||||||
echo "create_manifest creating file listing."
|
echo "create_manifest creating file listing."
|
||||||
local target_filelist=${2%.manifest}.filelist
|
local target_filelist=${2%.manifest}.filelist
|
||||||
(cd "${chroot_root}" && find -xdev) | sort > "${target_filelist}"
|
(cd "${chroot_root}" && find -xdev) | sort > "${target_filelist}"
|
||||||
# only creating sboms for CPC project at this time
|
if [ "$should_include_sbom" = "true" ]; then
|
||||||
if [[ ! $(which cpc-sbom) ]]; then
|
# only creating sboms for CPC project at this time
|
||||||
# ensure the tool is installed
|
if [[ ! $(which cpc-sbom) ]]; then
|
||||||
sudo snap install --classic --edge cpc-sbom
|
# ensure the tool is installed
|
||||||
fi
|
sudo snap install --classic --edge cpc-sbom
|
||||||
# generate the SBOM
|
fi
|
||||||
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}"
|
# generate the SBOM
|
||||||
SBOM_GENERATION_EXIT_CODE=$?
|
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}"
|
||||||
if [[ ${SBOM_GENERATION_EXIT_CODE} != "0" ]]; then
|
SBOM_GENERATION_EXIT_CODE=$?
|
||||||
# check for failure and print log
|
if [[ ${SBOM_GENERATION_EXIT_CODE} != "0" ]]; then
|
||||||
echo "ERROR: SBOM generation failed. See ${sbom_log}"
|
# check for failure and print log
|
||||||
cat "$sbom_log"
|
echo "ERROR: SBOM generation failed. See ${sbom_log}"
|
||||||
exit 1
|
cat "$sbom_log"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "SBOM generation succeeded. see ${sbom_log} for details"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "SBOM generation succeeded. see ${sbom_log} for details"
|
echo "SBOM generation skipped"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo "create_manifest finished"
|
echo "create_manifest finished"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user