From: Nathan Wagner Date: Sat, 1 Dec 2018 01:26:51 +0000 (+0000) Subject: add search options for installs X-Git-Tag: v0.3.0~3 X-Git-Url: https://pd.if.org/git/?p=zpackage;a=commitdiff_plain;h=9f738103968e7443ca1d5501f7c1b10bcc13c004 add search options for installs --- diff --git a/zpm-search.c b/zpm-search.c index defbe14..a98aa00 100644 --- a/zpm-search.c +++ b/zpm-search.c @@ -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) {