Skip to content

Commit

Permalink
Merge pull request #14962 from mlschroe/master
Browse files Browse the repository at this point in the history
[backend] bs_publish: also rename sbom files in slepool hack
  • Loading branch information
mlschroe committed Sep 25, 2023
2 parents b3e0670 + cfdb1c2 commit d32fce5
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 82 deletions.
2 changes: 1 addition & 1 deletion src/backend/BSPublisher/Container.pm
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ sub upload_all_containers {
for my $p (sort keys %$containers) {
my $containerinfo = $containers->{$p};
my $arch = $containerinfo->{'arch'};
my $goarch = $containerinfo->{'goarch'};
my $goarch = $containerinfo->{'goarch'} || (($containerinfo->{'type'} || '') eq 'helm' ? 'any' : $arch);
$goarch .= ":$containerinfo->{'govariant'}" if $containerinfo->{'govariant'};
$goarch .= "_$containerinfo->{'goos'}" if $containerinfo->{'goos'} && $containerinfo->{'goos'} ne 'linux';
my @tags = $mapper->($registry, $containerinfo, $projid, $repoid, $arch);
Expand Down
2 changes: 1 addition & 1 deletion src/backend/BSPublisher/Registry.pm
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ sub push_containers {
if (($containerinfo->{'type'} || '') eq 'helm') {
($tar, $mtime, $layer_compression) = BSContar::container_from_helm($containerinfo->{'uploadfile'}, $containerinfo->{'config_json'}, $containerinfo->{'tags'});
} else {
($tar, $mtime, $layer_compression) = BSContar::normalize_container($tarfd, 1);
($tar, $mtime, undef, undef, $layer_compression) = BSContar::normalize_container($tarfd, 1);
}
} else {
($tar, $mtime, $layer_compression) = BSPublisher::Containerinfo::construct_container_tar($containerinfo, 1);
Expand Down
111 changes: 56 additions & 55 deletions src/backend/BSXML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ our $modulemd = [
[],
'macros',
[[ 'dependencies' =>
[ 'buildrequires' ],
[ 'requires' ],
[ 'buildrequires' ],
[ 'requires' ],
]],
];

Expand Down Expand Up @@ -353,9 +353,9 @@ our $projpack = [
'originproject',
'revtime',
'constraintsmd5', # md5sum of constraints file in srcmd5
[ $linked ],
[ $linked ],
'error',
[ $packinfo ],
[ $packinfo ],
$aggregatelist,
$patchinfo,
'channelmd5',
Expand Down Expand Up @@ -687,14 +687,14 @@ our $jobstatus = [

our $buildreason = [
'reason' =>
[],
'explain', # Readable reason
'time', # unix time from start build
'oldsource', # last build source md5 sum, if a source change was the reason
[[ 'packagechange' => # list changed files which are used for building
'change', # kind of change (content/meta change, additional file or removed file)
'key', # file name
]],
[],
'explain', # Readable reason
'time', # unix time from start build
'oldsource', # last build source md5 sum, if a source change was the reason
[[ 'packagechange' => # list changed files which are used for building
'change', # kind of change (content/meta change, additional file or removed file)
'key', # file name
]],
];

our $buildstatus = [
Expand Down Expand Up @@ -757,10 +757,11 @@ our $event = [
'projectservicesmd5', # for type=servicedispatch
'oldsrcmd5', # for type=servicedispatch
'details', # for type=dispatchdetails
[[ 'included' => # for type=sourcepublish (optional)
'project',
'package',
'srcmd5' ]]
[[ 'included' => # for type=sourcepublish (optional)
'project',
'package',
'srcmd5',
]],
];

our $events = [
Expand Down Expand Up @@ -872,9 +873,9 @@ our $worker = [
'flavor'
],
[ 'hardware' =>
[ 'cpu' =>
[ 'flag' ],
],
[ 'cpu' =>
[ 'flag' ],
],
'processors',
'jobs',
'nativeonly', # don't allow usage via the helper script
Expand Down Expand Up @@ -1175,11 +1176,11 @@ our $pattern = [
'xmlns:rpm', # obsolete, moved to patterns
[],
'name',
'arch',
'arch',
[[ 'version' =>
'epoch',
'ver',
'rel',
'epoch',
'ver',
'rel',
]],
[[ 'summary' =>
'lang',
Expand Down Expand Up @@ -1286,7 +1287,7 @@ our $pattern_id = [
];

our $repoinfo_id = [
'repoinfo' =>
'repoinfo' =>
'project',
'repository',
'downloadurl',
Expand Down Expand Up @@ -1422,13 +1423,13 @@ our $request = [
'when',
[],
'comment',
[[ 'history' =>
'who',
'when',
[],
'comment',
'description',
]],
[[ 'history' =>
'who',
'when',
[],
'comment',
'description',
]],
]],
[[ 'history' =>
'name',
Expand Down Expand Up @@ -1505,42 +1506,42 @@ our $person = [
'email',
'realname',
[ 'owner' =>
'userid',
],
'userid',
],
'state',
[ 'globalrole' ],
'ignore_auth_services',
[ 'watchlist' =>
[[ 'project' =>
'name',
]],
[[ 'package' =>
'name',
'project'
]],
[[ 'request' =>
'number'
]],
[[ 'project' =>
'name',
]],
[[ 'package' =>
'name',
'project'
]],
[[ 'request' =>
'number'
]],
],
];

our $comps = [
'comps' =>
[[ 'group' =>
[],
'id',
[],
'id',
[[ 'description' =>
'xml:lang',
'_content',
'xml:lang',
'_content',
]],
[[ 'name' =>
'xml:lang',
'_content',
'xml:lang',
'_content',
]],
[ 'packagelist' =>
[[ 'packagereq' =>
'type',
'_content',
'type',
'_content',
]],
],
]],
Expand Down Expand Up @@ -1722,8 +1723,8 @@ our $configuration = [
[ 'schedulers' =>
[ 'arch' ],
],
'unlisted_projects_filter',
'unlisted_projects_filter_description'
'unlisted_projects_filter',
'unlisted_projects_filter_description'
];

our $issue_trackers = [
Expand Down Expand Up @@ -2054,8 +2055,8 @@ our $publishedpath = [

our $multibuild = [
'multibuild' =>
[ 'package' ], # obsolete
[ 'flavor' ],
[ 'package' ], # obsolete
[ 'flavor' ],
];

our $pubkeyinfo = [
Expand Down
55 changes: 34 additions & 21 deletions src/backend/bs_publish
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,33 @@ sub mapsleimage {
return $p;
}

# HACK: do fancy sle repo renaming
sub mapslepool {
my ($name, $rdir, $rbin, $bin) = @_;
$name ||= 'product';
my $sbom = '';
$sbom = $1 if $bin =~ s/(\.(?:cdx|spdx)\.json$)//;
my $p = $bin;
if ($name eq 'nobuildid') {
$p = "repo/$bin";
$p =~ s/-Build[\d\.]+-/-/;
} elsif ($bin =~ /.*-Media1?(\.license|)$/) {
$p = "$name$1";
} elsif ($bin =~ /-Media3$/) {
$p = "${name}_debug";
} elsif ($bin =~ /-Media2$/) {
my $rbin3 = $rbin;
$rbin3 =~ s/2$/3/;
if (-d "$rdir/$rbin3") {
$p = "${name}_source"; # 3 media available, 2 is source
} else {
$p = "${name}_debug"; # source is on media 1, 2 is debug
}
}
$p .= $sbom;
return $p;
}

sub depgp {
my ($content) = @_;
if ($content =~ /-----BEGIN PGP SIGNED MESSAGE-----\n/s) {
Expand Down Expand Up @@ -2386,9 +2413,13 @@ sub publish {
$p = $bin;
$kiwimedium = "$arch/$1" if !$2 && -e "$r/$1.packages";
$p = mapsleimage($sleimagedata, "$reporoot/$prp/$arch/:repo", $rbin, $p) if $sleimagedata;
} elsif ($bin =~ /\.(?:cdx|spdx).json$/) {
} elsif ($bin =~ /(.*)\.(?:cdx|spdx).json$/) {
next unless $config->{'publishflags:withsbom'};
$p = $bin;
$p = $bin;
if (-d "$r/$1") {
$p = "repo/$bin";
$p = mapslepool($repotype{'slepool'}->[0], $r, $rbin, $bin) if $repotype{'slepool'};
}
} elsif ($bin =~ /\.packages$/) {
# FIXME2.11: to be removed
next unless $config->{'publishflags:withreports'};
Expand All @@ -2413,25 +2444,7 @@ sub publish {
} elsif (-d "$r/$rbin") {
$p = "repo/$bin";
if ($repotype{'slepool'}) {
# HACK: do fancy sle repo renaming
my $name = $repotype{'slepool'}->[0] || 'product';
$p = $bin;
if ($name eq 'nobuildid') {
$p = "repo/$bin";
$p =~ s/-Build[\d\.]+-/-/;
} elsif ($bin =~ /.*-Media1?(\.license|)$/) {
$p = "$name$1";
} elsif ($bin =~ /-Media3$/) {
$p = "${name}_debug";
} elsif ($bin =~ /-Media2$/) {
my $rbin3 = $rbin;
$rbin3 =~ s/2$/3/;
if (-d "$r/$rbin3") {
$p = "${name}_source"; # 3 media available, 2 is source
} else {
$p = "${name}_debug"; # source is on media 1, 2 is debug
}
}
$p = mapslepool($repotype{'slepool'}->[0], $r, $rbin, $bin);
$p = $bin if $kiwimedium{"$arch/$p"}; # what???
}
$kiwimedium = "$arch/$bin";
Expand Down
8 changes: 4 additions & 4 deletions src/backend/bs_repserver
Original file line number Diff line number Diff line change
Expand Up @@ -2529,15 +2529,15 @@ sub copybuild {
# directories are stripped of the build/release number by default
if (!defined($setrelease)) {
$setrelease = '' if -d "$odir/$bin";
$setrelease = '' if $bin =~ /^(.*)\.report$/ && -d "$odir/$1"; # need to keep report in sync with dir
$setrelease = '' if $bin =~ /^(.*)\.milestone$/ && -d "$odir/$1"; # need to keep milestone as well
# need to keep associated files in sync with dir
$setrelease = '' if $bin =~ /^(.*)\.(?:report|milestone|cdx\.json|spdx\.json)$/ && -d "$odir/$1";
}
if (defined($oldsetrelease) && $oldsetrelease eq '-') {
# we use '-' as "released without setrelease" marker
undef $oldsetrelease;
$oldsetrelease = '' if -d "$odir/$bin";
$oldsetrelease = '' if $bin =~ /^(.*)\.report$/ && -d "$odir/$1"; # need to keep report in sync with dir
$oldsetrelease = '' if $bin =~ /^(.*)\.milestone$/ && -d "$odir/$1"; # need to keep milestone as well
# need to keep associated files in sync with dir
$oldsetrelease = '' if $bin =~ /^(.*)\.(?:report|milestone|cdx\.json|spdx\.json)$/ && -d "$odir/$1";
}
if (defined($setrelease)) {
$setrelease =~ s/^-?/-/; # "-" will drop the release tag
Expand Down

0 comments on commit d32fce5

Please sign in to comment.