summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorXavier Chantry <shiningxc@gmail.com>2008-08-17 19:30:36 +0200
committerDan McGee <dan@archlinux.org>2008-08-26 01:08:52 +0200
commit070135626023caa0186a77f9f846c078e3cf1be8 (patch)
tree94b481f19572ad3d1812fee8cd331c84ccfa0f0e /lib/libalpm
parent9dbe5c9d1ee5fb00f25515dfb5a2feb3ae6ebd59 (diff)
downloadpacman-070135626023caa0186a77f9f846c078e3cf1be8.tar.gz
pacman-070135626023caa0186a77f9f846c078e3cf1be8.tar.xz
Change checkdeps and checkdbconflicts to be more flexible.
These two functions now take directly a package list rather than a database. checkdbconflicts was renamed to checkconflicts. Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/add.c2
-rw-r--r--lib/libalpm/alpm.h4
-rw-r--r--lib/libalpm/conflict.c6
-rw-r--r--lib/libalpm/deps.c12
-rw-r--r--lib/libalpm/remove.c6
-rw-r--r--lib/libalpm/sync.c2
6 files changed, 14 insertions, 18 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 3c832b3e..50405895 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -114,7 +114,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
/* look for unsatisfied dependencies */
_alpm_log(PM_LOG_DEBUG, "looking for unsatisfied dependencies\n");
- lp = alpm_checkdeps(db, 1, NULL, trans->packages);
+ lp = alpm_checkdeps(_alpm_db_get_pkgcache(db), 1, NULL, trans->packages);
if(lp != NULL) {
if(data) {
*data = lp;
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index cdceaf01..382822cc 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -428,7 +428,7 @@ typedef enum _pmdepmod_t {
} pmdepmod_t;
int alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep);
-alpm_list_t *alpm_checkdeps(pmdb_t *db, int reversedeps,
+alpm_list_t *alpm_checkdeps(alpm_list_t *pkglist, int reversedeps,
alpm_list_t *remove, alpm_list_t *upgrade);
alpm_list_t *alpm_deptest(pmdb_t *db, alpm_list_t *targets);
@@ -436,7 +436,7 @@ const char *alpm_miss_get_target(const pmdepmissing_t *miss);
pmdepend_t *alpm_miss_get_dep(pmdepmissing_t *miss);
const char *alpm_miss_get_causingpkg(const pmdepmissing_t *miss);
-alpm_list_t *alpm_checkdbconflicts(pmdb_t *db_local);
+alpm_list_t *alpm_checkconflicts(alpm_list_t *pkglist);
const char *alpm_conflict_get_package1(pmconflict_t *conflict);
const char *alpm_conflict_get_package2(pmconflict_t *conflict);
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index a8bcdd59..cae237cf 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -219,11 +219,11 @@ alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages)
/** Check the package conflicts in a database
*
- * @param db_local the database to check
+ * @param pkglist the list of packages to check
* @return an alpm_list_t of pmconflict_t
*/
-alpm_list_t SYMEXPORT *alpm_checkdbconflicts(pmdb_t *db_local) {
- return(_alpm_innerconflicts(_alpm_db_get_pkgcache(db_local)));
+alpm_list_t SYMEXPORT *alpm_checkconflicts(alpm_list_t *pkglist) {
+ return(_alpm_innerconflicts(pkglist));
}
/* Returns a alpm_list_t* of file conflicts.
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index c667daa2..96c971a2 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -229,13 +229,13 @@ alpm_list_t SYMEXPORT *alpm_deptest(pmdb_t *db, alpm_list_t *targets)
/** Checks dependencies and returns missing ones in a list.
* Dependencies can include versions with depmod operators.
- * @param db pointer to the local package database
+ * @param pkglist the list of local packages
* @param reversedeps handles the backward dependencies
* @param remove an alpm_list_t* of packages to be removed
* @param upgrade an alpm_list_t* of packages to be upgraded (remove-then-upgrade)
* @return an alpm_list_t* of pmpkg_t* of missing_t pointers.
*/
-alpm_list_t SYMEXPORT *alpm_checkdeps(pmdb_t *db, int reversedeps,
+alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_list_t *pkglist, int reversedeps,
alpm_list_t *remove, alpm_list_t *upgrade)
{
alpm_list_t *i, *j;
@@ -245,12 +245,8 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(pmdb_t *db, int reversedeps,
ALPM_LOG_FUNC;
- if(db == NULL) {
- return(NULL);
- }
-
targets = alpm_list_join(alpm_list_copy(remove), alpm_list_copy(upgrade));
- for(i = _alpm_db_get_pkgcache(db); i; i = i->next) {
+ for(i = pkglist; i; i = i->next) {
void *pkg = i->data;
if(alpm_list_find(targets, pkg, _alpm_pkg_cmp)) {
modified = alpm_list_add(modified, pkg);
@@ -572,7 +568,7 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, alpm_list_t *list,
for(i = list; i; i = i->next) {
pmpkg_t *tpkg = i->data;
targ = alpm_list_add(NULL, tpkg);
- deps = alpm_checkdeps(local, 0, remove, targ);
+ deps = alpm_checkdeps(_alpm_db_get_pkgcache(local), 0, remove, targ);
alpm_list_free(targ);
for(j = deps; j; j = j->next) {
pmdepmissing_t *miss = j->data;
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 864fafaf..f0734902 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -104,7 +104,7 @@ static void remove_prepare_cascade(pmtrans_t *trans, pmdb_t *db,
}
alpm_list_free_inner(lp, (alpm_list_fn_free)_alpm_depmiss_free);
alpm_list_free(lp);
- lp = alpm_checkdeps(db, 1, trans->packages, NULL);
+ lp = alpm_checkdeps(_alpm_db_get_pkgcache(db), 1, trans->packages, NULL);
}
}
@@ -134,7 +134,7 @@ static void remove_prepare_keep_needed(pmtrans_t *trans, pmdb_t *db,
}
alpm_list_free_inner(lp, (alpm_list_fn_free)_alpm_depmiss_free);
alpm_list_free(lp);
- lp = alpm_checkdeps(db, 1, trans->packages, NULL);
+ lp = alpm_checkdeps(_alpm_db_get_pkgcache(db), 1, trans->packages, NULL);
}
}
@@ -161,7 +161,7 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
_alpm_log(PM_LOG_DEBUG, "looking for unsatisfied dependencies\n");
- lp = alpm_checkdeps(db, 1, trans->packages, NULL);
+ lp = alpm_checkdeps(_alpm_db_get_pkgcache(db), 1, trans->packages, NULL);
if(lp != NULL) {
if(trans->flags & PM_TRANS_FLAG_CASCADE) {
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 22b391bc..96ca6319 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -630,7 +630,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
}
_alpm_log(PM_LOG_DEBUG, "checking dependencies\n");
- deps = alpm_checkdeps(db_local, 1, remove, list);
+ deps = alpm_checkdeps(_alpm_db_get_pkgcache(db_local), 1, remove, list);
if(deps) {
pm_errno = PM_ERR_UNSATISFIED_DEPS;
ret = -1;