prt-auf: guard against using invalid keys in a hash
This commit is contained in:
parent
ab4a9ee6fd
commit
ae41c77bd4
@ -136,8 +136,8 @@ if (($action =~ /^(listinst|listorphans|dependent)/)
|
||||
next if (! $dep);
|
||||
if ($action ne "quickdep") {
|
||||
$ind = (grep { $_ eq $dep } keys %V_INST) ? "[i]" : "[ ]";
|
||||
$dep .= " $V_REPO{$dep}" if ($osearch{verbose}==1);
|
||||
$dep .= " $V_REPO{$dep}\n$DESC{$dep}" if ($osearch{verbose}>1);
|
||||
$dep .= " $V_REPO{$dep}" if (($osearch{verbose}==1) and ($V_REPO{$dep}));
|
||||
$dep .= " $V_REPO{$dep}\n$DESC{$dep}" if (($osearch{verbose}>1) and ($V_REPO{$dep}) and ($DESC{$dep}));
|
||||
}
|
||||
printf $strf, $ind, $dep unless ($action eq "quickdep");
|
||||
printf "%s ", $dep if ($action eq "quickdep");
|
||||
@ -534,7 +534,7 @@ sub port_unlock {
|
||||
open (LL, '>', $prtlocker."-tmp");
|
||||
foreach my $nl (@newlocks) { print LL "$nl\n" unless $nl =~ /^\s*$/; }
|
||||
close (LL);
|
||||
system ("mv",$prtlocker."-tmp",$prtlocker);
|
||||
rename ($prtlocker."-tmp",$prtlocker);
|
||||
}
|
||||
|
||||
sub list_ports {
|
||||
@ -572,7 +572,7 @@ sub list_ports {
|
||||
my %not_orphans = map { $_ => 0 } @searchspace;
|
||||
foreach my $port (@searchspace) {
|
||||
map { $not_orphans{$_} = 1 } split(/[ ,]+/, $DEPENDS{$port});
|
||||
if ($odepends{soft} == 1) {
|
||||
if (($odepends{soft} == 1) and ($SOFTDEPS{$port})) {
|
||||
map { $not_orphans{$_} = 1 } split(/[ ,]+/, $SOFTDEPS{$port});
|
||||
}
|
||||
}
|
||||
@ -595,38 +595,45 @@ sub list_ports {
|
||||
($odepends{tree} == 0) or print "$header\n";
|
||||
|
||||
our $indent=" "; our $height=0;
|
||||
our $ind; our %seen; our @lineage; my @fosters=();
|
||||
our $ind; our %seen; our @lineage; my @fosters=(); my @children=();
|
||||
$ind = ($V_INST{$seed}) ? "[i]" : "[ ]";
|
||||
print "$ind $seed\n" if ($odepends{tree}==1);
|
||||
$seen{$seed} = 1;
|
||||
my @children = ($direction eq "fwd") ? split /[ ,]+/, $DEPENDS{$sseed}:
|
||||
grep { " $DEPENDS{$_} " =~ / $sseed / } @searchspace;
|
||||
if ($odepends{soft}==1) {
|
||||
@fosters = ($direction eq "fwd") ?
|
||||
grep { ($V_INST{$_}) } split /[ ,]+/, $SOFTDEPS{$sseed}:
|
||||
grep { " $SOFTDEPS{$_} " =~ / $sseed / } @searchspace;
|
||||
}
|
||||
if ($direction eq "rev") {
|
||||
@children = grep { " $DEPENDS{$_} " =~ / $sseed / } @searchspace;
|
||||
} elsif ($DEPENDS{$sseed}) {
|
||||
@children = split /[ ,]+/, $DEPENDS{$sseed};
|
||||
}
|
||||
|
||||
if (($odepends{soft}==1) and ($direction eq "rev")) {
|
||||
@fosters = grep { " $SOFTDEPS{$_} " =~ / $sseed / } @searchspace;
|
||||
} elsif (($odepends{soft}==1) and ($SOFTDEPS{$sseed})) {
|
||||
@fosters = grep { ($V_INST{$_}) } split /[ ,]+/, $SOFTDEPS{$sseed};
|
||||
}
|
||||
|
||||
foreach my $sd (@children) { recurse_tree(0,$sd,$direction); }
|
||||
foreach my $sd (@fosters) { recurse_tree(1,$sd,$direction); }
|
||||
|
||||
sub recurse_tree {
|
||||
my $greedy = shift; my $s = shift; my $direction=shift;
|
||||
my %curdeps=(); my @optionals=();
|
||||
my $ps = (($seen{$s}) and ($odepends{all} !=1)) ? "-->\n" : "\n";
|
||||
$ind = ($V_INST{$s}) ? "[i]" : "[ ]";
|
||||
$ind = (($ind eq "[i]") and ($greedy)) ? "[s]" : $ind;
|
||||
print $ind.(${indent}x(1+$height))."$s".$ps if ($odepends{tree}==1);
|
||||
return if (($seen{$s}) and ($odepends{all} !=1));
|
||||
$seen{$s} = 1;
|
||||
my %curdeps = ($direction eq "fwd") ?
|
||||
map {$_ => 0} split /[ ,]+/, $DEPENDS{$s} :
|
||||
map {$_ => 0} grep { " $DEPENDS{$_} " =~ / $s / } @searchspace;
|
||||
if ($odepends{soft} == 1) {
|
||||
my @optionals = ($direction eq "fwd") ?
|
||||
grep { ($V_INST{$_}) } split /[ ,]+/, $SOFTDEPS{$s} :
|
||||
grep { " $SOFTDEPS{$_} " =~ / $s / } @searchspace;
|
||||
map {$curdeps{$_} = 1} @optionals;
|
||||
if ($direction eq "rev") {
|
||||
%curdeps = map {$_ => 0} grep { " $DEPENDS{$_} " =~ / $s / } @searchspace;
|
||||
} elsif ($DEPENDS{$s}) {
|
||||
%curdeps = map {$_ => 0} split /[ ,]+/, $DEPENDS{$s};
|
||||
}
|
||||
if (($odepends{soft}==1) and ($direction eq "rev")) {
|
||||
@optionals = grep { " $SOFTDEPS{$_} " =~ / $s / } @searchspace;
|
||||
} elsif (($odepends{soft}==1) and ($SOFTDEPS{$s})) {
|
||||
@optionals = grep { ($V_INST{$_}) } split /[ ,]+/, $SOFTDEPS{$s};
|
||||
}
|
||||
map {$curdeps{$_} = 1} @optionals;
|
||||
|
||||
foreach my $dc (keys %curdeps) {
|
||||
if (grep /^$dc$/, @lineage) {
|
||||
@ -717,11 +724,11 @@ sub deporder { # returns a sorted list of packages required.
|
||||
push(@treewalk, $s); $imark{$s}=1;
|
||||
|
||||
# assemble the list of dependencies that must be visited next
|
||||
%curdeps = map { $_ => $greedy } split /[ ,]+/, $DEPENDS{$s};
|
||||
(! $DEPENDS{$s}) or %curdeps = map { $_ => $greedy } split /[ ,]+/, $DEPENDS{$s};
|
||||
|
||||
# if the user toggles --softdeps, consider the optional dependencies
|
||||
# that are already installed or are given on the command line
|
||||
if ($odepends{soft} == 1) {
|
||||
if (($odepends{soft} == 1) and ($SOFTDEPS{$s})) {
|
||||
foreach (grep { ($V_INST{$_}) or ($given{$_}) }
|
||||
split /[ ,]+/, $SOFTDEPS{$s}) { $curdeps{$_} = 1; }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user