Skip to content

Commit

Permalink
generage_sbom: remove introduced vendor-parameter
Browse files Browse the repository at this point in the history
Removed parameter again, introduced queryconfig function
for needed parameters only.
  • Loading branch information
cschneemann committed Mar 28, 2024
1 parent 6cb5b23 commit c2ab0c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 1 addition & 2 deletions build-recipe-livebuild
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,9 @@ recipe_build_livebuild() {
done

for format in $(queryconfig --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" --archpath "$BUILD_ARCH" buildflags+ sbom | sort -u) ; do
vendormacro=$(queryconfig --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" --archpath "$BUILD_ARCH" eval %vendor || "")
echo "Generating $format sbom file"
pushd $BUILD_ROOT/$TOPDIR/$LIVEBUILD_ROOT >/dev/null
generate_sbom --format "$format" --vendor "$vendormacro" --dir "chroot" > "$BUILD_ROOT/$TOPDIR/OTHER/${RECIPEFILE%.livebuild}${buildnum}.${format/cyclonedx/cdx}.json"
generate_sbom --format "$format" --dir "chroot" > "$BUILD_ROOT/$TOPDIR/OTHER/${RECIPEFILE%.livebuild}${buildnum}.${format/cyclonedx/cdx}.json"
popd >/dev/null
pushd $BUILD_ROOT/$TOPDIR/OTHER >/dev/null
/usr/bin/sha256sum "${RECIPEFILE%.livebuild}${buildnum}.${format/cyclonedx/cdx}.json" > "${RECIPEFILE%.livebuild}${buildnum}.${format/cyclonedx/cdx}.json".sh256
Expand Down
18 changes: 10 additions & 8 deletions generate_sbom
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use File::Temp;
use Digest::SHA;
use Digest::MD5;

use Build;
use Build::Rpm;
use Build::Deb;
use Build::SimpleJSON;
Expand Down Expand Up @@ -637,6 +638,14 @@ sub spdx_encode_header {
return $spdx;
}

sub queryconfig {
my ($type, $param) = @_;
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);
}
}

##################################################################################################


Expand All @@ -647,7 +656,7 @@ my $istar;
my $distro;
my $rpmmd;
my $format;
my $vendorstring = "";
my $vendorstring=queryconfig('eval','%vendor');

while (@ARGV && $ARGV[0] =~ /^-/) {
my $opt = shift @ARGV;
Expand All @@ -665,8 +674,6 @@ while (@ARGV && $ARGV[0] =~ /^-/) {
$istar = 1;
} elsif ($opt eq '--format') {
$format = shift @ARGV;
} elsif ($opt eq '--vendor') {
$vendorstring = shift @ARGV;
} elsif ($opt eq '--help') {
echo_help();
exit(0);
Expand Down Expand Up @@ -715,11 +722,6 @@ Supported content
--container-archive CONTAINER_ARCHIVE
An container providing a system
Optional parameters
===================
--vendor VENDOR
The vendor string to be set when deb packages are used.
";
}
die("usage: generate_sbom [--distro NAME] [--format spdx|cyclonedx] [--intoto] [--dir DIRECTORY]|[--product DIRECTORY]|[--rpmmd DIRECTORY]|[--container-archive CONTAINER_ARCHIVE]\n") unless @ARGV == 1;
Expand Down

0 comments on commit c2ab0c8

Please sign in to comment.