index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Aaron Griffin <aaron@archlinux.org> | 2006-11-22 09:03:41 +0000 |
---|---|---|
committer | Aaron Griffin <aaron@archlinux.org> | 2006-11-22 09:03:41 +0000 |
commit | 986409f9bd7b84e63352b9ec1f825b0c917627a6 (patch) | |
tree | f74350bb415326724e86408985ea0d43fe93c7b0 /lib/libalpm/versioncmp.c | |
parent | 54691771831c97c7366bf8ee7c54da3952c22120 (diff) |
-rw-r--r-- | lib/libalpm/versioncmp.c | 43 |
diff --git a/lib/libalpm/versioncmp.c b/lib/libalpm/versioncmp.c index 652b7efb..2e406d9e 100644 --- a/lib/libalpm/versioncmp.c +++ b/lib/libalpm/versioncmp.c @@ -26,7 +26,12 @@ #include <stdio.h> #include <ctype.h> #include <string.h> +#include <libintl.h> /* pacman */ +#include "alpm.h" +#include "log.h" +#include "util.h" +#include "list.h" #include "versioncmp.h" #ifndef HAVE_STRVERSCMP @@ -238,4 +243,42 @@ int _alpm_versioncmp(const char *a, const char *b) return(*one ? 1 : -1); } +int _alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep) +{ + int equal = 0; + + if(strcmp(pkg->name, dep->name) == 0 || _alpm_list_is_strin(dep->name, pkg->provides)) { + if(dep->mod == PM_DEP_MOD_ANY) { + equal = 1; + } else { + int cmp = _alpm_versioncmp(pkg->version, 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; + } + } + + char *mod = "depends on"; + switch(dep->mod) { + case PM_DEP_MOD_EQ: mod = "=="; break; + case PM_DEP_MOD_GE: mod = ">="; break; + case PM_DEP_MOD_LE: mod = "<="; break; + } + + if(strlen(dep->version) > 0) { + _alpm_log(PM_LOG_DEBUG, _("depcmp: %s-%s %s %s-%s => %s"), + pkg->name, pkg->version, mod, dep->name, dep->version, + (equal ? "match" : "no match")); + } else { + _alpm_log(PM_LOG_DEBUG, _("depcmp: %s-%s %s %s => %s"), + pkg->name, pkg->version, mod, dep->name, + (equal ? "match" : "no match")); + } + } + + return equal; +} + + /* vim: set ts=2 sw=2 noet: */ |