expand the prt-get man-page with more examples

add more details to the prt-cache man-page
This commit is contained in:
John McQuah 2023-03-12 10:23:43 -04:00
parent 5d2b5e0ac0
commit 8ac36484c5
4 changed files with 92 additions and 33 deletions

View File

@ -14,7 +14,7 @@ prt\-cache is a synonym for
.B prt\-get --cache.
It's perfectly the same as calling prt\-get --cache, just shorter. See
.B man prt-get(8)
for details on how to use prt-get
for details on how to use prt-get.
.PP
Even though there are almost restrictions on using prt-cache over prt-get,
@ -38,7 +38,11 @@ ports tree),
and
.B prt-cache update
will use the version from the ports tree anyway, so there's no real
risk.
risk. On the other hand,
.B prt-cache depinst
will use the outdated cache for dependency resolution, which might be a problem
if the maintainer of your desired port has added dependencies since the last
time you generated the cache.
.PP
If you're using prt-cache, make sure to regenerate the cache by calling
@ -48,9 +52,39 @@ each time you make changes to the ports tree!
.PP
To create a cache, just invoke
.B prt-get cache.
Make sure you have the right permissions to do this
Make sure you have the right permissions to do this.
.SH "CACHE FORMAT"
.PP
The cache is a flat-text file, typically found at /var/lib/pkg/prt-get.cache.
The first line records the cache format identifier, to prevent prt-cache from
performing an operation using an incompatible cache format. The rest of the
file consists of 13 lines per port: name, absolute path to the repository,
version, release, description, dependencies, URL, optional dependencies,
maintainer, readme, pre-install, post-install, and a blank (separator) line. If
multiple ports with the same name appear among the active collections (as
reported by \fBprt\-get dup\fP), only the first port will be listed in the
cache.
.PP
Suppose you want to create a dependency map, like the one used by the setup
program when installing from a CRUX ISO. One way to do so is to run \fBprt\-get
cache\fP, and then process the resulting file with \fBawk(1)\fP:
.B
tail -n +2 /var/lib/pkg/prt-get.cache | awk '((NR-1) % 13 < 2) { printf("%s : ",$0) } (NR %13 == 6) { gsub(/,/," ",$0); printf("%s\\n",$0) }' | awk -F: '/ \\/usr\\/ports\\/(core|opt|xorg) / { printf("%-25s : %s\\n",$1,$3) }' | tee -a setup.dependencies
.PP
A slight variation will also extract all the optional dependencies of each
port, in case you want to mimic Gentoo USE flags by editing the resulting file
and referring to it in a wrapper script, as illustrated by the ffmpeg example
in the \fBprt\-get\fP(8) man-page.
.B
tail -n +2 /var/lib/pkg/prt-get.cache | awk '((NR-1) % 13 == 0) { printf("%s : ",$0) } (NR %13 == 8) { gsub(/,/," ",$0); printf("%s\\n",$0) }' | sudo tee -a /etc/prt-get.softdeps
.SH "AUTHORS"
Johannes Winkelmann <jw@tks6.net>
Johannes Winkelmann <jw@tks6.net>, John McQuah <jmcquah@disroot.org>
.SH "SEE ALSO"
prt-get(8), pkgmk(8) pkgadd(8), ports(8)

View File

