index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Judd Vinet <judd@archlinux.org> | 2005-12-14 02:23:14 +0000 |
---|---|---|
committer | Judd Vinet <judd@archlinux.org> | 2005-12-14 02:23:14 +0000 |
commit | 15689bddbfc37ada11c2d4d5d77997dabf303960 (patch) | |
tree | 1aa05c958ecb6b354569ba695bf790675df408d2 /src | |
parent | 74d389b7af53a2bb1651b96fc42256e70946ecb3 (diff) |
-rw-r--r-- | src/pacman/conf.h | 1 | ||||
-rw-r--r-- | src/pacman/pacman.c | 5 | ||||
-rw-r--r-- | src/pacman/query.c | 47 |
diff --git a/src/pacman/conf.h b/src/pacman/conf.h index 678c0062..4b2d3a84 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -38,6 +38,7 @@ typedef struct __config_t { unsigned short op_q_isfile; unsigned short op_q_info; unsigned short op_q_list; + unsigned short op_q_foreign; unsigned short op_q_orphans; unsigned short op_q_owns; unsigned short op_q_search; diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 698cbfe2..cdc6816c 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -383,6 +383,7 @@ int parseargs(int argc, char *argv[]) {"dbonly", no_argument, 0, 'k'}, {"list", no_argument, 0, 'l'}, {"nosave", no_argument, 0, 'n'}, + {"foreign", no_argument, 0, 'm'}, {"owns", no_argument, 0, 'o'}, {"file", no_argument, 0, 'p'}, {"print-uris", no_argument, 0, 'p'}, @@ -401,7 +402,7 @@ int parseargs(int argc, char *argv[]) }; char root[PATH_MAX]; - while((opt = getopt_long(argc, argv, "ARUFQSTDYr:b:vkhscVfnoldepiuwyg", opts, &option_index))) { + while((opt = getopt_long(argc, argv, "ARUFQSTDYr:b:vkhscVfmnoldepiuwyg", opts, &option_index))) { if(opt < 0) { break; } @@ -443,6 +444,7 @@ int parseargs(int argc, char *argv[]) case 'i': config->op_q_info++; config->op_s_info++; break; case 'k': config->flags |= PM_TRANS_FLAG_DBONLY; break; case 'l': config->op_q_list = 1; break; + case 'm': config->op_q_foreign = 1; break; case 'n': config->flags |= PM_TRANS_FLAG_NOSAVE; break; case 'o': config->op_q_owns = 1; break; case 'p': config->op_q_isfile = 1; config->op_s_printuris = 1; break; @@ -536,6 +538,7 @@ void usage(int op, char *myname) printf(" -g, --groups view all members of a package group\n"); printf(" -i, --info view package information\n"); printf(" -l, --list list the contents of the queried package\n"); + printf(" -m, --foreign list all packages that were not found in the sync repos\n"); printf(" -o, --owns <file> query the package that owns <file>\n"); printf(" -p, --file pacman will query the package file [package] instead of\n"); printf(" looking in the database\n"); diff --git a/src/pacman/query.c b/src/pacman/query.c index f2b74c83..0462f5aa 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -33,9 +33,12 @@ #include "query.h" #include "log.h" #include "conf.h" +#include "sync.h" +#include "util.h" extern config_t *config; extern PM_DB *db_local; +extern list_t *pmc_syncs; static int query_fileowner(PM_DB *db, char *filename) { @@ -90,6 +93,8 @@ int pacman_query(list_t *targets) { PM_PKG *info = NULL; list_t *targ; + list_t *i; + PM_LIST *j; char *package = NULL; int done = 0; @@ -100,6 +105,23 @@ int pacman_query(list_t *targets) return(0); } + if(config->op_q_foreign) { + if(pmc_syncs == NULL || !list_count(pmc_syncs)) { + ERR(NL, "no usable package repositories configured.\n"); + return(1); + } + + /* open the database(s) */ + for(i = pmc_syncs; i; i = i->next) { + sync_t *sync = i->data; + sync->db = alpm_db_register(sync->treename); + if(sync->db == NULL) { + ERR(NL, "%s\n", alpm_strerror(pm_errno)); + return(1); + } + } + } + for(targ = targets; !done; targ = (targ ? targ->next : NULL)) { if(targets == NULL) { done = 1; @@ -182,13 +204,36 @@ int pacman_query(list_t *targets) pkgname = alpm_pkg_getinfo(tmpp, PM_PKG_NAME); pkgver = alpm_pkg_getinfo(tmpp, PM_PKG_VERSION); - if(config->op_q_list || config->op_q_orphans) { + if(config->op_q_list || config->op_q_orphans || config->op_q_foreign) { info = alpm_db_readpkg(db_local, pkgname); if(info == NULL) { /* something weird happened */ ERR(NL, "package \"%s\" not found\n", pkgname); return(1); } + if(config->op_q_foreign) { + int match = 0; + for(i = pmc_syncs; i; i = i->next) { + sync_t *sync = (sync_t *)i->data; + for(j = alpm_db_getpkgcache(sync->db); j; j = alpm_list_next(j)) { + PM_PKG *pkg = alpm_list_getdata(j); + char *haystack; + char *needle; + haystack = strdup(alpm_pkg_getinfo(pkg, PM_PKG_NAME)); + strtoupper(haystack); + needle = strdup(alpm_pkg_getinfo(info, PM_PKG_NAME)); + strtoupper(needle); + if(strstr(haystack, needle)) { + match = 1; + } + FREE(haystack); + FREE(needle); + } + } + if(match==0) { + MSG(NL, "%s %s\n", pkgname, pkgver); + } + } if(config->op_q_list) { dump_pkg_files(info); } |