mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-11 11:55:12 -05:00
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>
This commit is contained in:
parent
70a86c14f4
commit
8b62d9bc0a
@ -905,10 +905,11 @@ typedef enum _pmdepmod_t {
|
|||||||
PM_DEP_MOD_LT
|
PM_DEP_MOD_LT
|
||||||
} pmdepmod_t;
|
} pmdepmod_t;
|
||||||
|
|
||||||
alpm_list_t *alpm_checkdeps(alpm_list_t *pkglist, int reversedeps,
|
alpm_list_t *alpm_checkdeps(pmhandle_t *handle, alpm_list_t *pkglist,
|
||||||
alpm_list_t *remove, alpm_list_t *upgrade);
|
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_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);
|
const char *alpm_miss_get_target(const pmdepmissing_t *miss);
|
||||||
pmdepend_t *alpm_miss_get_dep(pmdepmissing_t *miss);
|
pmdepend_t *alpm_miss_get_dep(pmdepmissing_t *miss);
|
||||||
|
@ -37,9 +37,6 @@
|
|||||||
#include "handle.h"
|
#include "handle.h"
|
||||||
#include "trans.h"
|
#include "trans.h"
|
||||||
|
|
||||||
/* global handle variable */
|
|
||||||
extern pmhandle_t *handle;
|
|
||||||
|
|
||||||
void _alpm_dep_free(pmdepend_t *dep)
|
void _alpm_dep_free(pmdepend_t *dep)
|
||||||
{
|
{
|
||||||
FREE(dep->name);
|
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.
|
/** Checks dependencies and returns missing ones in a list.
|
||||||
* Dependencies can include versions with depmod operators.
|
* Dependencies can include versions with depmod operators.
|
||||||
|
* @param handle the context handle
|
||||||
* @param pkglist the list of local packages
|
* @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 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 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.
|
* @return an alpm_list_t* of pmdepmissing_t pointers.
|
||||||
*/
|
*/
|
||||||
alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_list_t *pkglist, int reversedeps,
|
alpm_list_t SYMEXPORT *alpm_checkdeps(pmhandle_t *handle, alpm_list_t *pkglist,
|
||||||
alpm_list_t *remove, alpm_list_t *upgrade)
|
alpm_list_t *remove, alpm_list_t *upgrade, int reversedeps)
|
||||||
{
|
{
|
||||||
alpm_list_t *i, *j;
|
alpm_list_t *i, *j;
|
||||||
alpm_list_t *targets, *dblist = NULL, *modified = NULL;
|
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
|
* helper function for resolvedeps: search for dep satisfier in dbs
|
||||||
*
|
*
|
||||||
|
* @param handle the context handle
|
||||||
* @param dep is the dependency to search for
|
* @param dep is the dependency to search for
|
||||||
* @param dbs are the databases to search
|
* @param dbs are the databases to search
|
||||||
* @param excluding are the packages to exclude from the 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
|
* an error code without prompting
|
||||||
* @return the resolved package
|
* @return the resolved package
|
||||||
**/
|
**/
|
||||||
static pmpkg_t *resolvedep(pmdepend_t *dep, alpm_list_t *dbs,
|
static pmpkg_t *resolvedep(pmhandle_t *handle, pmdepend_t *dep,
|
||||||
alpm_list_t *excluding, int prompt)
|
alpm_list_t *dbs, alpm_list_t *excluding, int prompt)
|
||||||
{
|
{
|
||||||
alpm_list_t *i, *j;
|
alpm_list_t *i, *j;
|
||||||
int ignored = 0;
|
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
|
* First look for a literal, going through each db one by one. Then look for
|
||||||
* providers. The first satisfier found is returned.
|
* providers. The first satisfier found is returned.
|
||||||
* The dependency can include versions with depmod operators.
|
* 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 dbs an alpm_list_t* of pmdb_t where the satisfier will be searched
|
||||||
* @param depstring package or provision name, versioned or not
|
* @param depstring package or provision name, versioned or not
|
||||||
* @return a pmpkg_t* satisfying depstring
|
* @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;
|
pmdepend_t *dep;
|
||||||
pmpkg_t *pkg;
|
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);
|
dep = _alpm_splitdep(depstring);
|
||||||
ASSERT(dep, return NULL);
|
ASSERT(dep, return NULL);
|
||||||
pkg = resolvedep(dep, dbs, NULL, 1);
|
pkg = resolvedep(handle, dep, dbs, NULL, 1);
|
||||||
_alpm_dep_free(dep);
|
_alpm_dep_free(dep);
|
||||||
return pkg;
|
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
|
* Computes resolvable dependencies for a given package and adds that package
|
||||||
* and those resolvable dependencies to a list.
|
* and those resolvable dependencies to a list.
|
||||||
*
|
*
|
||||||
|
* @param handle the context handle
|
||||||
* @param localpkgs is the list of local packages
|
* @param localpkgs is the list of local packages
|
||||||
* @param dbs_sync are the sync databases
|
|
||||||
* @param pkg is the package to resolve
|
* @param pkg is the package to resolve
|
||||||
* @param packages is a pointer to a list of packages which will be
|
* @param packages is a pointer to a list of packages which will be
|
||||||
* searched first for any dependency packages needed to complete the
|
* 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
|
* unresolvable dependency, in which case the [*packages] list will be
|
||||||
* unmodified by this function
|
* 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 *preferred, alpm_list_t **packages,
|
||||||
alpm_list_t *remove, alpm_list_t **data)
|
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) {
|
for(i = alpm_list_last(*packages); i; i = i->next) {
|
||||||
pmpkg_t *tpkg = i->data;
|
pmpkg_t *tpkg = i->data;
|
||||||
targ = alpm_list_add(NULL, tpkg);
|
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);
|
alpm_list_free(targ);
|
||||||
|
|
||||||
for(j = deps; j; j = j->next) {
|
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);
|
pmpkg_t *spkg = find_dep_satisfier(preferred, missdep);
|
||||||
if(!spkg) {
|
if(!spkg) {
|
||||||
/* find a satisfier package in the given repositories */
|
/* 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) {
|
if(!spkg) {
|
||||||
pm_errno = PM_ERR_UNSATISFIED_DEPS;
|
pm_errno = PM_ERR_UNSATISFIED_DEPS;
|
||||||
|
@ -47,7 +47,7 @@ pmdepend_t *_alpm_dep_dup(const pmdepend_t *dep);
|
|||||||
void _alpm_depmiss_free(pmdepmissing_t *miss);
|
void _alpm_depmiss_free(pmdepmissing_t *miss);
|
||||||
alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int reverse);
|
alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int reverse);
|
||||||
void _alpm_recursedeps(pmdb_t *db, alpm_list_t *targs, int include_explicit);
|
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 *preferred, alpm_list_t **packages, alpm_list_t *remove,
|
||||||
alpm_list_t **data);
|
alpm_list_t **data);
|
||||||
pmdepend_t *_alpm_splitdep(const char *depstring);
|
pmdepend_t *_alpm_splitdep(const char *depstring);
|
||||||
|
@ -70,14 +70,15 @@ int SYMEXPORT alpm_remove_pkg(pmhandle_t *handle, pmpkg_t *pkg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void remove_prepare_cascade(pmtrans_t *trans, pmdb_t *db,
|
static void remove_prepare_cascade(pmhandle_t *handle, alpm_list_t *lp)
|
||||||
alpm_list_t *lp)
|
|
||||||
{
|
{
|
||||||
|
pmtrans_t *trans = handle->trans;
|
||||||
|
|
||||||
while(lp) {
|
while(lp) {
|
||||||
alpm_list_t *i;
|
alpm_list_t *i;
|
||||||
for(i = lp; i; i = i->next) {
|
for(i = lp; i; i = i->next) {
|
||||||
pmdepmissing_t *miss = (pmdepmissing_t *)i->data;
|
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(info) {
|
||||||
if(!_alpm_pkg_find(trans->remove, alpm_pkg_get_name(info))) {
|
if(!_alpm_pkg_find(trans->remove, alpm_pkg_get_name(info))) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "pulling %s in target list\n",
|
_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_inner(lp, (alpm_list_fn_free)_alpm_depmiss_free);
|
||||||
alpm_list_free(lp);
|
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,
|
static void remove_prepare_keep_needed(pmhandle_t *handle, alpm_list_t *lp)
|
||||||
alpm_list_t *lp)
|
|
||||||
{
|
{
|
||||||
|
pmtrans_t *trans = handle->trans;
|
||||||
|
|
||||||
/* Remove needed packages (which break dependencies) from target list */
|
/* Remove needed packages (which break dependencies) from target list */
|
||||||
while(lp != NULL) {
|
while(lp != NULL) {
|
||||||
alpm_list_t *i;
|
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_inner(lp, (alpm_list_fn_free)_alpm_depmiss_free);
|
||||||
alpm_list_free(lp);
|
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)) {
|
if((trans->flags & PM_TRANS_FLAG_RECURSE) && !(trans->flags & PM_TRANS_FLAG_CASCADE)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "finding removable dependencies\n");
|
_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)) {
|
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
|
||||||
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
|
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "looking for unsatisfied dependencies\n");
|
_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(lp != NULL) {
|
||||||
|
|
||||||
if(trans->flags & PM_TRANS_FLAG_CASCADE) {
|
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) {
|
} else if(trans->flags & PM_TRANS_FLAG_UNNEEDED) {
|
||||||
/* Remove needed packages (which would break dependencies)
|
/* Remove needed packages (which would break dependencies)
|
||||||
* from target list */
|
* from target list */
|
||||||
remove_prepare_keep_needed(trans, db, lp);
|
remove_prepare_keep_needed(handle, lp);
|
||||||
} else {
|
} else {
|
||||||
if(data) {
|
if(data) {
|
||||||
*data = lp;
|
*data = lp;
|
||||||
|
@ -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. */
|
building up a list of packages which could not be resolved. */
|
||||||
for(i = trans->add; i; i = i->next) {
|
for(i = trans->add; i; i = i->next) {
|
||||||
pmpkg_t *pkg = i->data;
|
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) {
|
&resolved, remove, data) == -1) {
|
||||||
unresolvable = alpm_list_add(unresolvable, pkg);
|
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)) {
|
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "checking dependencies\n");
|
_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) {
|
if(deps) {
|
||||||
pm_errno = PM_ERR_UNSATISFIED_DEPS;
|
pm_errno = PM_ERR_UNSATISFIED_DEPS;
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
@ -685,7 +685,7 @@ cleanup:
|
|||||||
|
|
||||||
static int process_targname(alpm_list_t *dblist, char *targname)
|
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 */
|
/* #FS23342 - skip ignored packages when user says no */
|
||||||
if(pm_errno == PM_ERR_PKG_IGNORED) {
|
if(pm_errno == PM_ERR_PKG_IGNORED) {
|
||||||
|
@ -98,7 +98,7 @@ static int checkdeps(alpm_list_t *pkglist)
|
|||||||
alpm_list_t *data, *i;
|
alpm_list_t *data, *i;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
/* check dependencies */
|
/* 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)) {
|
for(i = data; i; i = alpm_list_next(i)) {
|
||||||
pmdepmissing_t *miss = alpm_list_getdata(i);
|
pmdepmissing_t *miss = alpm_list_getdata(i);
|
||||||
pmdepend_t *dep = alpm_miss_get_dep(miss);
|
pmdepend_t *dep = alpm_miss_get_dep(miss);
|
||||||
|
Loading…
Reference in New Issue
Block a user