return @r;
}
+sub sortpacks {
+ my ($depsp, $mapp, $cycp, @packs) = @_;
+
+ return @packs if @packs < 2;
+ my @cycs;
+ @packs = BSSolv::depsort($depsp, $mapp, \@cycs, @packs);
+ if (@cycs) {
+ @$cycp = @cycs if $cycp;
+ print "cycle: ".join(' -> ', @$_)."\n" for @cycs;
+ }
+ return @packs;
+}
+
+
+sub getallbuilddepinfo {
+ my ($cgi, $projid, $repoid, $arch) = @_;
+ my %packids = map {$_ => 1} @{$cgi->{'package'} || []};
+ my $view = $cgi->{'view'} || '';
+ my $depends = BSUtil::retrieve("$reporoot/$projid/$repoid/$arch/:depends", 1);
+ return ({'package' => []}, $BSXML::builddepinfo) unless $depends;
+ my $subpacks = $depends->{'subpacks'} || {};
+ my $pkgdeps = $depends->{'pkgdeps'} || {};
+ my $pkg2src = $depends->{'pkg2src'} || {};
+ my $dep2src = $depends->{'dep2src'} || {};
+ my %subpack2pack;
+ my %notready;
+ if ($view eq 'pkgnames' || $view eq 'revpkgnames') {
+ for my $packid (sort keys %$pkg2src) {
+ my $n = $pkg2src->{$packid} || $packid;
+ if ($subpacks->{$n} && @{$subpacks->{$n}}) {
+ push @{$subpack2pack{$_}}, $packid for @{$subpacks->{$n}};
+ } else {
+ push @{$subpack2pack{$n}}, $packid;
+ }
+ }
+
+ if ($view eq 'revpkgnames') {
+ my %rdeps;
+ my @packs;
+ my @cycles;
+ my %pdeps;
+
+ for my $p (sort keys %$pkg2src){
+ push @packs,$p;
+ $pdeps{$p} = \@{$pkgdeps->{$p}};
+ }
+
+ @packs = sortpacks(\%pdeps, \$dep2src, \@cycles, @packs);
+
+ for my $pkid (@{$cgi->{'package'}})
+ {
+ $notready{$pkid} = 1;
+ for my $p (@packs)
+ {
+ my @blocked = grep {$notready{$dep2src->{$_}}} @{$pkgdeps->{$p}};
+ if(@blocked)
+ {
+
+ push @{$rdeps{$pkid}}, $p;
+ $notready{$p} = 1;
+ }
+
+ @blocked = ();
+
+ }
+ }
+ $pkgdeps = \%rdeps;
+ }
+ }
+ my @res;
+ for my $packid (sort keys %$pkg2src) {
+ next if %packids && !$packids{$packid};
+ my $n = $pkg2src->{$packid};
+ my @sp = sort @{$subpacks->{$n} || []};
+ push @sp, $n unless @sp;
+ if ($n ne $sp[0] && (grep {$_ eq $n} @sp)) {
+ @sp = grep {$_ ne $n} @sp;
+ unshift @sp, $n;
+ }
+ my $deps = $pkgdeps->{$packid} || [];
+ $deps = [ map {@{$subpack2pack{$_} || []}} @$deps ] if $view eq 'pkgnames';
+ $deps = [ sort(unify(@$deps)) ] if $view eq 'pkgnames' || $view eq 'revpkgnames';
+ push @res, {'name' => $packid,
+ 'source' => $n,
+ 'pkgdep' => $deps,
+ 'subpkg' => \@sp,
+ };
+ }
+ my @cycles = map {{'package' => $_}} @{$depends->{'cycles'} || []};
+ my $res = { 'package' => \@res, };
+ $res->{'cycle'} = \@cycles if @cycles;
+ return ($res, $BSXML::builddepinfo);
+}
+
+
+
+
sub getbuilddepinfo {
my ($cgi, $projid, $repoid, $arch) = @_;
my %packids = map {$_ => 1} @{$cgi->{'package'} || []};
'POST:/build/$project/$repository/$arch/_repository match:' => \&postrepo,
'/build/$project/$repository/$arch/_builddepinfo package* view:?' => \&getbuilddepinfo,
+ '/build/$project/$repository/$arch/_allbuilddepinfo package* view:?' => \&getallbuilddepinfo,
'/build/$project/$repository/$arch/_jobhistory package* code:* limit:num?' => \&getjobhistory,
'POST:/build/$project/$repository/$arch/_relsync' => \&postrelsync,
'/build/$project/$repository/$arch/_relsync' => \&getrelsync,
return ($res, $BSXML::builddepinfo);
}
+sub getallbuilddepinfo {
+ my ($cgi, $projid, $repoid, $arch) = @_;
+
+ checkprojrepoarch($projid, $repoid, $arch);
+ my @args;
+ push @args, map {"package=$_"} @{$cgi->{'package'} || []};
+ push @args, "view=$cgi->{'view'}" if $cgi->{'view'};
+ my $res = BSWatcher::rpc("$BSConfig::reposerver/build/$projid/$repoid/$arch/_allbuilddepinfo", $BSXML::builddepinfo, @args);
+ return ($res, $BSXML::builddepinfo);
+}
+
+
sub getjobhistory {
my ($cgi, $projid, $repoid, $arch) = @_;
'/build/$project/$repository/_buildconfig path:prp*' => \&getbuildconfig,
'/build/$project/$repository/$arch package* view:?' => \&getpackagelist_build,
'/build/$project/$repository/$arch/_builddepinfo package* view:?' => \&getbuilddepinfo,
+ '/build/$project/$repository/$arch/_allbuilddepinfo package* view:?' => \&getallbuilddepinfo,
'/build/$project/$repository/$arch/_jobhistory package* code:* limit:num?' => \&getjobhistory,
'POST:/build/$project/$repository/$arch/_repository match:' => \&postrepo,
'POST:/build/$project/$repository/$arch/$package cmd=copy oproject:project? opackage:package? orepository:repository? setupdateinfoid:? resign:bool?' => \©build,