--- /dev/null
+.TH zpm-search 8 2019-02-16 "ZPM 0.5"
+.SH NAME
+zpm-search \- search repositories for packages
+.SH SYNOPSIS
+.B zpm search
+[
+.B -ljqiIOfPRDMvn
+]
+[
+.BI -d " localdb"
+]
+[
+.BI -p " packagedir"
+]
+[
+.BI -r " repodir"
+]
+.RI [ package ...]
+.SH DESCRIPTION
+\fBzpm-search\fR
+searches for packages in repositories, the local database, and
+a directory of package files. Packages needed for library
+dependencies will be recursively searched for.
+.SH OPTIONS
+.TP
+.BI \-d localdb
+Specify the local database, if other than the default local database.
+.TP
+.BI \-p packagedir
+Specify a directory to search for packages in. Defaults to
+/var/lib/zpm/packages
+.TP
+.BI \-r repodir
+Specify the directory to find repository information in. Defaults
+to /var/lib/zpm/repo
+.TP
+.B \-i
+Match against installed packages. Normally, packages are searched
+for against the local database, but the output omits packages that
+are already installed. This option adds found but installed packages
+to the output.
+.TP
+.B \-l
+In addition to finding packages, also find packages supplying libraries
+needed by found packages.
+.TP
+.B \-I
+Suppress installed.
+.TP
+.B \-O
+Only local installed.
+.TP
+.B \-j
+Output results in json format. You will get a list with the \-n option,
+or an object of package id to location without the \-n option. A list
+of object is always output, even if empty.
+.TP
+.B \-f
+Only output found packages. Normally it is an error if a package
+can't be found. This option makes that not an error, and suppresses
+printing unfound packages to stderr.
+.TP
+.B \-q
+Suppress output. The exit status is the same as it would otherwise be.
+.TP
+.B \-v
+Increase verbosity. May be given multiple times.
+.TP
+.B \-M
+Match all package files. Normally when looking at files ending in .zpm,
+packages will only be searched for if the filename has the package id
+as a prefix. This is an optimization to speed up the search.
+.TP
+.B \-P
+Don't look in the package directory.
+.TP
+.B \-R
+Don't search repositories.
+.TP
+.B \-D
+Don't search the local database.
+.TP
+.B \-n
+list package names only, not name and location found.
+.SH EXAMPLES
+.TP
+.B zpm search
+lists all files in the local 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)
-.TH zpm-update 8 2018-12-10 "ZPM 0.4"
+.TH zpm-update 8 2019-02-16 "ZPM 0.4"
.SH NAME
zpm-update \- update set of installed packages
.SH SYNOPSIS
.BI -f " pkgfile"
]
[
-.B -LAOUnzvpSC
+.B -LAOUnzvpSCl
]
.RI [ \fB[+|-]\fIpackage ...]
.SH DESCRIPTION
and no files are changed, this can only detect and report some
types of errors.
.TP
+\-l
+Just list the computed set of packages to update.
+.TP
\-R \fIrootdir\fR
Specify a root directory for the package installs. Files will be
installed relative to this directory.
int matchinstalled;
int suppressinstalled;
int onlylocalinstalled;
+ int foundonly;
int verbose;
int dbrepos;
};
free(pkgfile);
}
-void print_pkghash(jsw_hash_t *hash, int json) {
+void print_pkghash(jsw_hash_t *hash, int json, int idonly) {
const char *pkgid, *file;
char *fmt;
- char *sep;
+ char *sep = "\n";
int count = 0;
-
- fmt = json ? "\"%s\": \"%s\"" : "%s:%s";
- sep = json ? ", " : "\n";
+ char *start = "";
+ char *end = "";
if (json) {
- printf("{ ");
+ sep = ", ";
+ if (idonly) {
+ fmt = "\"%s\"";
+ start = "[ ";
+ end = " ]\n";
+ } else {
+ fmt = "\"%s\": \"%s\"";
+ start = "{ ";
+ end = " }\n";
+ }
+ } else {
+ if (idonly) {
+ fmt = "%s";
+ start = "";
+ end = "";
+ } else {
+ fmt = "%s:%s";
+ start = "";
+ end = "";
+ }
}
+ printf("%s", start);
+
if (jsw_hsize(hash) > 0) {
for (jsw_hreset(hash); jsw_hitem(hash); jsw_hnext(hash)) {
pkgid = jsw_hkey(hash);
if (count++) {
printf("%s", sep);
}
- printf(fmt, pkgid, file);
+ if (idonly) {
+ printf(fmt, pkgid);
+ } else {
+ printf(fmt, pkgid, file);
+ }
}
+ if (!json) printf("\n");
}
- if (json) printf(" }");
- printf("\n");
+ printf("%s", end);
}
int main(int ac, char *av[]) {
- int option, argn;
- int findlibs = 0, json = 0;
+ int option, argn, rv = 0;
+ int findlibs = 0, json = 0, idonly = 0;
struct pkgloc *found;
jsw_hash_t *packages, *check, *forlibs, *nolib;
jsw_atree_t *nfound;
*/
int output = 1;
- while ((option = getopt(ac, av, "ljqPRDvp:r:d:MiIO")) != -1) {
+ while ((option = getopt(ac, av, "fljqPRDvp:r:d:MiIOn")) != -1) {
switch (option) {
case 'l': findlibs = 1; break;
case 'j': json = 1; break;
case 'I': opt.suppressinstalled = 1; break;
/* only find localdb pkgs if installed */
case 'O': opt.onlylocalinstalled = 1; break;
+ case 'f': opt.foundonly = 1; break;
case 'd': opt.localdb = optarg; break;
case 'p': opt.pkgdir = optarg; break;
case 'r': opt.repodir = optarg; break;
*/
case 'M': opt.matchallpkgfile = 1; break;
case 'v': opt.verbose++; break;
+ case 'n': idonly = 1; break;
default:
exit(EXIT_FAILURE);
break;
if (output) {
if (jsw_hsize(packages)) {
- print_pkghash(packages, json);
+ print_pkghash(packages, json, idonly);
}
if (jsw_hsize(forlibs)) {
- print_pkghash(forlibs, json);
+ print_pkghash(forlibs, json, idonly);
}
}
file = jsw_hitem(nolib);
fprintf(stderr, "no lib found %s:%s\n", pkgid, file);
}
+ rv = 1;
}
- if (jsw_asize(nfound) > 0) {
+ if (jsw_asize(nfound) > 0 && !opt.foundonly) {
jsw_atrav_t *i;
i = jsw_atnew();
char *pkgstr;
for (pkgstr = jsw_atfirst(i, nfound); pkgstr; pkgstr = jsw_atnext(i)) {
fprintf(stderr, "%s: not found\n", pkgstr);
}
+ rv = 1;
}
- return jsw_asize(nfound) > 0 || jsw_hsize(nolib) > 0 ? 1 : 0;
+ return rv;
}
fi
if [ -f "$rf" ]; then
# TODO merge in so packages aren't deleted
- zpm fetchurl -f '-#' -z "$rf" -o "$rf.tmp" "$url"
+ zpm fetchurl -fpn -z "$rf" -o "$rf.tmp" "$url"
rv=$?
else
- zpm fetchurl -f '-#' -o "$rf.tmp" "$url" && refresh "$repo"
+ zpm fetchurl -fpn -o "$rf.tmp" "$url" && refresh "$repo"
rv=$?
fi
if [ $rv -eq 0 ]; then
# TODO option to attempt to resume an ongoing install
# zpm-install [-SCn] [ -d localdb ] [ -f pkgfile ] [ -R installroot ] pkgstr ...
-while getopts f:d:R:nSCvAObBLUzp opt; do
+while getopts f:d:R:nSCvAObBLUzpl opt; do
case $opt in
f) pkgfile="$OPTARG" ;;
d) localdb="$OPTARG" ;;
nlist="$nlist $pkgid:$zpmfile"
continue
else
- echo downloading $zpmfile
zpm repo fetch $reponame $pkgid
if [ -f "$zpmfile" ]; then
nlist="$nlist $pkgid:$zpmfile"