summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-06-07 14:05:42 -0500
committerDan McGee <dan@archlinux.org>2011-06-13 19:35:22 -0500
commit8b62d9bc0ade64897990b8fc6a1b6a54b629cb5b (patch)
tree9f8239d9a953552aa0045e5206bd3bb2f8bba09e /lib/libalpm
parent70a86c14f4462ba59a9d6bbd3c9e9f0c75483777 (diff)
downloadpacman-8b62d9bc0ade64897990b8fc6a1b6a54b629cb5b.tar.xz
Add handle argument to two more alpm methods
This takes care of alpm_checkdeps() and alpm_find_dbs_satisfier(). Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/alpm.h7
-rw-r--r--lib/libalpm/deps.c29
-rw-r--r--lib/libalpm/deps.h2
-rw-r--r--lib/libalpm/remove.c27
-rw-r--r--lib/libalpm/sync.c5
5 files changed, 39 insertions, 31 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 7e61a03f..0fb9974d 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -905,10 +905,11 @@ typedef enum _pmdepmod_t {
PM_DEP_MOD_LT
} pmdepmod_t;
-alpm_list_t *alpm_checkdeps(alpm_list_t *pkglist, int reversedeps,
- alpm_list_t *remove, alpm_list_t *upgrade);
+alpm_list_t *alpm_checkdeps(pmhandle_t *handle, alpm_list_t *pkglist,
+ alpm_list_t *remove, alpm_list_t *upgrade, int reversedeps);
pmpkg_t *alpm_find_satisfier(alpm_list_t *pkgs, const char *depstring);
-pmpkg_t *alpm_find_dbs_satisfier(alpm_list_t *dbs, const char *depstring);
+pmpkg_t *alpm_find_dbs_satisfier(pmhandle_t *handle,
+ alpm_list_t *dbs, const char *depstring);
const char *alpm_miss_get_target(const pmdepmissing_t *miss);
pmdepend_t *alpm_miss_get_dep(pmdepmissing_t *miss);
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 32922892..1ebf45a1 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -37,9 +37,6 @@
#include "handle.h"
#include "trans.h"
-/* global handle variable */
-extern pmhandle_t *handle;
-
void _alpm_dep_free(pmdepend_t *dep)
{
FREE(dep->name);
@@ -257,14 +254,15 @@ pmpkg_t SYMEXPORT *alpm_find_satisfier(alpm_list_t *pkgs, const char *depstring)
/** Checks dependencies and returns missing ones in a list.
* Dependencies can include versions with depmod operators.
+ * @param handle the context handle
* @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)
+ * @param reversedeps handles the backward dependencies
* @return an alpm_list_t* of pmdepmissing_t pointers.
*/
-alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_list_t *pkglist, int reversedeps,
- alpm_list_t *remove, alpm_list_t *upgrade)
+alpm_list_t SYMEXPORT *alpm_checkdeps(pmhandle_t *handle, alpm_list_t *pkglist,
+ alpm_list_t *remove, alpm_list_t *upgrade, int reversedeps)
{
alpm_list_t *i, *j;
alpm_list_t *targets, *dblist = NULL, *modified = NULL;
@@ -541,6 +539,7 @@ void _alpm_recursedeps(pmdb_t *db, alpm_list_t *targs, int include_explicit)
/**
* helper function for resolvedeps: search for dep satisfier in dbs
*
+ * @param handle the context handle
* @param dep is the dependency to search for
* @param dbs are the databases to search
* @param excluding are the packages to exclude from the search
@@ -550,8 +549,8 @@ void _alpm_recursedeps(pmdb_t *db, alpm_list_t *targs, int include_explicit)
* an error code without prompting
* @return the resolved package
**/
-static pmpkg_t *resolvedep(pmdepend_t *dep, alpm_list_t *dbs,
- alpm_list_t *excluding, int prompt)
+static pmpkg_t *resolvedep(pmhandle_t *handle, pmdepend_t *dep,
+ alpm_list_t *dbs, alpm_list_t *excluding, int prompt)
{
alpm_list_t *i, *j;
int ignored = 0;
@@ -644,11 +643,13 @@ static pmpkg_t *resolvedep(pmdepend_t *dep, alpm_list_t *dbs,
* First look for a literal, going through each db one by one. Then look for
* providers. The first satisfier found is returned.
* The dependency can include versions with depmod operators.
+ * @param handle the context handle
* @param dbs an alpm_list_t* of pmdb_t where the satisfier will be searched
* @param depstring package or provision name, versioned or not
* @return a pmpkg_t* satisfying depstring
*/
-pmpkg_t SYMEXPORT *alpm_find_dbs_satisfier(alpm_list_t *dbs, const char *depstring)
+pmpkg_t SYMEXPORT *alpm_find_dbs_satisfier(pmhandle_t *handle,
+ alpm_list_t *dbs, const char *depstring)
{
pmdepend_t *dep;
pmpkg_t *pkg;
@@ -657,7 +658,7 @@ pmpkg_t SYMEXPORT *alpm_find_dbs_satisfier(alpm_list_t *dbs, const char *depstri
dep = _alpm_splitdep(depstring);
ASSERT(dep, return NULL);
- pkg = resolvedep(dep, dbs, NULL, 1);
+ pkg = resolvedep(handle, dep, dbs, NULL, 1);
_alpm_dep_free(dep);
return pkg;
}
@@ -666,8 +667,8 @@ pmpkg_t SYMEXPORT *alpm_find_dbs_satisfier(alpm_list_t *dbs, const char *depstri
* Computes resolvable dependencies for a given package and adds that package
* and those resolvable dependencies to a list.
*
+ * @param handle the context handle
* @param localpkgs is the list of local packages
- * @param dbs_sync are the sync databases
* @param pkg is the package to resolve
* @param packages is a pointer to a list of packages which will be
* searched first for any dependency packages needed to complete the
@@ -682,7 +683,7 @@ pmpkg_t SYMEXPORT *alpm_find_dbs_satisfier(alpm_list_t *dbs, const char *depstri
* unresolvable dependency, in which case the [*packages] list will be
* unmodified by this function
*/
-int _alpm_resolvedeps(alpm_list_t *localpkgs, alpm_list_t *dbs_sync, pmpkg_t *pkg,
+int _alpm_resolvedeps(pmhandle_t *handle, alpm_list_t *localpkgs, pmpkg_t *pkg,
alpm_list_t *preferred, alpm_list_t **packages,
alpm_list_t *remove, alpm_list_t **data)
{
@@ -707,7 +708,7 @@ int _alpm_resolvedeps(alpm_list_t *localpkgs, alpm_list_t *dbs_sync, pmpkg_t *pk
for(i = alpm_list_last(*packages); i; i = i->next) {
pmpkg_t *tpkg = i->data;
targ = alpm_list_add(NULL, tpkg);
- deps = alpm_checkdeps(localpkgs, 0, remove, targ);
+ deps = alpm_checkdeps(handle, localpkgs, remove, targ, 0);
alpm_list_free(targ);
for(j = deps; j; j = j->next) {
@@ -724,7 +725,7 @@ int _alpm_resolvedeps(alpm_list_t *localpkgs, alpm_list_t *dbs_sync, pmpkg_t *pk
pmpkg_t *spkg = find_dep_satisfier(preferred, missdep);
if(!spkg) {
/* find a satisfier package in the given repositories */
- spkg = resolvedep(missdep, dbs_sync, *packages, 0);
+ spkg = resolvedep(handle, missdep, handle->dbs_sync, *packages, 0);
}
if(!spkg) {
pm_errno = PM_ERR_UNSATISFIED_DEPS;
diff --git a/lib/libalpm/deps.h b/lib/libalpm/deps.h
index f728cad0..2d616537 100644
--- a/lib/libalpm/deps.h
+++ b/lib/libalpm/deps.h
@@ -47,7 +47,7 @@ pmdepend_t *_alpm_dep_dup(const pmdepend_t *dep);
void _alpm_depmiss_free(pmdepmissing_t *miss);
alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int reverse);
void _alpm_recursedeps(pmdb_t *db, alpm_list_t *targs, int include_explicit);
-int _alpm_resolvedeps(alpm_list_t *localpkgs, alpm_list_t *dbs_sync, pmpkg_t *pkg,
+int _alpm_resolvedeps(pmhandle_t *handle, alpm_list_t *localpkgs, pmpkg_t *pkg,
alpm_list_t *preferred, alpm_list_t **packages, alpm_list_t *remove,
alpm_list_t **data);
pmdepend_t *_alpm_splitdep(const char *depstring);
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index fedc7faa..30403f70 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -70,14 +70,15 @@ int SYMEXPORT alpm_remove_pkg(pmhandle_t *handle, pmpkg_t *pkg)
return 0;
}
-static void remove_prepare_cascade(pmtrans_t *trans, pmdb_t *db,
- alpm_list_t *lp)
+static void remove_prepare_cascade(pmhandle_t *handle, alpm_list_t *lp)
{
+ pmtrans_t *trans = handle->trans;
+
while(lp) {
alpm_list_t *i;
for(i = lp; i; i = i->next) {
pmdepmissing_t *miss = (pmdepmissing_t *)i->data;
- pmpkg_t *info = _alpm_db_get_pkgfromcache(db, miss->target);
+ pmpkg_t *info = _alpm_db_get_pkgfromcache(handle->db_local, miss->target);
if(info) {
if(!_alpm_pkg_find(trans->remove, alpm_pkg_get_name(info))) {
_alpm_log(PM_LOG_DEBUG, "pulling %s in target list\n",
@@ -91,13 +92,15 @@ 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(_alpm_db_get_pkgcache(db), 1, trans->remove, NULL);
+ lp = alpm_checkdeps(handle, _alpm_db_get_pkgcache(handle->db_local),
+ trans->remove, NULL, 1);
}
}
-static void remove_prepare_keep_needed(pmtrans_t *trans, pmdb_t *db,
- alpm_list_t *lp)
+static void remove_prepare_keep_needed(pmhandle_t *handle, alpm_list_t *lp)
{
+ pmtrans_t *trans = handle->trans;
+
/* Remove needed packages (which break dependencies) from target list */
while(lp != NULL) {
alpm_list_t *i;
@@ -119,7 +122,8 @@ 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(_alpm_db_get_pkgcache(db), 1, trans->remove, NULL);
+ lp = alpm_checkdeps(handle, _alpm_db_get_pkgcache(handle->db_local),
+ trans->remove, NULL, 1);
}
}
@@ -138,22 +142,23 @@ int _alpm_remove_prepare(pmhandle_t *handle, alpm_list_t **data)
if((trans->flags & PM_TRANS_FLAG_RECURSE) && !(trans->flags & PM_TRANS_FLAG_CASCADE)) {
_alpm_log(PM_LOG_DEBUG, "finding removable dependencies\n");
- _alpm_recursedeps(db, trans->remove, trans->flags & PM_TRANS_FLAG_RECURSEALL);
+ _alpm_recursedeps(db, trans->remove,
+ trans->flags & PM_TRANS_FLAG_RECURSEALL);
}
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
_alpm_log(PM_LOG_DEBUG, "looking for unsatisfied dependencies\n");
- lp = alpm_checkdeps(_alpm_db_get_pkgcache(db), 1, trans->remove, NULL);
+ lp = alpm_checkdeps(handle, _alpm_db_get_pkgcache(db), trans->remove, NULL, 1);
if(lp != NULL) {
if(trans->flags & PM_TRANS_FLAG_CASCADE) {
- remove_prepare_cascade(trans, db, lp);
+ remove_prepare_cascade(handle, lp);
} else if(trans->flags & PM_TRANS_FLAG_UNNEEDED) {
/* Remove needed packages (which would break dependencies)
* from target list */
- remove_prepare_keep_needed(trans, db, lp);
+ remove_prepare_keep_needed(handle, lp);
} else {
if(data) {
*data = lp;
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 518e853e..b4ac077c 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -336,7 +336,7 @@ int _alpm_sync_prepare(pmhandle_t *handle, alpm_list_t **data)
building up a list of packages which could not be resolved. */
for(i = trans->add; i; i = i->next) {
pmpkg_t *pkg = i->data;
- if(_alpm_resolvedeps(localpkgs, handle->dbs_sync, pkg, trans->add,
+ if(_alpm_resolvedeps(handle, localpkgs, pkg, trans->add,
&resolved, remove, data) == -1) {
unresolvable = alpm_list_add(unresolvable, pkg);
}
@@ -521,7 +521,8 @@ int _alpm_sync_prepare(pmhandle_t *handle, alpm_list_t **data)
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
_alpm_log(PM_LOG_DEBUG, "checking dependencies\n");
- deps = alpm_checkdeps(_alpm_db_get_pkgcache(db_local), 1, trans->remove, trans->add);
+ deps = alpm_checkdeps(handle, _alpm_db_get_pkgcache(handle->db_local),
+ trans->remove, trans->add, 1);
if(deps) {
pm_errno = PM_ERR_UNSATISFIED_DEPS;
ret = -1;