prt-auf: respect --install-root when running pre- and post-install scripts
This commit is contained in:
parent
99d51f625d
commit
a76248a9cb
@ -1,5 +1,5 @@
|
|||||||
.\" man page for prt-auf
|
.\" man page for prt-auf
|
||||||
.\" last edited March 2023 by John McQuah, jmcquah at disroot dot org
|
.\" last edited May 2023 by John McQuah, jmcquah at disroot dot org
|
||||||
.\"
|
.\"
|
||||||
.\" based on original work by Johannes Winkelmann, jw at tks6 dot net
|
.\" based on original work by Johannes Winkelmann, jw at tks6 dot net
|
||||||
.\"
|
.\"
|
||||||
@ -200,7 +200,7 @@ built by an 'install' command).
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B depends [\-\-softdeps] <package1> [<package2> ...]
|
.B depends [\-\-softdeps] <package1> [<package2> ...]
|
||||||
print a sorted list of dependencies needed to install the packages passed
|
Print a sorted list of dependencies needed to install the packages passed
|
||||||
as argument. Packages that need to be installed first are listed first. It
|
as argument. Packages that need to be installed first are listed first. It
|
||||||
shows a list of the dependencies that were found in the ports tree, followed by
|
shows a list of the dependencies that were found in the ports tree, followed by
|
||||||
a list of the dependencies that could not be found. Pass the --softdeps flag if
|
a list of the dependencies that could not be found. Pass the --softdeps flag if
|
||||||
@ -209,7 +209,7 @@ the output.
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B quickdep [\-\-softdeps] <package1> [<package2> ...]
|
.B quickdep [\-\-softdeps] <package1> [<package2> ...]
|
||||||
mostly the same output as depends, but stripped of the installation status
|
Mostly the same output as depends, but stripped of the installation status
|
||||||
indicator, and separated by spaces rather than newlines. Also, ports that
|
indicator, and separated by spaces rather than newlines. Also, ports that
|
||||||
cannot be found in the ports tree are omitted from the results. This formatting
|
cannot be found in the ports tree are omitted from the results. This formatting
|
||||||
is useful in command substitution, e.g. instead of running
|
is useful in command substitution, e.g. instead of running
|
||||||
@ -225,7 +225,7 @@ needed for successful builds.
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B deptree [\-\-softdeps] <package>
|
.B deptree [\-\-softdeps] <package>
|
||||||
print a tree of the dependencies of
|
Print a tree of the dependencies of
|
||||||
.B <package>.
|
.B <package>.
|
||||||
|
|
||||||
Pass the --softdeps flag if you want optional dependencies to appear in the
|
Pass the --softdeps flag if you want optional dependencies to appear in the
|
||||||
@ -241,20 +241,20 @@ occurred.
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B dependent [\-\-softdeps] [\-\-all] [\-\-recursive] [\-\-tree] <package>
|
.B dependent [\-\-softdeps] [\-\-all] [\-\-recursive] [\-\-tree] <package>
|
||||||
print a list of ports which have
|
Print a list of ports which have
|
||||||
.B <package>
|
.B <package>
|
||||||
in their "Depends on:" line. To also search the "Optional:" lines, pass the
|
in their "Depends on:" line. To also search the "Optional:" lines, pass the
|
||||||
--softdeps flag. By default, output is restricted to ports that are installed.
|
--softdeps flag. By default, output is restricted to ports that are installed.
|
||||||
To see all hard dependencies, add the --all switch; use --recursive to get a
|
To see all the dependencies, add the --all switch; use --recursive to get a
|
||||||
recursive list (without duplication), and --tree to get a nicely indented one.
|
recursive list (without duplication), and --tree to get a nicely indented one.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B ls [--path] <port>
|
.B ls [--path] <port>
|
||||||
Prints out a listing of the port's directory
|
Print out a listing of the port's directory
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B cat <port> [<file>]
|
.B cat <port> [<file>]
|
||||||
Prints out the file to stdout. If <file> is not specified, 'Pkgfile' is used.
|
Print out the file to stdout. If <file> is not specified, 'Pkgfile' is used.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B edit <port> [<file>]
|
.B edit <port> [<file>]
|
||||||
@ -336,27 +336,27 @@ are replaced like this:
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
\ \ \ \(bu
|
\ \ \ \(bu
|
||||||
%P -> optional dependencies
|
%P \-> optional dependencies
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\ \ \ \(bu
|
\ \ \ \(bu
|
||||||
%M -> Maintainer
|
%M \-> Maintainer
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\ \ \ \(bu
|
\ \ \ \(bu
|
||||||
%R -> Readme ("yes"/"no")
|
%R \-> Readme ("yes"/"no")
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\ \ \ \(bu
|
\ \ \ \(bu
|
||||||
%E -> pre-install script ("yes"/"no")
|
%E \-> pre-install script ("yes"/"no")
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\ \ \ \(bu
|
\ \ \ \(bu
|
||||||
%O -> post-install script ("yes"/"no")
|
%O \-> post-install script ("yes"/"no")
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\ \ \ \(bu
|
\ \ \ \(bu
|
||||||
%l -> is locked ("yes"/"no")
|
%l \-> is locked ("yes"/"no")
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\ \ \ \(bu
|
\ \ \ \(bu
|
||||||
@ -584,7 +584,15 @@ looking for, without needing to clutter the code base by reimplementing shell
|
|||||||
wildcards.
|
wildcards.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B no "--ignore" switch.
|
.B no \-\-config\-prepend, \-\-config\-append, or \-\-config\-set switches.
|
||||||
|
Users of \fBprt\-get\fP might find it inconvenient not to have such a
|
||||||
|
mechanism for overriding the config file settings on a temporary basis. The
|
||||||
|
workaround is to create different variations of the config file, and use the
|
||||||
|
\fB\-\-config=\fP switch to select the appropriate file whenever a
|
||||||
|
non-default setting is desired.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B no \-\-ignore switch.
|
||||||
This feature is easy enough to add at a later date, but a newcomer to CRUX will
|
This feature is easy enough to add at a later date, but a newcomer to CRUX will
|
||||||
likely be confused at having such fine-grained control over the automatic
|
likely be confused at having such fine-grained control over the automatic
|
||||||
dependency resolution. The two main reasons to use "--ignore" (an erroneous
|
dependency resolution. The two main reasons to use "--ignore" (an erroneous
|
||||||
|
@ -12,10 +12,10 @@ use strict;
|
|||||||
|
|
||||||
################### Initialize global variables #######################
|
################### Initialize global variables #######################
|
||||||
my $title="prt-auf"; my $version=0.51; my $cache_ver="V5.1";
|
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-get.cache"; my %LOCKED; my %ALIASES; my %DEPENDS;
|
my $prtcache="$CONFDIR/prt-get.cache"; my $altroot=""; my %LOCKED; my %ALIASES;
|
||||||
my @allports; my %V_REPO; my %V_INST; my %DESC; my %SOFTDEPS;
|
my @allports; my %V_REPO; my %V_INST; my %DESC; my %DEPENDS; 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 = ( inject=>1, soft=>0, tree=>0, recursive=>0, all=>0 );
|
my %odepends = ( inject=>1, soft=>0, tree=>0, recursive=>0, all=>0 );
|
||||||
@ -47,7 +47,7 @@ if (($action !~ /^(fsearch|isinst|current)$/) and ($osearch{cache}==0)) {
|
|||||||
if ($osearch{cache}==1) { fill_hashes_from_cache(); }
|
if ($osearch{cache}==1) { fill_hashes_from_cache(); }
|
||||||
|
|
||||||
if ($action !~ /^(search|dsearch|fsearch|info|dup|ls|readme|cat)$/) {
|
if ($action !~ /^(search|dsearch|fsearch|info|dup|ls|readme|cat)$/) {
|
||||||
open (DB, $pkgdb) or die "Could not open package database!\n";
|
open (DB, "$altroot$pkgdb") or die "Could not open package database!\n";
|
||||||
local $/="";
|
local $/="";
|
||||||
while (<DB>) { $V_INST{$1} = $2 if m/^(.*)\n(.*)\n/; }
|
while (<DB>) { $V_INST{$1} = $2 if m/^(.*)\n(.*)\n/; }
|
||||||
close (DB);
|
close (DB);
|
||||||
@ -147,11 +147,9 @@ if (($action =~ /^(listinst|listorphans|dependent)/) and
|
|||||||
"Readme", "PreInstall", "PostInstall");
|
"Readme", "PreInstall", "PostInstall");
|
||||||
for (my $i=0; $i<9; $i++) { printf $strf, $fields[$i], $results[$i] unless ($results[$i] =~ /^\s*$/); }
|
for (my $i=0; $i<9; $i++) { printf $strf, $fields[$i], $results[$i] unless ($results[$i] =~ /^\s*$/); }
|
||||||
} elsif ($action eq "remove") {
|
} elsif ($action eq "remove") {
|
||||||
my %removed = %$ind;
|
my @removed = @$ind;
|
||||||
my @successes = grep { $removed{$_}==1 } keys %removed;
|
print "Ports removed:\n" if (@removed);
|
||||||
my @failures = grep { $removed{$_}==0 } keys %removed;
|
foreach my $p (@removed) { print "$p\n"; }
|
||||||
print "Ports removed:\n" if (@successes);
|
|
||||||
foreach my $p (@successes) { print "$p\n"; }
|
|
||||||
} elsif ($action =~ /^(install|sysup)$/) {
|
} elsif ($action =~ /^(install|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;
|
||||||
@ -215,8 +213,11 @@ sub parse_args {
|
|||||||
} elsif ($arg eq "-fi") { $opkg{aargs} .= " -f";
|
} elsif ($arg eq "-fi") { $opkg{aargs} .= " -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;
|
||||||
} elsif ($arg =~ /^--aargs=(-r|--root)=(.+)/) { $opkg{aargs} .= "$1 $2";
|
} elsif (($arg =~ /^--install-root=(.+)$/) and (-d $1)) { $altroot=$1;
|
||||||
} elsif ($arg =~ /^--rargs=(-r|--root)=(.+)/) { $opkg{rargs} .= "$1 $2";
|
} elsif (($arg =~ /^--aargs=(-r|--root)=(.+)/) and (-d $2)) { $altroot=$2;
|
||||||
|
} elsif (($arg =~ /^--rargs=(-r|--root)=(.+)/) and (-d $2)) { $altroot=$2;
|
||||||
|
} elsif ($arg =~ /^--aargs=(.+)/) { $opkg{aargs} .= " $1";
|
||||||
|
} elsif ($arg =~ /^--rargs=(.+)/) { $opkg{rargs} .= " $1";
|
||||||
} elsif ($arg =~ /^-/) {
|
} elsif ($arg =~ /^-/) {
|
||||||
print "'$arg' is not a recognized option.\n";
|
print "'$arg' is not a recognized option.\n";
|
||||||
} else { push (@query, $arg); }
|
} else { push (@query, $arg); }
|
||||||
@ -309,13 +310,13 @@ sub find_dups {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub get_locked_and_aliased {
|
sub get_locked_and_aliased {
|
||||||
if (-f $prtalias) {
|
if (-f "$altroot$prtalias") {
|
||||||
open (AL, $prtalias);
|
open (AL, "$altroot$prtalias");
|
||||||
while (<AL>) { $ALIASES{$1} = $2 if m/^\s*(.*)\s*:\s*(.*)/; }
|
while (<AL>) { $ALIASES{$1} = $2 if m/^\s*(.*)\s*:\s*(.*)/; }
|
||||||
close (AL);
|
close (AL);
|
||||||
}
|
}
|
||||||
if (-f $prtlocker) {
|
if (-f "$altroot$prtlocker") {
|
||||||
open (LK, $prtlocker);
|
open (LK, "$altroot$prtlocker");
|
||||||
while (<LK>) { chomp; $LOCKED{$_}=1 unless /^\s*$/; }
|
while (<LK>) { chomp; $LOCKED{$_}=1 unless /^\s*$/; }
|
||||||
close (LK);
|
close (LK);
|
||||||
}
|
}
|
||||||
@ -491,12 +492,16 @@ sub uninstall {
|
|||||||
my @rubbish = grep { ! defined $V_INST{$_} } @_;
|
my @rubbish = grep { ! defined $V_INST{$_} } @_;
|
||||||
foreach my $r (@rubbish) { print "$r not installed; ignoring.\n"; }
|
foreach my $r (@rubbish) { print "$r not installed; ignoring.\n"; }
|
||||||
my %removed = map { $_ => 0 } @targets;
|
my %removed = map { $_ => 0 } @targets;
|
||||||
|
if (($altroot ne "") and ($opkg{rargs} !~ m/(-r|--root)/)) {
|
||||||
|
$opkg{rargs} .= " -r $altroot";
|
||||||
|
}
|
||||||
foreach my $t (@targets) {
|
foreach my $t (@targets) {
|
||||||
($opkg{test} eq "no") ? system($PKGRM,$opkg{rargs},$t) : print "$PKGRM $opkg{rargs} $t\n";
|
($opkg{test} eq "no") ? system($PKGRM,$opkg{rargs},$t) : print "$PKGRM $opkg{rargs} $t\n";
|
||||||
$removed{$t}=1 if ($?>>8 == 0);
|
$removed{$t}=1 if ($?>>8 == 0);
|
||||||
if (($LOCKED{$t}) and ($opkg{test} eq "no")) { port_unlock($t); }
|
if (($LOCKED{$t}) and ($opkg{test} eq "no")) { port_unlock($t); }
|
||||||
}
|
}
|
||||||
return \%removed;
|
my @successes = grep { $removed{$_} == 1 } keys %removed;
|
||||||
|
return @successes;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub port_lock {
|
sub port_lock {
|
||||||
@ -764,7 +769,10 @@ sub up_inst { # returns scalar references to five arrays
|
|||||||
$builtpkg{$t} =~ s/uuiVer/$pvars{'%v'}/g;
|
$builtpkg{$t} =~ s/uuiVer/$pvars{'%v'}/g;
|
||||||
$builtpkg{$t} =~ s/uuiRel/$pvars{'%r'}/g;
|
$builtpkg{$t} =~ s/uuiRel/$pvars{'%r'}/g;
|
||||||
$mkcmd{$t} = "$PKGMK -d $opkg{$t}";
|
$mkcmd{$t} = "$PKGMK -d $opkg{$t}";
|
||||||
$addcmd{$t} = "$PKGADD -u $builtpkg{$t}";
|
if (($altroot ne "") and ($opkg{aargs} !~ m/(-r|--root)/)) {
|
||||||
|
$opkg{aargs} .= " -r $altroot";
|
||||||
|
}
|
||||||
|
$addcmd{$t} = "$PKGADD -u $opkg{aargs} $builtpkg{$t}";
|
||||||
if ($olog{write} eq "enabled") {
|
if ($olog{write} eq "enabled") {
|
||||||
$logfile{$t} = $olog{file};
|
$logfile{$t} = $olog{file};
|
||||||
$logfile{$t} =~ s/(%n|%v|%r|%p)/$pvars{$1}/g;
|
$logfile{$t} =~ s/(%n|%v|%r|%p)/$pvars{$1}/g;
|
||||||
@ -788,8 +796,12 @@ sub up_inst { # returns scalar references to five arrays
|
|||||||
next BUILDLOG;
|
next BUILDLOG;
|
||||||
}
|
}
|
||||||
if ($mkcmd{$t} ne "") {
|
if ($mkcmd{$t} ne "") {
|
||||||
if ((-f "$pdirs{$t}/pre-install") and ($opkg{runscripts} eq "yes")) {
|
if (($opkg{runscripts} eq "yes") and (-f "$pdirs{$t}/pre-install")) {
|
||||||
|
if ($altroot ne "") {
|
||||||
|
system("chroot",$altroot,"sh","$pdirs{$t}/pre-install");
|
||||||
|
} else {
|
||||||
system("sh","$pdirs{$t}/pre-install");
|
system("sh","$pdirs{$t}/pre-install");
|
||||||
|
}
|
||||||
( $?>>8 == 0 ) ? $ok_pre{$t} = 1 : delete $ok_pre{$t};
|
( $?>>8 == 0 ) ? $ok_pre{$t} = 1 : delete $ok_pre{$t};
|
||||||
}
|
}
|
||||||
chdir $pdirs{$t}; system("$mkcmd{$t}"); $status=( $?>>8 == 0 );
|
chdir $pdirs{$t}; system("$mkcmd{$t}"); $status=( $?>>8 == 0 );
|
||||||
@ -811,9 +823,13 @@ sub up_inst { # returns scalar references to five arrays
|
|||||||
} elsif ( ($not_ok{$t}) and (-f "$builtpkg{$t}") ) {
|
} elsif ( ($not_ok{$t}) and (-f "$builtpkg{$t}") ) {
|
||||||
system("mv $builtpkg{$t} $builtpkg{$t}.CHECKME");
|
system("mv $builtpkg{$t} $builtpkg{$t}.CHECKME");
|
||||||
}
|
}
|
||||||
if (($ok{$t}) and (-f "$pdirs{$t}/post-install")
|
if (($ok{$t}) and ($opkg{runscripts} eq "yes")
|
||||||
and ($opkg{runscripts} eq "yes")) {
|
and (-f "$pdirs{$t}/post-install")) {
|
||||||
|
if ($altroot ne "") {
|
||||||
|
system("chroot",$altroot,"sh","$pdirs{$t}/post-install");
|
||||||
|
} else {
|
||||||
system("sh","$pdirs{$t}/post-install");
|
system("sh","$pdirs{$t}/post-install");
|
||||||
|
}
|
||||||
( $?>>8 == 0 ) ? $ok_post{$t}=1 : delete $ok_post{$t};
|
( $?>>8 == 0 ) ? $ok_post{$t}=1 : delete $ok_post{$t};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user