sub readdeps {
my ($config, $pkginfo, @depfiles) = @_;
- my %requires;
- my %recommends;
+
local *F;
+ my %requires;
my %provides;
my %pkgconflicts;
my %pkgobsoletes;
+ my %recommends;
+ my %supplements;
my $dofileprovides = %{$config->{'fileprovides'} || {}};
for my $depfile (@depfiles) {
if (ref($depfile) eq 'HASH') {
for my $rr (keys %$depfile) {
$provides{$rr} = $depfile->{$rr}->{'provides'};
$requires{$rr} = $depfile->{$rr}->{'requires'};
- $recommends{$rr} = $depfile->{$rr}->{'recommends'};
$pkgconflicts{$rr} = $depfile->{$rr}->{'conflicts'};
$pkgobsoletes{$rr} = $depfile->{$rr}->{'obsoletes'};
+ $recommends{$rr} = $depfile->{$rr}->{'recommends'};
+ $supplements{$rr} = $depfile->{$rr}->{'supplements'};
}
next;
}
}
my %ss;
@ss = grep {!$ss{$_}++} @ss;
- if ($s =~ /^(P|R|C|O|r):(.*)\.(.*)-\d+\/\d+\/\d+:$/) {
+ if ($s =~ /^(P|R|C|O|r|s):(.*)\.(.*)-\d+\/\d+\/\d+:$/) {
my $pkgid = $2;
my $arch = $3;
if ($1 eq "P") {
$pkginfo->{$pkgid}->{'requires'} = \@ss if $pkginfo;
next;
}
- if ($1 eq "r") {
- $recommends{$pkgid} = \@ss;
- $pkginfo->{$pkgid}->{'recommends'} = \@ss if $pkginfo;
- next;
- }
if ($1 eq "C") {
$pkgconflicts{$pkgid} = \@ss;
$pkginfo->{$pkgid}->{'conflicts'} = \@ss if $pkginfo;
$pkginfo->{$pkgid}->{'obsoletes'} = \@ss if $pkginfo;
next;
}
+ if ($1 eq "r") {
+ $recommends{$pkgid} = \@ss;
+ $pkginfo->{$pkgid}->{'recommends'} = \@ss if $pkginfo;
+ next;
+ }
+ if ($1 eq "s") {
+ $supplements{$pkgid} = \@ss;
+ $pkginfo->{$pkgid}->{'supplements'} = \@ss if $pkginfo;
+ next;
+ }
}
}
close F;
}
$config->{'providesh'} = \%provides;
$config->{'requiresh'} = \%requires;
- $config->{'recommendsh'} = \%recommends;
$config->{'pkgconflictsh'} = \%pkgconflicts;
$config->{'pkgobsoletesh'} = \%pkgobsoletes;
+ $config->{'recommendsh'} = \%recommends;
+ $config->{'supplementsh'} = \%supplements;
makewhatprovidesh($config);
}
print $fh "F:$id$url$pkg->{'location'}\n";
print $fh "P:$id".join(' ', @{$pkg->{'provides'} || []})."\n";
print $fh "R:$id".join(' ', @{$pkg->{'requires'}})."\n" if $pkg->{'requires'};
- print $fh "r:$id".join(' ', @{$pkg->{'recommends'}})."\n" if $pkg->{'recommends'};
print $fh "C:$id".join(' ', @{$pkg->{'conflicts'}})."\n" if $pkg->{'conflicts'};
print $fh "O:$id".join(' ', @{$pkg->{'obsoletes'}})."\n" if $pkg->{'obsoletes'};
+ print $fh "r:$id".join(' ', @{$pkg->{'recommends'}})."\n" if $pkg->{'recommends'};
+ print $fh "s:$id".join(' ', @{$pkg->{'supplements'}})."\n" if $pkg->{'supplements'};
print $fh "I:$id".getbuildid($pkg)."\n";
}
delete $config->{'providesh'};
delete $config->{'whatprovidesh'};
delete $config->{'requiresh'};
- delete $config->{'recommendsh'};
delete $config->{'pkgconflictsh'};
delete $config->{'pkgobsoletesh'};
+ delete $config->{'recommendsh'};
+ delete $config->{'supplementsh'};
}
my %addproviders_fm = (
return 0;
}
+sub todo2recommended {
+ my ($config, $recommended, $todo) = @_;
+ my $whatprovides = $config->{'whatprovidesh'};
+ my $pkgrecommends = $config->{'recommendsh'} || {};
+ for my $p (splice @$todo) {
+ for my $r (@{$pkgrecommends->{$p} || []}) {
+ $recommended->{$_} = 1 for @{$whatprovides->{$r} || addproviders($config, $r)}
+ }
+ }
+}
+
sub expand {
my ($config, @p) = @_;
my $prefer = $config->{'preferh'};
my $ignore = $config->{'ignoreh'};
my $ignoreconflicts = $config->{'expandflags:ignoreconflicts'};
+ my $ignoreignore;
+ my $userecommendsforchoices = 1;
my $whatprovides = $config->{'whatprovidesh'};
my $requires = $config->{'requiresh'};
- my $recommends = $config->{'recommendsh'};
my %xignore = map {substr($_, 1) => 1} grep {/^-/} @p;
my @directdepsend;
}
@p = grep {!/^-/} @p;
- my %p; # expanded packages
my %aconflicts; # packages we are conflicting with
+ for (grep {/^!/} @p) {
+ my $r = /^!!/ ? substr($_, 2) : substr($_, 1);
+ my @q = @{$whatprovides->{$r} || addproviders($config, $r)};
+ @q = nevrmatch($config, $r, @q) if /^!!/;
+ $aconflicts{$_} = "is in BuildConflicts" for @q;
+ }
+ my %recommended; # recommended by installed packages
+ my @rec_todo; # installed todo
+
+ @p = grep {!/^[-!]/} @p;
+ my %p; # expanded packages
# add direct dependency packages. this is different from below,
# because we add packages even if the dep is already provided and
$aconflicts{$_} = "is obsoleted by installed $q[0]" for nevrmatch($config, $r, @{$whatprovides->{$r} || addproviders($config, $r)});
}
}
+ push @rec_todo, $q[0] if $userecommendsforchoices;
}
push @p, @directdepsend;
last;
}
}
- if (@q > 1 && $config->{"buildflags:userecommendsforchoices"} && @{$recommends->{$p} || []} > 0) {
- my @recommendedq;
- my $i;
-
- for my $iq (@q) {
- for my $rpkg (@{$recommends->{$p}}) {
- if ($rpkg =~ /$iq/) {
- push @recommendedq, $iq;
- }
- }
- }
- if (@recommendedq > 0) {
- print "recommended [@recommendedq] among [@q]\n" if $expand_dbg;
- @q = @recommendedq;
- }
+ if ($doamb == 2) {
+ todo2recommended($config, \%recommended, \@rec_todo) if @rec_todo;
+ my @pq = grep {$recommended{$_}} @q;
+ print "recommended [@pq] among [@q]\n" if $expand_dbg;
+ @q = @pq if @pq;
}
if (@q > 1) {
if ($r ne $p) {
$aconflicts{$_} = "is obsoleted by installed $q[0]" for nevrmatch($config, $r, @{$whatprovides->{$r} || addproviders($config, $r)});
}
}
+ push @rec_todo, $q[0] if $userecommendsforchoices;
@error = ();
$doamb = 0;
}
next if @p; # still work to do
# only ambig stuff left
- if (@pamb && !$doamb) {
+ if (@pamb && ($doamb == 0 || $doamb == 1)) {
@p = @pamb;
@pamb = ();
- $doamb = 1;
- print "now doing undecided dependencies\n" if $expand_dbg;
+ todo2recommended($config, \%recommended, \@rec_todo) if @rec_todo;
+ $doamb = %recommended ? 2 : 3;
+ print "now doing undecided dependencies, $doamb = $doamb\n" if $expand_dbg;
next;
}
return undef, @error if @error;
$binarytype = $cf->{'binarytype'} if $cf->{'binarytype'} && $cf->{'binarytype'} ne 'UNDEFINED';
}
-my (%fn, %prov, %req, %rec, %con, %obs);
+my (%fn, %prov, %req, %con, %obs, %rec, %sup);
my %packs;
my %repo;
open(F, '<', $rpmdeps) || die("$rpmdeps: $!\n");
# WARNING: the following code assumes that the 'I' tag comes last
-my ($pkgF, $pkgP, $pkgR, $pkgr, $pkgC, $pkgO);
+my ($pkgF, $pkgP, $pkgR, $pkgC, $pkgO, $pkgr, $pkgs);
my $verscmp = \&Build::Rpm::verscmp;
$pkgO = $2;
next if $obs{$1};
$obs{$1} = $2;
+ } elsif (/^r:(.*?)-\d+\/\d+\/\d+: (.*)$/) {
+ $pkgr = $2;
+ } elsif (/^s:(.*?)-\d+\/\d+\/\d+: (.*)$/) {
+ $pkgs = $2;
} elsif (/^I:(.*?)-\d+\/\d+\/\d+: (.*)$/) {
my $r = 0;
if ($usehigherdeps) {
delete $rec{$i};
delete $con{$i};
delete $obs{$i};
+ delete $rec{$i};
+ delete $sup{$i};
$req{$i} = $pkgR;
- $rec{$i} = $pkgr;
$con{$i} = $pkgC if defined $pkgC;
$obs{$i} = $pkgO if defined $pkgO;
+ $rec{$i} = $pkgr if defined $pkgr;
+ $sup{$i} = $pkgs if defined $pkgs;
} else {
next if $ids{$1};
$ids{$1} = $2;
undef $pkgF;
undef $pkgP;
undef $pkgR;
- undef $pkgr;
undef $pkgC;
undef $pkgO;
+ undef $pkgr;
+ undef $pkgs;
} elsif ($_ eq 'D:') {
%packs_done = %ids;
}
for my $pack (keys %packs) {
my $r = {};
- my (@s, $s, @pr, @re, @rc, @co, @ob);
+ my (@s, $s, @pr, @re, @co, @ob, @rc, @su);
@s = split(' ', $prov{$packs{$pack}} || '');
while (@s) {
$s = shift @s;
splice(@s, 0, 2);
}
}
+ @s = split(' ', $con{$packs{$pack}} || '');
+ while (@s) {
+ $s = shift @s;
+ next if !$dofileprovides && $s =~ /^\//;
+ push @co, $s;
+ while (@s && $s[0] =~ /^[\(<=>|]/) {
+ $co[-1] .= " $s[0] $s[1]";
+ $co[-1] =~ s/ \((.*)\)/ $1/;
+ $co[-1] =~ s/(<|>){2}/$1/;
+ splice(@s, 0, 2);
+ }
+ }
+ @s = split(' ', $obs{$packs{$pack}} || '');
+ while (@s) {
+ $s = shift @s;
+ next if !$dofileprovides && $s =~ /^\//;
+ push @ob, $s;
+ while (@s && $s[0] =~ /^[\(<=>|]/) {
+ $ob[-1] .= " $s[0] $s[1]";
+ $ob[-1] =~ s/ \((.*)\)/ $1/;
+ $ob[-1] =~ s/(<|>){2}/$1/;
+ splice(@s, 0, 2);
+ }
+ }
@s = split(' ', $rec{$packs{$pack}} || '');
while (@s) {
$s = shift @s;
splice(@s, 0, 2);
}
}
- @s = split(' ', $con{$packs{$pack}} || '');
+ @s = split(' ', $sup{$packs{$pack}} || '');
while (@s) {
$s = shift @s;
next if !$dofileprovides && $s =~ /^\//;
- push @co, $s;
- while (@s && $s[0] =~ /^[\(<=>|]/) {
- $co[-1] .= " $s[0] $s[1]";
- $co[-1] =~ s/ \((.*)\)/ $1/;
- $co[-1] =~ s/(<|>){2}/$1/;
+ if ($s =~ /^rpmlib\(/) {
splice(@s, 0, 2);
+ next;
}
- }
- @s = split(' ', $obs{$packs{$pack}} || '');
- while (@s) {
- $s = shift @s;
- next if !$dofileprovides && $s =~ /^\//;
- push @ob, $s;
+ push @su, $s;
while (@s && $s[0] =~ /^[\(<=>|]/) {
- $ob[-1] .= " $s[0] $s[1]";
- $ob[-1] =~ s/ \((.*)\)/ $1/;
- $ob[-1] =~ s/(<|>){2}/$1/;
+ $rc[-1] .= " $s[0] $s[1]";
+ $rc[-1] =~ s/ \((.*)\)/ $1/;
+ $rc[-1] =~ s/(<|>){2}/$1/;
splice(@s, 0, 2);
}
}
$r->{'provides'} = \@pr;
$r->{'requires'} = \@re;
- $r->{'recommends'} = \@rc;
$r->{'conflicts'} = \@co;
$r->{'obsoletes'} = \@ob;
+ $r->{'recommends'} = \@rc;
+ $r->{'supplements'} = \@su;
$repo{$pack} = $r;
}