Skip to content

Commit

Permalink
Set name for spdx in macro %mkosi_spdx_name
Browse files Browse the repository at this point in the history
The name for the spdx profile can be set using the macro
`%mkosi_spdx_name`  in the project configuration.
Default is `image` if not set.
  • Loading branch information
cschneemann committed May 24, 2024
1 parent 58ccc54 commit f1ff503
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions build-recipe-mkosi
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,29 @@ recipe_build_mkosi() {
cp -r "/.build/" "$TOPDIR/scripts"
chmod +x "$TOPDIR/scripts/.build/generate_sbom"
mkdir -p $BUILD_ROOT/$TOPDIR/SOURCES/mkosi.conf.d/99-sbom/
IMAGENAME=$(queryconfig --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" --archpath "$BUILD_ARCH" eval '%{?mkosi_sbom_name}' || "image")
IMAGENAME=${IMAGENAME:-image}
echo "IMAGENAME= $IMAGENAME"
echo "generating script for sbom $format"
cat << EOF >> $BUILD_ROOT/$TOPDIR/SOURCES/mkosi.conf.d/99-sbom/mkosi.finalize
#!/usr/bin/bash
# script generated by build-receipe-mkosi for sbom buildflags
echo "Generating $format sbom file"
imgname="image.${RELEASE}"
imgname="$IMAGENAME.${RELEASE}"
ln -sf \$BUILDROOT "$IMAGENAME"
export PERL5LIB="$TOPDIR/scripts/.build"
$TOPDIR/scripts/.build/generate_sbom \
--dist "$TOPDIR/scripts/$BUILD_DIST" \
--configdir "$TOPDIR/scripts/$CONFIG_DIR" \
--archpath "$BUILD_ARCH" \
--format "$format" \
--dir \$BUILDROOT > "\$OUTPUTDIR/\${imgname}${buildnum}.${format/cyclonedx/cdx}.json"
--dir "$IMAGENAME" > "\$OUTPUTDIR/\${imgname}${buildnum}.${format/cyclonedx/cdx}.json"
pushd \$OUTPUTDIR >/dev/null
/usr/bin/sha256sum "\${imgname}${buildnum}.${format/cyclonedx/cdx}.json" > "\${imgname}${buildnum}.${format/cyclonedx/cdx}.json".sh256
popd >/dev/null
EOF
chmod +x $BUILD_ROOT/$TOPDIR/SOURCES/mkosi.conf.d/99-sbom/mkosi.finalize
cat $BUILD_ROOT/$TOPDIR/SOURCES/mkosi.conf.d/99-sbom/mkosi.finalize
done

set -- mkosi \
Expand Down

0 comments on commit f1ff503

Please sign in to comment.