fix FS#1910 and 1930; introduce Alan's --group flag;

expand the prt-get man-page with more examples
This commit is contained in:
John McQuah 2023-03-12 07:37:16 -04:00
parent 38bb3aa21a
commit b3404ff38e
13 changed files with 846 additions and 303 deletions

View File

@ -14,7 +14,7 @@ prt\-cache is a synonym for
.B prt\-get --cache. .B prt\-get --cache.
It's perfectly the same as calling prt\-get --cache, just shorter. See It's perfectly the same as calling prt\-get --cache, just shorter. See
.B man prt-get(8) .B man prt-get(8)
for details on how to use prt-get for details on how to use prt-get.
.PP .PP
Even though there are almost restrictions on using prt-cache over prt-get, Even though there are almost restrictions on using prt-cache over prt-get,
@ -38,7 +38,11 @@ ports tree),
and and
.B prt-cache update .B prt-cache update
will use the version from the ports tree anyway, so there's no real 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 .PP
If you're using prt-cache, make sure to regenerate the cache by calling 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 .PP
To create a cache, just invoke To create a cache, just invoke
.B prt-get cache. .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" .SH "AUTHORS"
Johannes Winkelmann <jw@tks6.net> Johannes Winkelmann <jw@tks6.net>, John McQuah <jmcquah@disroot.org>
.SH "SEE ALSO" .SH "SEE ALSO"
prt-get(8), pkgmk(8) pkgadd(8), ports(8) prt-get(8), pkgmk(8) pkgadd(8), ports(8)

View File

