prt-auf: refine the arg parser, speed up the dependency resolver
This commit is contained in:
parent
1c14f4c46a
commit
070a91ce7b
438
scripts/prt-auf
438
scripts/prt-auf
@ -11,17 +11,17 @@ use warnings;
|
|||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
################### Initialize global variables #######################
|
################### Initialize global variables #######################
|
||||||
my $title="prt-auf"; my $version=0.5;
|
my $title="prt-auf"; my $version=0.51; my $cache_ver="V5.1";
|
||||||
my $CONFDIR = "/var/lib/pkg"; my $prtalias="/etc/prt-get.aliases";
|
my $CONFDIR = "/var/lib/pkg"; my $prtalias="/etc/prt-get.aliases";
|
||||||
my $pkgdb="$CONFDIR/db"; my $prtlocker="$CONFDIR/prt-get.locker";
|
my $pkgdb="$CONFDIR/db"; my $prtlocker="$CONFDIR/prt-get.locker";
|
||||||
my $prtcache="$CONFDIR/prt-auf.cache"; my @LOCKED; my %ALIASES; my %DEPENDS;
|
my $prtcache="$CONFDIR/prt-get.cache"; my @LOCKED; my %ALIASES; my %DEPENDS;
|
||||||
my @allports; my %V_REPO; my %V_INST; my %DESC; my %SOFTDEPS;
|
my @allports; my %V_REPO; my %V_INST; my %DESC; my %SOFTDEPS;
|
||||||
my @results; my $strf; my $ind; my $hh; my $portpath; my $built_pkg;
|
my @results; my $strf; my $ind; my $hh; my $portpath; my $built_pkg;
|
||||||
my %osearch = ( cache => 0, regex => 0, path => 0, exact => 0, verbose => 0 );
|
my %osearch = ( cache => 0, regex => 0, path => 0, exact => 0, verbose => 0 );
|
||||||
my %odepends = ( soft => 0, tree => 0, recursive => 0, all => 0 );
|
my %odepends = ( soft => 0, tree => 0, recursive => 0, all => 0 );
|
||||||
my %opkg = ( margs => "", aargs => "", rargs => "", runscripts => "yes",
|
my %opkg = ( margs => "", aargs => "", rargs => "", runscripts => "yes",
|
||||||
makecommand => "/usr/bin/pkgmk", addcommand => "/usr/bin/pkgadd",
|
makecommand => "/usr/bin/pkgmk", addcommand => "/usr/bin/pkgadd",
|
||||||
removecommand => "/usr/bin/pkgrm", test => "no" );
|
removecommand => "/usr/bin/pkgrm", test => "no", group => "no" );
|
||||||
my %olog = ( write => "disabled", mode => "overwrite", rm_on_success => "yes",
|
my %olog = ( write => "disabled", mode => "overwrite", rm_on_success => "yes",
|
||||||
file => "/var/log/pkgbuild/%n.log" );
|
file => "/var/log/pkgbuild/%n.log" );
|
||||||
my $prtconf = "/etc/prt-get.conf";
|
my $prtconf = "/etc/prt-get.conf";
|
||||||
@ -66,15 +66,16 @@ if ($action eq "path") { @results = find_port_by_name($query[0],1,1,0);
|
|||||||
} elsif ($action eq "unlock") { port_unlock(@query);
|
} elsif ($action eq "unlock") { port_unlock(@query);
|
||||||
} elsif ($action eq "ls") { port_ls(@query);
|
} elsif ($action eq "ls") { port_ls(@query);
|
||||||
} elsif ($action =~ /^(cat|edit|readme)$/) { port_edit($1,@query);
|
} elsif ($action =~ /^(cat|edit|readme)$/) { port_edit($1,@query);
|
||||||
} elsif ($action =~ /^(depends|deptree|quickdep)$/) { @results=deporder($1,@query);
|
} elsif ($action =~ /^(depends|quick)dep$/) { @results=deporder($1,@query);
|
||||||
} elsif ($action eq "dependent") { @results=list_ports("dependent",@query);
|
} elsif ($action =~ /^dep(endent|tree)$/) { @results=list_ports($action,@query);
|
||||||
} elsif ($action eq "sysup") { @results = sysup();
|
} elsif ($action eq "sysup") { my @outdated = grep { s/ .+// } port_diff("quick");
|
||||||
} elsif ($action =~ /^(install|update|depinst|grpinst)$/) {
|
@results = up_inst("sysup", @outdated);
|
||||||
@results = up_inst($1,@query);
|
} elsif ($action =~ /^(install|update)$/) { @results = up_inst($action,@query);
|
||||||
|
} elsif ($action eq "depinst") { @results = up_inst("depinst",@query);
|
||||||
} elsif ($action eq "dup") { $ind=find_dups(@query);
|
} elsif ($action eq "dup") { $ind=find_dups(@query);
|
||||||
} elsif ($action eq "remove") { $ind=uninstall(@query);
|
} elsif ($action eq "remove") { $ind=uninstall(@query);
|
||||||
} elsif ($action =~ /^(isinst|current)$/) { $ind = port_diff($1,@query);
|
} elsif ($action =~ /^(isinst|current)$/) { @results = port_diff($1,@query);
|
||||||
} elsif ($action =~ /(.*)diff$/) { $ind = port_diff($1);
|
} elsif ($action =~ /(.*)diff$/) { @results = port_diff($1);
|
||||||
} elsif ($action =~ /^list(.*)/) { @results = list_ports($1);
|
} elsif ($action =~ /^list(.*)/) { @results = list_ports($1);
|
||||||
} elsif ($action eq "help") { print_help();
|
} elsif ($action eq "help") { print_help();
|
||||||
} elsif ($action eq "version") { print "$title $version\n";
|
} elsif ($action eq "version") { print "$title $version\n";
|
||||||
@ -88,7 +89,7 @@ if ($action =~ /^(listinst|listorphans)/) {
|
|||||||
$result .= " $V_INST{$result}\n$DESC{$result}\n" if $osearch{verbose}>1;
|
$result .= " $V_INST{$result}\n$DESC{$result}\n" if $osearch{verbose}>1;
|
||||||
printf $strf, $result;
|
printf $strf, $result;
|
||||||
}
|
}
|
||||||
} elsif ($action =~ /^(list|search|dsearch|path|dependent)/) {
|
} elsif ($action =~ /^(list|search|dsearch|path)/) {
|
||||||
foreach my $result (@results) {
|
foreach my $result (@results) {
|
||||||
next if ((! $result) or ($result =~ /^\s*$/));
|
next if ((! $result) or ($result =~ /^\s*$/));
|
||||||
$result =~ s/.*\/(.*)$/$1/ if (($action ne "path") and ($osearch{path}==0));
|
$result =~ s/.*\/(.*)$/$1/ if (($action ne "path") and ($osearch{path}==0));
|
||||||
@ -104,27 +105,34 @@ if ($action =~ /^(listinst|listorphans)/) {
|
|||||||
@fmatch = split /\s/, $hits{$fh};
|
@fmatch = split /\s/, $hits{$fh};
|
||||||
foreach my $fileN (@fmatch) { printf $strf, $fh, $fileN; }
|
foreach my $fileN (@fmatch) { printf $strf, $fh, $fileN; }
|
||||||
}
|
}
|
||||||
} elsif ($action =~ /^(diff|quickdiff|current|isinst|dup)$/) {
|
} elsif ($action =~ /^(current|isinst|dup|diff|quickdiff)$/) {
|
||||||
exit $ind;
|
my $format = "%20s %15s %20s\n"; my $ind = shift(@results);
|
||||||
} elsif ($action =~ /^(depends|deptree|quickdep)$/) {
|
if ($action eq "diff") { printf $format, "Port", "Installed", "Available in Repo"; }
|
||||||
print "-- dependencies ([i] = installed, [a] = alias installed)\n" if ($action =~ /^dep/);
|
foreach my $diffline (@results) {
|
||||||
my $indent=($action eq "deptree") ? " " : "";
|
if ($action =~ /^(current|isinst)$/) { print $diffline; next; }
|
||||||
my @installed=keys %V_INST unless ($action eq "quickdep");
|
my ($diffN, $diffI, $diffR) = split(/ /, $diffline);
|
||||||
my %seen; my $strf="%3s %s\n"; my $depline; my $dep; my $missing=0;
|
next if (($osearch{filter}) and ($diffN !~ /$osearch{filter}/));
|
||||||
foreach $depline (@results) {
|
next if ((grep {$_ eq $diffN} @LOCKED) and ($odepends{all}==0));
|
||||||
if ($depline =~ /MISSING/) { $missing=1; print "-- missing packages\n"; next; }
|
printf "$format", $diffN, $diffI, $diffR if ($action eq "diff");
|
||||||
my $cleandep = $depline;
|
printf "%s ", $diffN if ($action eq "quickdiff" and $diffR ne "MISSING!");
|
||||||
$cleandep =~ s/ .satisfies dependency .*// if ($action eq "deptree");
|
}
|
||||||
$dep = (split / /, $cleandep)[-1];
|
print "\n" if ($action eq "quickdiff");
|
||||||
next if ((! $dep) or (($seen{$dep}) and ($odepends{all}==0)));
|
exit $ind;
|
||||||
$seen{$dep}=1;
|
} elsif ($action =~ /^(depends|quickdep)$/) {
|
||||||
|
print "-- dependency list ([i] = installed, [a] = alias installed)\n" if ($action =~ /^dep/);
|
||||||
|
my $strf="%3s %s\n"; my $dep; my $missing=0;
|
||||||
|
foreach $dep (@results) {
|
||||||
|
if ($dep =~ /MISSING/) { $missing=1; print "-- missing packages\n"; next; }
|
||||||
|
next if (! $dep); my $alias;
|
||||||
if ($action ne "quickdep") {
|
if ($action ne "quickdep") {
|
||||||
$ind = (grep { $_ eq $dep } @installed) ? "[i]" : "[ ]";
|
$ind = (grep { $_ eq $dep } keys %V_INST) ? "[i]" : "[ ]";
|
||||||
$ind = ($depline =~ / .satisfies dependency /) ? "[a]" : $ind;
|
$alias = who_aliased_to($dep);
|
||||||
|
$ind = ((! $V_INST{$dep}) and ($alias)) ? "[a]" : $ind;
|
||||||
|
$dep .= " (provided by $alias)" if ($ind eq "[a]");
|
||||||
|
$dep .= " $V_REPO{$dep}" if (($osearch{verbose}==1) and ($ind ne "[a]"));
|
||||||
|
$dep .= " $V_REPO{$dep}\n$DESC{$dep}" if (($osearch{verbose}>1) and ($ind ne "[a]"));
|
||||||
}
|
}
|
||||||
$depline .= " $V_REPO{$dep}" if $osearch{verbose}==1;
|
printf $strf, $ind, $dep unless ($action eq "quickdep");
|
||||||
$depline .= " $V_REPO{$dep}\n$DESC{$dep}" if $osearch{verbose}>1;
|
|
||||||
printf $strf, $ind, $depline unless ($action eq "quickdep");
|
|
||||||
printf "%s ", $dep if ($action eq "quickdep");
|
printf "%s ", $dep if ($action eq "quickdep");
|
||||||
}
|
}
|
||||||
print "\n" if ($action eq "quickdep");
|
print "\n" if ($action eq "quickdep");
|
||||||
@ -132,20 +140,20 @@ if ($action =~ /^(listinst|listorphans)/) {
|
|||||||
$strf = "%14s: %-s\n";
|
$strf = "%14s: %-s\n";
|
||||||
exit 1 if ($#results < 0);
|
exit 1 if ($#results < 0);
|
||||||
my @fields = ("Name", "Repository", "Version", "Release", "Description",
|
my @fields = ("Name", "Repository", "Version", "Release", "Description",
|
||||||
"Dependencies", "Optional Deps", "URL", "Packager", "Maintainer",
|
"Dependencies", "URL", "Optional Deps", "Maintainer",
|
||||||
"Readme", "PreInstall", "PostInstall");
|
"Readme", "PreInstall", "PostInstall");
|
||||||
for (my $i=0; $i<6; $i++) { printf $strf, $fields[$i], $results[$i]; }
|
for (my $i=0; $i<9; $i++) { printf $strf, $fields[$i], $results[$i]; }
|
||||||
printf $strf, $fields[7], $results[7];
|
|
||||||
printf $strf, $fields[9], $results[9];
|
|
||||||
} elsif ($action eq "remove") {
|
} elsif ($action eq "remove") {
|
||||||
my %removed = %$ind;
|
my %removed = %$ind;
|
||||||
my @successes = grep { $removed{$_}==1 } keys %removed;
|
my @successes = grep { $removed{$_}==1 } keys %removed;
|
||||||
my @failures = grep { $removed{$_}==0 } keys %removed;
|
my @failures = grep { $removed{$_}==0 } keys %removed;
|
||||||
print "Ports removed:\n" if (@successes);
|
print "Ports removed:\n" if (@successes);
|
||||||
foreach my $p (@successes) { print "$p\n"; }
|
foreach my $p (@successes) { print "$p\n"; }
|
||||||
} elsif ($action =~ /^(install|update|depinst|grpinst|sysup)$/) {
|
} elsif ($action =~ /^(install|update|depinst|sysup)$/) {
|
||||||
my @ok = @{$results[0]}; my @ok_pre = @{$results[1]}; my @ok_post = @{$results[2]};
|
my @ok = @{$results[0]}; my @ok_pre = @{$results[1]}; my @ok_post = @{$results[2]};
|
||||||
my @ok_readme = @{$results[3]}; my @not_ok = @{$results[4]}; my $note;
|
my @ok_readme = @{$results[3]}; my @not_ok = @{$results[4]}; my $note;
|
||||||
|
if ($opkg{test} eq "yes") { print "\n$action successful.\n";
|
||||||
|
print "*** prt-auf: test mode end\n\n"; }
|
||||||
if (($opkg{test} eq "no") and (@ok)) {
|
if (($opkg{test} eq "no") and (@ok)) {
|
||||||
print "Successful ports:\n";
|
print "Successful ports:\n";
|
||||||
foreach my $k (@ok) {
|
foreach my $k (@ok) {
|
||||||
@ -156,12 +164,12 @@ if ($action =~ /^(listinst|listorphans)/) {
|
|||||||
}
|
}
|
||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
if (($opkg{test} eq "no") and (@ok_readme)) {
|
if (@ok_readme) {
|
||||||
print "Successful ports with README files:\n";
|
print "Ports with README files:\n";
|
||||||
foreach (@ok_readme) { print " $_\n"; }
|
foreach (@ok_readme) { print " $_\n"; }
|
||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
if (($opkg{test} eq "no") and (@not_ok)) {
|
if (@not_ok) {
|
||||||
print "Ports with pkgmk/pkgadd failures:\n";
|
print "Ports with pkgmk/pkgadd failures:\n";
|
||||||
foreach (@not_ok) { print " $_\n"; }
|
foreach (@not_ok) { print " $_\n"; }
|
||||||
print "\n";
|
print "\n";
|
||||||
@ -175,10 +183,13 @@ sub parse_args {
|
|||||||
my @query;
|
my @query;
|
||||||
while (my $arg = shift) {
|
while (my $arg = shift) {
|
||||||
if ($arg =~ /^(search|dsearch|fsearch|path|info|list|remove)$/) { $action = $1;
|
if ($arg =~ /^(search|dsearch|fsearch|path|info|list|remove)$/) { $action = $1;
|
||||||
} elsif ($arg =~ /^(install|update|depinst|grpinst|sysup)$/) { $action = $1;
|
} elsif ($arg =~ /^(install|update|depinst|sysup)$/) { $action = $1;
|
||||||
|
} elsif ($arg eq "grpinst") { $action = "install"; $opkg{group} = "yes";
|
||||||
|
print "Warning: grpinst is obsolescent, using install --group\n";
|
||||||
} elsif ($arg =~ /^(lock|unlock|listlocked|current|isinst)$/) { $action = $1;
|
} elsif ($arg =~ /^(lock|unlock|listlocked|current|isinst)$/) { $action = $1;
|
||||||
} elsif ($arg =~ /^(diff|quickdiff|printf|listinst|listorphans)$/) { $action = $1;
|
} elsif ($arg =~ /^(diff|quickdiff|printf|listinst|listorphans)$/) { $action = $1;
|
||||||
} elsif ($arg =~ /^(depends|deptree|quickdep|dependent|dup)$/) { $action = $1;
|
} elsif ($arg =~ /^(depends|quickdep|dup|dependent)$/) { $action = $1;
|
||||||
|
} elsif ($arg eq "deptree") { $action = $arg; $odepends{tree} = 1;
|
||||||
} elsif ($arg =~ /^(readme|cat|edit|ls|help|version|cache)$/) { $action = $1;
|
} elsif ($arg =~ /^(readme|cat|edit|ls|help|version|cache)$/) { $action = $1;
|
||||||
} elsif ($arg eq "--tree") { $odepends{tree} = 1;
|
} elsif ($arg eq "--tree") { $odepends{tree} = 1;
|
||||||
} elsif ($arg eq "--all") { $odepends{all} = 1;
|
} elsif ($arg eq "--all") { $odepends{all} = 1;
|
||||||
@ -192,6 +203,7 @@ sub parse_args {
|
|||||||
} elsif ($arg eq "-v") { $osearch{verbose} += 1;
|
} elsif ($arg eq "-v") { $osearch{verbose} += 1;
|
||||||
} elsif ($arg eq "-vv") { $osearch{verbose} += 2;
|
} elsif ($arg eq "-vv") { $osearch{verbose} += 2;
|
||||||
} elsif ($arg eq "--test") { $opkg{test} = "yes";
|
} elsif ($arg eq "--test") { $opkg{test} = "yes";
|
||||||
|
} elsif ($arg eq "--group") { $opkg{group} = "yes";
|
||||||
} elsif ($arg eq "-fr") { $opkg{margs} .= " -f";
|
} elsif ($arg eq "-fr") { $opkg{margs} .= " -f";
|
||||||
} elsif ($arg =~ /^(-uf|-if|-us|-is|-ns|-kw)$/) { $opkg{margs} .= " $1";
|
} elsif ($arg =~ /^(-uf|-if|-us|-is|-ns|-kw)$/) { $opkg{margs} .= " $1";
|
||||||
} elsif ($arg =~ /^--margs=(.+)/) { $opkg{margs} .= $1;
|
} elsif ($arg =~ /^--margs=(.+)/) { $opkg{margs} .= $1;
|
||||||
@ -219,7 +231,7 @@ sub parse_args {
|
|||||||
print "$1 requires exactly one argument.\n"; exit 1;
|
print "$1 requires exactly one argument.\n"; exit 1;
|
||||||
}
|
}
|
||||||
if (($#query < 0) and
|
if (($#query < 0) and
|
||||||
($action =~ /^(install|update|depinst|grpinst|remove)$/)) {
|
($action =~ /^(install|update|depinst|remove)$/)) {
|
||||||
print "$1 requires at least one argument.\n"; exit 1;
|
print "$1 requires at least one argument.\n"; exit 1;
|
||||||
}
|
}
|
||||||
return $action, @query;
|
return $action, @query;
|
||||||
@ -312,8 +324,8 @@ sub who_aliased_to {
|
|||||||
sub printf_ports {
|
sub printf_ports {
|
||||||
my $FS; my @pstats; my $p; my $inputf=shift; my @targets=@_;
|
my $FS; my @pstats; my $p; my $inputf=shift; my @targets=@_;
|
||||||
my @pos; my @outfields; my $outputf; my %FS = ( "t"=>"\t", "n"=>"\n" );
|
my @pos; my @outfields; my $outputf; my %FS = ( "t"=>"\t", "n"=>"\n" );
|
||||||
my %subscripts = ( "n"=>0, "p"=>1, "v"=>2, "r"=>3, "d"=>4, "o"=>5, "e"=>6,
|
my %subscripts = ( "n"=>0, "p"=>1, "v"=>2, "r"=>3, "d"=>4, "u"=>5,
|
||||||
"u"=>7, "P"=>8, "M"=>9, "R"=>10, "E"=>11, "O"=>12, "l"=>13, "i"=>14);
|
"P"=>7, "M"=>8, "R"=>9, "E"=>10, "O"=>11, "l"=>12, "i"=>13);
|
||||||
if ($inputf eq "CACHE") {
|
if ($inputf eq "CACHE") {
|
||||||
open (CACHE,'>',$prtcache) or die "cannot create a new cache file";
|
open (CACHE,'>',$prtcache) or die "cannot create a new cache file";
|
||||||
print CACHE "V5.1\n";
|
print CACHE "V5.1\n";
|
||||||
@ -331,19 +343,19 @@ sub printf_ports {
|
|||||||
foreach (@outfields) {
|
foreach (@outfields) {
|
||||||
if (m/\\(t|n)/) { $outputf .= $FS{$1}; next; }
|
if (m/\\(t|n)/) { $outputf .= $FS{$1}; next; }
|
||||||
$strf = $_;
|
$strf = $_;
|
||||||
s/%(p|n|v|r|d|o|e|u|P|M|R|E|O|l|i)/_Z_$subscripts{$1}/g;
|
s/%(p|n|v|r|d|u|P|M|R|E|O|l|i)/_Z_$subscripts{$1}/g;
|
||||||
push @pos, grep { s/([0-9]+)(.*)/$1/ } (split /_Z_/, $_);
|
push @pos, grep { s/([0-9]+)(.*)/$1/ } (split /_Z_/, $_);
|
||||||
$strf =~ s/%(p|n|v|r|d|o|e|u|P|M|R|E|O|l|i)/%s/g;
|
$strf =~ s/%(p|n|v|r|d|u|P|M|R|E|O|l|i)/%s/g;
|
||||||
$outputf .= $strf;
|
$outputf .= $strf;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $pp (@targets) {
|
foreach my $pp (@targets) {
|
||||||
$p = (split /\//, $pp)[-1];
|
$p = (split /\//, $pp)[-1];
|
||||||
@pstats = get_pkgfile_fields($pp,"all");
|
@pstats = get_pkgfile_fields($pp,"all");
|
||||||
$pstats[13] = (grep /^$p$/, @LOCKED) ? "yes" : "no";
|
$pstats[12] = (grep /^$p$/, @LOCKED) ? "yes" : "no";
|
||||||
$pstats[14] = (grep /^$p$/, keys %V_INST) ? "yes" : "no";
|
$pstats[13] = (grep /^$p$/, keys %V_INST) ? "yes" : "no";
|
||||||
if (($pstats[14] eq "yes") and ($V_INST{$p} ne $V_REPO{$p})) {
|
if (($pstats[13] eq "yes") and ($V_INST{$p} ne $V_REPO{$p})) {
|
||||||
$pstats[14] = "diff" }
|
$pstats[13] = "diff" }
|
||||||
printf STDOUT $outputf, @pstats[@pos];
|
printf STDOUT $outputf, @pstats[@pos];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,7 +364,10 @@ sub printf_ports {
|
|||||||
sub fill_hashes_from_cache {
|
sub fill_hashes_from_cache {
|
||||||
open (my $cf,$prtcache) or die "cannot use $prtcache as a cache!\n";
|
open (my $cf,$prtcache) or die "cannot use $prtcache as a cache!\n";
|
||||||
my $p; my $parent; my $deps; my $softDeps;
|
my $p; my $parent; my $deps; my $softDeps;
|
||||||
my $ignored=<$cf>; # first line only contains the cache format version
|
my $ignored=<$cf>; chomp($ignored);
|
||||||
|
if ($ignored ne "$cache_ver") {
|
||||||
|
die "incompatible cache format; regenerate by running $0 cache";
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
$p = <$cf>; last unless defined $p;
|
$p = <$cf>; last unless defined $p;
|
||||||
@ -360,13 +375,12 @@ sub fill_hashes_from_cache {
|
|||||||
push @allports, "$parent/$p";
|
push @allports, "$parent/$p";
|
||||||
$V_REPO{$p} = <$cf>; chomp($V_REPO{$p});
|
$V_REPO{$p} = <$cf>; chomp($V_REPO{$p});
|
||||||
$V_REPO{$p} .= "-".<$cf>; $DESC{$p} = <$cf>;
|
$V_REPO{$p} .= "-".<$cf>; $DESC{$p} = <$cf>;
|
||||||
$deps = <$cf>; $softDeps = <$cf>;
|
$deps = <$cf>; $ignored=<$cf>; $softDeps = <$cf>;
|
||||||
chomp($deps, $softDeps, $DESC{$p}, $V_REPO{$p});
|
chomp($deps, $softDeps, $DESC{$p}, $V_REPO{$p});
|
||||||
$DEPENDS{$p} = $deps;
|
$DEPENDS{$p} = $deps; $SOFTDEPS{$p} = $softDeps;
|
||||||
$SOFTDEPS{$p} = $softDeps;
|
|
||||||
$DEPENDS{$p} =~ s/, / /g; $DEPENDS{$p} =~ s/,/ /g;
|
$DEPENDS{$p} =~ s/, / /g; $DEPENDS{$p} =~ s/,/ /g;
|
||||||
$SOFTDEPS{$p} =~ s/, / /g; $SOFTDEPS{$p} =~ s/,/ /g;
|
$SOFTDEPS{$p} =~ s/, / /g; $SOFTDEPS{$p} =~ s/,/ /g;
|
||||||
for (my $i=7; $i<14; $i++) { $ignored = <$cf>; }
|
for (my $i=8; $i<13; $i++) { $ignored = <$cf>; }
|
||||||
}
|
}
|
||||||
close ($cf);
|
close ($cf);
|
||||||
}
|
}
|
||||||
@ -389,7 +403,7 @@ sub fill_hashes_from_pkgfiles {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub get_pkgfile_fields {
|
sub get_pkgfile_fields {
|
||||||
my ($descrip, $url, $maintainer, $packager, $Version, $Release)=('','','','','',0,0);
|
my ($descrip, $url, $maintainer, $Version, $Release)=('','','',0,0);
|
||||||
my ($readme, $preInstall, $postInstall, $Dependencies, $SoftDeps)=("no","no","no",'','');
|
my ($readme, $preInstall, $postInstall, $Dependencies, $SoftDeps)=("no","no","no",'','');
|
||||||
my $portpath = shift; my $Name = (split /\//, $portpath)[-1];
|
my $portpath = shift; my $Name = (split /\//, $portpath)[-1];
|
||||||
my $pkgfile = "$portpath/Pkgfile";
|
my $pkgfile = "$portpath/Pkgfile";
|
||||||
@ -408,7 +422,6 @@ sub get_pkgfile_fields {
|
|||||||
elsif (s/^release=(.*)/$1/) { $Release = $_; }
|
elsif (s/^release=(.*)/$1/) { $Release = $_; }
|
||||||
elsif (s/^# Depends on:\s*(.*)/$1/) { $Dependencies = $_; }
|
elsif (s/^# Depends on:\s*(.*)/$1/) { $Dependencies = $_; }
|
||||||
elsif (s/^# (Optional|Nice to have):\s*(.*)/$2/) { $SoftDeps = $_; }
|
elsif (s/^# (Optional|Nice to have):\s*(.*)/$2/) { $SoftDeps = $_; }
|
||||||
elsif (s/^# Packager:\s*(.*)/$1/) { $packager = $_; }
|
|
||||||
elsif (s/^# Maintainer:\s*(.*)/$1/) { $maintainer = $_; }
|
elsif (s/^# Maintainer:\s*(.*)/$1/) { $maintainer = $_; }
|
||||||
else {}
|
else {}
|
||||||
} close(PF);
|
} close(PF);
|
||||||
@ -417,7 +430,7 @@ sub get_pkgfile_fields {
|
|||||||
$SoftDeps =~ s/, / /g; $SoftDeps =~ s/,/ /g;
|
$SoftDeps =~ s/, / /g; $SoftDeps =~ s/,/ /g;
|
||||||
if (shift) {
|
if (shift) {
|
||||||
return $Name, $portpath, $Version, $Release, $descrip, $Dependencies,
|
return $Name, $portpath, $Version, $Release, $descrip, $Dependencies,
|
||||||
$SoftDeps, $url, $packager, $maintainer, $readme, $preInstall, $postInstall;
|
$url, $SoftDeps, $maintainer, $readme, $preInstall, $postInstall;
|
||||||
} else { return $Version, $Release, $descrip, $Dependencies, $SoftDeps; }
|
} else { return $Version, $Release, $descrip, $Dependencies, $SoftDeps; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,7 +513,6 @@ sub port_unlock {
|
|||||||
|
|
||||||
sub list_ports {
|
sub list_ports {
|
||||||
my @found; my $subset = shift;
|
my @found; my $subset = shift;
|
||||||
our $indent="0 "; our $height=0; our @descendants=(); our @outfile;
|
|
||||||
|
|
||||||
if (! $subset) { # empty arg: list all valid ports
|
if (! $subset) { # empty arg: list all valid ports
|
||||||
foreach my $collection (@basedirs) {
|
foreach my $collection (@basedirs) {
|
||||||
@ -515,13 +527,13 @@ sub list_ports {
|
|||||||
}
|
}
|
||||||
} elsif ($subset eq "inst") { @found = keys %V_INST;
|
} elsif ($subset eq "inst") { @found = keys %V_INST;
|
||||||
} elsif ($subset eq "locked") { @found=@LOCKED;
|
} elsif ($subset eq "locked") { @found=@LOCKED;
|
||||||
} elsif ($subset =~ /^(orphans|dependent)$/) {
|
} elsif ($subset =~ /^(orphans|dependent|deptree)$/) {
|
||||||
my $seed; my $sseed;
|
my $seed; my $sseed;
|
||||||
our @searchspace=(($subset eq "orphans") or ($odepends{all}==0)) ?
|
our @searchspace=(($subset ne "orphans") and ($odepends{all} != 0)) ?
|
||||||
keys %V_INST : keys %DEPENDS;
|
keys %V_REPO : keys %V_INST;
|
||||||
@searchspace = grep { defined $DEPENDS{$_} } @searchspace;
|
@searchspace = grep { defined $DEPENDS{$_} } @searchspace;
|
||||||
|
|
||||||
if ($subset eq "dependent") {
|
if ($subset =~ /^dep/) {
|
||||||
$seed=shift; $sseed = $seed;
|
$seed=shift; $sseed = $seed;
|
||||||
if (! find_port_by_name($seed,1,1,0)) {
|
if (! find_port_by_name($seed,1,1,0)) {
|
||||||
print "$seed not found in the ports tree.\n"; return;
|
print "$seed not found in the ports tree.\n"; return;
|
||||||
@ -531,10 +543,12 @@ sub list_ports {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($subset eq "orphans") {
|
if ($subset eq "orphans") {
|
||||||
my %not_orphans = map { $_ => 0 } keys %V_INST; my @ndd;
|
my %not_orphans = map { $_ => 0 } keys %V_INST;
|
||||||
foreach my $port (@searchspace) {
|
foreach my $port (@searchspace) {
|
||||||
@ndd=split(/ /, $DEPENDS{$port});
|
map { $not_orphans{$_} = 1 } split(/ /, $DEPENDS{$port});
|
||||||
map { $not_orphans{$_} = 1 } @ndd;
|
if ($odepends{soft} == 1) {
|
||||||
|
map { $not_orphans{$_} = 1 } split(/ /, $SOFTDEPS{$port});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@found = grep { $not_orphans{$_} eq 0 } keys %V_INST;
|
@found = grep { $not_orphans{$_} eq 0 } keys %V_INST;
|
||||||
} elsif (($subset eq "dependent") and ($odepends{recursive}==0)) {
|
} elsif (($subset eq "dependent") and ($odepends{recursive}==0)) {
|
||||||
@ -542,62 +556,81 @@ sub list_ports {
|
|||||||
if ($odepends{tree}==1) {
|
if ($odepends{tree}==1) {
|
||||||
@found = grep { s/^/ / } @found; unshift (@found, "$seed");
|
@found = grep { s/^/ / } @found; unshift (@found, "$seed");
|
||||||
}
|
}
|
||||||
} elsif (($subset eq "dependent") and ($odepends{recursive}==1)) {
|
} elsif ($subset =~ /^dep(endent|tree)/) {
|
||||||
push @outfile, "$seed";
|
our $direction = ($subset eq "deptree") ? "fwd" : "rev";
|
||||||
|
my $header = (($subset eq "deptree") and ($odepends{tree} == 1)) ?
|
||||||
|
"-- dependencies ([i] = installed, '-->' = already shown)\n":
|
||||||
|
"-- reverse dependencies ('-->' = already shown)\n";
|
||||||
|
if (($subset eq "deptree") and ($odepends{soft} == 1)) {
|
||||||
|
$header =~ s/installed,/installed, [s] = installed softdep,/;
|
||||||
|
}
|
||||||
|
print $header unless ($odepends{tree} == 0);
|
||||||
|
|
||||||
my @children = grep { " $DEPENDS{$_} " =~ / $sseed / } @searchspace;
|
our $indent=" "; our $height=0;
|
||||||
foreach my $sd (@children) { recurse_offtree($sd); }
|
our $ind; our %seen; our @lineage; my @fosters=();
|
||||||
|
$ind = ($V_INST{$seed}) ? "[i]" : "[ ]";
|
||||||
sub recurse_offtree {
|
print "$ind $seed\n" if (($odepends{tree}==1) or ($odepends{all}==1));
|
||||||
my $s = shift; push @outfile, (${indent}x(1+$height))."$s";
|
$seen{$seed} = 1;
|
||||||
my @offspring = grep { " $DEPENDS{$_} " =~ / $s / } @searchspace;
|
my @children = ($subset eq "deptree") ? split /[ ,]/, $DEPENDS{$sseed}:
|
||||||
foreach my $dc (@offspring) {
|
grep { " $DEPENDS{$_} " =~ / $sseed / } @searchspace;
|
||||||
if (grep /^$dc$/, @descendants) {
|
if ($odepends{soft}==1) {
|
||||||
print "Warning: cyclic dependencies found!\n";
|
@fosters = ($subset eq "deptree") ?
|
||||||
return;
|
grep { ($V_INST{$_}) } split /[ ,]/, $SOFTDEPS{$sseed}:
|
||||||
}
|
grep { " $SOFTDEPS{$_} " =~ / $sseed / } @searchspace;
|
||||||
push (@descendants, $dc);
|
|
||||||
$height = 1+$#descendants;
|
|
||||||
recurse_offtree($dc);
|
|
||||||
pop(@descendants);
|
|
||||||
$height = 1+$#descendants;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my %seen;
|
foreach my $sd (@children) { recurse_tree(0,$sd,$direction); }
|
||||||
@outfile = grep { !m/^\s*$/ } @outfile;
|
foreach my $sd (@fosters) { recurse_tree(1,$sd,$direction); }
|
||||||
@outfile = sort(@outfile) unless ($odepends{tree}==1);
|
|
||||||
@found = ($odepends{tree}==1) ? grep { s/0 / /g } @outfile :
|
sub recurse_tree {
|
||||||
grep !$seen{$_}++, grep { s/0 //g } grep { /0 / } @outfile ;
|
my $greedy = shift; my $s = shift; my $direction=shift;
|
||||||
unshift (@found, $seed) if ($odepends{tree}==1);
|
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 unless ($odepends{tree}==0);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $dc (keys %curdeps) {
|
||||||
|
if (grep /^$dc$/, @lineage) {
|
||||||
|
print "Warning: dependency cycle => ".$dc."\n" unless ($greedy|$curdeps{$dc});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
push (@lineage, $dc);
|
||||||
|
$height = $#lineage+1;
|
||||||
|
recurse_tree($greedy|$curdeps{$dc},$dc,$direction);
|
||||||
|
pop(@lineage);
|
||||||
|
$height = $#lineage+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@found = sort(keys %seen);
|
||||||
}
|
}
|
||||||
# possibilities for the recursive switch have been exhausted
|
# possibilities for the recursive switch have been exhausted
|
||||||
else { }
|
else { }
|
||||||
} # possibilities for the filter have been exhausted
|
} # possibilities for the filter have been exhausted
|
||||||
else { }
|
else { }
|
||||||
@found = sort(@found) unless (($subset) and ($subset eq "dependent") and ($odepends{tree}==1));
|
return @found if ((! $subset) or ($subset =~ /^(orphans|locked)$/));
|
||||||
return @found if ((! $subset) or ($subset =~ /^(orphans|dependent|locked)$/));
|
|
||||||
if (! $osearch{filter}) { return @found; }
|
if (! $osearch{filter}) { return @found; }
|
||||||
else { return grep {$_ !~ /$osearch{filter}/} @found; }
|
else { return grep {$_ !~ /$osearch{filter}/} @found; }
|
||||||
}
|
}
|
||||||
|
|
||||||
sub port_diff { # returns a scalar indicating how many differences were found
|
sub port_diff { # returns a list of all the ports with differences
|
||||||
my $dtype=shift; my $lastcol;
|
my $dtype=shift; my @argq=@_; my @outfile=(); my $retval=0;
|
||||||
my @argq=@_; my $retval=0; my $format="%30s %20s %20s\n";
|
|
||||||
|
|
||||||
if ($dtype !~ /^(current|isinst|utd)/) {
|
if ($dtype !~ /^(current|isinst|utd)/) {
|
||||||
printf "$format", "Port", "Installed", "In Repository" if (! $dtype);
|
|
||||||
foreach my $p (sort(keys %V_INST)) {
|
foreach my $p (sort(keys %V_INST)) {
|
||||||
next if (($osearch{filter}) and ($p !~ /$osearch{filter}/));
|
push @outfile, "$p $V_INST{$p} $V_REPO{$p}" if (($V_REPO{$p}) and ($V_INST{$p} ne $V_REPO{$p}));
|
||||||
next if ((grep /$p/, @LOCKED) and ($odepends{all}==0));
|
push @outfile, "$p $V_INST{$p} MISSING" if (! $V_REPO{$p});
|
||||||
$lastcol = ($V_REPO{$p}) ? $V_REPO{$p} : "MISSING!";
|
|
||||||
|
|
||||||
if ($lastcol ne $V_INST{$p}) {
|
|
||||||
printf "$format", $p, $V_INST{$p}, $lastcol if (! $dtype);
|
|
||||||
printf "%s ", $p if ($dtype eq "quick" and $lastcol ne "MISSING!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
printf "\n" if ($dtype eq "quick");
|
|
||||||
} elsif ($dtype eq "utd") {
|
} elsif ($dtype eq "utd") {
|
||||||
while (my $q=shift(@argq) and $retval==0) {
|
while (my $q=shift(@argq) and $retval==0) {
|
||||||
$retval-- if (! $V_INST{$q});
|
$retval-- if (! $V_INST{$q});
|
||||||
@ -606,92 +639,112 @@ sub port_diff { # returns a scalar indicating how many differences were found
|
|||||||
} elsif ($dtype =~ /^(current|isinst)$/) {
|
} elsif ($dtype =~ /^(current|isinst)$/) {
|
||||||
foreach my $q (@argq) {
|
foreach my $q (@argq) {
|
||||||
if (! $V_INST{$q}) {
|
if (! $V_INST{$q}) {
|
||||||
print "$q: not installed\n"; $retval++;
|
push @outfile, "$q: not installed"; $retval++;
|
||||||
} else {
|
} else {
|
||||||
print "$V_INST{$q}\n" if ($dtype eq "current");
|
push @outfile, "$q: version $V_INST{$q}" if ($dtype eq "current");
|
||||||
print "$q is installed.\n" if ($dtype eq "isinst");
|
push @outfile, "$q is installed." if ($dtype eq "isinst");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {}
|
} else {}
|
||||||
return $retval;
|
return $retval, @outfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub deporder {
|
sub deporder {
|
||||||
# returns an indented list if called with first arg "deptree",
|
# returns an annotated list using a variation on depth-first search.
|
||||||
# otherwise returns a flattened list, pruned of duplicates.
|
|
||||||
# Recursion does NOT continue beyond a dependency satisfied by an alias.
|
# Recursion does NOT continue beyond a dependency satisfied by an alias.
|
||||||
|
|
||||||
my $format=shift; our $indent="0 "; our $height=0;
|
our @treewalk=(); our %seen; our @missing; my @seeds=@_; our @results;
|
||||||
our @ancestry=(); our @outfile=(); our @missing; my %seen;
|
our %imark; our %fmark; our $fmarks; my $type=shift;
|
||||||
|
|
||||||
recurse_deptree($odepends{soft},@_);
|
# first strip out all the names not found in the ports collections
|
||||||
|
push @missing, grep { (! $V_REPO{$_}) } @seeds;
|
||||||
|
@seeds = grep { ($V_REPO{$_}) } @seeds;
|
||||||
|
|
||||||
|
# determine the minimal set of targets needed to satisfy all dependencies
|
||||||
|
foreach (@seeds) { recurse_deptree($_) }
|
||||||
|
|
||||||
sub recurse_deptree {
|
sub recurse_deptree {
|
||||||
my $greedy=shift; my @seeds=@_; my %curdeps; my @optionals;
|
my $s=shift; my %curdeps; my @optionals;
|
||||||
push @missing, grep { (! $V_REPO{$_}) } @seeds;
|
|
||||||
@seeds = grep { ($V_REPO{$_}) } @seeds;
|
|
||||||
|
|
||||||
foreach my $s (@seeds) {
|
my $substitute = who_aliased_to($s);
|
||||||
my $substitute = who_aliased_to($s);
|
if ((($substitute) and (! $V_INST{$s})) or ($V_REPO{$s})) {
|
||||||
$s = "$substitute (satisfies dependency $s)" if ($substitute);
|
$seen{$s} = 1;
|
||||||
push @outfile, (${indent}x(1+$height))."$s";
|
} else {
|
||||||
next if ($substitute);
|
push (@missing, $s); return;
|
||||||
|
}
|
||||||
|
return if ($substitute);
|
||||||
|
|
||||||
%curdeps = map { $_ => 0 } split /[ ,]/, $DEPENDS{$s};
|
# cycle detection
|
||||||
# if the user toggles --softdeps, consider only the
|
if (! grep { $_ eq $s } @treewalk) {
|
||||||
# optional dependencies that are already installed
|
push (@treewalk, $s);
|
||||||
if ($odepends{soft}*$greedy == 1) {
|
} else { return; }
|
||||||
|
|
||||||
|
%curdeps = map { $_ => 0 } split /[ ,]/, $DEPENDS{$s};
|
||||||
|
# if the user toggles --softdeps, consider only the
|
||||||
|
# optional dependencies that are already installed
|
||||||
|
if ($odepends{soft} == 1) {
|
||||||
@optionals = grep { ($V_INST{$_}) } split /[ ,]/, $SOFTDEPS{$s};
|
@optionals = grep { ($V_INST{$_}) } split /[ ,]/, $SOFTDEPS{$s};
|
||||||
foreach (@optionals) { $curdeps{$_} = 1 }
|
foreach (@optionals) { $curdeps{$_} = 1 }
|
||||||
}
|
|
||||||
|
|
||||||
SUCCESSOR: foreach my $sd (keys %curdeps) {
|
|
||||||
if (grep /^$sd$/, @ancestry) {
|
|
||||||
if (($greedy|$curdeps{$sd}) == 1) { next SUCCESSOR;
|
|
||||||
} else {
|
|
||||||
print "Warning: cyclic dependency found!\n";
|
|
||||||
print ((join " => ", @ancestry)." => $sd\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
push (@ancestry,$sd);
|
|
||||||
$height = 1+$#ancestry;
|
|
||||||
recurse_deptree($greedy|$curdeps{$sd},$sd);
|
|
||||||
pop @ancestry;
|
|
||||||
$height = 1+$#ancestry;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($format eq "deptree") {
|
foreach my $sd (keys %curdeps) {
|
||||||
@outfile = grep { s/0 / /g; !m/^\s*$/; } @outfile;
|
next if ($seen{$sd});
|
||||||
} else {
|
recurse_deptree($sd);
|
||||||
@outfile = grep { !$seen{$_}++ } (grep
|
}
|
||||||
{ s/0 //g; s/ .satisfies dependency .*//g; !m/^\s*$/; } sort(@outfile));
|
pop (@treewalk);
|
||||||
}
|
}
|
||||||
return @outfile if (($#missing < 0) or ($format eq "quickdep"));
|
|
||||||
return @outfile, "MISSING", @missing if ($#missing >= 0);
|
# proceed with the topological sort
|
||||||
|
my $graphsize = keys %seen; $fmarks = 0;
|
||||||
|
while ($fmarks < $graphsize) {
|
||||||
|
my @unvisited = grep { ! ($fmark{$_}) } keys %seen;
|
||||||
|
my $node = pop @unvisited;
|
||||||
|
visit($node,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub visit {
|
||||||
|
my $node = shift; my $greedy = shift;
|
||||||
|
if ( $fmark{$node} ) { return; }
|
||||||
|
if ( $imark{$node} ) {
|
||||||
|
print "cycle detected!\n" unless ($greedy==1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$imark{$node} = 1;
|
||||||
|
foreach my $dep (split /[ ,]/, $DEPENDS{$node}) { visit($dep,$greedy); }
|
||||||
|
if ( $odepends{soft} == 1 ) {
|
||||||
|
foreach my $sd (grep { ($V_INST{$_}) }
|
||||||
|
split /[ ,]/, $SOFTDEPS{$node}) {
|
||||||
|
visit($sd,1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete $imark{$node};
|
||||||
|
$fmark{$node} = 1;
|
||||||
|
$fmarks = keys %fmark;
|
||||||
|
push (@results, $node);
|
||||||
|
}
|
||||||
|
if (($#missing>-1) and ($type ne "quick")) { push (@results, "MISSING", @missing); }
|
||||||
|
return @results;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub up_inst { # returns scalar references to five arrays
|
sub up_inst { # returns scalar references to five arrays
|
||||||
my $type=shift; my @requested=@_; my @targets; my %EXEMPT; my %WANTED; my %pdirs;
|
my $type=shift; my @requested=@_; my @targets; my %EXEMPT; my %pdirs;
|
||||||
my %builtpkg; my %mkcmd; my %addcmd; my %status; my %logfile; my %pvars;
|
my %builtpkg; my %mkcmd; my %addcmd; my %status; my %logfile; my %pvars;
|
||||||
my $PKGMK=$opkg{makecommand}; my $PKGADD=$opkg{addcommand};
|
my $PKGMK=$opkg{makecommand}; my $PKGADD=$opkg{addcommand};
|
||||||
|
|
||||||
# resolve all dependencies if the command was not 'grpinst',
|
# respect the user-supplied list of ports unless 'depinst' or 'sysup',
|
||||||
# putting glibc{,-32} at the front of the queue
|
# in which case put glibc{,-32} at the front of the queue
|
||||||
if ($type eq "grpinst") {
|
if ($type =~ /^(depinst|sysup)$/) {
|
||||||
@targets=grep { ($V_REPO{$_}) } @requested;
|
@requested = deporder("quick",@requested);
|
||||||
} else {
|
@targets=grep { !m/^glibc(|-32)$/ } @requested;
|
||||||
@targets=grep { !m/^glibc(|-32)$/ } deporder("quickdep", @requested);
|
|
||||||
unshift @targets, grep { m/^glibc(|-32)$/ } @requested;
|
unshift @targets, grep { m/^glibc(|-32)$/ } @requested;
|
||||||
|
} else {
|
||||||
|
@targets=grep { ($V_REPO{$_}) } @requested;
|
||||||
}
|
}
|
||||||
|
|
||||||
# exempt any locked ports from an update operation
|
# exempt any locked ports unless they were explicitly requested
|
||||||
%EXEMPT = map { $_ => 1 } @LOCKED;
|
%EXEMPT = map { $_ => 1 } @LOCKED;
|
||||||
%WANTED = map { $_ => 1 } @requested;
|
if ($type =~ /^(depinst|sysup)$/) {
|
||||||
if ($action =~ /^(update|install|depinst)$/) {
|
@targets = grep {(! $EXEMPT{$_})} @targets;
|
||||||
@targets = grep {(! $EXEMPT{$_}) or ($WANTED{$_})} @targets;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# first determine the directories from which pkgmk must be called,
|
# first determine the directories from which pkgmk must be called,
|
||||||
@ -700,7 +753,7 @@ sub up_inst { # returns scalar references to five arrays
|
|||||||
my ($COMPRESSION, $PKG_DIR) = parse_pkgmk_conf();
|
my ($COMPRESSION, $PKG_DIR) = parse_pkgmk_conf();
|
||||||
foreach my $t (@targets) {
|
foreach my $t (@targets) {
|
||||||
$opkg{$t} = $opkg{margs}; $pvars{'%n'}=$t;
|
$opkg{$t} = $opkg{margs}; $pvars{'%n'}=$t;
|
||||||
$opkg{$t} =~ s/-f// unless ($WANTED{$t});
|
$opkg{$t} =~ s/-f// unless (grep { $_ eq $t } @requested);
|
||||||
$pvars{'%p'} = find_port_by_name($t,1,1,0); $pdirs{$t} = $pvars{'%p'};
|
$pvars{'%p'} = find_port_by_name($t,1,1,0); $pdirs{$t} = $pvars{'%p'};
|
||||||
($pvars{'%v'}, $pvars{'%r'}) = (get_pkgfile_fields($pvars{'%p'}))[0,1];
|
($pvars{'%v'}, $pvars{'%r'}) = (get_pkgfile_fields($pvars{'%p'}))[0,1];
|
||||||
$builtpkg{$t} = ($PKG_DIR) ? "$PKG_DIR/$t#$pvars{'%v'}-$pvars{'%r'}.pkg.tar.$COMPRESSION" : "$pvars{'%p'}/$t#$pvars{'%v'}-$pvars{'%r'}.pkg.tar.$COMPRESSION";
|
$builtpkg{$t} = ($PKG_DIR) ? "$PKG_DIR/$t#$pvars{'%v'}-$pvars{'%r'}.pkg.tar.$COMPRESSION" : "$pvars{'%p'}/$t#$pvars{'%v'}-$pvars{'%r'}.pkg.tar.$COMPRESSION";
|
||||||
@ -716,40 +769,47 @@ sub up_inst { # returns scalar references to five arrays
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($opkg{test} eq "yes") { print("*** prt-auf $type: test mode\n\n");
|
||||||
|
print "-- Packages changed\n"; }
|
||||||
|
|
||||||
# build each package, unless already installed or satisfied by an alias
|
# build each package, unless already installed or satisfied by an alias
|
||||||
foreach my $t (@targets) {
|
BUILDLOG: foreach my $t (@targets) {
|
||||||
if (who_aliased_to($t)) {
|
if (who_aliased_to($t)) {
|
||||||
$mkcmd{$t} = "echo \"skipped build ($t provided by an alias)\"";
|
$mkcmd{$t} = "echo \"skipped build ($t provided by an alias)\"";
|
||||||
} else {
|
} else {
|
||||||
$mkcmd{$t} = "echo \"skipped build ($t up to date)\"" if ((-f $builtpkg{$t}) and
|
$mkcmd{$t} = "echo \"skipped build ($t up to date)\"" if
|
||||||
((-M $builtpkg{$t}) < (-M "$pdirs{$t}/Pkgfile")) and ($opkg{$t} !~ /-f/));
|
((-f $builtpkg{$t}) and ($opkg{$t} !~ /-f/))
|
||||||
$mkcmd{$t} = "" if ((port_diff("utd",$t)==0) and !($WANTED{$t}));
|
and ((-M $builtpkg{$t}) < (-M "$pdirs{$t}/Pkgfile"));
|
||||||
$mkcmd{$t} = "" if (($V_INST{$t}) and ($type =~ /^(install|depinst)$/) and ($opkg{$t} !~ /-f/));
|
$mkcmd{$t} = "" if (($opkg{$t} !~ /-f/) and ($V_REPO{$t} eq $V_INST{$t}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mkcmd{$t}) {
|
if ($opkg{test} eq "yes") {
|
||||||
|
print("$t\n") if ($mkcmd{$t} ne "");
|
||||||
|
next BUILDLOG;
|
||||||
|
}
|
||||||
|
if ($mkcmd{$t} ne "") {
|
||||||
if ((-f "$pdirs{$t}/pre-install") and ($opkg{runscripts} eq "yes")) {
|
if ((-f "$pdirs{$t}/pre-install") and ($opkg{runscripts} eq "yes")) {
|
||||||
system("sh","$pdirs{$t}/pre-install") unless ($opkg{test} eq "yes");
|
system("sh","$pdirs{$t}/pre-install");
|
||||||
$status{$t} .= ( $?>>8 == 0 ) ? "pre-install ok. " : "pre-install failed. ";
|
$status{$t} .= ( $?>>8 == 0 ) ? "pre-install ok. " : "pre-install failed. ";
|
||||||
}
|
}
|
||||||
($opkg{test} eq "no") ? chdir $pdirs{$t} : print "cd $pdirs{$t}\n";
|
chdir $pdirs{$t}; system("$mkcmd{$t}");
|
||||||
($opkg{test} eq "no") ? system("$mkcmd{$t}") : print "$mkcmd{$t}\n";
|
|
||||||
$status{$t} .= ( $?>>8 == 0 ) ? "build ok. " : "build failed. " unless ($logfile{$t});
|
$status{$t} .= ( $?>>8 == 0 ) ? "build ok. " : "build failed. " unless ($logfile{$t});
|
||||||
$status{$t} .= (! log_failure($logfile{$t})) ? "build ok. " : "build failed. " if ($logfile{$t});
|
$status{$t} .= (! log_failure($logfile{$t})) ? "build ok. " : "build failed. " if ($logfile{$t});
|
||||||
$status{$t} = ( $mkcmd{$t} =~ /skipped/ ) ? "build skipped. " : $status{$t};
|
$status{$t} = ( $mkcmd{$t} =~ /skipped/ ) ? "build skipped. " : $status{$t};
|
||||||
if (($status{$t} =~ /build ok/) or ($mkcmd{$t} =~ /up to date/)) {
|
if (($status{$t} =~ /build ok/) or ($mkcmd{$t} =~ /up to date/)) {
|
||||||
$addcmd{$t} =~ s/ -u / / if (port_diff("utd",$t)<0);
|
$addcmd{$t} =~ s/ -u / / if (port_diff("utd",$t)<0);
|
||||||
($opkg{test} eq "no") ? system("$addcmd{$t}") : print "$addcmd{$t}\n";
|
system("$addcmd{$t}");
|
||||||
$status{$t} .= ( $?>>8 == 0 ) ? "pkgadd ok. " : "pkgadd failed. ";
|
$status{$t} .= ( $?>>8 == 0 ) ? "pkgadd ok. " : "pkgadd failed. ";
|
||||||
unlink($logfile{$t}) if (($logfile{$t}) and ($olog{rm_on_success} eq "yes"));
|
unlink($logfile{$t}) if (($status{$t} =~ /ok. $/) and
|
||||||
|
($logfile{$t}) and ($olog{rm_on_success} eq "yes"));
|
||||||
}
|
}
|
||||||
if (($status{$t} =~ /pkgadd ok/) and (-f "$pdirs{$t}/post-install")
|
if (($status{$t} =~ /pkgadd ok/) and (-f "$pdirs{$t}/post-install")
|
||||||
and ($opkg{runscripts} eq "yes")) {
|
and ($opkg{runscripts} eq "yes")) {
|
||||||
system("sh","$pdirs{$t}/post-install") unless ($opkg{test} eq "yes");
|
system("sh","$pdirs{$t}/post-install");
|
||||||
$status{$t} .= ( $?>>8 == 0 ) ? "post-install ok. " : "post-install failed. ";
|
$status{$t} .= ( $?>>8 == 0 ) ? "post-install ok. " : "post-install failed. ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
last if (($status{$t} =~ /failed/) and ($type eq "grpinst"));
|
last if (($status{$t} =~ /failed/) and ($opkg{group} eq "yes"));
|
||||||
}
|
}
|
||||||
|
|
||||||
sub log_failure {
|
sub log_failure {
|
||||||
@ -759,24 +819,14 @@ sub up_inst { # returns scalar references to five arrays
|
|||||||
close(FH); return $failed;
|
close(FH); return $failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
my @ok = grep { $status{$_} =~ /pkgadd ok/ } @targets;
|
|
||||||
my @ok_pre = grep { $status{$_} =~ /pre-install ok/ } @targets;
|
|
||||||
my @ok_post = grep { $status{$_} =~ /post-install ok/ } @ok;
|
|
||||||
my @ok_readme = grep -f $pdirs{$_}."/README", @ok;
|
|
||||||
my @not_ok = grep { $status{$_} =~ /(pkgadd|build) failed/ } @targets;
|
my @not_ok = grep { $status{$_} =~ /(pkgadd|build) failed/ } @targets;
|
||||||
|
my @ok = grep { $status{$_} !~ /(pkgadd|build) failed/ } @targets;
|
||||||
|
my @ok_pre = grep { $status{$_} !~ /pre-install failed/ } @targets;
|
||||||
|
my @ok_post = grep { $status{$_} !~ /post-install failed/ } @ok;
|
||||||
|
my @ok_readme = grep -f $pdirs{$_}."/README", @ok;
|
||||||
return \@ok, \@ok_pre, \@ok_post, \@ok_readme, \@not_ok;
|
return \@ok, \@ok_pre, \@ok_post, \@ok_readme, \@not_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub sysup {
|
|
||||||
my @targets; my $v_repo;
|
|
||||||
foreach my $p (keys %V_INST) {
|
|
||||||
next if grep /^$p$/, @LOCKED;
|
|
||||||
$v_repo = ($V_REPO{$p}) ? $V_REPO{$p} : "MISSING" ;
|
|
||||||
push @targets, $p if (($v_repo ne $V_INST{$p}) and ($v_repo ne "MISSING"));
|
|
||||||
}
|
|
||||||
return up_inst("sysup",@targets);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub parse_pkgmk_conf {
|
sub parse_pkgmk_conf {
|
||||||
my $CONF="/etc/pkgmk.conf"; my $COMPRESSION; my $PKG_DIR="";
|
my $CONF="/etc/pkgmk.conf"; my $COMPRESSION; my $PKG_DIR="";
|
||||||
|
|
||||||
@ -850,9 +900,8 @@ DIFFERENCES / DEPENDENCIES
|
|||||||
dependent <port> show installed packages which depend on <port>
|
dependent <port> show installed packages which depend on <port>
|
||||||
|
|
||||||
INSTALL, UPDATE and REMOVAL
|
INSTALL, UPDATE and REMOVAL
|
||||||
install [opt] <port1 port2...> install ports and their dependencies
|
install [opt] <port1 port2...> install/update ports in the listed order
|
||||||
update [opt] <port1 port2...> update ports and their dependencies
|
depinst [opt] <port1 port2...> install/update ports and their dependencies
|
||||||
grpinst [opt] <port1 port2...> install these ports, do not resolve dependencies
|
|
||||||
remove [opt] <port1 port2...> remove ports
|
remove [opt] <port1 port2...> remove ports
|
||||||
lock <port1 port2...> lock each <port> at its current version
|
lock <port1 port2...> lock each <port> at its current version
|
||||||
unlock <port1 port2...> release the lock on each <port>
|
unlock <port1 port2...> release the lock on each <port>
|
||||||
@ -876,6 +925,7 @@ COMMON OPTIONS
|
|||||||
--path print path to port if appropriate (search, list, depends)
|
--path print path to port if appropriate (search, list, depends)
|
||||||
--regex treat search term as a Perl-compatible regular expression
|
--regex treat search term as a Perl-compatible regular expression
|
||||||
--cache use a cache file
|
--cache use a cache file
|
||||||
|
--group stop the install/update operation if any port fails
|
||||||
--test do not actually run pkgmk/pkgadd, just print the commands on STDOUT
|
--test do not actually run pkgmk/pkgadd, just print the commands on STDOUT
|
||||||
EOF
|
EOF
|
||||||
exit;
|
exit;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user