Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/deps.c
diff options
context:
space:
mode:
authorXavier Chantry <chantry.xavier@gmail.com>2010-10-17 00:52:13 +0200
committerXavier Chantry <chantry.xavier@gmail.com>2011-01-29 19:33:15 +0100
commitb8590ed634babc060b35e2ad7a035347234d836a (patch)
treee7afdb7b971a836f62a08be01cae8d6959e216d3 /lib/libalpm/deps.c
parent4097c98c1ee65d6b3a659d042c6c84e0632673bf (diff)
alpm/dep: add alpm_find_dbs_satisfier
This is a public interface for resolvedep. It looks nicer to expose it this way rather than through sync_target. This function can also be helpful for external tools as it should give good results close to how pacman select a package for satisfying a given dep. Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
Diffstat (limited to 'lib/libalpm/deps.c')
-rw-r--r--lib/libalpm/deps.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 28a51bcf..609200f3 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -494,6 +494,28 @@ void _alpm_recursedeps(pmdb_t *db, alpm_list_t *targs, int include_explicit)
}
}
+/** Find a package satisfying a specified dependency.
+ * 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 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)
+{
+ pmdepend_t *dep;
+ pmpkg_t *pkg;
+
+ ASSERT(dbs, return(NULL));
+
+ dep = _alpm_splitdep(depstring);
+ ASSERT(dep, return(NULL));
+ pkg = _alpm_resolvedep(dep, dbs, NULL, 1);
+ _alpm_dep_free(dep);
+ return(pkg);
+}
+
/**
* helper function for resolvedeps: search for dep satisfier in dbs
*