--- /dev/null
+.TH zpm-findpkg 8 2019-02-22 "ZPM 0.3"
+.SH NAME
+zpm-findpkg \- find package ids
+.SH SYNOPSIS
+.B zpm findpkg
+[
+.BI \-f " pkgfile"
+]
+[
+.B \-Imre
+]
+[
+.BI \-s status
+]
+[
+.BI \-S status
+]
+.I package
+[
+.I package
+]
+.SH DESCRIPTION
+\fBzpm-findpkg\fR
+finds packages in package databases. A package may be specified as
+an incomplete package id. If found, the full package id will
+be printed to stdout. Where more than one package matches,
+the latest one (as if by zpm-vercmp) will be found.
+.PP
+If two arguments are given, they form an inclusive range of packages.
+Either may be a partial package id, but both must have the same
+package name.
+.SH OPTIONS
+.TP
+.BI \-f package
+specify the package file to find packages in
+.TP
+.B \-I
+Only find installed packages. Equivalent to \fB\-s installed\fR.
+.TP
+.B \-m
+This reverses the sense of the arguments. The first argument is
+taken as the maximum package version to find. A second argument,
+if given, is taken as the minimum. Implies \-r.
+.TP
+.B \-r
+Find package within a range, rather than an exact match. The
+first package argument is the inclusive lower bound. The second
+argument, if provides, is the inclusive upper bound. If no
+second argument is given, there is no upper bound.
+This option is implied if two arguments are given.
+.TP
+.B \-l
+Find the earliest package in a range, as if compared by zpm-vercmp.
+Implies \-r.
+.TP
+.BI \-s status
+Add \fIstatus\fR to the set of package statuses to match. If the
+list is empty, any status will match.
+.TP
+.BI \-S status
+Add \fIstatus\fR to the set of package statuses to exclude from
+matching. If a given status is listed both in include and exclude,
+the package status will be excluded.
+.SH EXAMPLES
+.TP
+.B zpm findpkg foo
+find the latest version of foo in the default database.
+.SH EXIT STATUS
+0 on success non zero on failure
+.SH FILES
+/var/lib/zpm/local.db
+.SH ENVIRONMENT
+ZPMDB
+.SH AUTHOR
+Nathan Wagner
+.SH SEE ALSO
+.BR zpm (8)
+.BR zpm-vercmp (8)
-.TH zpm-rmpackage 8 2019-02-15 "ZPM 0.3"
+.TH zpm-rmpackage 8 2019-02-28 "ZPM 0.3"
.SH NAME
zpm-rmpackage \- remove packages from a database
.SH SYNOPSIS
- f) pkgfile="$OPTARG" ;;
- v) verbose=1 ;;
- m) message="$OPTARG" ;;
.B zpm rmpackage
[
.BI -f " pkgfile"
.BI -m " message"
]
[
+.BI -s " status"
+]
+[
+.BI -S " status"
+]
+[
.B -v
]
.RI [ package ...]
.BI \-m message
specify a message for each log message.
.TP
+.BI \-s status
+Require that packages listed have the given status. This is primarily
+a safety feature so that you don't accidentally remove installed packages
+from the database.
+Passed through to zpm-findpkg and may be given more than once.
+.TP
+.BI \-S status
+Require that packages not have the given status. Useful for excluding
+installed packages without specifying other statuses explicitly.
+Passed through to zpm-findpkg and may be given more than once.
+.TP
.B \-v
Verbose mode.
.SH EXAMPLES
Nathan Wagner
.SH SEE ALSO
.BR zpm (8)
-.BR zpm-findpackage (8)
+.BR zpm-findpkg (8)
.BR zpm-log (8)
verbose=0
# newpackage -f pkgfile $pkgid
-while getopts :f:vm: opt; do
+while getopts :f:vm:s:S: opt; do
case $opt in
f) pkgfile="$OPTARG" ;;
v) verbose=1 ;;
m) message="$OPTARG" ;;
+ s) status="$status -s $OPTARG" ;;
+ S) exclude="$exclude -S $OPTARG" ;;
esac
done
shift $(( OPTIND - 1))
{
printf ".bail on\n"
+ printf ".echo on\n"
printf "begin;\n"
for pkgstr in "$@"; do
- pkgid=$(zpm findpkg -f $pkgfile "$pkgstr")
+ pkgid=$(zpm findpkg $status $exclude -f $pkgfile "$pkgstr")
+ if [ -z "$pkgid" ]; then
+ continue;
+ fi
if [ $verbose -gt 0 ]; then
- if [ -z "$pkgid" ]; then
- warn "$pkgstr not found"
- continue;
- fi
if [ $verbose -gt 1 ]; then
warn "found %s -> %s\n" "$pkgstr", "$pkgid"
fi