Skip to content

Commit

Permalink
generate_sbom: Buildflag to influence licenseDeclare
Browse files Browse the repository at this point in the history
by setting the BuildFlag spdx-declared-license to NOASSERTION (spdx-declared-license:NOASSERTION)
the corresponding spdx element for a package will be set to NOASSERTION instead of the
found license. Default is setting the element to a license if found.
  • Loading branch information
cschneemann committed Mar 28, 2024
1 parent c2ab0c8 commit 61d4b76
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions generate_sbom
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,11 @@ sub spdx_encode_pkg {
if ($license) {
$license =~ s/ and / AND /g;
$spdx->{'licenseConcluded'} = $license;
$spdx->{'licenseDeclared'} = $license;
if (queryconfig('buildflags', 'spdx-declared-license')eq "NOASSERTION") {
$spdx->{'licenseDeclared'} = 'NOASSERTION';
} else {
$spdx->{'licenseDeclared'} = $license;
}
}
$spdx->{'copyrightText'} = 'NOASSERTION';
my $copyrightText = $p->{'COPYRIGHTTEXT'};
Expand Down Expand Up @@ -639,10 +643,12 @@ sub spdx_encode_header {
}

sub queryconfig {
my ($type, $param) = @_;
my ($type, $argument) = @_;
my $cf = Build::read_config_dist($::ENV{'BUILD_DIST'}, $::ENV{'BUILD_ARCH'}, $::ENV{'CONFIG_DIR'});
if ($type eq 'eval') {
return Build::Rpm::expandmacros($cf, $param);
return Build::Rpm::expandmacros($cf, $argument) || "";
} elsif ($type eq 'buildflags') {
return $cf->{"buildflags:$argument"} || "";
}
}

Expand Down

0 comments on commit 61d4b76

Please sign in to comment.