@ -220,19 +220,21 @@ Print the port's README file if it exists; if set, uses $PAGER
print a recursive list of dependencies needed to install the packages passed
as argument. It shows a list of the dependencies that were found in the ports tree,
plus a list of the dependencies that could not be found. Pass the --softdeps flag
if you want the sorting algorithm to take optional dependencies into account.
if you want the sorting algorithm to consider optional dependencies too.
.TP
.B quickdep [\-\-softdeps] <package1> [<package2> ...]
print a simple list of recursive dependencies for all the packages passed
as argument. The output is formatted to be useful in command substitution, e.g.
instead of running
same output as \fBdepends\fP, but separated by spaces rather than newlines, and
stripped of any dependencies that could not be found in the ports tree.
Useful in case the list of dependencies is too large to fit on one screen, or
if you don't want to filter out manually the ports that are invalid targets for
installation. For example, instead of
.B prt\-get depinst xorg-server
you might micromanage the process as follows:
.B for i in $(prt\-get quickdep xorg-server); do if prt\-get isinst $i 2>/dev/null; then prt\-get update $i; else prt\-get install $i; fi; done
.B for i in $(prt\-get quickdep xorg-server); do if prt\-get isinst $i 2>/dev/null; then prt\-get update \-fr $i; else prt\-get install $i; fi; done
which ensures that the latest version of each dependency is built.
Note: output is restricted to those dependencies that can be found in the ports tree.
It might be useful to run
Note: It might be useful to run
.B prt\-get depends <package1> | grep \(dq\-\- missing packages\(dq
as a first step, in order to ensure that your ports tree has everything needed
for successful builds.
@ -387,8 +389,8 @@ dependencies.
.TP
.B listorphans [\-v|\-vv|\-\-softdeps]
List installed ports which do not appear in the "Depends on:" line of
any other port currently installed. Pass the --softdeps flag to exclude ports
that are listed as soft dependencies of currently-installed ports.
any other port currently installed. Pass the --softdeps flag to also exclude
ports that are listed as optional dependencies of currently-installed ports.
Output appears alphabetically separated by newlines, making it suitable for
process substitution as shown in the
.B EXAMPLES
@ -398,11 +400,13 @@ for an explanation of this practice.
.TP
.B isinst <package1> [<package2> ...]
Check whether each package given on the command line is installed. Output in the case of multiple
arguments is separated by newlines, suitable for processing by awk or grep. Similar to
Check whether each package given on the command line is installed. Output in
the case of multiple arguments is separated by newlines, suitable for
processing by awk or grep. Similar to
.B pkginfo \-i|grep \-E '^(package1|package2|...)'
but does not print the version information. This command has a return value of 0 if
all packages given as argument are installed, otherwise a return value greater than 0.
but does not print the version information. This command has a return value of
0 if all packages given as argument are installed, otherwise a return value
greater than 0.
.TP
.B current <package>
@ -414,7 +418,7 @@ this command does \fBnot\fP accept more than one package as argument. Use
to work around this limitation.
.TP
.B ls [--path] <package>
.B ls [\-\-path] <package>
Prints out a listing of the port's directory
.TP
@ -437,12 +441,12 @@ Dump the configuration to the current terminal
.TP
.B version
Shows the current version of prt\-get
Shows the current version of prt-get
.TP
.B cache
create a cache file from the ports tree to be used by prt\-get using the
\-\-cache option. Remember to run prt\-get cache each time you update the
create a cache file from the ports tree to be used by prt-get using the
--cache option. Remember to run prt-get cache each time you update the
ports tree.
.SH "OPTIONS"
@ -608,7 +612,7 @@ a sysup operation.
.TP
.B \-\-strict\-diff, \-sd
Override the 'preferhigher' configuration option. Equivalent to
.B \-\-config\-set="preferhigher no"
.B \-\-config\-set=\(dqpreferhigher no\(dq
@ -637,21 +641,34 @@ Update your current version of openssh, forcing a rebuild even if no version dif
Useful if there was a major version change in one of its dependencies, and \fBrevdep openssh\fP
indicates a broken package. :\-)
.TP
.B MISSLIBS=$(revdep -vvv mpv | awk -v FS=: '/(missing library)/ {print $3}'); [ -n \(dq${MISSLIBS[@]}\(dq ] && for i in ${MISSLIBS[@]}; do prt\-get fsearch $i; done
(adapted from a script by ppetrov^) Check for the presence of the runtime libraries needed by mpv.
If any are absent, search the footprints to determine which ports provide the missing libraries.
.TP
.B prt\-get isinst $(prt-get info ffmpeg | awk -v FS=: '/^Optional/ {gsub(/,/,\(dq \(dq,$2); print $2}') | awk -v FS=\(dq \(dq '/not installed/ {print $2}'
Show all the optional dependencies of ffmpeg that are not currently installed.
.TP
.B prt\-get isinst $(prt-get info ffmpeg | awk -v FS=: '/^Optional/ {gsub(/,/,\(dq \(dq,$2); print $2}') | awk -v FS=\(dq \(dq '/not installed/ {print $2}' | xargs prt\-get depinst \-\-group \-\-softdeps ffmpeg
Extension of the above. Installs ffmpeg and all its optional dependencies, in
Extension of the above. Installs ffmpeg and all its optional dependencies, in
the order that guarantees a maximal feature set. The --group flag tells
\fBprt\-get\fP to abort the operation if any port fails to build, so as not to
spend any resources on ffmpeg until all its optional dependencies are in place.
spend any resources on ffmpeg until all of its optional dependencies are in
place.
.TP
.B MISSLIBS=$(revdep -vvv mpv | awk -v FS=: '/(missing library)/ {print $3}'); [ -n \(dq${MISSLIBS[@]}\(dq ] && for i in ${MISSLIBS[@]}; do prt\-get fsearch $i; done
(adapted from a script by ppetrov^) Check for the presence of the runtime libraries needed by mpv.
If any are absent, search the footprints to determine which ports provide the missing libraries.
.B prt\-get isinst $(if grep -qE '^ffmpeg:' /etc/prt-get.softdeps 2>/dev/null; then grep -E '^ffmpeg:' /etc/prt-get.softdeps | cut -d: -f2 | tr ',' ' '; else prt-get info ffmpeg | awk -v FS=: '/^Optional/ {gsub(/,/,\(dq \(dq,$2); print $2}'; fi) | awk -v FS=\(dq \(dq '/not installed/ {print $2}' | xargs prt\-get depinst \-\-group \-\-softdeps ffmpeg
Extension of the above (addressing a use case envisioned by ivandi). The
user can create the file /etc/prt-get.softdeps containing a line like
.B ffmpeg: x264 x265
and then the above command will perform a depinst --group operation to ensure that
at least x264 and x265 (but not necessarily any of the other optional
dependencies) are present before trying to build ffmpeg. In the absence of such
a .softdeps config, the operation reverts to the behaviour of the preceding
example (maximal feature set). Implementing Gentoo USE flags with such an
awkward one-liner might draw criticism from advocates of the KISS principle.
.TP
.B prt\-get search \-\-regex '^(m|n|p)c.*'

View File

@ -213,7 +213,6 @@ bool ArgParser::parse()
m_printTree = true;
} else if ( s == "--depsort" ) {
m_depSort = true;
} else if ( s == "-f" ) {
m_pkgaddArgs += " " + s;
} else if ( s == "-fr" ) {
@ -273,11 +272,19 @@ bool ArgParser::parse()
if (!m_isCommandGiven) {
string s = m_argv[i];
m_commandName = s;
for ( int i = 0; i < commandCount; ++i ) {
if ( s == commands[i] ) {
m_isCommandGiven = true;
m_commandType = commandID[i];
break;
if ( s == "grpinst" ) {
m_isCommandGiven = true;
m_commandType = commandID[7];
m_group = true;
cout << "Warning: grpinst is obsolescent";
cout << "; using install --group" << endl;
} else {
for ( int i = 0; i < commandCount; ++i ) {
if ( s == commands[i] ) {
m_isCommandGiven = true;
m_commandType = commandID[i];
break;
}
}
}
// first argument must be command

View File

@ -14,6 +14,7 @@
#include <list>
#include <string>
#include <iostream>
using namespace std;
/*!