Skip to content

Commit

Permalink
Merge pull request #16204 from mlschroe/master
Browse files Browse the repository at this point in the history
[backend] Add "keepobsolete" publish flag
  • Loading branch information
mlschroe committed May 27, 2024
2 parents 2cc5565 + 48c1bb3 commit cb6027a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 18 deletions.
9 changes: 8 additions & 1 deletion src/backend/BSSched/Checker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,7 @@ sub publish {
my %pubenabled;
for my $packid (@$packs) {
my $pdata = $pdatas->{$packid};
$pubenabled{$packid} = 0;
next if defined($pdata->{'lock'}) && BSUtil::enabled($repoid, $pdata->{'lock'}, $locked, $myarch);
next if !defined($pdata->{'lock'}) && $locked;
if ($pdata->{'publish'}) {
Expand Down Expand Up @@ -1471,9 +1472,15 @@ sub publish {
return ('broken', "not publishing failed packages: @bad") if @bad;
}

# obey keepobsolete publish flag
my $keepobsolete;
if ($ctx->{'conf'}->{'publishflags:keepobsolete'} && !$pubenabled) {
$keepobsolete = 1;
}

# update :repo directory
mkdir_p($gdst);
my $publisherror = BSSched::PublishRepo::prpfinished($ctx, $packs, \%pubenabled, $force);
my $publisherror = BSSched::PublishRepo::prpfinished($ctx, $packs, \%pubenabled, $force, $keepobsolete);
if ($publisherror) {
return ('building', $publisherror) if $publisherror eq 'delta generation: building';
return ('delayed', substr($publisherror, 8)) if $publisherror eq 'delayed' || $publisherror =~ /^delayed:/;
Expand Down
51 changes: 34 additions & 17 deletions src/backend/BSSched/PublishRepo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,10 @@ sub wait_for_lock {
$packs - packages in project
undef -> arch no longer builds this repository
$pubenabled - only publish those packages
undef -> publish all packages
=cut

sub prpfinished {
my ($ctx, $packs, $pubenabled, $nodelayed) = @_;
my ($ctx, $packs, $pubenabled, $nodelayed, $keepobsolete) = @_;

my $gctx = $ctx->{'gctx'};
my $gdst = $ctx->{'gdst'};
Expand Down Expand Up @@ -161,6 +160,33 @@ sub prpfinished {
return "Testcase publish error";
}

die unless $pubenabled;

my $rinfo;
my $rinfo_packid2bins;

# read old repoinfo if we have packages that have publishing disabled
if ($keepobsolete || grep {!$pubenabled->{$_}} @$packs) {
$rinfo = {};
$rinfo = BSUtil::retrieve("${rdir}info") if -s "${rdir}info";
$rinfo->{'binaryorigins'} ||= {};
# create package->binaries helper hash
$rinfo_packid2bins = {};
my $rb = $rinfo->{'binaryorigins'};
for (keys %$rb) {
push @{$rinfo_packid2bins->{$rb->{$_}}}, $_;
}
}

# honor keepobsolete flag
if ($keepobsolete) {
$packs = [ @$packs ]; # so we can add packages
my %known = map {$_ => 1} @$packs;
my @obsolete = grep {!$known{$_}} sort keys %$rinfo_packid2bins;
push @$packs, @obsolete;
$keepobsolete = { map {$_ => 1} @obsolete };
}

# make all the deltas we need
my $needdeltas;
$needdeltas = 1 if grep {"$_:" =~ /:(?:deltainfo|prestodelta):/} @{$bconf->{'repotype'} || []};
Expand All @@ -173,9 +199,6 @@ sub prpfinished {
}


my $rinfo;
my $rinfo_packid2bins;

# link all packages into :repo, put origin data into :repoinfo
my %origin;
my $changed;
Expand Down Expand Up @@ -206,20 +229,14 @@ sub prpfinished {
my %newchecksums;
# sort like in the full tree
for my $packid (BSSched::ProjPacks::orderpackids($projpacks->{$projid}, @$packs)) {
if ($pubenabled && !$pubenabled->{$packid}) {
if (!$pubenabled->{$packid}) {
# publishing of this package is disabled, copy binary list from old info
if (!$rinfo) {
$rinfo = {};
$rinfo = BSUtil::retrieve("${rdir}info") if -s "${rdir}info";
$rinfo->{'binaryorigins'} ||= {};
# create package->binaries helper hash
$rinfo_packid2bins = {};
my $rb = $rinfo->{'binaryorigins'};
for (keys %$rb) {
push @{$rinfo_packid2bins->{$rb->{$_}}}, $_;
}
die unless $rinfo_packid2bins;
if ($keepobsolete && $keepobsolete->{$packid}) {
print " $packid: keeping obsolete\n";
} else {
print " $packid: publishing disabled\n";
}
print " $packid: publishing disabled\n";
for my $bin (@{$rinfo_packid2bins->{$packid} || []}) {
next if exists $origin{$bin}; # first one wins
$origin{$bin} = $packid;
Expand Down

0 comments on commit cb6027a

Please sign in to comment.