From 986409f9bd7b84e63352b9ec1f825b0c917627a6 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 22 Nov 2006 09:03:41 +0000 Subject: * Completed getinfo api changes (pmmissing_t, pmtrans_t, etc) * Modified some dependancy checking * Changed "performing local database upgrade" message to be more clear * Change 'usize' to 'isize' in database files * Scriptlet output is now sent to pacman's log file * Limited some debugging output to be more clear --- lib/libalpm/versioncmp.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'lib/libalpm/versioncmp.c') 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 #include #include +#include /* 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: */ -- cgit v1.2.3