FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 06-07-2011, 09:36 PM
Dan McGee
 
Default 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>
---
lib/libalpm/alpm.h | 7 ++++---
lib/libalpm/deps.c | 29 +++++++++++++++--------------
lib/libalpm/deps.h | 2 +-
lib/libalpm/remove.c | 27 ++++++++++++++++-----------
lib/libalpm/sync.c | 5 +++--
src/pacman/sync.c | 2 +-
src/util/testdb.c | 2 +-
7 files changed, 41 insertions(+), 33 deletions(-)

diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 270418e..821f2fa 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -903,10 +903,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 3292289..1ebf45a 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 f728cad..2d61653 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 0682a35..5f09930 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -68,14 +68,15 @@ int SYMEXPORT alpm_remove_pkg(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
",
@@ -89,13 +90,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;
@@ -117,7 +120,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);
}
}

@@ -136,22 +140,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
");
- _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
");
- 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 518e853..b4ac077 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
");
- 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;
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 8405002..cf350d7 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -685,7 +685,7 @@ cleanup:

static int process_targname(alpm_list_t *dblist, char *targname)
{
- pmpkg_t *pkg = alpm_find_dbs_satisfier(dblist, targname);
+ pmpkg_t *pkg = alpm_find_dbs_satisfier(config->handle, dblist, targname);

/* #FS23342 - skip ignored packages when user says no */
if(pm_errno == PM_ERR_PKG_IGNORED) {
diff --git a/src/util/testdb.c b/src/util/testdb.c
index 839a9cf..bda67d5 100644
--- a/src/util/testdb.c
+++ b/src/util/testdb.c
@@ -98,7 +98,7 @@ static int checkdeps(alpm_list_t *pkglist)
alpm_list_t *data, *i;
int ret = 0;
/* check dependencies */
- data = alpm_checkdeps(pkglist, 0, NULL, pkglist);
+ data = alpm_checkdeps(handle, pkglist, NULL, pkglist, 0);
for(i = data; i; i = alpm_list_next(i)) {
pmdepmissing_t *miss = alpm_list_getdata(i);
pmdepend_t *dep = alpm_miss_get_dep(miss);
--
1.7.5.2
 

Thread Tools




All times are GMT. The time now is 07:08 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org