Consolidate --foreign/--native filtering
Also fix a small bug where pacman won't check if the sync dbs are first downloaded when invoked with --native (it should). Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
8624eddb31
commit
cb43bd8dfb
3 changed files with 17 additions and 14 deletions
|
@ -50,8 +50,6 @@ 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_native;
|
||||
unsigned short op_q_unrequired;
|
||||
unsigned short op_q_deps;
|
||||
unsigned short op_q_explicit;
|
||||
|
@ -60,6 +58,7 @@ typedef struct __config_t {
|
|||
unsigned short op_q_changelog;
|
||||
unsigned short op_q_upgrade;
|
||||
unsigned short op_q_check;
|
||||
unsigned short op_q_locality;
|
||||
|
||||
unsigned short op_s_clean;
|
||||
unsigned short op_s_downloadonly;
|
||||
|
@ -137,6 +136,14 @@ enum {
|
|||
PM_CLEAN_KEEPCUR = (1 << 1)
|
||||
};
|
||||
|
||||
/** package locality */
|
||||
enum {
|
||||
PKG_LOCALITY_UNSET = 0,
|
||||
PKG_LOCALITY_LOCAL = (1 << 0),
|
||||
PKG_LOCALITY_FOREIGN = (1 << 1)
|
||||
};
|
||||
|
||||
|
||||
/* global config variable */
|
||||
extern config_t *config;
|
||||
|
||||
|
|
|
@ -463,8 +463,8 @@ static int parsearg_query(int opt)
|
|||
case 'i': (config->op_q_info)++; break;
|
||||
case 'k': (config->op_q_check)++; break;
|
||||
case 'l': config->op_q_list = 1; break;
|
||||
case 'm': config->op_q_foreign = 1; break;
|
||||
case 'n': config->op_q_native = 1; break;
|
||||
case 'm': config->op_q_locality |= PKG_LOCALITY_LOCAL; break;
|
||||
case 'n': config->op_q_locality |= PKG_LOCALITY_FOREIGN; break;
|
||||
case 'o': config->op_q_owns = 1; break;
|
||||
case 'p': config->op_q_isfile = 1; break;
|
||||
case 'q': config->quiet = 1; break;
|
||||
|
|
|
@ -361,7 +361,7 @@ static int query_group(alpm_list_t *targets)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int is_foreign(alpm_pkg_t *pkg)
|
||||
static unsigned short pkg_get_locality(alpm_pkg_t *pkg)
|
||||
{
|
||||
const char *pkgname = alpm_pkg_get_name(pkg);
|
||||
alpm_list_t *j;
|
||||
|
@ -369,10 +369,10 @@ static int is_foreign(alpm_pkg_t *pkg)
|
|||
|
||||
for(j = sync_dbs; j; j = alpm_list_next(j)) {
|
||||
if(alpm_db_get_pkg(j->data, pkgname)) {
|
||||
return 0;
|
||||
return PKG_LOCALITY_LOCAL;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
return PKG_LOCALITY_FOREIGN;
|
||||
}
|
||||
|
||||
static int is_unrequired(alpm_pkg_t *pkg)
|
||||
|
@ -397,12 +397,8 @@ static int filter(alpm_pkg_t *pkg)
|
|||
alpm_pkg_get_reason(pkg) != ALPM_PKG_REASON_DEPEND) {
|
||||
return 0;
|
||||
}
|
||||
/* check if this pkg is in a sync DB */
|
||||
if(config->op_q_native && is_foreign(pkg)) {
|
||||
return 0;
|
||||
}
|
||||
/* check if this pkg isn't in a sync DB */
|
||||
if(config->op_q_foreign && !is_foreign(pkg)) {
|
||||
/* check if this pkg is or isn't in a sync DB */
|
||||
if(config->op_q_locality && config->op_q_locality & pkg_get_locality(pkg)) {
|
||||
return 0;
|
||||
}
|
||||
/* check if this pkg is unrequired */
|
||||
|
@ -474,7 +470,7 @@ int pacman_query(alpm_list_t *targets)
|
|||
return ret;
|
||||
}
|
||||
|
||||
if(config->op_q_foreign || config->op_q_upgrade) {
|
||||
if(config->op_q_locality || config->op_q_upgrade) {
|
||||
if(check_syncdbs(1, 1)) {
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue