Skip to content

Commit

Permalink
Merge pull request #10357 from mlschroe/master
Browse files Browse the repository at this point in the history
Do a simplified setup if all packages are locked
  • Loading branch information
adrianschroeter committed Oct 30, 2020
2 parents 8edff30 + 6832e30 commit 311cfdc
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 35 deletions.
44 changes: 32 additions & 12 deletions src/backend/BSSched/Checker.pm
Expand Up @@ -90,6 +90,7 @@ sub new {
'gdst' => "$gctx->{'reporoot'}/$prp/$myarch",
@conf
};
$ctx->{'alllocked'} = 1 if $gctx->{'alllocked'}->{$prp};
return bless $ctx, $class;
}

Expand Down Expand Up @@ -240,7 +241,6 @@ sub setup {
return (0, 'repo does not exist') unless $repo;

my $prpsearchpath = $gctx->{'prpsearchpath'}->{$prp};
return (0, 'no prpsearchpath?') unless $prpsearchpath;
$ctx->{'prpsearchpath'} = $prpsearchpath if $prpsearchpath;

if ($repo->{'status'} && $repo->{'status'} eq 'disabled') {
Expand All @@ -250,7 +250,16 @@ sub setup {
return ('blocked', join(', ', @$suspend)) if $suspend;
$ctx->{'repo'} = $repo;

if ($ctx->{'alllocked'}) {
# shortcut, do simplified setup
$ctx->{'conf'} = {};
my $pdatas = $proj->{'package'} || {};
$ctx->{'packs'} = [ sort keys %$pdatas ];
return ('scheduling', undef);
}

# set config
return (0, 'no prpsearchpath?') unless $prpsearchpath;
my $bconf = BSSched::ProjPacks::getconfig($gctx, $projid, $repoid, $myarch, $prpsearchpath);
if (!$bconf) {
# see if it is caused by a remote error
Expand Down Expand Up @@ -349,6 +358,7 @@ sub wipeobsolete {
my $projpacks = $gctx->{'projpacks'};
my $proj = $projpacks->{$projid};
my $myarch = $gctx->{'arch'};
return if $ctx->{'alllocked'}; # must not wipe anything
my $linkedbuild = $ctx->{'repo'}->{'linkedbuild'};
my $pdatas = $proj->{'package'} || {};
my $dstcache = { 'fullcache' => {}, 'bininfocache' => {} };
Expand Down Expand Up @@ -412,6 +422,7 @@ sub preparepool {
my $bconf = $ctx->{'conf'};
my $prp = $ctx->{'prp'};

return ('scheduling', undef) if $ctx->{'alllocked'}; # we do not need a pool
my $pool = BSSolv::pool->new();
$pool->settype('deb') if $bconf->{'binarytype'} eq 'deb';
$pool->settype('arch') if $bconf->{'binarytype'} eq 'arch';
Expand Down Expand Up @@ -515,6 +526,10 @@ sub expandandsort {
my $repoid = $ctx->{'repository'};
my $bconf = $ctx->{'conf'};
my $repo = $ctx->{'repo'};
my $prp = $ctx->{'prp'};

return ('scheduling', undef) if $ctx->{'alllocked'}; # all deps are empty

if ($bconf->{'expandflags:preinstallexpand'}) {
if ($gctx->{'arch'} ne 'local' || !defined($BSConfig::localarch)) {
return ('broken', 'Build::expandpreinstalls does not exist') unless defined &Build::expandpreinstalls;
Expand Down Expand Up @@ -887,6 +902,17 @@ sub checkpkgs {
}
}

# check if this package is project link excluded
if (exists($pdata->{'originproject'}) && (!$pdata->{'error'} || $pdata->{'error'} eq 'disabled')) {
# this is a package from a project link
my $repo = $ctx->{'repo'};
if (!$repo->{'linkedbuild'} || ($repo->{'linkedbuild'} ne 'localdep' && $repo->{'linkedbuild'} ne 'all')) {
$packstatus{$packid} = 'excluded';
$packerror{$packid} = 'project link';
next;
}
}

# check if this package is broken
if ($pdata->{'error'}) {
if ($pdata->{'error'} eq 'disabled' || $pdata->{'error'} eq 'locked' || $pdata->{'error'} eq 'excluded') {
Expand Down Expand Up @@ -916,17 +942,6 @@ sub checkpkgs {
next;
}

# check if this package is project link excluded
if (exists($pdata->{'originproject'})) {
# this is a package from a project link
my $repo = $ctx->{'repo'};
if (!$repo->{'linkedbuild'} || ($repo->{'linkedbuild'} ne 'localdep' && $repo->{'linkedbuild'} ne 'all')) {
$packstatus{$packid} = 'excluded';
$packerror{$packid} = 'project link';
next;
}
}

# check if this package is build disabled
if ($pdata->{'build'}) {
if (!BSUtil::enabled($repoid, $pdata->{'build'}, $projbuildenabled, $myarch)) {
Expand Down Expand Up @@ -1125,6 +1140,11 @@ sub publish {
my $repoid = $ctx->{'repository'};
my $unfinished = $ctx->{'unfinished'};

if ($ctx->{'alllocked'}) {
print " publishing is locked\n";
return ('done', undef);
}

my $myarch = $gctx->{'arch'};
my $projpacks = $gctx->{'projpacks'};
my $pdatas = $projpacks->{$projid}->{'package'} || {};
Expand Down
37 changes: 23 additions & 14 deletions src/backend/BSSched/ProjPacks.pm
Expand Up @@ -991,6 +991,29 @@ sub setup_projects {
my $repoid = $repo->{'name'};
my $prp = "$projid/$repoid";
$myprps{$prp} = 1;

# check if all packages are locked
my $alllocked;
if ($proj->{'lock'} && BSUtil::enabled($repoid, $proj->{'lock'}, 0, $myarch)) {
$alllocked = 1;
for my $pack (grep {$_->{'lock'}} values(%{$proj->{'package'} || {}})) {
$alllocked = 0 unless BSUtil::enabled($repoid, $pack->{'lock'}, 1, $myarch);
}
}
if ($alllocked) {
$gctx->{'alllocked'}->{$prp} = 1;
} else {
delete $gctx->{'alllocked'}->{$prp};
}

# if all packages are locked we do not have dependencies
if ($alllocked) {
my @sp;
$prpsearchpath->{$prp} = \@sp;
$prpdeps->{$prp} = \@sp;
next;
}

my @searchpath = expandsearchpath($gctx, $projid, $repo);
# map searchpath to internal prp representation
my @sp = map {"$_->{'project'}/$_->{'repository'}"} @searchpath;
Expand Down Expand Up @@ -1035,20 +1058,6 @@ sub setup_projects {
# get list of related prp
my @related_prps = grep { $prp ne $_ && is_related($projid, $_) } @{$prpdeps->{$prp} || []};
$relatedprpdeps->{$prp} = \@related_prps if @related_prps;

# check if all packages are locked
my $alllocked;
if ($proj->{'lock'} && BSUtil::enabled($repoid, $proj->{'lock'}, 0, $myarch)) {
$alllocked = 1;
for my $pack (grep {$_->{'lock'}} values(%{$proj->{'package'} || {}})) {
$alllocked = 0 unless BSUtil::enabled($repoid, $pack->{'lock'}, 1, $myarch);
}
}
if ($alllocked) {
$gctx->{'alllocked'}->{$prp} = 1;
} else {
delete $gctx->{'alllocked'}->{$prp};
}
}
$gctx->{'project_prps'}->{$projid} = [ sort keys %myprps ] if %myprps;
}
Expand Down
28 changes: 19 additions & 9 deletions src/backend/bs_sched
Expand Up @@ -1044,10 +1044,18 @@ eval {
$ctx->set_repo_state('scheduling');

# setup our special expander
my $xp = BSSolv::expander->new($ctx->{'pool'}, $ctx->{'conf'});
$ctx->{'expander'} = $xp;
my $xp;
if ($ctx->{'pool'}) {
$xp = BSSolv::expander->new($ctx->{'pool'}, $ctx->{'conf'});
$ctx->{'expander'} = $xp;
}
no warnings 'redefine';
local *Build::expand = sub { $_[0] = $xp; goto &BSSolv::expander::expand; };
local *Build::expand;
if ($xp) {
*Build::expand = sub { $_[0] = $xp; goto &BSSolv::expander::expand; };
} else {
*Build::expand = sub { return (0, "no expander") };
}
use warnings 'redefine';

# Step 2c: expand all dependencies, put them in %pdeps hash and sort the packages
Expand Down Expand Up @@ -1095,12 +1103,14 @@ eval {
$gctx->{'prpfinished'}->{$prp} = 1;
# write out lastcheck cache and delete it
my $lastcheck = $gctx->{'lastcheck'}->{$prp};
if ($lastcheck && %$lastcheck) {
BSUtil::store("$gdst/.:lastcheck", "$gdst/:lastcheck", $lastcheck);
} else {
unlink("$gdst/:lastcheck");
if ($lastcheck) {
if (%$lastcheck) {
BSUtil::store("$gdst/.:lastcheck", "$gdst/:lastcheck", $lastcheck);
} else {
unlink("$gdst/:lastcheck") unless $gctx->{'alllocked'}->{$prp};
}
delete $gctx->{'lastcheck'}->{$prp};
}
delete $gctx->{'lastcheck'}->{$prp};
# delete pkg meta cache
$gctx->{'repodatas'}->dropmeta($prp, $myarch);

Expand All @@ -1110,7 +1120,7 @@ eval {
my @unfinishedprps;
my $remoteprojs = $gctx->{'remoteprojs'};
my $prpfinished = $gctx->{'prpfinished'};
for (@{$gctx->{'prpdeps'}->{$prp}}) {
for (@{$gctx->{'prpdeps'}->{$prp} || []}) {
next if $prpfinished->{$_};
# if this is a remote repo, check prpnotready
if (!%{$gctx->{'prpnotready'}->{$_} || {}}) {
Expand Down

0 comments on commit 311cfdc

Please sign in to comment.