Skip to content

Commit

Permalink
[backend] implement handling of containerinfo/obsbinlnk when copying …
Browse files Browse the repository at this point in the history
…builds

Those two files contain the package name and container name, so
we need to update if there are changes.
  • Loading branch information
mlschroe committed Feb 2, 2018
1 parent f1b01c8 commit c9b5a57
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/backend/bs_repserver
Original file line number Diff line number Diff line change
Expand Up @@ -2195,7 +2195,7 @@ sub copybuild {
$needsign = 1 if $bin =~ /\.(?:d?rpm|sha256|iso)$/;
my $nbin = $bin;
my $setrelease = $cgi->{'setrelease'};
# directories get stripped the build/release number by default
# 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
Expand All @@ -2209,6 +2209,26 @@ sub copybuild {
$renamed{$bin} = $nbin if $bin ne $nbin;
if (-d "$odir/$bin") {
$delayed_linking{"$dir/$nbin"} = "$odir/$bin";
} elsif ($bin =~ /\.containerinfo$/) {
# update file path in containerinfo
my $containerinfo = readstr("$odir/$bin");
my $from = $bin;
my $to = $nbin;
$from =~ s/\.containerinfo$//;
$to =~ s/\.containerinfo$//;
# the hacky way to change json
$containerinfo =~ s/(\"file\": [^\n]*)\Q$from\E/$1$to/s;
writestr("$dir/$nbin", undef, $containerinfo);
} elsif ($bin =~ /\.obsbinlnk$/) {
my $obsbinlnk = BSUtil::retrieve("$odir/$bin");
my $from = $bin;
my $to = $nbin;
$from =~ s/\.obsbinlnk$//;
$to =~ s/\.obsbinlnk$//;
$obsbinlnk->{'path'} =~ s/.*\///;
$obsbinlnk->{'path'} =~ s/\Q$from\E/$to/;
$obsbinlnk->{'path'} = "../$packid/$obsbinlnk->{'path'}";
BSUtil::store("$dir/$nbin", undef, $obsbinlnk);
} else {
# patch in new file name if we renamed files
if (%renamed && $bin =~ /\.sha256$/ && (((-s "$odir/$bin") || 0) <= 65536)) {
Expand Down

0 comments on commit c9b5a57

Please sign in to comment.