summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/alpm.h22
-rw-r--r--lib/libalpm/be_local.c1
-rw-r--r--lib/libalpm/be_sync.c4
-rw-r--r--lib/libalpm/db.c22
-rw-r--r--lib/libalpm/db.h1
-rw-r--r--lib/libalpm/deps.c15
-rw-r--r--lib/libalpm/sync.c15
7 files changed, 76 insertions, 4 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index c6d97c59..b049007c 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -709,6 +709,28 @@ alpm_list_t *alpm_db_get_groupcache(alpm_db_t *db);
*/
alpm_list_t *alpm_db_search(alpm_db_t *db, const alpm_list_t *needles);
+typedef enum _alpm_db_usage_ {
+ ALPM_DB_USAGE_SYNC = 1,
+ ALPM_DB_USAGE_SEARCH = (1 << 1),
+ ALPM_DB_USAGE_INSTALL = (1 << 2),
+ ALPM_DB_USAGE_UPGRADE = (1 << 3),
+ ALPM_DB_USAGE_ALL = (1 << 4) - 1,
+} alpm_db_usage_t;
+
+/** Sets the usage of a database.
+ * @param db pointer to the package database to set the status for
+ * @param usage a bitmask of alpm_db_usage_t values
+ * @return 0 on success, or -1 on error
+ */
+int alpm_db_set_usage(alpm_db_t *db, alpm_db_usage_t usage);
+
+/** Gets the usage of a database.
+ * @param db pointer to the package database to get the status of
+ * @param usage pointer to an alpm_db_usage_t to store db's status
+ * @return 0 on success, or -1 on error
+ */
+int alpm_db_get_usage(alpm_db_t *db, alpm_db_usage_t *usage);
+
/** @} */
/** @addtogroup alpm_api_packages Package Functions
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 49b1c742..2c18a453 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -1091,6 +1091,7 @@ alpm_db_t *_alpm_db_register_local(alpm_handle_t *handle)
}
db->ops = &local_db_ops;
db->handle = handle;
+ db->usage = ALPM_DB_USAGE_ALL;
if(local_db_validate(db)) {
/* pm_errno set in local_db_validate() */
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 0b996843..123d9539 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -183,6 +183,10 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
ASSERT(db != handle->db_local, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
ASSERT(db->servers != NULL, RET_ERR(handle, ALPM_ERR_SERVER_NONE, -1));
+ if(!(db->usage & ALPM_DB_USAGE_SYNC)) {
+ return 0;
+ }
+
syncpath = get_sync_dir(handle);
if(!syncpath) {
return -1;
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 3a04a87b..3245d64f 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -292,6 +292,23 @@ alpm_list_t SYMEXPORT *alpm_db_search(alpm_db_t *db, const alpm_list_t *needles)
return _alpm_db_search(db, needles);
}
+/** Sets the usage bitmask for a repo */
+int SYMEXPORT alpm_db_set_usage(alpm_db_t *db, alpm_db_usage_t usage)
+{
+ ASSERT(db != NULL, return -1);
+ db->usage = usage;
+ return 0;
+}
+
+/** Gets the usage bitmask for a repo */
+int SYMEXPORT alpm_db_get_usage(alpm_db_t *db, alpm_db_usage_t *usage)
+{
+ ASSERT(db != NULL, return -1);
+ ASSERT(usage != NULL, return -1);
+ *usage = db->usage;
+ return 0;
+}
+
/** @} */
@@ -365,6 +382,11 @@ alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles)
{
const alpm_list_t *i, *j, *k;
alpm_list_t *ret = NULL;
+
+ if(!(db->usage & ALPM_DB_USAGE_SEARCH)) {
+ return NULL;
+ }
+
/* copy the pkgcache- we will free the list var after each needle */
alpm_list_t *list = alpm_list_copy(_alpm_db_get_pkgcache(db));
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index 80292933..4bb6ee91 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -73,6 +73,7 @@ struct __alpm_db_t {
/* flags determining validity, local, loaded caches, etc. */
enum _alpm_dbstatus_t status;
alpm_siglevel_t siglevel;
+ alpm_db_usage_t usage;
};
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index c8aabb2d..745eac17 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -654,7 +654,14 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
/* 1. literals */
for(i = dbs; i; i = i->next) {
- alpm_pkg_t *pkg = _alpm_db_get_pkgfromcache(i->data, dep->name);
+ alpm_pkg_t *pkg;
+ alpm_db_t *db = i->data;
+
+ if(!(db->usage & (ALPM_DB_USAGE_INSTALL|ALPM_DB_USAGE_UPGRADE))) {
+ continue;
+ }
+
+ pkg = _alpm_db_get_pkgfromcache(db, dep->name);
if(pkg && _alpm_depcmp_literal(pkg, dep)
&& !alpm_pkg_find(excluding, pkg->name)) {
if(_alpm_pkg_should_ignore(handle, pkg)) {
@@ -676,7 +683,11 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
}
/* 2. satisfiers (skip literals here) */
for(i = dbs; i; i = i->next) {
- for(j = _alpm_db_get_pkgcache(i->data); j; j = j->next) {
+ alpm_db_t *db = i->data;
+ if(!(db->usage & (ALPM_DB_USAGE_INSTALL|ALPM_DB_USAGE_UPGRADE))) {
+ continue;
+ }
+ for(j = _alpm_db_get_pkgcache(db); j; j = j->next) {
alpm_pkg_t *pkg = j->data;
/* with hash != hash, we can even skip the strcmp() as we know they can't
* possibly be the same string */
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index f9217bd4..98c0bc1d 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -60,7 +60,12 @@ alpm_pkg_t SYMEXPORT *alpm_sync_newversion(alpm_pkg_t *pkg, alpm_list_t *dbs_syn
pkg->handle->pm_errno = 0;
for(i = dbs_sync; !spkg && i; i = i->next) {
- spkg = _alpm_db_get_pkgfromcache(i->data, pkg->name);
+ alpm_db_t *db = i->data;
+ if(!(db->usage & ALPM_DB_USAGE_SEARCH)) {
+ continue;
+ }
+
+ spkg = _alpm_db_get_pkgfromcache(db, pkg->name);
}
if(spkg == NULL) {
@@ -212,8 +217,14 @@ int SYMEXPORT alpm_sync_sysupgrade(alpm_handle_t *handle, int enable_downgrade)
/* Search for replacers then literal (if no replacer) in each sync database. */
for(j = handle->dbs_sync; j; j = j->next) {
alpm_db_t *sdb = j->data;
- alpm_list_t *replacers = check_replacers(handle, lpkg, sdb);
+ alpm_list_t *replacers;
+
+ if(!(sdb->usage & ALPM_DB_USAGE_UPGRADE)) {
+ continue;
+ }
+
/* Check sdb */
+ replacers = check_replacers(handle, lpkg, sdb);
if(replacers) {
trans->add = alpm_list_join(trans->add, replacers);
/* jump to next local package */