prt-auf: fix the handling of sysup --softdeps

This commit is contained in:
John McQuah 2023-05-19 16:00:18 -04:00
parent f014d86816
commit 1165eb8dae

View File

@ -554,9 +554,9 @@ sub list_ports {
if ($subset eq "orphans") {
my %not_orphans = map { $_ => 0 } @searchspace;
foreach my $port (@searchspace) {
map { $not_orphans{$_} = 1 } split(/ /, $DEPENDS{$port});
map { $not_orphans{$_} = 1 } split(/[ ,]/, $DEPENDS{$port});
if ($odepends{soft} == 1) {
map { $not_orphans{$_} = 1 } split(/ /, $SOFTDEPS{$port});
map { $not_orphans{$_} = 1 } split(/[ ,]/, $SOFTDEPS{$port});
}
}
@found = grep { $not_orphans{$_} eq 0 } keys %V_INST;
@ -671,39 +671,41 @@ sub port_diff { # find differences between the pkgdb and the repo
}
sub deporder { # returns a sorted list of packages required.
my $type=shift; my @seeds=@_; our @treewalk=(); our @missing;
our %numPred; our %children; my @result; our %SEEDS = map { $_ => 1 } @seeds;
my $type=shift; my @seeds=@_; our @treewalk=(); our %missing;
our %numPred = map { $_ => 0 } @seeds; our %children; my @result;
# determine the minimal set of targets needed to satisfy all dependencies
foreach my $t (@seeds) {
($V_REPO{$t}) ? recurse_deptree(0,$t) : push (@missing, $t);
}
foreach my $t (@seeds) { recurse_deptree(0,$t); }
sub recurse_deptree {
my $greedy=shift; my $s=shift; my %curdeps; my @optionals;
my $greedy=shift; my $s=shift; my %curdeps;
if ((! $numPred{$s}) and ($greedy==0)) { $numPred{$s} = 0; }
# detect any dependencies that have been dropped from the repositories
if (! $V_REPO{$s}) { $missing{$s}=1; undef $numPred{$s}; return; }
# cycle detection
( grep /^$s$/, @treewalk ) ? return : push(@treewalk, $s);
%curdeps = map { $_ => 0 } split /[ ,]/, $DEPENDS{$s};
# if the user toggles --softdeps, consider only the optional dependencies
# if the user toggles --softdeps, consider the optional dependencies
# that are already installed or are given on the command line
if ($odepends{soft} == 1) {
@optionals = grep { ($V_INST{$_}) or ($SEEDS{$_}) } split /[ ,]/, $SOFTDEPS{$s};
foreach (@optionals) { $curdeps{$_} = 1; }
foreach (grep { ($V_INST{$_}) or ($numPred{$_}) }
split /[ ,]/, $SOFTDEPS{$s}) {
$curdeps{$_} = 1;
}
}
foreach my $sd (keys %curdeps) {
my $subit = who_aliased_to($sd);
if ($subit) {
$children{$s} .= " $subit ";
$numPred{$subit} += 1;
$numPred{$subit} += 1 unless ($greedy == 1);
recurse_deptree($curdeps{$sd},$subit);
} else {
$children{$s} .= " $sd ";
$numPred{$sd} += 1;
$numPred{$sd} += 1 unless ($greedy == 1);
recurse_deptree($curdeps{$sd},$sd);
}
}
@ -728,7 +730,7 @@ sub deporder { # returns a sorted list of packages required.
# support), and must be reversed.
@result = reverse @result;
if (($#missing>-1) and ($type ne "quickdep")) { push (@result, "MISSING", @missing); }
if ((keys %missing > 0) and ($type ne "quickdep")) { push (@result, "MISSING", sort(keys %missing)); }
return @result;
}