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:
authorDan McGee <dan@archlinux.org>2007-07-12 15:20:43 -0400
committerDan McGee <dan@archlinux.org>2007-07-12 15:20:43 -0400
commit20f73d6299c08fa79c2c8edd3d1955e208e701cb (patch)
tree470b4e84b81009aaaf318c04cee3fa1dcb1e2b53 /lib/libalpm/deps.c
parent653fb8fe036363dfb550785c45adcf26f6fcbfbc (diff)
Remove versioncmp.{c,h}, clean up selective #ifdefs
Remove versioncmp.c by moving all functions to locations that make sense. Move replacement functions (for building without glibc) into util.c where they belong, and do proper checks for them instead of using __sun__, etc. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/deps.c')
-rw-r--r--lib/libalpm/deps.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 591e5a87..003f26d4 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -40,7 +40,6 @@
#include "db.h"
#include "cache.h"
#include "provide.h"
-#include "versioncmp.h"
#include "handle.h"
extern pmhandle_t *handle;
@@ -433,6 +432,48 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op,
return(baddeps);
}
+int SYMEXPORT alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep)
+{
+ int equal = 0;
+
+ ALPM_LOG_FUNC;
+
+ if(strcmp(pkg->name, dep->name) == 0
+ || alpm_list_find_str(alpm_pkg_get_provides(pkg), dep->name)) {
+ if(dep->mod == PM_DEP_MOD_ANY) {
+ equal = 1;
+ } else {
+ int cmp = _alpm_versioncmp(alpm_pkg_get_version(pkg), dep->version);
+ switch(dep->mod) {
+ case PM_DEP_MOD_EQ: equal = (cmp == 0); break;
+ case PM_DEP_MOD_GE: equal = (cmp >= 0); break;
+ case PM_DEP_MOD_LE: equal = (cmp <= 0); break;
+ default: equal = 1; break;
+ }
+ }
+
+ char *mod = "~=";
+ switch(dep->mod) {
+ case PM_DEP_MOD_EQ: mod = "=="; break;
+ case PM_DEP_MOD_GE: mod = ">="; break;
+ case PM_DEP_MOD_LE: mod = "<="; break;
+ default: break;
+ }
+
+ if(strlen(dep->version) > 0) {
+ _alpm_log(PM_LOG_DEBUG, "depcmp: %s-%s %s %s-%s => %s",
+ alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg),
+ mod, dep->name, dep->version, (equal ? "match" : "no match"));
+ } else {
+ _alpm_log(PM_LOG_DEBUG, "depcmp: %s-%s %s %s => %s",
+ alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg),
+ mod, dep->name, (equal ? "match" : "no match"));
+ }
+ }
+
+ return equal;
+}
+
pmdepend_t SYMEXPORT *alpm_splitdep(const char *depstring)
{
pmdepend_t *depend;