1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-10 11:35:00 -05:00

added Frugalware patch: -Q --foreign to display packages not found in sync repos

This commit is contained in:
Judd Vinet 2005-12-14 02:23:14 +00:00
parent 74d389b7af
commit 15689bddbf
4 changed files with 55 additions and 2 deletions

View File

@ -105,6 +105,10 @@ dependencies, conflicts, etc.
List all files in the specified repositories. Multiple repositories can
be specified on the command line.
.TP
.B "\-m, \-\-foreign"
List all packages that were not found in the sync database(s). Typically these
are packages that were downloading manually and installed with --add.
.TP
.B "\-p, \-\-print-uris"
Print out URIs for each specified package and its dependencies. These
can be piped to a file and downloaded at a later time, using a program

View File

@ -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;

View File

@ -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");

View File

@ -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);
}