]> pd.if.org Git - zpackage/commitdiff
update search
authorNathan Wagner <nw@hydaspes.if.org>
Sun, 17 Feb 2019 20:41:30 +0000 (20:41 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Sun, 17 Feb 2019 20:41:30 +0000 (20:41 +0000)
doc/zpm-search.8 [new file with mode: 0644]
doc/zpm-update.8
src/search.c
zpm-repo
zpm-update

diff --git a/doc/zpm-search.8 b/doc/zpm-search.8
new file mode 100644 (file)
index 0000000..d711e1d
--- /dev/null
@@ -0,0 +1,98 @@
+.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)
index 4f10ca6037f6bed57e28ec62dad11a925d006b1c..c25751e03edb8581bbdd43f93659672431d198b6 100644 (file)
@@ -1,4 +1,4 @@
-.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
 .SH NAME
 zpm-update \- update set of installed packages
 .SH SYNOPSIS
@@ -7,7 +7,7 @@ zpm-update \- update set of installed packages
 .BI -f " pkgfile"
 ]
 [
 .BI -f " pkgfile"
 ]
 [
-.B -LAOUnzvpSC
+.B -LAOUnzvpSCl
 ]
 .RI [ \fB[+|-]\fIpackage ...]
 .SH DESCRIPTION
 ]
 .RI [ \fB[+|-]\fIpackage ...]
 .SH DESCRIPTION
@@ -58,6 +58,9 @@ and doesn't run any package scripts.  Since scripts aren't run
 and no files are changed, this can only detect and report some
 types of errors.
 .TP
 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.
 \-R \fIrootdir\fR
 Specify a root directory for the package installs.  Files will be
 installed relative to this directory.
index 9b6ec887cd015f45b88f72e0de32df74d31303a2..dd324d55a7d1664d0006b283a6f5a6aab292bbd7 100644 (file)
@@ -28,6 +28,7 @@ struct search_ctl {
        int matchinstalled;
        int suppressinstalled;
        int onlylocalinstalled;
        int matchinstalled;
        int suppressinstalled;
        int onlylocalinstalled;
+       int foundonly;
        int verbose;
        int dbrepos;
 };
        int verbose;
        int dbrepos;
 };
@@ -389,19 +390,39 @@ void checklibs(struct search_ctl *opts,
        free(pkgfile);
 }
 
        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;
        const char *pkgid, *file;
        char *fmt;
-       char *sep;
+       char *sep = "\n";
        int count = 0;
        int count = 0;
-
-       fmt = json ? "\"%s\": \"%s\"" : "%s:%s";
-       sep = json ? ", " : "\n";
+       char *start = "";
+       char *end = "";
 
        if (json) {
 
        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 (jsw_hsize(hash) > 0) {
                for (jsw_hreset(hash); jsw_hitem(hash); jsw_hnext(hash)) {
                        pkgid = jsw_hkey(hash);
@@ -409,16 +430,20 @@ void print_pkghash(jsw_hash_t *hash, int json) {
                        if (count++) {
                                printf("%s", sep);
                        }
                        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 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;
        struct pkgloc *found;
        jsw_hash_t *packages, *check, *forlibs, *nolib;
        jsw_atree_t *nfound;
@@ -462,7 +487,7 @@ int main(int ac, char *av[]) {
         */
 
        int output = 1;
         */
 
        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;
                switch (option) {
                        case 'l': findlibs = 1; break;
                        case 'j': json = 1; break;
@@ -472,6 +497,7 @@ int main(int ac, char *av[]) {
                        case 'I': opt.suppressinstalled = 1; break;
                                  /* only find localdb pkgs if installed */
                        case 'O': opt.onlylocalinstalled = 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 'd': opt.localdb = optarg; break;
                        case 'p': opt.pkgdir = optarg; break;
                        case 'r': opt.repodir = optarg; break;
@@ -484,6 +510,7 @@ int main(int ac, char *av[]) {
                                   */
                        case 'M': opt.matchallpkgfile = 1; break;
                        case 'v': opt.verbose++; break;
                                   */
                        case 'M': opt.matchallpkgfile = 1; break;
                        case 'v': opt.verbose++; break;
+                       case 'n': idonly = 1; break;
                        default:
                                  exit(EXIT_FAILURE);
                                  break;
                        default:
                                  exit(EXIT_FAILURE);
                                  break;
@@ -559,10 +586,10 @@ int main(int ac, char *av[]) {
 
        if (output) {
                if (jsw_hsize(packages)) {
 
        if (output) {
                if (jsw_hsize(packages)) {
-                       print_pkghash(packages, json);
+                       print_pkghash(packages, json, idonly);
                }
                if (jsw_hsize(forlibs)) {
                }
                if (jsw_hsize(forlibs)) {
-                       print_pkghash(forlibs, json);
+                       print_pkghash(forlibs, json, idonly);
                }
        }
 
                }
        }
 
@@ -573,9 +600,10 @@ int main(int ac, char *av[]) {
                        file = jsw_hitem(nolib);
                        fprintf(stderr, "no lib found %s:%s\n", pkgid, file);
                }
                        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;
                jsw_atrav_t *i;
                i = jsw_atnew();
                char *pkgstr;
@@ -583,7 +611,8 @@ int main(int ac, char *av[]) {
                for (pkgstr = jsw_atfirst(i, nfound); pkgstr; pkgstr = jsw_atnext(i)) {
                        fprintf(stderr, "%s: not found\n", 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;
 }
 }
index 4fe8845b65707434be197d20b79370b2623e109e..76359b8e2f6679ae2f80b01ea3779d1acf6a3b30 100755 (executable)
--- a/zpm-repo
+++ b/zpm-repo
@@ -105,10 +105,10 @@ update_info() {
                fi
                if [ -f "$rf" ]; then
                        # TODO merge in so packages aren't deleted
                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
                        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
                        rv=$?
                fi
                if [ $rv -eq 0 ]; then
index 39c111a2f17f6e7274bac7f298f09834b8e427ea..0bac954fe6b84dad3cf8530edd88de02b9231de3 100755 (executable)
@@ -109,7 +109,7 @@ uninstall=0
 
 # TODO option to attempt to resume an ongoing install
 # zpm-install [-SCn] [ -d localdb ] [ -f pkgfile ] [ -R installroot ] pkgstr ...
 
 # 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" ;;
        case $opt in
                f) pkgfile="$OPTARG" ;;
                d) localdb="$OPTARG" ;;
@@ -237,7 +237,6 @@ for mergepkg in $merge; do
                                nlist="$nlist $pkgid:$zpmfile"
                                continue
                        else
                                nlist="$nlist $pkgid:$zpmfile"
                                continue
                        else
-                               echo downloading $zpmfile
                                zpm repo fetch $reponame $pkgid
                                if [ -f "$zpmfile" ]; then
                                        nlist="$nlist $pkgid:$zpmfile"
                                zpm repo fetch $reponame $pkgid
                                if [ -f "$zpmfile" ]; then
                                        nlist="$nlist $pkgid:$zpmfile"