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:
authorFlorian Pritz <bluewind@xinu.at>2014-08-06 11:36:51 +0200
committerAllan McRae <allan@archlinux.org>2014-09-30 22:07:11 +1000
commit13c9745302b11dcee7b1b894d95789a2caf11c9d (patch)
tree58ccf0d58fab2305ddab502802accb3021141494 /lib/libalpm/deps.c
parentb275e5184ef1acc3f8dd4a02131149a9b58a5828 (diff)
deps.c: split _alpm_depcmp into _alpm_depcmp_provides
This allows to reuse the provision checker for a simple list of provisions without a package. Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib/libalpm/deps.c')
-rw-r--r--lib/libalpm/deps.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index c5acfc95..7daa28d3 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -416,17 +416,18 @@ int _alpm_depcmp_literal(alpm_pkg_t *pkg, alpm_depend_t *dep)
return dep_vercmp(pkg->version, dep->mod, dep->version);
}
-int _alpm_depcmp(alpm_pkg_t *pkg, alpm_depend_t *dep)
+/**
+ * @param dep dependency to check agains the provision list
+ * @param provisions provision list
+ * @return 1 if provider is found, 0 otherwise
+ */
+int _alpm_depcmp_provides(alpm_depend_t *dep, alpm_list_t *provisions)
{
+ int satisfy = 0;
alpm_list_t *i;
- int satisfy = _alpm_depcmp_literal(pkg, dep);
-
- if(satisfy) {
- return satisfy;
- }
/* check provisions, name and version if available */
- for(i = alpm_pkg_get_provides(pkg); i && !satisfy; i = i->next) {
+ for(i = provisions; i && !satisfy; i = i->next) {
alpm_depend_t *provision = i->data;
if(dep->mod == ALPM_DEP_MOD_ANY) {
@@ -444,6 +445,12 @@ int _alpm_depcmp(alpm_pkg_t *pkg, alpm_depend_t *dep)
return satisfy;
}
+int _alpm_depcmp(alpm_pkg_t *pkg, alpm_depend_t *dep)
+{
+ return _alpm_depcmp_literal(pkg, dep)
+ || _alpm_depcmp_provides(dep, alpm_pkg_get_provides(pkg));
+}
+
alpm_depend_t *_alpm_splitdep(const char *depstring)
{
alpm_depend_t *depend;