Compare commits

..

3 Commits

3 changed files with 128 additions and 44 deletions

View File

@ -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
@ -432,15 +432,20 @@ be affected by the operation.
.TP .TP
.B \-fr .B \-fr
Force rebuild, Implies 'pkgmk -f'; same as --margs=-f Force rebuild. Implies 'pkgmk -f'; same as --margs=-f
.TP
In the most common uses of \fB\-fr\fP, it is not desired to rebuild all the
dependencies too, even the ones that are out of date. Hence the \fB\-fr\fP flag
will be interpreted to imply also \fB\-\-nodeps\fP. But you can override this
side effect by passing \fB\-\-depsort\fP AFTER the \fB\-fr\fP flag.
.TP .TP
.B \-us .B \-us
Update signature, implies 'pkgmk -us'; same as --margs=-us Update signature. Implies 'pkgmk -us'; same as --margs=-us
.TP .TP
.B \-is .B \-is
Ignore signature, implies 'pkgmk -is'; same as --margs=-is Ignore signature. Implies 'pkgmk -is'; same as --margs=-is
.TP .TP
.B \-uf .B \-uf
@ -467,6 +472,13 @@ note that \-d is already passed to pkgmk anyway.
.B \-\-aargs="...", e.g. \-\-aargs="\-f" .B \-\-aargs="...", e.g. \-\-aargs="\-f"
Pass these additional arguments to pkgadd Pass these additional arguments to pkgadd
.TP
.B \-\-install\-root="...", e.g. \-\-install\-root="/mnt"
Specify a mountpoint other than "/", where the built packages are to be
installed. This setting affects the package database that is subject to
read/write operations, but not the ports tree (which remains governed by
the prtdir directives in \fBprt-get.conf(5)\fP).
.TP .TP
.B \-\-cache .B \-\-cache
Use cache file for this command Use cache file for this command
@ -491,7 +503,7 @@ Interpret filter and search pattern as regular expression
.SH "CONFIGURATION" .SH "CONFIGURATION"
Most of the directives available in prt\-get.conf(5) are also recognized and Most of the directives available in \fBprt\-get.conf(5)\fP are also recognized and
respected by \fBprt\-auf\fP. Notably, you can specify the active port respected by \fBprt\-auf\fP. Notably, you can specify the active port
collections by ensuring that they appear on lines beginning with 'prtdir '. collections by ensuring that they appear on lines beginning with 'prtdir '.
You can also toggle the running of pre-/post-install scripts by editing the You can also toggle the running of pre-/post-install scripts by editing the
@ -584,7 +596,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

View File

@ -14,8 +14,8 @@ use strict;
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=(.+)$/) { $altroot=$1;
} elsif ($arg =~ /^--rargs=(-r|--root)=(.+)/) { $opkg{rargs} .= "$1 $2"; } elsif ($arg =~ /^--aargs=(-r|--root)=(.+)/) { $altroot=$2;
} elsif ($arg =~ /^--rargs=(-r|--root)=(.+)/) { $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);
} }
@ -433,6 +434,7 @@ sub get_pkgfile_fields {
if (($Version =~ m/\$\(.*\)/) or ($Version =~ m/`.*`/)) { if (($Version =~ m/\$\(.*\)/) or ($Version =~ m/`.*`/)) {
open(ECHO,"-|","bash -c \'source $pkgfile; echo \$version\'"); open(ECHO,"-|","bash -c \'source $pkgfile; echo \$version\'");
while(<ECHO>) { chomp; $Version = $_; } while(<ECHO>) { chomp; $Version = $_; }
close(ECHO);
} }
$Dependencies =~ s/, / /g; $Dependencies =~ s/,/ /g; $Dependencies =~ s/, / /g; $Dependencies =~ s/,/ /g;
@ -491,12 +493,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 {
@ -759,12 +765,15 @@ sub up_inst { # returns scalar references to five arrays
$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'} = $1 if ( $V_REPO{$t} =~ m/(.+)-[0-9]+$/ ); $pvars{'%v'} = $1 if ( $V_REPO{$t} =~ m/(.+)-[0-9]+$/ );
$pvars{'%r'} = $1 if ( $V_REPO{$t} =~ m/-([0-9]+)$/ ); $pvars{'%r'} = $1 if ( $V_REPO{$t} =~ m/-([0-9]+)$/ );
$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 ne "") ? "$PKG_DIR/$t#$pvars{'%v'}-$pvars{'%r'}.pkg.tar.$COMPRESSION" : "$pvars{'%p'}/$t#$pvars{'%v'}-$pvars{'%r'}.pkg.tar.$COMPRESSION";
$builtpkg{$t} =~ s/uuiName/$t/g; $builtpkg{$t} =~ s/uuiName/$t/g;
$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 +797,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 +824,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};
} }
} }
@ -836,11 +853,11 @@ sub parse_pkgmk_conf {
my @pkgmkVars; my @pkgmkVars;
my $heredoc = "bash -c 'name=uuiName; version=uuiVer;"; my $heredoc = "bash -c 'name=uuiName; version=uuiVer;";
$heredoc .= "release=uuiRel; source /etc/pkgmk.conf; "; $heredoc .= "release=uuiRel; source /etc/pkgmk.conf; ";
$heredoc .= "printf \"%s\\t%s\" \"\$PKGMK_PACKAGE_DIR\" "; $heredoc .= "printf \"%s:%s\" \"\$PKGMK_PACKAGE_DIR\" ";
$heredoc .= "\$PKGMK_COMPRESSION_MODE;'"; $heredoc .= "\$PKGMK_COMPRESSION_MODE;'";
open (CF,"-|",$heredoc) or return; open (CF,"-|",$heredoc) or return;
while (<CF>) { @pkgmkVars = split /\t/; while (<CF>) { @pkgmkVars = split /:/;
} close (CF); } close (CF);
my $COMPRESSION = ($pkgmkVars[1] eq "") ? "gz" : $pkgmkVars[1]; my $COMPRESSION = ($pkgmkVars[1] eq "") ? "gz" : $pkgmkVars[1];

47
scripts/prtorphan.awk Executable file
View File

@ -0,0 +1,47 @@
#!/usr/bin/awk -f
#
# reimplementation in awk of the prtorphan script by Opel (2003).
# Only detects installed ports that have been dropped from the repos,
# does NOT accept the argument '-d' to activate directory mode.
BEGIN {
RS="\n\n"; FS="\n";
while ( (getline < "/var/lib/pkg/db") > 0 ) {
Version[$1] = $2;
}
RS="\n"; FS=" ";
while ( (getline line < "/etc/prt-get.conf") > 0 ) {
if (line ~ /^prtdir /) {
sub(/^prtdir /,"",line);
sub(/ #.*$/,"",line);
if (line !~ /:/) {
portdirs[line] = 1;
} else {
split(line,a,":");
base = a[1];
split(a[2],filter,",");
for (i in filter) {
portdirs[(base "/" filter[i])] = 1;
}
}
}
}
for (dir in portdirs) {
ports = "find " dir " -name Pkgfile -printf '%h\n'";
while ((ports | getline entry) > 0 ) {
sub(/.*\//,"",entry);
if (entry == ".") {
validports[dir] = 1;
} else {
validports[entry] = 1;
}
}
}
# print the orphaned ports
for (name in Version) {
if (! (name in validports)) { printf("%s\n",name); }
}
}