prt-auf: rewrite the deporder subroutine
This commit is contained in:
parent
47dae3092c
commit
4037fba241
285
scripts/prt-auf
285
scripts/prt-auf
@ -17,39 +17,42 @@ my $pkgdb="$CONFDIR/db"; my $prtlocker="$CONFDIR/prt-get.locker";
|
||||
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 @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 %odepends = ( soft => 0, tree => 0, recursive => 0, all => 0 );
|
||||
my %opkg = ( margs => "", aargs => "", rargs => "", runscripts => "yes",
|
||||
makecommand => "/usr/bin/pkgmk", addcommand => "/usr/bin/pkgadd",
|
||||
removecommand => "/usr/bin/pkgrm", test => "no", group => "no" );
|
||||
my %osearch = ( cache=>0, regex=>0, path=>0, exact=>0, verbose=>0 );
|
||||
my %odepends = ( inject=>1, soft=>0, tree=>0, recursive=>0, all=>0 );
|
||||
my %opkg = ( margs=>"", aargs=>"", rargs=>"", runscripts=>"yes", nolock=>0,
|
||||
makecommand=>"/usr/bin/pkgmk", addcommand=>"/usr/bin/pkgadd",
|
||||
removecommand=>"/usr/bin/pkgrm", test=>"no", group=>"no" );
|
||||
my %olog = ( write => "disabled", mode => "overwrite", rm_on_success => "yes",
|
||||
file => "/var/log/pkgbuild/%n.log" );
|
||||
my $prtconf = "/etc/prt-get.conf";
|
||||
|
||||
################### Process the given command #########################
|
||||
my ($action, @query) = parse_args(@ARGV);
|
||||
$osearch{cache}=1 if ($0 =~ /cache$/);
|
||||
if ($0 =~ /cache$/) { $osearch{cache} = 1; }
|
||||
if (($0 =~ /cache$/) and ($action eq "cache")) {
|
||||
print "cannot create cache from a cache!\nUse $title instead.\n";
|
||||
exit 0;
|
||||
}
|
||||
my @bldirs = parse_prt_conf($prtconf);
|
||||
my @basedirs = @{$bldirs[0]}; my @localports = @{$bldirs[1]};
|
||||
|
||||
# load some data structures into memory for the actions that need them
|
||||
|
||||
get_locked_and_aliased();
|
||||
|
||||
if (($action !~ /^(fsearch|isinst|current)$/) and ($osearch{cache}==0)) {
|
||||
@allports = list_ports();
|
||||
fill_hashes_from_pkgfiles();
|
||||
}
|
||||
if ($osearch{cache}==1) { fill_hashes_from_cache(); }
|
||||
|
||||
if ($action !~ /^(quickdep|search|dsearch|fsearch|info|dup|readme|cat)$/) {
|
||||
if ($action !~ /^(search|dsearch|fsearch|info|dup|ls|readme|cat)$/) {
|
||||
open (DB, $pkgdb) or die "Could not open package database!\n";
|
||||
local $/="";
|
||||
while (<DB>) { $V_INST{$1} = $2 if m/^(.*)\n(.*)\n/; }
|
||||
close (DB);
|
||||
}
|
||||
|
||||
if ($action =~ /^(diff|quickdiff|listlocked|depends|deptree|remove|install|update|depinst|grpinst|sysup)$/) {
|
||||
get_locked_and_aliased();
|
||||
}
|
||||
|
||||
############## Branch based on the requested action #################
|
||||
|
||||
if ($action eq "path") { @results = find_port_by_name($query[0],1,1,0);
|
||||
@ -68,13 +71,10 @@ if ($action eq "path") { @results = find_port_by_name($query[0],1,1,0);
|
||||
} elsif ($action =~ /^(cat|edit|readme)$/) { port_edit($1,@query);
|
||||
} elsif ($action =~ /^(depends|quickdep)$/) { @results=deporder($1,@query);
|
||||
} elsif ($action =~ /^dep(endent|tree)$/) { @results=list_ports($action,@query);
|
||||
} elsif ($action eq "sysup") { my @outdated = grep { s/ .+// } port_diff("quick");
|
||||
shift @outdated; @results = up_inst("sysup", @outdated);
|
||||
} elsif ($action =~ /^(install|update)$/) { @results = up_inst($action,@query);
|
||||
} elsif ($action eq "depinst") { @results = up_inst("depinst",@query);
|
||||
} elsif ($action eq "install") { @results = up_inst(@query);
|
||||
} elsif ($action eq "dup") { $ind=find_dups(@query);
|
||||
} elsif ($action eq "remove") { $ind=uninstall(@query);
|
||||
} elsif ($action =~ /^(isinst|current)$/) { @results = port_diff($1,@query);
|
||||
} elsif ($action =~ /^(isinst|current|sysup)$/) { @results = port_diff($1,@query);
|
||||
} elsif ($action =~ /(.*)diff$/) { @results = port_diff($1);
|
||||
} elsif ($action =~ /^list(.*)/) { @results = list_ports($1);
|
||||
} elsif ($action eq "help") { print_help();
|
||||
@ -115,23 +115,20 @@ if (($action =~ /^(listinst|listorphans|dependent)/) and
|
||||
next if (($osearch{filter}) and ($diffN !~ /$osearch{filter}/));
|
||||
next if ((grep {$_ eq $diffN} @LOCKED) and ($odepends{all}==0));
|
||||
printf "$format", $diffN, $diffI, $diffR if ($action eq "diff");
|
||||
printf "%s ", $diffN if (($action eq "quickdiff") and ($diffR ne "MISSING"));
|
||||
printf "%s ", $diffN if ($action eq "quickdiff");
|
||||
}
|
||||
print "\n" if ($action eq "quickdiff");
|
||||
exit $ind;
|
||||
} elsif ($action =~ /^(depends|quickdep)$/) {
|
||||
print "-- dependency list ([i] = installed, [a] = alias installed)\n" if ($action =~ /^dep/);
|
||||
print "-- dependency list ([i] = 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 (! $dep) { next; }
|
||||
if ($action ne "quickdep") {
|
||||
$ind = (grep { $_ eq $dep } keys %V_INST) ? "[i]" : "[ ]";
|
||||
$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]"));
|
||||
$dep .= " $V_REPO{$dep}" if ($osearch{verbose}==1);
|
||||
$dep .= " $V_REPO{$dep}\n$DESC{$dep}" if ($osearch{verbose}>1);
|
||||
}
|
||||
printf $strf, $ind, $dep unless ($action eq "quickdep");
|
||||
printf "%s ", $dep if ($action eq "quickdep");
|
||||
@ -150,17 +147,17 @@ if (($action =~ /^(listinst|listorphans|dependent)/) and
|
||||
my @failures = grep { $removed{$_}==0 } keys %removed;
|
||||
print "Ports removed:\n" if (@successes);
|
||||
foreach my $p (@successes) { print "$p\n"; }
|
||||
} elsif ($action =~ /^(install|update|depinst|sysup)$/) {
|
||||
my @ok = @{$results[0]}; my @ok_pre = @{$results[1]}; my @ok_post = @{$results[2]};
|
||||
} elsif ($action =~ /^(install|sysup)$/) {
|
||||
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;
|
||||
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)) {
|
||||
print "Successful ports:\n";
|
||||
foreach my $k (@ok) {
|
||||
$note = (grep /^$k$/, @ok_pre) ? " pre: ok. " : "";
|
||||
$note .= (grep /^$k$/, @ok_post) ? " post: ok. " : "";
|
||||
$note = ((grep /^$k$/, @ok_pre) or (grep /^$k$/, @ok_post))? "($note)" : "";
|
||||
$note = ($ok_pre{$k}) ? " pre: ok. " : "";
|
||||
$note .= ($ok_post{$k}) ? " post: ok. " : "";
|
||||
$note = ( grep /(pre|post):/, $note ) ? "($note)" : "";
|
||||
print " $k $note\n";
|
||||
}
|
||||
print "\n";
|
||||
@ -184,7 +181,8 @@ sub parse_args {
|
||||
my @query;
|
||||
while (my $arg = shift) {
|
||||
if ($arg =~ /^(search|dsearch|fsearch|path|info|list|remove)$/) { $action = $1;
|
||||
} elsif ($arg =~ /^(install|update|depinst|sysup)$/) { $action = $1;
|
||||
} elsif ($arg =~ /^(install|update|depinst)$/) { $action = "install";
|
||||
} elsif ($arg eq "sysup") { $action = "sysup"; $opkg{nolock}=0;
|
||||
} 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;
|
||||
@ -195,6 +193,8 @@ sub parse_args {
|
||||
} elsif ($arg =~ /^(readme|cat|edit|ls|help|version|cache)$/) { $action = $1;
|
||||
} elsif ($arg eq "--tree") { $odepends{tree} = 1;
|
||||
} elsif ($arg eq "--all") { $odepends{all} = 1;
|
||||
} elsif ($arg eq "--nodeps") { $odepends{inject} = 0;
|
||||
} elsif ($arg eq "--depsort") { $odepends{inject} = 1;
|
||||
} elsif ($arg eq "--softdeps") { $odepends{soft} = 1;
|
||||
} elsif ($arg eq "--recursive") { $odepends{recursive} = 1;
|
||||
} elsif ($arg eq "--cache") { $osearch{cache} = 1;
|
||||
@ -207,6 +207,7 @@ sub parse_args {
|
||||
} elsif ($arg eq "--test") { $opkg{test} = "yes";
|
||||
} elsif ($arg eq "--group") { $opkg{group} = "yes";
|
||||
} elsif ($arg eq "-fr") { $opkg{margs} .= " -f";
|
||||
} elsif ($arg eq "-fi") { $opkg{aargs} .= " -f";
|
||||
} elsif ($arg =~ /^(-uf|-if|-us|-is|-ns|-kw)$/) { $opkg{margs} .= " $1";
|
||||
} elsif ($arg =~ /^--margs=(.+)/) { $opkg{margs} .= $1;
|
||||
} elsif ($arg =~ /^--aargs=(-r|--root)=(.+)/) { $opkg{aargs} .= "$1 $2";
|
||||
@ -627,13 +628,17 @@ sub list_ports {
|
||||
else { return grep {$_ !~ /$osearch{filter}/} @found; }
|
||||
}
|
||||
|
||||
sub port_diff { # returns a list of all the ports with differences
|
||||
sub port_diff { # find differences between the pkgdb and the repo
|
||||
my $dtype=shift; my @argq=@_; my @outfile=(); my $retval=0;
|
||||
|
||||
if ($dtype !~ /^(current|isinst|utd)/) {
|
||||
foreach my $p (sort(keys %V_INST)) {
|
||||
push @outfile, "$p $V_INST{$p} $V_REPO{$p}" if (($V_REPO{$p}) and ($V_INST{$p} ne $V_REPO{$p}));
|
||||
push @outfile, "$p $V_INST{$p} MISSING" if ((! $V_REPO{$p}) and ($dtype ne "quick"));
|
||||
if (($V_REPO{$p}) and ($V_REPO{$p} ne $V_INST{$p})) {
|
||||
($dtype =~ /^(quick|sysup)/) ? push @outfile, "$p" :
|
||||
push @outfile, "$p $V_INST{$p} $V_REPO{$p}";
|
||||
} elsif ((! $V_REPO{$p}) and ($dtype !~ /^(quick|sysup)/)) {
|
||||
push @outfile, "$p $V_INST{$p} MISSING";
|
||||
}
|
||||
}
|
||||
} elsif ($dtype eq "utd") { my $q=shift(@argq);
|
||||
if (! $V_INST{$q}) { $retval--;
|
||||
@ -649,114 +654,108 @@ sub port_diff { # returns a list of all the ports with differences
|
||||
}
|
||||
}
|
||||
} else {}
|
||||
return $retval, @outfile unless ($dtype eq "utd");
|
||||
return $retval if ($dtype eq "utd");
|
||||
return $retval, @outfile if ($dtype !~ /^(utd|sysup)/);
|
||||
return $retval if ($dtype ne "sysup");
|
||||
|
||||
# proceed with the sysup operation
|
||||
return up_inst(@outfile);
|
||||
}
|
||||
|
||||
sub deporder {
|
||||
# returns an annotated list using a variation on depth-first search.
|
||||
# Recursion does NOT continue beyond a dependency satisfied by an alias.
|
||||
sub deporder { # returns a sorted list of packages required.
|
||||
|
||||
my $type=shift; my @seeds=@_; our @treewalk=(); our %seen; our @missing;
|
||||
our %imark; our %fmark; our $fmarks; our @results;
|
||||
|
||||
# first strip out all the names not found in the ports collections
|
||||
push @missing, grep { (! $V_REPO{$_}) } @seeds;
|
||||
@seeds = grep { ($V_REPO{$_}) } @seeds;
|
||||
my $type=shift; my @seeds=@_; our @treewalk=(); our @missing;
|
||||
our %numPred; our %children; my @result;
|
||||
|
||||
# determine the minimal set of targets needed to satisfy all dependencies
|
||||
foreach (@seeds) { recurse_deptree($_) }
|
||||
foreach my $t (@seeds) {
|
||||
($V_REPO{$t}) ? recurse_deptree($t) : push (@missing, $t);
|
||||
}
|
||||
|
||||
sub recurse_deptree {
|
||||
my $s=shift; my %curdeps; my @optionals;
|
||||
|
||||
my $substitute = who_aliased_to($s);
|
||||
if ((($substitute) and (! $V_INST{$s})) or ($V_REPO{$s})) {
|
||||
$seen{$s} = 1;
|
||||
} else {
|
||||
push (@missing, $s); return;
|
||||
}
|
||||
return if ($substitute);
|
||||
|
||||
# cycle detection
|
||||
if (! grep { $_ eq $s } @treewalk) {
|
||||
push (@treewalk, $s);
|
||||
} else { return; }
|
||||
( grep /^$s$/, @treewalk ) ? return : push(@treewalk, $s);
|
||||
|
||||
if (! $numPred{$s}) { $numPred{$s} = 0; }
|
||||
|
||||
%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};
|
||||
foreach (@optionals) { $curdeps{$_} = 1 }
|
||||
foreach (@optionals) { $curdeps{$_} = 1; }
|
||||
}
|
||||
|
||||
foreach my $sd (keys %curdeps) {
|
||||
next if ($seen{$sd});
|
||||
recurse_deptree($sd);
|
||||
my $subit = who_aliased_to($sd);
|
||||
if ($subit) {
|
||||
$children{$s} .= " $subit ";
|
||||
$numPred{$subit} += 1;
|
||||
recurse_deptree($subit);
|
||||
} else {
|
||||
$children{$s} .= " $sd ";
|
||||
$numPred{$sd} += 1;
|
||||
recurse_deptree($sd);
|
||||
}
|
||||
}
|
||||
pop (@treewalk);
|
||||
|
||||
} # proceed with the topological sort
|
||||
# initialize a queue of nodes with in-degree zero (nothing depends on them)
|
||||
my @indZero = grep { ($numPred{$_} == 0) } keys %numPred;
|
||||
|
||||
# move each node from the queue to the sorted list, and reduce by 1 the
|
||||
# in-degree of its dependencies (Kahn 1962)
|
||||
while (my $q = shift @indZero) {
|
||||
push(@result, $q);
|
||||
next if (! $children{$q});
|
||||
foreach my $s (split / /, $children{$q}) {
|
||||
$numPred{$s} -= 1;
|
||||
push(@indZero,$s) if ($numPred{$s} == 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);
|
||||
}
|
||||
# the resulting list is backwards (dependencies come after the packages they
|
||||
# support), and must be reversed.
|
||||
@result = reverse @result;
|
||||
|
||||
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 "quickdep")) { push (@results, "MISSING", @missing); }
|
||||
return @results;
|
||||
if (($#missing>-1) and ($type ne "quickdep")) { push (@result, "MISSING", @missing); }
|
||||
return @result;
|
||||
}
|
||||
|
||||
sub up_inst { # returns scalar references to five arrays
|
||||
my $type=shift; my @requested=@_; my @targets; my %EXEMPT; my %pdirs;
|
||||
my %builtpkg; my %mkcmd; my %addcmd; my %status; my %logfile; my %pvars;
|
||||
my @requested=@_; my @sortedList; my @targets; my %EXEMPT; my %pdirs;
|
||||
my %builtpkg; my %mkcmd; my %addcmd; my %logfile; my %pvars; my $status;
|
||||
my %ok; my %not_ok; my %ok_pre; my %ok_post; my @ok_readme=();
|
||||
my $PKGMK=$opkg{makecommand}; my $PKGADD=$opkg{addcommand};
|
||||
|
||||
# respect the user-supplied list of ports unless 'depinst' or 'sysup',
|
||||
# in which case put glibc{,-32} at the front of the queue
|
||||
@targets=grep { ($V_REPO{$_}) } @requested;
|
||||
if ($type =~ /^(depinst|sysup)$/) {
|
||||
@requested = deporder("quick",@requested);
|
||||
@targets=grep { !m/^glibc(|-32)$/ } @requested;
|
||||
unshift @targets, grep { m/^glibc(|-32)$/ } @requested;
|
||||
}
|
||||
|
||||
# exempt any locked ports unless they were explicitly requested
|
||||
%EXEMPT = map { $_ => 1 } @LOCKED;
|
||||
if ($type =~ /^(depinst|sysup)$/) {
|
||||
@targets = grep {(! $EXEMPT{$_})} @targets;
|
||||
# resolve dependencies unless --nodeps was given,
|
||||
# but put glibc{,-32} at the front of the queue
|
||||
if ($odepends{inject}==1) {
|
||||
@sortedList = deporder("quickdep", @requested);
|
||||
@targets=grep { !m/^glibc(|-32)$/ } @sortedList;
|
||||
unshift @targets, grep { m/^glibc(|-32)$/ } @sortedList;
|
||||
} else {
|
||||
@targets = grep { ($V_REPO{$_}) } @requested;
|
||||
}
|
||||
|
||||
# omit the ports that appear up to date, unless a rebuild is forced
|
||||
if ("$opkg{margs} $opkg{aargs}" !~ m/-f/) {
|
||||
@targets = grep {( (! $V_INST{$_}) or ($V_REPO{$_} ne $V_INST{$_}) )} @targets;
|
||||
}
|
||||
|
||||
# exempt any locked ports from being updated
|
||||
%EXEMPT = map { $_ => 1 } @LOCKED;
|
||||
@targets = grep {(! $EXEMPT{$_})} @targets unless $opkg{nolock}==1;
|
||||
|
||||
# first determine the directories from which pkgmk must be called,
|
||||
# the package that will appear after a successful build,
|
||||
# and where to save the build log.
|
||||
my ($COMPRESSION, $PKG_DIR) = parse_pkgmk_conf();
|
||||
foreach my $t (@targets) {
|
||||
$opkg{$t} = $opkg{margs}; $pvars{'%n'}=$t;
|
||||
$opkg{$t} =~ s/-f// unless (grep { $_ eq $t } @requested);
|
||||
$opkg{$t} =~ s/-f// unless (grep /^$t$/, @requested);
|
||||
$pvars{'%p'} = find_port_by_name($t,1,1,0); $pdirs{$t} = $pvars{'%p'};
|
||||
$pvars{'%v'} = $1 if ( $V_REPO{$t} =~ m/(.+)-[0-9]+$/ );
|
||||
$pvars{'%r'} = $1 if ( $V_REPO{$t} =~ m/-([0-9]+)$/ );
|
||||
@ -764,7 +763,6 @@ sub up_inst { # returns scalar references to five arrays
|
||||
$builtpkg{$t} =~ s/\$name/$t/g; $builtpkg{$t} =~ s/\$\{name\}/$t/g;
|
||||
$mkcmd{$t} = "$PKGMK -d $opkg{$t}";
|
||||
$addcmd{$t} = "$PKGADD -u $builtpkg{$t}";
|
||||
$status{$t} = "not done";
|
||||
if ($olog{write} eq "enabled") {
|
||||
$logfile{$t} = $olog{file};
|
||||
$logfile{$t} =~ s/(%n|%v|%r|%p)/$pvars{$1}/g;
|
||||
@ -773,47 +771,49 @@ sub up_inst { # returns scalar references to five arrays
|
||||
}
|
||||
}
|
||||
|
||||
if ($opkg{test} eq "yes") { print("*** prt-auf $type: test mode\n\n");
|
||||
if ($opkg{test} eq "yes") { print("*** prt-auf: 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
|
||||
BUILDLOG: foreach my $t (@targets) {
|
||||
if (who_aliased_to($t)) {
|
||||
$mkcmd{$t} = "echo \"skipped build ($t provided by an alias)\"";
|
||||
} else {
|
||||
$mkcmd{$t} = "echo \"skipped build ($t up to date)\"" if
|
||||
((-f $builtpkg{$t}) and ($opkg{$t} !~ /-f/))
|
||||
and ((-M $builtpkg{$t}) < (-M "$pdirs{$t}/Pkgfile"));
|
||||
$mkcmd{$t} = "" if (($opkg{$t} !~ /-f/) and (port_diff("utd",$t)==0));
|
||||
if ( (-f $builtpkg{$t}) and ($opkg{$t} !~ /-f/) and
|
||||
((-M $builtpkg{$t}) > (-M "$pdirs{$t}/Pkgfile")) ) {
|
||||
$mkcmd{$t} = "echo \"skipped build (package already exists)\"";
|
||||
}
|
||||
|
||||
if ($opkg{test} eq "yes") {
|
||||
print("$t\n") if ($mkcmd{$t} ne "");
|
||||
print("$t\n") if ($mkcmd{$t} !~ /skipped/);
|
||||
$ok{$t}=1;
|
||||
next BUILDLOG;
|
||||
}
|
||||
if ($mkcmd{$t} ne "") {
|
||||
push (@ok_readme, $t) if (-f $pdirs{$t}."/README");
|
||||
if ((-f "$pdirs{$t}/pre-install") and ($opkg{runscripts} eq "yes")) {
|
||||
system("sh","$pdirs{$t}/pre-install");
|
||||
$status{$t} .= ( $?>>8 == 0 ) ? "pre-install ok. " : "pre-install failed. ";
|
||||
( $?>>8 == 0 ) ? $ok_pre{$t} = 1 : delete $ok_pre{$t};
|
||||
}
|
||||
chdir $pdirs{$t}; system("$mkcmd{$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} = ( $mkcmd{$t} =~ /skipped/ ) ? "build skipped. " : $status{$t};
|
||||
if (($status{$t} =~ /build ok/) or ($mkcmd{$t} =~ /up to date/)) {
|
||||
$addcmd{$t} =~ s/ -u / / if (port_diff("utd",$t)<0);
|
||||
chdir $pdirs{$t}; system("$mkcmd{$t}"); $status=( $?>>8 == 0 );
|
||||
if ($logfile{$t}) {
|
||||
( $status ) ? $ok{$t} = 1 : $not_ok{$t} = 1;
|
||||
} else {
|
||||
(! log_failure($logfile{$t})) ? $ok{$t} = 1 : $not_ok{$t} = 1;
|
||||
}
|
||||
if ( $ok{$t} ) {
|
||||
$addcmd{$t} =~ s/ -u / / if (! $V_INST{$t});
|
||||
system("$addcmd{$t}");
|
||||
$status{$t} .= ( $?>>8 == 0 ) ? "pkgadd ok. " : "pkgadd failed. ";
|
||||
unlink($logfile{$t}) if (($status{$t} =~ /ok. $/) and
|
||||
($logfile{$t}) and ($olog{rm_on_success} eq "yes"));
|
||||
if ( $?>>8 == 0 ) { $ok{$t} = 1;
|
||||
} else {
|
||||
$not_ok{$t} = 1; $ok{$t} = 0;
|
||||
}
|
||||
unlink($logfile{$t}) if ( ($ok{$t}==1) and
|
||||
($logfile{$t}) and ($olog{rm_on_success} eq "yes") );
|
||||
}
|
||||
if (($status{$t} =~ /pkgadd ok/) and (-f "$pdirs{$t}/post-install")
|
||||
and ($opkg{runscripts} eq "yes")) {
|
||||
if (($ok{$t}) and (-f "$pdirs{$t}/post-install")
|
||||
and ($opkg{runscripts} eq "yes")) {
|
||||
system("sh","$pdirs{$t}/post-install");
|
||||
$status{$t} .= ( $?>>8 == 0 ) ? "post-install ok. " : "post-install failed. ";
|
||||
( $?>>8 == 0 ) ? $ok_post{$t}=1 : delete $ok_post{$t};
|
||||
}
|
||||
}
|
||||
last if (($status{$t} =~ /failed/) and ($opkg{group} eq "yes"));
|
||||
last if (($opkg{group} eq "yes") and ($not_ok{$t}) and ($not_ok{$t}==1));
|
||||
}
|
||||
|
||||
sub log_failure {
|
||||
@ -823,12 +823,9 @@ sub up_inst { # returns scalar references to five arrays
|
||||
close(FH); return $failed;
|
||||
}
|
||||
|
||||
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;
|
||||
my @ok = keys %ok;
|
||||
my @not_ok = keys %not_ok;
|
||||
return \@ok, \%ok_pre, \%ok_post, \@ok_readme, \@not_ok;
|
||||
}
|
||||
|
||||
sub parse_pkgmk_conf {
|
||||
@ -924,13 +921,15 @@ GENERAL INFORMATION
|
||||
current <port> installed version of port
|
||||
|
||||
COMMON OPTIONS
|
||||
-v show version in listing
|
||||
-vv show version and decription in listing
|
||||
--path print path to port if appropriate (search, list, depends)
|
||||
--regex treat search term as a Perl-compatible regular expression
|
||||
--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
|
||||
-v show version in listing
|
||||
-vv show version and decription in listing
|
||||
--path print path to port if appropriate (search, list, depends)
|
||||
--regex treat search term as a Perl-compatible regular expression
|
||||
--cache use a cache file
|
||||
--group stop the install/update operation if any port fails
|
||||
--softdeps when sorting the targets, consider optional dependencies too
|
||||
--nodeps do not inject or sort by dependencies
|
||||
--test do not actually run pkgmk/pkgadd, just print the affected ports
|
||||
EOF
|
||||
exit;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user