summaryrefslogtreecommitdiffstats
path: root/src/pacman/query.c
diff options
context:
space:
mode:
authorSimon Gomizelj <simongmzlj@gmail.com>2012-12-13 16:06:41 +0100
committerAllan McRae <allan@archlinux.org>2013-01-29 04:36:58 +0100
commitcb43bd8dfbee0396ff6f56c20690995adfcf3b99 (patch)
tree0a728b69281137a92b29ae9f216f6a0508ecbd03 /src/pacman/query.c
parent8624eddb31dc360312b50b5435f6688bec4543c5 (diff)
downloadpacman-cb43bd8dfbee0396ff6f56c20690995adfcf3b99.tar.gz
pacman-cb43bd8dfbee0396ff6f56c20690995adfcf3b99.tar.xz
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>
Diffstat (limited to 'src/pacman/query.c')
-rw-r--r--src/pacman/query.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/pacman/query.c b/src/pacman/query.c
index ef279d97..1247c3d4 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -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;
}