@ -1,7 +1,8 @@
.\" man page for prt-get .\" man page for prt-get
.\" Johannes Winkelmann, jw@tks6.net .\" original work by Johannes Winkelmann, jw at tks6 dot net
.\" .\"
.\" my first man page, so forgive me for the errors :-) .\" extended in 2013 by Alan Mizrahi, alan at mizrahi dot com dot ve
.\" and in 2023 by John McQuah, jmcquah at disroot dot org
.\" .\"
.\" .PU .\" .PU
.TH "prt-get" "8" "" "" "" .TH "prt-get" "8" "" "" ""
@ -14,9 +15,9 @@ pkgutils from CRUX (see http://www.crux.nu)
.br .br
.SH "DESCRIPTION" .SH "DESCRIPTION"
prt\-get is a package management tool which provides additional prt\-get is a package management tool which provides additional
functionality to crux' package management system. It works with the functionality to the CRUX package management system. It works with the
local ports tree and is therefore fully compatible with ports(8) and local ports tree and is therefore fully compatible with ports(8) and
pkgmk(8)/pkgadd(8). It offers the following features: pkgmk(8)/pkgadd(8)/pkgrm(8). It offers the following features:
.PP .PP
.TP .TP
@ -41,8 +42,8 @@ search within the ports
.PP .PP
What prt\-get basically does is installing and upgrading packages, using What prt\-get basically does is build, install/upgrade, and remove packages, using
pkgmk and pkgadd. Additionally, you don't have be in the port's pkgmk, pkgadd, and pkgrm. Additionally, you don't have be in the port's
directory to call prt\-get. prt\-get will search for the respective port directory to call prt\-get. prt\-get will search for the respective port
itself in a list of directories specified in /etc/prt\-get.conf. This itself in a list of directories specified in /etc/prt\-get.conf. This
allows you to just install or update a package, without caring where allows you to just install or update a package, without caring where
@ -50,26 +51,24 @@ it actually is located on your file system.
.PP .PP
prt\-get also offers some features like searching ports by name, prt\-get also lets you search for ports by name,
showing information about ports (without installing them of course) find information about ports (without installing them of course),
and can list the dependencies listed in the Pkgfile, and provide a or print the dependencies of a port (as a space- or newline-separated list,
complete dependency list for a port. Note that dependencies are no or a formatted tree). Note that dependencies are no
requirement for crux packages and therefore not always accurate. There's requirement for crux packages and therefore not always accurate.
a possiblity to use an external dependency map to get dependency
listings for ports which don't provide them in their Pkgfile.
.PP .PP
prt\-get has a test mode so you can see what effect an install/update prt\-get has a test mode so you can see what effect an install/update
operation would have. Use the \-\-test switch for this (see also: operation would have. Use the \-\-test switch for this (more details in
OPTIONS) the \fBOPTIONS\fP section below).
.SH "RETURN VALUE" .SH "RETURN VALUE"
prt\-get returns 0 on success and a non-zero value otherwise (exact prt\-get returns 0 on success and a non-zero value otherwise (exact
value -> meaning mapping to be determined...) value -> meaning mapping to be determined...)
.SH "COMMANDS" .SH "COMMANDS"
prt\-get uses so called commands, which always have to be the first prt\-get uses so\-called commands, which always have to be the first
non-option argument passed. This is very similar to non-option argument passed. This is very similar to
.B cvs(1). .B cvs(1).
[command] can be one of the following: [command] can be one of the following:
@ -78,32 +77,49 @@ non-option argument passed. This is very similar to
.TP .TP
.B install [\-\-margs] [\-\-aargs] [\-\-log] <package1> [<package2> ...] .B install [\-\-margs] [\-\-aargs] [\-\-log] <package1> [<package2> ...]
install all packages in the listed order. Note that you can do this install all packages in the listed order. Note that you can do this
from any directory from any directory.
.TP .TP
.B depinst [\-\-margs] [\-\-aargs] [\-\-log] <package1> [<package2> ...] .B depinst [\-\-margs] [\-\-aargs] [\-\-log] [\-\-softdeps] <package1> [<package2> ...]
install all packages in the listed order including their dependencies. install all packages given on the command line, including their dependencies.
Note that outdated packages won't be updated. Passing the --softdeps flag tells \fBprt-get\fP to consider also the optional
dependencies when sorting. Note that already-installed packages will be left
.TP at their current version, even if out of date. prt\-get depinst behaves this
.B grpinst [\-\-margs] [\-\-aargs] [\-\-log] <package1> [<package2> ...] way because all of its child pkgadd processes will \fBlack\fP the \-u flag,
install all packages in the listed order, but stop if installation of which is needed when updating an already-installed package.
one package fails. This can be used to install packages where package2
depends on package1
.TP .TP
.B update [\-\-margs] [\-\-aargs] [\-\-log] <package1> [<package2> ...] .B update [\-\-margs] [\-\-aargs] [\-\-log] <package1> [<package2> ...]
update all packages listed in this order update all packages listed in this order. Note: if the latest version of
a package has acquired dependencies that were not needed by the currently-installed
version and are not present on the system, the update command will not attempt to
resolve this omission. prt-get update behaves this way because pkgadd invocations
inherit the flag -u for every package in the transaction, causing an error if
the package is not already installed. You can follow the CRUX mailing list or the
IRC channels to stay informed of the situations where an update will require manual
intervention, or filter the output of
.B prt\-get quickdep $(prt\-get quickdiff)
through \fBprt\-get isinst\fP to get a list of packages suitable for an
\fBinstall\fP or \fBupdate\fP command.
See the \fBEXAMPLES\fP section below for details.
.TP .TP
.B remove <package1> [<package2> ...] .B remove <package1> [<package2> ...]
remove packages listed in this order remove packages listed in this order
.TP .TP
.B sysup [\-\-nodeps] .B sysup [\-\-softdeps] [\-\-nodeps]
Update all installed packages which are outdated. Sorts by dependencies Update all installed packages which are outdated. Sorts by hard dependencies
by default. If you don't want prt-get to resolve the dependencies, use by default. Passing the --softdeps switch tells \fBprt\-get\fP to also consider
the --nodeps switch. Also see the optional dependencies when sorting. Passing the --nodeps switch tells prt-get
not to sort by dependencies at all, for approximately the same effect as
.B prt\-get update $(prt\-get quickdiff).
As with an \fBupdate\fP command, the child \fBpkgadd\fP processes will
inherit the \-u flag, so if a port has acquired new dependencies since
its last successful build, those new dependencies will be omitted from
the transaction (unless they happen to be installed for some other reason and
are also in need of an update). See the \fBEXAMPLES\fP section for a way to
automate the resolution of such omissions. Also see the
.B lock .B lock
and and
.B unlock .B unlock
@ -133,11 +149,11 @@ also includes the description from the Pkgfile. Note that the
switch will slow down the operation remarkably. switch will slow down the operation remarkably.
.TP .TP
.B diff [--all] [<package1> <package2> ...] .B diff [\-\-all] [\-\-prefer\-higher] [<package1> <package2> ...]
show differences between installed packages and ports in the ports show differences between installed packages and ports in the ports
tree. If arguments are given, shows only differences for these tree. If arguments are given, shows only differences for these
packages, otherwise all differences are shown. It's also possible to use packages, otherwise all differences are shown. It's also possible to use
shell like shell-like
.B wildcards .B wildcards
for the diff command. Make sure you escape where needed. Locked for the diff command. Make sure you escape where needed. Locked
packages are only displayed if you use the --all switch. If you want packages are only displayed if you use the --all switch. If you want
@ -147,37 +163,44 @@ the ports tree, use the --prefer-higher option.
.TP .TP
.B quickdiff .B quickdiff
prints a simple list of packages which have a different version in the prints a simple list of packages which have a different version in the
ports tree than what is installed. This is meant as an input for ports tree than what is installed. The output is sorted alphabetically,
.B prt\-get update, but you can generate a (larger) list sorted by dependencies using
so you can update all ports on your system with one simple command. If you want .B prt\-get quickdep $(prt\-get quickdiff).
to see only diffs which have a lower version installed than the one in Note that the resulting list is usually a mix of installed and
not-installed packages, so it must be filtered by
.B prt\-get isinst
before being passed as argument to prt\-get install or prt\-get update. See the
.B EXAMPLES
section below.
If you want to see only diffs which have a lower version installed than the one in
the ports tree, use the --prefer-higher option. the ports tree, use the --prefer-higher option.
.TP .TP
.B search [\-v|\-vv] [--path] [--regex]<expr> .B search [\-v|\-vv] [\-\-path] [\-\-regex] <expr>
Search the ports tree for Search the ports tree for
.B expr .B expr
in their name in their name
.TP .TP
.B dsearch [\-v|\-vv] [--path] [--regex]<expr> .B dsearch [\-v|\-vv] [\-\-path] [\-\-regex] <expr>
Search the ports tree for Search the ports tree (both name and description) for the pattern
.B expr .B expr
in both name and description. The search in the description is not case (which can be a shell-like wildcard pattern or a regexp). The search in
sensitive. Note that this requires prt\-get to read every Pkgfile, which the description is not case sensitive. Note that this requires prt\-get
makes it rather slow; if you like this, consider using the cache to read every Pkgfile, which makes it rather slow; if you like this,
functionality, so you only have to spend this time once after updating consider using the cache functionality, so you only have to spend this
the ports tree has been updated. time once after updating the ports tree has been updated.
.TP .TP
.B fsearch [--full] [--regex] <pattern> .B fsearch [\-\-full] [\-\-regex] <pattern>
Search the ports tree for Search the ports tree for
.B pattern .B pattern
as file name in their footprint. When called without '--full', strips as file name in their footprint. When called without '--full', strips
the directories from the file names before matching; this behaviour the directories from the file names before matching; this behaviour
will change in prt-get 0.6, where full path search will be will change in prt-get 0.6, where full path search will be the
default. Pattern can be a shell-like wildcard pattern (e.g prt-get default. Pattern can be a shell-like wildcard pattern (e.g. prt-get
fsearch "*.h") or regexps. fsearch "*.h") or a regular expression (e.g. prt-get fsearch --regex 'liblz(o2|ma).*')
.TP .TP
@ -193,34 +216,51 @@ Print the path of a port
Print the port's README file if it exists; if set, uses $PAGER Print the port's README file if it exists; if set, uses $PAGER
.TP .TP
.B depends <package1> [<package2> ...] .B depends [\-\-softdeps] <package1> [<package2> ...]
print a recursive list of dependencies to install the packages passed print a recursive list of dependencies needed to install the packages passed
as argument. It shows a list with ports which are found, plus a list as argument. It shows a list of the dependencies that were found in the ports tree,
of ports which are missing plus a list of the dependencies that could not be found. Pass the --softdeps flag
if you want the sorting algorithm to consider optional dependencies too.
.TP .TP
.B quickdep <package1> [<package2> ...] .B quickdep [\-\-softdeps] <package1> [<package2> ...]
print a simple list of recursive dependencies for all the ports passed same output as \fBdepends\fP, but separated by spaces rather than newlines, and
as argument in a simple format to be used by stripped of any dependencies that could not be found in the ports tree.
.B prt\-get install Useful in case the list of dependencies is too large to fit on one screen, or
to make an install including dependencies if you don't want to filter out manually the ports that are invalid targets for
.B Does not display dependencies which are not in the ports tree 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 \-fr $i; else prt\-get install $i; fi; done
which ensures that the latest version of each dependency is built.
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.
.TP .TP
.B dependent <package> .B deptree [\-\-softdeps] <package>
print a list of package which depend on
.B package.
Usually shows dependent packages which are installed. To see all dependencies,
add the --all switch; use --recursive to get a recursive list (without
duplication), and --tree to get a nicely indented one
.TP
.B deptree <package>
print a tree of the dependencies of the package print a tree of the dependencies of the package
.B package. .B <package>.
Subtrees already shown are marked with '-->' to save some space, in Pass the --softdeps flag to also show the installed packages that mention
order to show them all, add the --all switch .B <package>
as an optional dependency.
Subtrees already shown are marked with '-->' to save some space. In
order to show them all, add the --all switch.
.SH ""
.TP
.B dependent [\-\-softdeps] <package>
print a list of ports which have
.B <package>
in their "Depends on:" line. Use the --softdeps flag to also search the
"Optional:" lines for \fB<package>\fP.
By default, output is restricted to ports that are installed. To see all hard
dependencies, add the --all switch; use --recursive to get a recursive list
(without duplication), and --tree to get a nicely indented one.
.TP .TP
.B dup [-v] [format] .B dup [-v] [format]
@ -252,19 +292,18 @@ specified formats. The following symbols are currently replaced:
.TP .TP
.B list [\-v|\-vv] [filter] [--path] [--regex] .B list [\-v|\-vv] [\-\-path] [\-\-regex] [filter]
List ports available in the ports tree. It's basically the same as List ports available in the ports tree. It's basically the same as
.B ports \-l .B ports \-l
but looks in all directories specified in but looks in all directories specified in
.B /etc/prt\-get.conf. .B /etc/prt\-get.conf.
It's also possible to use It's also possible to use shell-like
shell like
.B wildcards .B wildcards
for the list command. Make sure you escape where needed for the list command. Make sure you escape where needed
.TP .TP
.B printf <format string1> [\-\-sort=<format string2>] [\-\-filter=<filter>] .B printf <format string1> [\-\-sort=<format string2>] [\-\-filter=<filter>]
Print formated port list format string can contain variables, which Print formatted port list format string can contain variables, which
are replaced like this: are replaced like this:
.TP .TP
\ \ \ \(bu \ \ \ \(bu
@ -292,11 +331,11 @@ are replaced like this:
.TP .TP
\ \ \ \(bu \ \ \ \(bu
%u \-> URL %P -> optional dependencies
.TP .TP
\ \ \ \(bu \ \ \ \(bu
%P -> Packager %u \-> URL
.TP .TP
\ \ \ \(bu \ \ \ \(bu
@ -332,7 +371,7 @@ to filter by package name.
.TP .TP
.B listinst [\-v|\-vv] [filter] [--regex] [--depsort] .B listinst [\-v|\-vv] [\-\-regex] [\-\-depsort] [filter]
List installed ports. It's basically the same as List installed ports. It's basically the same as
.B pkginfo \-i, .B pkginfo \-i,
but omits version when called without verbose (\-v, \-vv) switch. Plus but omits version when called without verbose (\-v, \-vv) switch. Plus
@ -341,41 +380,55 @@ adds version and description.
.B Warning: .B Warning:
\-vv will slow down the process because it requires prt\-get to scan \-vv will slow down the process because it requires prt\-get to scan
both the ports database and the ports tree. both the ports database and the ports tree.
It's also possible to use shell like It's also possible to use shell-like
.B wildcards .B wildcards
for the listinst command. Make sure you escape where needed. Finally, by for the listinst command. Make sure you escape where needed. By default
default it's sorted alphabetically; use the \-\-depsort switch to sort by it's sorted alphabetically; use the \-\-depsort switch to sort by
dependencies dependencies.
.TP .TP
.B listorphans [\-v|\-vv] .B listorphans [\-v|\-vv|\-\-softdeps]
List installed ports which have no dependent packages List installed ports which do not appear in the "Depends on:" line of
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
section below. Note that some core ports might be runtime
dependencies despite their absence in the "Depends on:" line; see \fBPkgfile(5)\fP
for an explanation of this practice.
.TP .TP
.B isinst <package> .B isinst <package1> [<package2> ...]
Check whether a package is installed. The same as Check whether each package given on the command line is installed. Output in
.B pkginfo \-i|grep ^package the case of multiple arguments is separated by newlines, suitable for
.TP 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.
.TP .TP
.B current <package> .B current <package>
Prints out the version of the currently installed package Shows the currently-installed version of <package>, or a message
that <package> is not installed. Unlike
.B prt\-get isinst package1 package2,
this command does \fBnot\fP accept more than one package as argument. Use
.B pkginfo \-i| grep \-E '^(package1|package2|...)'
to work around this limitation.
.TP .TP
.B ls [--path] <package> .B ls [\-\-path] <package>
Prints out a listing of the port's directory Prints out a listing of the port's directory
.TP .TP
.B cat <package> [<file>] .B cat <package> [<file>]
Prints out the file to stdout. If <file> is not specified, 'Pkgfile' is used. If set, uses $PAGER Prints out the file to stdout. If <file> is not specified, 'Pkgfile' is used. If set, uses $PAGER.
.TP .TP
.B edit <package> <file> .B edit <package> [<file>]
Edit the file using the editor specified in the $EDITOR environment variable. Edit the file using the editor specified in the $EDITOR environment variable.
If <file> is not specified, 'Pkgfile' is used If <file> is not specified, 'Pkgfile' is used.
.TP .TP
@ -388,60 +441,85 @@ Dump the configuration to the current terminal
.TP .TP
.B version .B version
Shows the current version of prt\-get Shows the current version of prt-get
.TP .TP
.B cache .B cache
create a cache file from the ports tree to be used by prt\-get using 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 --cache option. Remember to run prt-get cache each time you update the
ports tree ports tree.
.SH "OPTIONS" .SH "OPTIONS"
The following options are primarily useful for install/update transactions.
.TP .TP
.B -f, -i .B \-g, \-\-group
Stop install or update operation if one package fails (patch by Alan Mizrahi)
.TP
.B \-f, \-fi
Force install; Implies 'pkgadd -f'; same as --aargs=-f Force install; Implies 'pkgadd -f'; same as --aargs=-f
.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 .TP
.B -um .B \-um
Update md5sum, implies 'pkgmk -um'; same as --margs=-um Update md5sum, implies 'pkgmk -um'; same as --margs=-um
.TP .TP
.B -im .B \-im
Ignore md5sum, implies 'pkgmk -im'; same as --margs=-im Ignore md5sum, implies 'pkgmk -im'; same as --margs=-im
.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
Update footprint, implies 'pkgmk -uf'; same as --margs=-uf Update footprint, implies 'pkgmk -uf'; same as --margs=-uf
.TP .TP
.B -if .B \-if
Ignore footprint, implies 'pkgmk -if'; same as --margs=-if Ignore footprint, implies 'pkgmk -if'; same as --margs=-if
.TP .TP
.B -ns .B \-ns
No stripping, implies 'pkgmk -ns'; same as --margs=-ns No stripping, implies 'pkgmk -ns'; same as --margs=-ns
.TP .TP
.B -kw .B \-kw
Keep working directory, implies 'pkgmk -kw'; same as --margs=-kw Keep working directory, implies 'pkgmk -kw'; same as --margs=-kw
.TP .TP
.B --ignore=<package1,package2,...> .B \-\-margs="...", e.g. \-\-margs="\-im"
Don't install those packages, even if they're listed as dependency additional arguments to be passed to pkgmk;
note that \-d is already passed to pkgmk anyway
.TP
.B \-\-aargs="...", e.g. \-\-aargs="\-f"
additional arguments to be passed to pkgadd
.TP
.B \-\-rargs="..."
arguments to be passed to pkgrm; currently not used, implemented for
future uses and consistency reasons
.TP
.B \-\-ignore=<package1,package2,...>
Don't install these packages, even if they're listed as dependencies
.TP
.B \-\-softdeps
Consider optional dependencies when determining the order in which to build
the packages passed as arguments (in a \fBdepinst\fP or \fBsysup\fP operation).
Also affects the output of \fBdeptree\fP, \fBdependent\fP, and \fBlistorphans\fP.
.TP .TP
.B \-\-cache .B \-\-cache
@ -450,7 +528,7 @@ Use cache file for this command
.TP .TP
.B \-\-test .B \-\-test
Dry run, don't actually install anything, mostly interesting for Dry run, don't actually install anything, mostly interesting for
.B prt\-get install, prt\-get grpinst, prt\-get update, prt\-get sysup .B prt\-get install, prt\-get update, prt\-get sysup
.TP .TP
.B \-\-pre-install .B \-\-pre-install
@ -464,6 +542,28 @@ Execute post-install script if it's there
.B \-\-install-scripts .B \-\-install-scripts
Execute pre-install and post-install script if they're there Execute pre-install and post-install script if they're there
.TP
.B \-\-install-root=<dir>
Use <dir> as root directory for your installation; allows you to install
the requested packages onto a different directory than '/'. In daily usage,
this option is not required; it's primarily interesting if you're developing
an independent installation.
The setting for --install-root determines which package database is used for
reading/writing (so <dir>/var/lib/pkg/db must exist), and where the pkg.tar.?z
archives get unpacked, but the relevant prt\-get.conf and ports tree are those
on the parent filesystem. Therefore it is not necessary for <dir> to contain
its own copy of the ports tree, or even a copy of prt-get.conf.
However, if <dir>/etc/pkgadd.conf exists and is different from /etc/pkgadd.conf,
then install or update commands might behave unexpectedly. In order to preserve
the \fBpkgadd.conf(5)\fP settings from the host system, append the option
--aargs='-c /etc/pkgadd.conf' to your \fBprt-get install\fP
command, or just copy the desired directives into <dir>/etc/pkgadd.conf .
.TP
.B \-\-log
Write build output to log file
.TP .TP
.B \-\-no-std-config .B \-\-no-std-config
Don't parse the default configuration file Don't parse the default configuration file
@ -480,62 +580,41 @@ Append <string> to configuration
.B \-\-config-set=<string> .B \-\-config-set=<string>
Set <string> in configuration, overriding configuration file Set <string> in configuration, overriding configuration file
.TP
.B \-\-config=<file>
Use alternative configuration file to read ports directories from
.SH ""
The following options are primarily useful for non-install (information-seeking)
transactions, although some of them affect the behaviour of install/upgrade
transactions as well.
.TP .TP
.B \-v, \-vv .B \-v, \-vv
verbose and more verbose, relevant for (verbosity level) Show version of a port (\-v), or show both version
.B prt\-get search, prt\-get list and description (\-vv). Passing more than one of these options is equivalent to \-vv.
verbose shows version of a port, more verbose shows version and
description (if available)
.TP .TP
.B \-\-path .B \-\-path
Show path info; used in 'search', 'dsearch', 'list' and 'depends' Show path info for the ports found by a search or a dependency calculation
.TP .TP
.B \-\-regex .B \-\-regex
Interpret filter and search pattern as regular expression Interpret filter and search pattern as regular expression
.TP .TP
.B \-\-margs="...", e.g. \-\-margs="\-im" .B \-\-prefer\-higher, \-ph
arguments to be passed to pkgmk, relevant for
.B prt\-get install, prt\-get grpinst, prt\-get update
note that \-d is already passed to pkgmk anyway
.TP
.B \-\-aargs="...", e.g. \-\-aargs="\-f"
arguments to be passed to pkgadd, relevant for
.B prt\-get install, prt\-get grpinst, prt\-get update
.TP
.B \-\-rargs="..."
arguments to be passed to pkgrm; currently not used, implemented for
future uses and consistency reasons
.TP
.B \-\-prefer-higher, -ph
Make prt-get parse the version strings and prefer the higher version, Make prt-get parse the version strings and prefer the higher version,
even if the one found in the ports tree is lower. Will influence diff, even if the one found in the ports tree is lower. Also used during
quickdiff and sysup. a sysup operation.
.TP .TP
.B \-\-strict-diff, -sd .B \-\-strict\-diff, \-sd
Override the 'preferhigher' configuration option Override the 'preferhigher' configuration option. Equivalent to
.B \-\-config\-set=\(dqpreferhigher no\(dq
.TP
.B \-\-config=<file>
Use alternative configuration file to read ports directories from
.TP
.B \-\-install-root=<dir>
Use <dir> as root directory for your installation; allows to install to
a different directory than '/'. In daily usage, this option is not
required; helpful if you're developing an independent installation.
.TP
.B \-\-log
Write build output to log file
.SH "CONFIGURATION" .SH "CONFIGURATION"
.TP .TP
@ -544,36 +623,121 @@ See man prt\-get.conf(5)
.SH "EXAMPLES" .SH "EXAMPLES"
.TP .TP
.B prt\-get install irssi .B prt\-get install irssi
download, build and install irssi, with one simple command Download, build and install irssi, with one simple command
.TP .TP
.B prt\-get install indent mplayer .B prt\-get install paper yasm
install indent and mplayer Install paper and yasm. Abort with an informative error message if either package is already
installed, allowing you to issue a revised command.
.TP .TP
.B prt\-get update openssh .B prt\-get update bmake cmake
update your current version of openssh :\-) Update bmake and cmake. Abort with an informative error message if either package is not yet
installed, allowing you to issue a revised command.
.TP .TP
.B prt\-get info kdelibs .B prt\-get update -fr openssh
show info about kdelibs Update your current version of openssh, forcing a rebuild even if no version difference is detected.
Useful if there was a major version change in one of its dependencies, and \fBrevdep openssh\fP
indicates a broken package. :\-)
.TP .TP
.B prt\-get search icq .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
Search all ports containing 'icq' in their name (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 .TP
.B prt\-get grpinst \-\-test `prt\-get quickdep kdenetwork` .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 what would happen if you installed all packages needed for Show all the optional dependencies of ffmpeg that are not currently installed.
kdenetwork (test mode). Remove \-\-test to install kdenetwork and all
it's dependencies. Remember that grpinst stops installing when one
installing of one package fails
.TP .TP
.B prt\-get update `prt\-get quickdiff` .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
Update all packages where a different version is in the ports tree 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 of its optional dependencies are in
place.
.TP
.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.*'
Return a list of all ports whose names start with "mc", "nc", or "pc"
.TP
.B prt\-get dsearch irc
Return a list of all ports having "irc" in their name or description
.TP
.B comm -13 <(ls /usr/ports/core) <(prt-get listorphans)
(based on comments from Romster and jue) Filter out the core ports from the list of orphans, in
shells (like bash) that support process substitution
.TP
.B comm -13 <(cat ~/.keepers <(ls /usr/ports/core) | sort) <(prt\-get listorphans) | xargs prt\-get remove
(system-hosing extension of the above) A one-liner inspired by \fBpkg\-clean\fP
and \fBpkgfoster\fP, but without the safeguard of interactivity. \fBDo not try this on a
mission-critical system.\fP
.TP
.B prt\-get isinst $(prt\-get quickdep $(prt\-get quickdiff)) | awk '/not installed/ {print $2}'
(adapted from a comment by Fun) After updating your ports tree, print out a list of dependencies
that were not needed the last time you built your currently-installed ports, but are needed now by
the newer versions of these ports. The output of this command is sorted by dependencies, therefore
suitable for piping to \fBxargs prt\-get install\fP.
.TP
.B prt\-get isinst $(prt\-get quickdep $(prt\-get quickdiff)) | awk '/is installed/ {print $2}'
Same as above, but only print the dependencies that are already installed. The output of this
command is suitable for piping to \fBxargs prt\-get update\fP.
.TP
.B comm -3 <(prt\-get printf \(dq%i:%n %v-%r\en\(dq | grep -v ^no | cut -d: -f2 | sort) <(pkginfo -i | sort)
(inspired by a bug report from teodor) an alternative to \fBprt\-get diff\fP.
In the output, left-justified lines show the version available in the
repositories, while indented lines show the version installed. On a
reasonably up-to-date system, the two processes in the above command will
return many identical lines; these are suppressed by the -3 flag to
\fBcomm(1)\fP.
.TP
.B prt\-get printf \(dq%p\et%u\en\(dq | awk '($1 ~ /\e/myrepo$/) { print $2 }'
Print the upstream URL for each port in the collection \(dqmyrepo\(dq, perhaps
as the first step in keeping your personal overlay up to date.
.TP
.B prt\-get printf \(dq%M\et%n\en\(dq | grep ^Tim | wc -l
Count how many ports our most-overworked core team member claims responsibility for.
.TP
.B comm -13 <(prt\-get depends firefox-bin |tail -n +2 |sort) <(prt\-get depends firefox |tail -n +2 |sort)
Find the build-time dependencies of firefox. Runtime dependencies would also appear in the list generated by
the first process substitution, and \fBcomm -13\fP will suppress what the two lists have in common.
.TP
.B prt-get listinst \-\-depsort | xargs prt-get install \-\-install\-root=/mnt
Sort the list of installed packages by dependencies, and then install all
those packages onto a backup filesystem (mounted at /mnt). If you have a customized
pkgadd.conf that you want applied to this operation, either copy it to
/mnt/etc where pkgadd will be looking for it, or pass the additional option \-\-aargs=\(dq\-c
/etc/pkgadd.conf\(dq to the install command.
.TP
.B prt-get list --path --regex '^xorg.*' | grep -v \(dq/usr/ports/xorg\(dq
Show the ports whose names begin with xorg, but which appear outside the xorg port collection.
(At the time of writing, this command returned at least two font ports.)
.SH "AUTHORS" .SH "AUTHORS"
Johannes Winkelmann <jw@tks6.net> Johannes Winkelmann <jw@tks6.net>, and others cited inline
.SH "SEE ALSO" .SH "SEE ALSO"
prt\-get.conf(5), prt\-cache(8), pkgmk(8) pkgadd(8), ports(8) prt\-get.conf(5), prt\-cache(8), Pkgfile(5), pkgmk(8), pkgadd(8), ports(8)

View File

@ -1,6 +1,3 @@
j2sdk: j2re
lesstif: openmotif
postfix: sendmail postfix: sendmail
exim: sendmail exim: sendmail
qmail: sendmail rust-bin: rust
masqmail: sendmail

View File

@ -1,6 +1,8 @@
# prt-get(8), prt-cache(8) completion by Johannes Winkelmann, jw@tks6.net # prt-get(8), prt-cache(8) completion by Johannes Winkelmann, jw@tks6.net
# problems: options ending on = should not add a space afterwards # problems: options ending on = should not add a space afterwards
# #
# 12.03.2023: add the flag --softdeps
# 28.08.2013: use 'install --group' instead of 'grpinst' (patch by Alan)
# 07.07.2002: use prt-get listinst (from 0.3.1pre1) instead of pkginfo # 07.07.2002: use prt-get listinst (from 0.3.1pre1) instead of pkginfo
# 06.07.2002: first version # 06.07.2002: first version
@ -14,7 +16,7 @@ _prt-get()
if [ $COMP_CWORD -eq 1 ]; then if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W ' \ COMPREPLY=( $( compgen -W ' \
install depinst update grpinst help \ install depinst update help \
version readme list info path \ version readme list info path \
search dsearch fsearch printf cache \ search dsearch fsearch printf cache \
dependent sysup current lock unlock \ dependent sysup current lock unlock \
@ -27,7 +29,7 @@ _prt-get()
if [ $COMP_CWORD '>' 1 ]; then if [ $COMP_CWORD '>' 1 ]; then
if [[ "$cur" != -* ]]; then if [[ "$cur" != -* ]]; then
case ${COMP_WORDS[1]} in case ${COMP_WORDS[1]} in
"install" | "depinst" | "grpinst" | "path" | "dependent" | \ "install" | "depinst" | "path" | "dependent" | \
"depends" | "quickdep" | "info" | "readme" | \ "depends" | "quickdep" | "info" | "readme" | \
"ls" | "isinst" | "deptree" ) "ls" | "isinst" | "deptree" )
if [ -f /var/lib/pkg/prt-get.cache ]; then if [ -f /var/lib/pkg/prt-get.cache ]; then
@ -65,12 +67,12 @@ _prt-get()
esac esac
else else
case ${COMP_WORDS[1]} in case ${COMP_WORDS[1]} in
"install" | "update" | "groupinst") "install" | "update" | "depinst" )
COMPREPLY=( $( compgen -W '--config= --cache \ COMPREPLY=( $( compgen -W '--config= --cache \
--pre-install \ --pre-install \
--post-install \ --post-install \
--install-scripts \ --install-scripts \
--log --test \ --log --test --group \
--config \ --config \
--config-append= \ --config-append= \
--config-prepend= \ --config-prepend= \
@ -78,7 +80,15 @@ _prt-get()
--aargs= --margs= \ --aargs= --margs= \
--rargs= \ --rargs= \
--install-root=' \ --install-root=' \
-- $cur ) ) -- $cur ) )
;;
"depends" | "quickdep" | "deptree" | "listorphans" )
COMPREPLY=( $( compgen -W '--softdeps' -- $cur ) )
;;
"dependent" )
COMPREPLY=( $( compgen -W '--softdeps \
--recursive \
--tree' -- $cur ) )
;; ;;
"list" | "search" | "dsearch" ) "list" | "search" | "dsearch" )
COMPREPLY=( $( compgen -W '-v -vv --cache \ COMPREPLY=( $( compgen -W '-v -vv --cache \

300
misc/prt-get_complete_zsh Normal file
View File

@ -0,0 +1,300 @@
#compdef prt-get prt-cache
_commands=(
help:'show this help'
version:'show the current version'
list:'show a list of available ports'
printf:'print formatted list of available ports'
listinst:'show a list of installed ports'
listorphans:'list of ports with no packages depending on them'
info:'show info about a port'
path:'show path of a port'
readme:'show a port'"'"'s readme file (if it exists)'
dup:'find duplicate ports'
isinst:'print whether ports are installed'
current:'print installed version of port'
diff:'list outdated packages (or check args for change)'
quickdiff:'same as diff but simple format'
depends:'show dependencies for these ports'
quickdep:'same as depends but simple format'
deptree:'show dependencies tree for <port>'
dependent:'show installed packages which depend on '"'"'port'"'"''
search:'show port names containing '"'"'expr'"'"''
dsearch:'show ports containing '"'"'expr'"'"' in the name or description'
fsearch:'show file names in footprints matching '"'"'pattern'"'"''
install:'install ports'
update:'update ports'
depinst:'install ports and their dependencies'
remove:'remove ports'
sysup:'update all outdated ports'
lock:'lock current version of packages'
unlock:'unlock packages'
listlocked:'list locked packages'
ls:'print a listing of the port'"'"'s directory'
cat:'print out '"'"'port/file'"'"''
edit:'edit '"'"'port/file'"'"''
)
# Options Information
_infooptions=(
"--depsort[Sort by dependencies]"
)
# Options for Differences / Check for updates
_diffoptions=(
"--all[display locked ports too]"
"--prefer-higher[prefer higher installed versions over lower ports]"
"--strict-diff[override prefer higher configuration setting]"
)
# Options for Dependencies
_depoptions=(
"--all[list all dependent packages, not only installed]"
"--recursive[print recursive listing]"
"--tree[print recursive tree listing]"
"--softdeps[consider optional dependencies too]"
)
# Options for Install, Update and Removal
_installoptions=(
"-f[force installation]"
"-fi[force installation]"
"-fr[force rebuild]"
"-uf[update footprint]"
"-if[ignore footprint]"
"-um[update md5sum]"
"-im[ignore md5sum]"
"-us[update signature]"
"-is[ignore signature]"
"--margs=[pass 'string' to pkgmk]"
"--aargs=[pass 'string' to pkgadd]"
"--rargs=[pass 'string' to pkgrm]"
"--group[stop if any package fails to build]"
"--test[test mode]"
"--log[write log file]"
"--ignore=[Don't install/update those packages]:ignored packages:_allports"
"--pre-install[execute pre-install script]"
"--post-install[execute post-install script]"
"--install-scripts[execute pre-install and post-install script]"
)
# Options for System Update
_sysupoptions=(
"--nodeps[don't sort by dependencies]"
"--softdeps[consider optional dependencies when sorting]"
"--group[stop if any package fails to build]"
"--test[test mode]"
"--log[write log file]"
"--prefer-higher[prefer higher installed versions over lower ones in ports tree]"
"--strict-diff[override prefer higher configuration setting]"
)
_printfoptions=(
'%n[name]'
'%p[path]'
'%v[version]'
'%r[release]'
'%d[description]'
'%e[dependencies]'
'%P[optional dependencies]'
'%u[URL]'
'%M[Maintainer]'
'%R[Readme]'
'%E[pre-install script]'
'%O[post-install script]'
'%l[is locked]'
'%i[installed]'
)
# Options for General Options
_options=(
"-v[Show version in listing]"
"-vv[Show version and decription in listing]"
"--path[Print path to port if appropriate (search, list, depends)]"
"--cache[Use a cache file]"
"--config=[Use alternative configuration file]:file:_files"
"--install-root=[Use alternative install root directory]:directory:_directories"
"--no-std-config[Don't parse default configuration file]"
"--config-prepend=[Prepend '..' to configuration]:directory:_directories"
"--config-append=[Append '..' to configuration]:directory:_directories"
"--config-set=[Set configuration data '..', overriding config file]:data"
)
# Port list generators
_allports() {
local -a list
list=(${(f)"$(prt-get list 2>/dev/null)"})
_describe 'ports' list
}
_installedports() {
local -a list
list=(${(f)"$(prt-get listinst 2>/dev/null)"})
_describe 'installedports' list
}
_notinstalledports() {
local -a installed_ports all_ports not_installed_ports
installed_ports=(${(f)"$(prt-cache listinst 2>/dev/null)"})
all_ports=(${(f)"$(prt-cache list 2>/dev/null)"})
not_installed_ports=(${all_ports:|installed_ports})
_describe 'notinstalledports' not_installed_ports
}
_lockedports() {
local -a list
list=(${(f)"$(prt-cache listlocked 2>/dev/null)"})
_describe 'lockedports' list
}
_unlockedports() {
local -a installed locked list
installed=("${(f)$(prt-cache listinst)}")
locked=("${(f)$(prt-cache listlocked)}")
list=("${(f)$(echo ${installed[@]} ${locked[@]} | tr ' ' '\n' | sort | uniq -u)}")
_describe 'unlockedports' list
}
_outdatedports() {
local -a list
list=(${(f)"$(prt-cache quickdiff | tr ' ' '\n' | sort)"})
_describe 'outdatedports' list
}
# TODO: print files from <port> that exist inside the directory
# valid file for cat and edit
_validfiles() {
local -a list
list=(
"Pkgfile"
".signature"
".footprint"
"README"
"README.md"
)
_describe 'validfiles' list
}
# Main completion function
_arguments \
"${_options[@]}" \
":command:->command" \
"*::options:->options"
# Command completion
case $state in
command)
_describe 'commands' _commands
;;
options)
case $words[1] in
help | version | listorphans)
# No options for help | version command
;;
list)
_description list list '<filter>, e.g. *xorg*'
;;
listinst)
# TODO [<filter>]
_arguments -C \
"${_infooptions[@]}"
;;
printf)
# TODO <format>
# TODO [--sort=<format string2>] [--filter=<filter>]
local msg=(
'format string'
'[--sort=format_string2] [--filter=filter_string]'
''
'Supported format specifiers:'
'%n - name'
'%p - path'
'%v - version'
'%r - release'
'%d - description'
'%e - dependencies'
'%P - optional dependencies'
'%u - URL'
'%M - Maintainer'
'%R - Readme (yes/no)'
'%E - pre-install script (yes/no)'
'%O - post-install script (yes/no)'
'%l - is locked (yes/no)'
'%i - installed (no/yes/diff)'
)
;;
info | path | readme | ls)
_arguments \
":port:_allports"
;;
current)
_arguments -S \
":installedports:_installedports"
;;
cat | edit)
_arguments -C \
":port:_allports" \
":validfiles:_validfiles" \
;;
diff)
_arguments -S \
"*:outdatedports:_outdatedports" \
"${_diffoptions[@]}"
;;
quickdiff)
# No Options for quickdiff
;;
depends | quickdep | isinst)
_arguments -S \
":port:_allports" \
;;
dependent)
_arguments \
":port:_allports" \
"${_depoptions[@]}"
;;
deptree)
_arguments \
":port:_allports"
;;
dup | listlocked)
# No arguments for dup and listlocked commands
;;
search | dsearch)
# TODO <expr>
;;
fsearch)
# TODO <pattern>
;;
update | remove)
# TODO: highlight ports that have an update available?
# TODO: this completes only outdated once, if available,
# then show installedports..
_arguments -S \
":outdatedports:_outdatedports" \
"*:installedports:_installedports" \
"${_installoptions[@]}"
;;
install | depinst)
_arguments -S \
"*:notinstalledports:_notinstalledports" \
"${_installoptions[@]}"
;;
sysup)
_arguments -S \
"${_sysupoptions[@]}"
;;
lock)
_arguments -S \
"*:unlockedports:_unlockedports"
;;
unlock)
_arguments -S \
"*:lockedports:_lockedports"
;;
*)
;;
esac
;;
esac

View File

@ -20,7 +20,6 @@ using namespace std;
*/ */
ArgParser::ArgParser( int argc, char** argv ) ArgParser::ArgParser( int argc, char** argv )
: m_isCommandGiven( false ), : m_isCommandGiven( false ),
m_isForced( false ),
m_isTest( false ), m_isTest( false ),
m_isAlternateConfigGiven( false ), m_isAlternateConfigGiven( false ),
m_useCache( false ), m_useCache( false ),
@ -36,6 +35,7 @@ ArgParser::ArgParser( int argc, char** argv )
m_execPostInstall( false ), m_execPostInstall( false ),
m_preferHigher( false ), m_preferHigher( false ),
m_strictDiff( false ), m_strictDiff( false ),
m_group( false ),
m_useRegex(false), m_useRegex(false),
m_fullPath(false), m_fullPath(false),
m_recursive(false), m_recursive(false),
@ -128,13 +128,12 @@ const string& ArgParser::alternateConfigFile() const
*/ */
bool ArgParser::parse() bool ArgParser::parse()
{ {
const int commandCount = 35; const int commandCount = 34;
string commands[commandCount] = { "list", "search", "dsearch", string commands[commandCount] = { "list", "search", "dsearch",
"info", "info", "version", "cache",
"depends", "install", "depinst", "depends", "install", "depinst",
"help", "isinst", "dup", "update", "help", "isinst", "dup", "update",
"quickdep", "diff", "quickdiff", "quickdep", "diff", "quickdiff",
"grpinst", "version", "cache",
"path", "listinst", "printf", "readme", "path", "listinst", "printf", "readme",
"dependent", "sysup", "current", "dependent", "sysup", "current",
"fsearch", "lock", "unlock", "fsearch", "lock", "unlock",
@ -143,10 +142,10 @@ bool ArgParser::parse()
"listorphans" }; "listorphans" };
Type commandID[commandCount] = { LIST, SEARCH, DSEARCH, INFO, Type commandID[commandCount] = { LIST, SEARCH, DSEARCH, INFO,
SHOW_VERSION, CREATE_CACHE,
DEPENDS, INSTALL, DEPINST, DEPENDS, INSTALL, DEPINST,
HELP, ISINST, DUP, UPDATE, HELP, ISINST, DUP, UPDATE,
QUICKDEP, DIFF, QUICKDIFF, QUICKDEP, DIFF, QUICKDIFF,
GRPINST, SHOW_VERSION, CREATE_CACHE,
PATH, LISTINST, PRINTF, README, PATH, LISTINST, PRINTF, README,
DEPENDENT, SYSUP, CURRENT, DEPENDENT, SYSUP, CURRENT,
FSEARCH, LOCK, UNLOCK, LISTLOCKED, FSEARCH, LOCK, UNLOCK, LISTLOCKED,
@ -175,8 +174,6 @@ bool ArgParser::parse()
m_verbose += 1; m_verbose += 1;
} else if ( s == "-vv" ) { } else if ( s == "-vv" ) {
m_verbose += 2; m_verbose += 2;
} else if ( s == "--force" ) {
m_isForced = true;
} else if ( s == "--test" ) { } else if ( s == "--test" ) {
m_isTest = true; m_isTest = true;
} else if ( s == "--cache" ) { } else if ( s == "--cache" ) {
@ -204,6 +201,8 @@ bool ArgParser::parse()
m_preferHigher = true; m_preferHigher = true;
} else if ( s == "--strict-diff" || s == "-sd" ) { } else if ( s == "--strict-diff" || s == "-sd" ) {
m_strictDiff = true; m_strictDiff = true;
} else if ( s == "--group" || s == "-g" ) {
m_group = true;
} else if ( s == "--regex" ) { } else if ( s == "--regex" ) {
m_useRegex = true; m_useRegex = true;
} else if ( s == "--full" ) { } else if ( s == "--full" ) {
@ -214,7 +213,6 @@ bool ArgParser::parse()
m_printTree = true; m_printTree = true;
} else if ( s == "--depsort" ) { } else if ( s == "--depsort" ) {
m_depSort = true; m_depSort = true;
} else if ( s == "-f" ) { } else if ( s == "-f" ) {
m_pkgaddArgs += " " + s; m_pkgaddArgs += " " + s;
} else if ( s == "-fr" ) { } else if ( s == "-fr" ) {
@ -274,11 +272,19 @@ bool ArgParser::parse()
if (!m_isCommandGiven) { if (!m_isCommandGiven) {
string s = m_argv[i]; string s = m_argv[i];
m_commandName = s; m_commandName = s;
for ( int i = 0; i < commandCount; ++i ) { if ( s == "grpinst" ) {
if ( s == commands[i] ) { m_isCommandGiven = true;
m_isCommandGiven = true; m_commandType = commandID[7];
m_commandType = commandID[i]; m_group = true;
break; 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 // first argument must be command
@ -297,15 +303,6 @@ bool ArgParser::parse()
} }
/*!
\return true whether --force has been specified
*/
bool ArgParser::isForced() const
{
return m_isForced;
}
/*! /*!
\return true whether --test has been specified \return true whether --test has been specified
*/ */
@ -473,6 +470,11 @@ bool ArgParser::strictDiff() const
return m_strictDiff; return m_strictDiff;
} }
bool ArgParser::group() const
{
return m_group;
}
bool ArgParser::useRegex() const bool ArgParser::useRegex() const
{ {
return m_useRegex; return m_useRegex;

View File

@ -14,6 +14,7 @@
#include <list> #include <list>
#include <string> #include <string>
#include <iostream>
using namespace std; using namespace std;
/*! /*!
@ -32,7 +33,7 @@ public:
/*! Command type */ /*! Command type */
enum Type { HELP, LIST, SEARCH, DSEARCH, INSTALL, DEPINST, enum Type { HELP, LIST, SEARCH, DSEARCH, INSTALL, DEPINST,
INFO, DEPENDS, ISINST, DUP, UPDATE, INFO, DEPENDS, ISINST, DUP, UPDATE,
QUICKDEP, DIFF, GRPINST, GRPUPDATE, QUICKDEP, DIFF,
QUICKDIFF, SHOW_VERSION, CREATE_CACHE, PATH, QUICKDIFF, SHOW_VERSION, CREATE_CACHE, PATH,
LISTINST, PRINTF, README, DEPENDENT, SYSUP, LISTINST, PRINTF, README, DEPENDENT, SYSUP,
CURRENT, FSEARCH, LOCK, UNLOCK, LISTLOCKED, CURRENT, FSEARCH, LOCK, UNLOCK, LISTLOCKED,
@ -40,7 +41,6 @@ public:
DEPTREE, DUMPCONFIG, LISTORPHANS }; DEPTREE, DUMPCONFIG, LISTORPHANS };
bool isCommandGiven() const; bool isCommandGiven() const;
bool isForced() const;
bool isTest() const; bool isTest() const;
bool isAlternateConfigGiven() const; bool isAlternateConfigGiven() const;
bool useCache() const; bool useCache() const;
@ -55,6 +55,7 @@ public:
bool execPostInstall() const; bool execPostInstall() const;
bool preferHigher() const; bool preferHigher() const;
bool strictDiff() const; bool strictDiff() const;
bool group() const;
bool useRegex() const; bool useRegex() const;
bool fullPath() const; bool fullPath() const;
bool recursive() const; bool recursive() const;
@ -89,7 +90,6 @@ public:
private: private:
bool m_isCommandGiven; bool m_isCommandGiven;
bool m_isForced;
bool m_isTest; bool m_isTest;
bool m_isAlternateConfigGiven; bool m_isAlternateConfigGiven;
bool m_useCache; bool m_useCache;
@ -109,6 +109,7 @@ private:
bool m_execPostInstall; bool m_execPostInstall;
bool m_preferHigher; bool m_preferHigher;
bool m_strictDiff; bool m_strictDiff;
bool m_group;
bool m_useRegex; bool m_useRegex;
bool m_fullPath; bool m_fullPath;

View File

@ -143,12 +143,11 @@ InstallTransaction::installError() const
install (commit) a transaction install (commit) a transaction
\param parser the argument parser \param parser the argument parser
\param update whether this is an update operation \param update whether this is an update operation
\param group whether this is a group transaction (stops transaction on error)
\return returns an InstallResult telling whether installation worked \return returns an InstallResult telling whether installation worked
*/ */
InstallTransaction::InstallResult InstallTransaction::InstallResult
InstallTransaction::install( const ArgParser* parser, InstallTransaction::install( const ArgParser* parser,
bool update, bool group ) bool update )
{ {
if ( m_packages.empty() ) { if ( m_packages.empty() ) {
return NO_PACKAGE_GIVEN; return NO_PACKAGE_GIVEN;
@ -170,7 +169,7 @@ InstallTransaction::install( const ArgParser* parser,
if ( package == NULL ) { if ( package == NULL ) {
m_missingPackages.push_back( make_pair( it->first, string("") ) ); m_missingPackages.push_back( make_pair( it->first, string("") ) );
if ( group ) { if ( parser->group() ) {
return PACKAGE_NOT_FOUND; return PACKAGE_NOT_FOUND;
} }
continue; continue;
@ -203,7 +202,7 @@ InstallTransaction::install( const ArgParser* parser,
} }
m_installErrors.push_back( make_pair(package->name(), info) ); m_installErrors.push_back( make_pair(package->name(), info) );
if ( group ) { if ( parser->group() ) {
return PKGMK_FAILURE; return PKGMK_FAILURE;
} }
} }
@ -568,7 +567,7 @@ void InstallTransaction::checkDependencies( bool greedy,
if ( pos != string::npos && (pos+1) < softdep.length() ) { if ( pos != string::npos && (pos+1) < softdep.length() ) {
softdep = softdep.substr( pos + 1 ); softdep = softdep.substr( pos + 1 );
} }
if ( m_pkgDB->isInstalled(softdep, true) ) { if ( m_pkgDB->isInstalled(softdep, false) or isRequested(softdep) ) {
const Package* p = m_repo->getPackage( softdep ); const Package* p = m_repo->getPackage( softdep );
if ( p ) { if ( p ) {
checkDependencies( true, p, index ); checkDependencies( true, p, index );
@ -586,6 +585,16 @@ void InstallTransaction::checkDependencies( bool greedy,
treeWalk.pop_back(); treeWalk.pop_back();
} }
/*!
Method to determine whether a package was passed on the command line
*/
bool InstallTransaction::isRequested(const string pname) {
list< pair<string, const Package*> >::iterator it = m_packages.begin();
for ( ; it != m_packages.end(); ++it ) {
if ( it->first == pname ) { return true; }
}
return false;
}
/*! /*!
This method returns a list of packages which should be installed to This method returns a list of packages which should be installed to

View File

@ -85,8 +85,7 @@ public:
}; };
InstallResult install( const ArgParser* parser, InstallResult install( const ArgParser* parser,
bool update, bool update );
bool group );
InstallResult calcDependencies(); InstallResult calcDependencies();
const list< pair<string, InstallInfo> >& installedPackages() const; const list< pair<string, InstallInfo> >& installedPackages() const;
@ -109,6 +108,7 @@ private:
const ArgParser* parser, const ArgParser* parser,
bool update, bool update,
InstallInfo& info ) const; InstallInfo& info ) const;
bool isRequested(const string pname);
static string getPkgmkSetting(const string& setting); static string getPkgmkSetting(const string& setting);
static string getPkgmkSettingFromFile(const string& setting, static string getPkgmkSettingFromFile(const string& setting,

View File

@ -87,11 +87,8 @@ int main( int argc, char** argv )
prtGet.install(); prtGet.install();
break; break;
case ArgParser::DEPINST: case ArgParser::DEPINST:
prtGet.install(false, true, true);
break;
case ArgParser::GRPINST:
prtGet.install( false, true ); prtGet.install( false, true );
break; break;
case ArgParser::DEPENDS: case ArgParser::DEPENDS:
prtGet.printDepends(); prtGet.printDepends();
break; break;

View File

@ -143,7 +143,7 @@ void PrtGet::printUsage()
<< endl; << endl;
cout << "\nDEPENDENCIES" << endl; cout << "\nDEPENDENCIES" << endl;
cout << " depends <port1 port2...> show dependencies for these ports" cout << " depends <port1 port2...> calculate dependencies of the given ports"
<< endl; << endl;
cout << " quickdep <port1 port2...> same as 'depends' but simple format" cout << " quickdep <port1 port2...> same as 'depends' but simple format"
<< endl; << endl;
@ -171,13 +171,12 @@ void PrtGet::printUsage()
cout << "\nINSTALL, UPDATE and REMOVAL" << endl; cout << "\nINSTALL, UPDATE and REMOVAL" << endl;
cout << " install [opt] <port1 port2...> install ports" << endl; cout << " install [opt] <port1 port2...> install ports" << endl;
cout << " update [opt] <port1 port2...> update ports" << endl; cout << " update [opt] <port1 port2...> update ports" << endl;
cout << " grpinst [opt] <port1 port2...> install ports, stop on error"
<< endl;
cout << " depinst [opt] <port1 port2...> install ports and their dependencies" cout << " depinst [opt] <port1 port2...> install ports and their dependencies"
<< endl; << endl;
cout << " remove [opt] <port1 port2...> remove ports" cout << " remove [opt] <port1 port2...> remove ports"
<< endl; << endl;
cout << " where opt can be:" << endl; cout << " where opt can be:" << endl;
cout << " -g, --group stop if one package fails" << endl;
cout << " -f, -fi force installation" << endl; cout << " -f, -fi force installation" << endl;
cout << " -fr force rebuild" << endl; cout << " -fr force rebuild" << endl;
cout << " -uf update footprint" << endl; cout << " -uf update footprint" << endl;
@ -590,32 +589,47 @@ void PrtGet::listInstalled()
/*! /*!
install package install package
\param update whether this is an update operation \param update, whether this is an update operation
\param group whether it's a group install (stop on error) \param dependencies, whether to consider dependencies
*/ */
void PrtGet::install( bool update, bool group, bool dependencies ) void PrtGet::install( bool update, bool dependencies )
{ {
assertMinArgCount(1); assertMinArgCount(1);
// this can be done without initRepo() // this can be done without initRepo()
const list<char*>& args = m_parser->otherArgs(); const list<char*>& args = m_parser->otherArgs();
list<string> invalidArgs;
list<char*>::const_iterator it = args.begin(); list<char*>::const_iterator it = args.begin();
if ( args.size() == 1 ) { if ( update ) {
for ( ; it != args.end(); ++it ) { for ( ; it != args.end(); ++it ) {
string s = *it; string s = *it;
if ( !update && m_pkgDB->isInstalled( s ) ) { if ( !m_pkgDB->isInstalled( s ) ) {
cout << "package " << s << " is installed" << endl; // can't upgrade what isn't installed
m_returnValue = PG_GENERAL_ERROR; invalidArgs.push_back( s );
return;
} else if ( update && !m_pkgDB->isInstalled( s ) ) {
// can't upgrade
cout << "package " << s << " is not installed" << endl;
m_returnValue = PG_GENERAL_ERROR;
return;
} }
} }
} else {
for ( ; it != args.end(); ++it ) {
string s = *it;
if ( m_pkgDB->isInstalled( s ) ) {
// pkgadd will fail on these, since it won't be given the -u flag
invalidArgs.push_back( s );
}
}
}
if ( invalidArgs.size() > 0 ) {
string attemptedOp = ( update ) ? "update" : "install";
attemptedOp += " the following packages ";
attemptedOp += ( update ) ? "(not yet installed)" : "(already installed)";
cout << "cannot "<< attemptedOp <<endl;
list<string>::const_iterator it = invalidArgs.begin();
for ( ; it != invalidArgs.end(); ++it ) {
cout << *it << endl;
}
m_returnValue = PG_GENERAL_ERROR ;
return;
} }
initRepo(); initRepo();
@ -648,16 +662,16 @@ void PrtGet::install( bool update, bool group, bool dependencies )
} }
InstallTransaction transaction( deps, m_repo, m_pkgDB, m_config ); InstallTransaction transaction( deps, m_repo, m_pkgDB, m_config );
executeTransaction( transaction, update, group ); executeTransaction( transaction, update );
} else { } else {
InstallTransaction transaction( m_parser->otherArgs(), InstallTransaction transaction( m_parser->otherArgs(),
m_repo, m_pkgDB, m_config ); m_repo, m_pkgDB, m_config );
executeTransaction( transaction, update, group ); executeTransaction( transaction, update );
} }
} }
void PrtGet::executeTransaction( InstallTransaction& transaction, void PrtGet::executeTransaction( InstallTransaction& transaction,
bool update, bool group ) bool update )
{ {
m_currentTransaction = &transaction; m_currentTransaction = &transaction;
@ -672,49 +686,64 @@ void PrtGet::executeTransaction( InstallTransaction& transaction,
} }
InstallTransaction::InstallResult result = InstallTransaction::InstallResult result =
transaction.install( m_parser, update, group ); transaction.install( m_parser, update );
bool failed = false; bool failed = false;
// TODO: use switch switch (result) {
if ( result == InstallTransaction::PACKAGE_NOT_FOUND ) { case InstallTransaction::SUCCESS:
cout << m_appName << ": package(s) not found" << endl; break;
} else if ( result == InstallTransaction::PKGMK_EXEC_ERROR ) { case InstallTransaction::PACKAGE_NOT_FOUND:
cout << m_appName << " couldn't excecute pkgmk " cout << m_appName << ": package(s) not found" << endl;
<< "(or alternative command). " break;
<< "Make sure it's installed properly" << endl; case InstallTransaction::PKGMK_EXEC_ERROR:
} else if ( result == InstallTransaction::PKGMK_FAILURE ) { cout << m_appName << " couldn't excecute pkgmk "
cout << m_appName << ": error while " << command[0] << endl; << "(or alternative command). "
} else if ( result == InstallTransaction::NO_PACKAGE_GIVEN ) { << "Make sure it's installed properly" << endl;
cout << m_appName << ": no package specified for " break;
<< command[0] << endl; case InstallTransaction::PKGMK_FAILURE:
} else if ( result == InstallTransaction::PKGADD_EXEC_ERROR ) { cout << m_appName << ": error while " << command[0] << endl;
cout << m_appName << " couldn't excecute pkgadd. " break;
<< "Make sure it's installed properly" << endl; case InstallTransaction::NO_PACKAGE_GIVEN:
} else if ( result == InstallTransaction::PKGDEST_ERROR ) { cout << m_appName << ": no package specified for "
cout << m_appName << ": error changing to PKGDEST directory " << command[0] << endl;
<< transaction.getPkgmkPackageDir() << endl; break;
failed = true; case InstallTransaction::PKGADD_EXEC_ERROR:
} else if ( result == InstallTransaction::PKGADD_FAILURE ) { cout << m_appName << " couldn't excecute pkgadd. "
cout << m_appName << ": error while pkgadding " << endl; << "Make sure it's installed properly" << endl;
} else if ( result == InstallTransaction::LOG_DIR_FAILURE ) { break;
cout << m_appName << ": can't create log file directory " << endl; case InstallTransaction::PKGDEST_ERROR:
} else if ( result == InstallTransaction::LOG_FILE_FAILURE ) { cout << m_appName << ": error changing to PKGDEST directory "
cout << m_appName << ": can't create log file" << endl; << transaction.getPkgmkPackageDir() << endl;
failed = true; failed = true;
} else if ( result == InstallTransaction::NO_LOG_FILE ) { break;
cout << m_appName << ": no log file specified, but logging enabled" case InstallTransaction::PKGADD_FAILURE:
<< endl; cout << m_appName << ": error while pkgadding " << endl;
failed = true; break;
} else if ( result == InstallTransaction::CANT_LOCK_LOG_FILE ) { case InstallTransaction::LOG_DIR_FAILURE:
cout << m_appName << ": can't create lock file for the log file. " cout << m_appName << ": can't create log file directory "
<< "\nMaybe there's another instance of prt-get using the same " << endl;
<< "file." break;
<< "\nIf this is a stale not, please remove " case InstallTransaction::LOG_FILE_FAILURE:
// TODO: file name of lock file cout << m_appName << ": can't create log file" << endl;
<< endl; failed = true;
failed = true; break;
} else if ( result != InstallTransaction::SUCCESS ) { case InstallTransaction::NO_LOG_FILE:
cout << m_appName << ": Unknown error " << result << endl; cout << m_appName << ": no log file specified, but logging enabled"
failed = true; << endl;
failed = true;
break;
case InstallTransaction::CANT_LOCK_LOG_FILE:
cout << m_appName
<< ": can't create lock file for the log file. "
<< "\nMaybe there's another instance of prt-get "
<< "using the same file."
<< "\nIf this is a stale log, please remove "
// TODO: file name of lock file
<< endl;
failed = true;
break;
default:
cout << m_appName << ": Unknown error " << result << endl;
failed = true;
} }
if ( !failed ) { if ( !failed ) {
@ -763,7 +792,7 @@ void PrtGet::printDepends( bool simpleListing )
} }
} else { } else {
if ( deps.size() > 0 ) { if ( deps.size() > 0 ) {
cout << "-- dependencies ("; cout << "-- dependency list for the requested ports (";
if ( m_followSoftdeps ) { if ( m_followSoftdeps ) {
cout << "including optionals, "; cout << "including optionals, ";
} }
@ -875,20 +904,19 @@ void PrtGet::printFormattedDiffLine(const string& name,
const string& versionPortsTree, const string& versionPortsTree,
bool isLocked) bool isLocked)
{ {
unsigned int minWidth=20;
cout.setf( ios::left, ios::adjustfield ); cout.setf( ios::left, ios::adjustfield );
cout.width( 20 ); cout.width( minWidth );
cout.fill( ' ' ); cout.fill( ' ' );
cout << name; ( name.size() < minWidth ) ? cout << name : cout << name + " ";
cout.width( 20 ); cout.width( minWidth );
cout.fill( ' ' ); cout.fill( ' ' );
cout << versionInstalled; ( versionInstalled.size() < minWidth ) ? cout << versionInstalled :
cout << versionInstalled + " ";
string locked = ""; string locked = ( isLocked ) ? "locked" : "";
if ( isLocked ) { cout.width( minWidth );
locked = "locked";
}
cout.width( 20 );
cout.fill( ' ' ); cout.fill( ' ' );
cout << versionPortsTree << locked << endl; cout << versionPortsTree << locked << endl;
} }
@ -1411,7 +1439,8 @@ void PrtGet::printDependent(const string& dep, int level)
dependent.insert( p ); dependent.insert( p );
} }
} }
if ( p && m_pkgDB->isInstalled(p->name(),false) && m_followSoftdeps if ( p && m_followSoftdeps &&
( m_parser->all() || m_pkgDB->isInstalled( p->name() ) )
&& p->optionals().find( dep ) != string::npos ) { && p->optionals().find( dep ) != string::npos ) {
list<string> tokens; list<string> tokens;
StringHelper::split( p->optionals(), ',', tokens ); StringHelper::split( p->optionals(), ',', tokens );
@ -1599,7 +1628,7 @@ void PrtGet::sysup()
InstallTransaction transaction( *target, InstallTransaction transaction( *target,
m_repo, m_pkgDB, m_config ); m_repo, m_pkgDB, m_config );
executeTransaction( transaction, true, false ); executeTransaction( transaction, true );
} }
@ -2025,11 +2054,12 @@ void PrtGet::printDependTree()
if ( (p->dependencies().length() > 0) or if ( (p->dependencies().length() > 0) or
(m_followSoftdeps && p->optionals().length() > 0) ) { (m_followSoftdeps && p->optionals().length() > 0) ) {
cout << "-- dependencies ("; cout << "-- dependencies ([i] installed";
if ( m_followSoftdeps ) { if ( m_followSoftdeps ) {
cout << "[s] soft, "; cout << ", [s] installed softdeps";
} else {
cout << ", [ ] not installed";
} }
cout << "[i] hard, [ ] not installed";
if (!m_parser->all()) { if (!m_parser->all()) {
cout << ", '-->' already shown"; cout << ", '-->' already shown";
} }

View File

@ -62,7 +62,6 @@ public:
void readme(); void readme();
void install( bool update=false, void install( bool update=false,
bool group=false,
bool dependencies=false ); bool dependencies=false );
void sysup(); void sysup();
void current(); void current();
@ -102,7 +101,7 @@ protected:
void printDependent(const std::string& dep, int level); void printDependent(const std::string& dep, int level);
void executeTransaction( InstallTransaction& transaction, void executeTransaction( InstallTransaction& transaction,
bool update, bool group ); bool update );
void evaluateResult( InstallTransaction& transaction, void evaluateResult( InstallTransaction& transaction,
bool update, bool update,
bool interrupted=false ); bool interrupted=false );

View File

@ -30,7 +30,7 @@ using namespace std;
using namespace StringHelper; using namespace StringHelper;
const string Repository::CACHE_VERSION = "V5"; const string Repository::CACHE_VERSION = "V5.1";
/*! /*!
Create a repository Create a repository