summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/alpm.h1
-rw-r--r--lib/libalpm/deps.c38
2 files changed, 36 insertions, 3 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 95482f07..6724bf78 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -383,6 +383,7 @@ typedef enum _pmtransconv_t {
PM_TRANS_CONV_CORRUPTED_PKG = (1 << 3),
PM_TRANS_CONV_LOCAL_NEWER = (1 << 4),
PM_TRANS_CONV_REMOVE_PKGS = (1 << 5),
+ PM_TRANS_CONV_SELECT_PROVIDER = (1 << 6),
} pmtransconv_t;
/* Transaction Progress */
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index a7203b4b..28a51bcf 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -511,6 +511,10 @@ pmpkg_t *_alpm_resolvedep(pmdepend_t *dep, alpm_list_t *dbs,
{
alpm_list_t *i, *j;
int ignored = 0;
+
+ alpm_list_t *providers = NULL;
+ int count;
+
/* 1. literals */
for(i = dbs; i; i = i->next) {
pmpkg_t *pkg = _alpm_db_get_pkgfromcache(i->data, dep->name);
@@ -550,12 +554,40 @@ pmpkg_t *_alpm_resolvedep(pmdepend_t *dep, alpm_list_t *dbs,
continue;
}
}
- _alpm_log(PM_LOG_WARNING, _("provider package was selected (%s provides %s)\n"),
- pkg->name, dep->name);
- return(pkg);
+ _alpm_log(PM_LOG_DEBUG, "provider found (%s provides %s)\n",
+ pkg->name, dep->name);
+ providers = alpm_list_add(providers, pkg);
+ /* keep looking for other providers in the all dbs */
}
}
}
+
+ /* first check if one provider is already installed locally */
+ for(i = providers; i; i = i->next) {
+ pmpkg_t *pkg = i->data;
+ if (_alpm_pkg_find(_alpm_db_get_pkgcache(handle->db_local), pkg->name)) {
+ alpm_list_free(providers);
+ return(pkg);
+ }
+ }
+ count = alpm_list_count(providers);
+ if (count >= 1) {
+ /* default to first provider if there is no QUESTION callback */
+ int index = 0;
+ if(count > 1) {
+ /* if there is more than one provider, we ask the user */
+ QUESTION(handle->trans, PM_TRANS_CONV_SELECT_PROVIDER,
+ providers, dep, NULL, &index);
+ }
+ if(index >= 0 && index < count) {
+ pmpkg_t *pkg = alpm_list_getdata(alpm_list_nth(providers, index));
+ alpm_list_free(providers);
+ return(pkg);
+ }
+ alpm_list_free(providers);
+ providers = NULL;
+ }
+
if(ignored) { /* resolvedeps will override these */
pm_errno = PM_ERR_PKG_IGNORED;
} else {