Skip to content

Conversation

@rpkelly
Copy link
Contributor

@rpkelly rpkelly commented Oct 16, 2025

Added macros so that a $PACKAGE-sbom sub package is always created unless an opt out is used. This package contains the spdx and cyclonedx sbom files generated by sbomtool.

Issue number:
#302

Description of changes:
Changes to macro files to ensure that each package generates an SBOM and stores it in a subpackage.

Testing done:
Built a core kit, kernel kit, and AMIs using this change

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

Added macros so that a $PACKAGE-sbom sub package is always created
unless an opt out is used. This package contains the spdx and cyclonedx
sbom files generated by sbomtool.

Signed-off-by: Richard Kelly <[email protected]>
%_cross_sbom_package_dir %{_cross_sbom_dir}/%{_uncross_name}

%cross_generate_sbom \
%cross_sbom_files %{_cross_sbom_package_dir}/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: might not be worth the extra macro for this.

Comment on lines +315 to +318
# Auto-inject SBOM subpackage - set flag then expand template
%install %{?_enable_sbom_packages:%{?buildsubdir:%{expand:%%global __sbom_package 1}%_sbom_template}}\
%%install\
%{nil}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like messing with %install like this. What does it actually do?

Comment on lines +380 to +383
# Post-build hook for SBOM generation
%__spec_build_post \
%{?__sbom_package:%cross_generate_sbom} \
%{___build_post}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to split this into two phases, instead of combining generate and install?

%{cross_sbom_files}\
%{nil}

%_enable_sbom_packages 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it's two ways to disable SBOM generation:

%undefine _enable_sbom_packages
%global __sbom_package %{nil}

I think it'd be more clear to do what debuginfo_package does, so there's only one "user-facing" macro to set:

# The duplicate __sbom_package definition is needed to ensure matching
# state when %install is skipped due to short-circuit, IFF buildsubdir
# is defined (indicating use of automatic debuginfo generation)
%sbom_package \
%global __sbom_package 1\
%{?buildsubdir:%%global __sbom_package 1}\
%_sbom_template\
%{nil}

At the spec level:

# turns off debug package
%global debug_package %{nil}

# turns off sbom package
%global sbom_package %{nil}

At the macro level (here):

%__arch_install_post \
...
%{?__sbom_package:%{__sbom_install_post}}\

%cross_generate_sbom() \
mkdir -p %{_builddir}/sbom-temp \
sbomtool generate --name %{name} --out-dir %{_builddir}/sbom-temp --build-dir %{_builddir} --spdx --cyclonedx
sbomtool generate --name %{?1:%{1}}%{!?1:%{name}} --out-dir %{_builddir}/sbom-temp --build-dir %{?2:%{2}}%{!?2:%{_builddir}} --spdx --cyclonedx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give some examples of %cross_generate_sbom invocations? The two argument form vs. no arguments?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants