Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/versioncmp.c
diff options
context:
space:
mode:
authorAaron Griffin <aaron@archlinux.org>2006-11-22 09:03:41 +0000
committerAaron Griffin <aaron@archlinux.org>2006-11-22 09:03:41 +0000
commit986409f9bd7b84e63352b9ec1f825b0c917627a6 (patch)
treef74350bb415326724e86408985ea0d43fe93c7b0 /lib/libalpm/versioncmp.c
parent54691771831c97c7366bf8ee7c54da3952c22120 (diff)
* 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
Diffstat (limited to 'lib/libalpm/versioncmp.c')
-rw-r--r--lib/libalpm/versioncmp.c43
1 files changed, 43 insertions, 0 deletions
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: */