]> pd.if.org Git - zpackage/commitdiff
add search options for installs
authorNathan Wagner <nw@hydaspes.if.org>
Sat, 1 Dec 2018 01:26:51 +0000 (01:26 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Sat, 1 Dec 2018 01:27:27 +0000 (01:27 +0000)
zpm-search.c

index defbe14fd09173cf243461442b05986b3427ef7d..a98aa002cd3abe8b570bb6454d4c5de3d2a419ac 100644 (file)
@@ -27,6 +27,7 @@ struct search_ctl {
        int matchallpkgfile;
        int matchinstalled;
        int suppressinstalled;
+       int onlylocalinstalled;
        int verbose;
        int dbrepos;
 };
@@ -205,12 +206,14 @@ struct pkgloc *find_package(char *pkgstr, struct search_ctl *opt) {
                        latest = installed;
                        pkgfile = opt->zpmdb->path;
                }
-               found = zpm_findpkg(opt->zpmdb, pkgstr, NULL);
-               if (found) {
-                       rv = zpm_vercmp(found, latest);
-                       if (rv == 1) {
-                               latest = found;
-                               pkgfile = opt->zpmdb->path;
+               if (!opt->onlylocalinstalled) {
+                       found = zpm_findpkg(opt->zpmdb, pkgstr, NULL);
+                       if (found) {
+                               rv = zpm_vercmp(found, latest);
+                               if (rv == 1) {
+                                       latest = found;
+                                       pkgfile = opt->zpmdb->path;
+                               }
                        }
                }
 
@@ -442,7 +445,7 @@ int main(int ac, char *av[]) {
         */
 
        int output = 1;
-       while ((option = getopt(ac, av, "ljqPRDvp:r:d:MiI")) != -1) {
+       while ((option = getopt(ac, av, "ljqPRDvp:r:d:MiIO")) != -1) {
                switch (option) {
                        case 'l': findlibs = 1; break;
                        case 'j': json = 1; break;
@@ -450,6 +453,8 @@ int main(int ac, char *av[]) {
                                  /* show installed files */
                        case 'i': opt.matchinstalled = 1; break;
                        case 'I': opt.suppressinstalled = 1; break;
+                                 /* only find localdb pkgs if installed */
+                       case 'O': opt.onlylocalinstalled = 1; break;
                        case 'd': opt.localdb = optarg; break;
                        case 'p': opt.pkgdir = optarg; break;
                        case 'r': opt.repodir = optarg; break;
@@ -522,6 +527,9 @@ int main(int ac, char *av[]) {
 
        if (findlibs) {
                checklibs(&opt, check, forlibs, nolib);
+               /* remove from forlibs anything already explicitly
+                * in packages
+                */
        }
 
        if (output) {