Skip to content

Commit

Permalink
[backend] expand _obsrepositories in reposerver/scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Jul 1, 2013
1 parent 260b39f commit c21bf4a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 28 deletions.
21 changes: 15 additions & 6 deletions src/backend/bs_repserver
Original file line number Diff line number Diff line change
Expand Up @@ -2265,6 +2265,15 @@ sub getjobhistory {
return ($ret, $BSXML::jobhistlist);
}

sub expandkiwipath_hash {
my ($info, $repo) = @_;
return map {$_->{'project'} eq '_obsrepositories' ? @{$repo->{'path'} || []} : ($_)} @{$info->{'path'} || []};
}

sub expandkiwipath {
return map {"$_->{'project'}/$_->{'repository'}"} expandkiwipath_hash(@_);
}

sub getkiwiproductpackages {
my ($proj, $repo, $pdata, $info, $deps, $remotemap) = @_;

Expand All @@ -2275,7 +2284,7 @@ sub getkiwiproductpackages {
my @deps = @{$deps || []};
my %deps = map {$_ => 1} @deps;
delete $deps{''};
my @aprps = map {"$_->{'project'}/$_->{'repository'}"} @{$info->{'path'} || []};
my @aprps = expandkiwipath($info, $repo);
my $allpacks = $deps{'*'} ? 1 : 0;
for my $aprp (@aprps) {
my %known;
Expand Down Expand Up @@ -2387,7 +2396,7 @@ sub getbuildinfo {
my $kiwitype;
if ($packtype eq 'kiwi') {
if (@{$info->{'path'} || []}) {
@args = map {"project=$_->{'project'}"} @{$info->{'path'}};
@args = map {"project=$_->{'project'}"} grep {$_->{'project'} ne '_obsrepositories'} @{$info->{'path'}};
push @args, "partition=$BSConfig::partition" if $BSConfig::partition;
my $pp = BSRPC::rpc("$BSConfig::srcserver/getprojpack", $BSXML::projpack, 'withremotemap', 'nopackages', @args);
%remotemap = (%remotemap, map {$_->{'project'} => $_} @{$pp->{'remotemap'} || []});
Expand All @@ -2399,7 +2408,7 @@ sub getbuildinfo {
}
# a repo with no path will expand to just the prp as the only element
if ($kiwitype eq 'image' || @{$repo->{'path'} || []} < 2) {
@configpath = map {"$_->{'project'}/$_->{'repository'}"} @{$info->{'path'} || []};
@configpath = expandkiwipath($info, $repo);
unshift @configpath, "$projid/$repoid" unless @configpath;
}
}
Expand All @@ -2416,13 +2425,13 @@ sub getbuildinfo {
my @prp = map {"$_->{'project'}/$_->{'repository'}"} @{$repo->{'path'} || []};
if ($packtype eq 'kiwi') {
$ret->{'imagetype'} = $info->{'imagetype'} || [];
if (@prp < 2) {
$ret->{'path'} = $info->{'path'} || [];
if (@prp < 2 || grep {$_->{'project'} eq '_obsrepositories'} @{$info->{'path'} || []}) {
$ret->{'path'} = [ expandkiwipath_hash($info, $repo) ];
} else {
push @{$ret->{'path'}}, @{$info->{'path'} || []}; # XXX: should unify
}
if ($kiwitype eq 'image' || @{$repo->{'path'} || []} < 2) {
@prp = map {"$_->{'project'}/$_->{'repository'}"} @{$info->{'path'} || []};
@prp = expandkiwipath($info, $repo);
}
}
if ($cgi->{'internal'}) {
Expand Down
25 changes: 19 additions & 6 deletions src/backend/bs_sched
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,19 @@ sub add_crossmarker {
BSUtil::touch($marker);
}

sub expandkiwipath {
my ($info, $prpsearchpath) = @_;
my @path;
for ({$info->{'path'} || []}) {
if ($_->{'project'} eq '_obsrepositories') {
push @path, @{$prpsearchpath || []};
} else {
push @path, "$_->{'project'}/$_->{'repository'}";
}
}
return @path;
}

#
# set_building - create a new build job
#
Expand Down Expand Up @@ -609,7 +622,6 @@ sub set_building {
$packtype = 'arch' if $info->{'file'} eq 'PKGBUILD';
$packtype = 'preinstallimage' if $info->{'file'} eq '_preinstallimage';

my $searchpath = [];
my $syspath;
if ($packtype eq 'kiwi') {
if ($prpsearchpath) {
Expand All @@ -627,8 +639,9 @@ sub set_building {
}
}
}
$prpsearchpath = [ map {"$_->{'project'}/$_->{'repository'}"} @{$info->{'path'} || []} ];
$prpsearchpath = [ expandkiwipath($info, $prpsearchpath) ];
}
my $searchpath = [];
for (@$prpsearchpath) {
my @pr = split('/', $_, 2);
if ($remoteprojs{$pr[0]}) {
Expand Down Expand Up @@ -3855,9 +3868,9 @@ sub checkkiwiimage {
my $projid = $ctx->{'project'};
my $repoid = $ctx->{'repository'};
my $prp = $ctx->{'prp'};
my @aprps = map {"$_->{'project'}/$_->{'repository'}"} @{$info->{'path'} || []};
my $repo = $ctx->{'repo'};

my @aprps = expandkiwipath($info, $ctx->{'prpsearchpath'});
# get config from path
my $bconf = getconfig($myarch, \@aprps);
if (!$bconf) {
Expand Down Expand Up @@ -3958,7 +3971,7 @@ sub rebuildkiwiimage {
if (!@{$repo->{'path'} || []}) {
# repo has no path, use kiwi repositories also for kiwi system setup
my $prp = "$projid/$repoid";
my @aprps = map {"$_->{'project'}/$_->{'repository'}"} @{$info->{'path'} || []};
my @aprps = expandkiwipath($info, $ctx->{'prpsearchpath'});
# setup pool again for kiwi system expansion
my $pool = BSSolv::pool->new();
$pool->settype('deb') if $bconf->{'binarytype'} eq 'deb';
Expand Down Expand Up @@ -4076,7 +4089,7 @@ sub checkkiwiproduct {
my %deps = map {$_ => 1} @deps;
delete $deps{''};

my @aprps = map {"$_->{'project'}/$_->{'repository'}"} @{$info->{'path'} || []};
my @aprps = expandkiwipath($info, $ctx->{'prpsearchpath'});
my @bprps = @{$ctx->{'prpsearchpath'}};
my $bconf = $ctx->{'conf'};

Expand Down Expand Up @@ -4383,7 +4396,7 @@ sub rebuildkiwiproduct {
}
}
}
my @aprps = map {"$_->{'project'}/$_->{'repository'}"} @{$info->{'path'} || []};
my @aprps = expandkiwipath($info, $ctx->{'prpsearchpath'});
my $searchpath = [];
for (@aprps) {
my @pr = split('/', $_, 2);
Expand Down
18 changes: 2 additions & 16 deletions src/backend/bs_srcserver
Original file line number Diff line number Diff line change
Expand Up @@ -3023,27 +3023,13 @@ sub getprojpack {
my $myarch = $conf->{'target'} ? (split('-', $conf->{'target'}))[0] : $arch;
$rinfo->{'error'} = 'excluded' if $d->{'exclarch'} && !grep {$_ eq $myarch} @{$d->{'exclarch'}};
$rinfo->{'error'} = 'excluded' if $d->{'badarch'} && grep {$_ eq $myarch} @{$d->{'badarch'}};
for my $path (@{$d->{path}||[]}) {
$rinfo->{'path'} ||= [];
if ($path->{'project'} eq '_obsrepositories') {
# replace it with the expanded repository list from repository definition of the project
my @a = expandsearchpath($projid, $repoid, $remotemap);
for my $prp (@a) {
my @s = split('/', $prp, 2);
my $h = {'project' => $s[0], 'repository' => $s[1]};
push @{$rinfo->{'path'}}, $h;
}
next;
}
push @{$rinfo->{'path'}}, $path;
}
for ('imagetype', 'extrasource') {
for ('imagetype', 'path', 'extrasource') {
$rinfo->{$_} = $d->{$_} if exists $d->{$_};
}
if ($remotemap && $rinfo->{'path'} && !$repo->{'path'}) {
# simple way to fill the remote map
eval {
concatconfigs($projid, $repoid, $remotemap, map {"$_->{'project'}/$_->{'repository'}"} @{$rinfo->{'path'}});
concatconfigs($projid, $repoid, $remotemap, map {"$_->{'project'}/$_->{'repository'}"} grep {$_->{'project'} ne '_obsrepositories'} @{$rinfo->{'path'}});
};
}
} else {
Expand Down

0 comments on commit c21bf4a

Please sign in to comment.