summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2007-12-10 14:58:44 +0000
committerMichael Schroeder <mls@suse.de>2007-12-10 14:58:44 +0000
commitc9b149fcab3c154479acbcb3d356a3d976211650 (patch)
tree76c15ae810f1834a931b92908196b40f23226ab4 /src
parentd531ff2799ea9cbd4fa2817988054cb0e8a66f18 (diff)
downloadlibsolv-c9b149fcab3c154479acbcb3d356a3d976211650.tar.gz
libsolv-c9b149fcab3c154479acbcb3d356a3d976211650.tar.bz2
libsolv-c9b149fcab3c154479acbcb3d356a3d976211650.zip
- add evrcmp mode parameter
Diffstat (limited to 'src')
-rw-r--r--src/evr.c26
-rw-r--r--src/evr.h8
-rw-r--r--src/policy.c4
-rw-r--r--src/pool.c2
-rw-r--r--src/solver.c2
5 files changed, 27 insertions, 15 deletions
diff --git a/src/evr.c b/src/evr.c
index 07701b3..857b92e 100644
--- a/src/evr.c
+++ b/src/evr.c
@@ -73,10 +73,13 @@ vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
return s1 < q1 ? 1 : s2 < q2 ? -1 : 0;
}
+#define EVRCMP_COMPARE 0
+#define EVRCMP_MATCH_RELEASE 1
+#define EVRCMP_MATCH 2
// edition (e:v-r) compare
int
-evrcmp(Pool *pool, Id evr1id, Id evr2id)
+evrcmp(Pool *pool, Id evr1id, Id evr2id, int mode)
{
int r;
const char *evr1, *evr2;
@@ -89,7 +92,7 @@ evrcmp(Pool *pool, Id evr1id, Id evr2id)
evr2 = id2str(pool, evr2id);
#if 0
- POOL_DEBUG(DEBUG_EVRCMP, "evrcmp %s %s\n", evr1, evr2);
+ POOL_DEBUG(DEBUG_EVRCMP, "evrcmp %s %s mode=%d\n", evr1, evr2, mode);
#endif
for (s1 = evr1; *s1 >= '0' && *s1 <= '9'; s1++)
;
@@ -132,15 +135,20 @@ evrcmp(Pool *pool, Id evr1id, Id evr2id)
for (s2 = evr2, r2 = 0; *s2; s2++)
if (*s2 == '-')
r2 = s2;
- r = vercmp(evr1, r1 ? r1 : s1, evr2, r2 ? r2 : s2);
+
+ r = 0;
+ if (mode != EVRCMP_MATCH || (evr1 != (r1 ? r1 : s1) && evr2 != (r2 ? r2 : s2)))
+ r = vercmp(evr1, r1 ? r1 : s1, evr2, r2 ? r2 : s2);
if (r)
return r;
-#ifdef DEBIAN_SEMANTICS
- if (!r1 && r2)
- return -1;
- if (r1 && !r2)
- return 1;
-#endif
+
+ if (mode == EVRCMP_COMPARE)
+ {
+ if (!r1 && r2)
+ return -1;
+ if (r1 && !r2)
+ return 1;
+ }
if (r1 && r2)
{
if (s1 != ++r1 && s2 != ++r2)
diff --git a/src/evr.h b/src/evr.h
index 5fe0c9d..7606608 100644
--- a/src/evr.h
+++ b/src/evr.h
@@ -19,8 +19,12 @@ extern "C" {
#include "pooltypes.h"
-extern int vercmp( const char *s1, const char *q1, const char *s2, const char *q2 );
-extern int evrcmp( Pool *pool, Id evr1id, Id evr2id );
+#define EVRCMP_COMPARE 0
+#define EVRCMP_MATCH_RELEASE 1
+#define EVRCMP_MATCH 2
+
+extern int vercmp(const char *s1, const char *q1, const char *s2, const char *q2);
+extern int evrcmp(Pool *pool, Id evr1id, Id evr2id, int mode);
#ifdef __cplusplus
}
diff --git a/src/policy.c b/src/policy.c
index 71e2b38..4c632e5 100644
--- a/src/policy.c
+++ b/src/policy.c
@@ -282,7 +282,7 @@ prune_to_best_version(Pool *pool, Queue *plist)
if (pool->solvables[best].evr != s->evr) /* compare evr */
{
- if (evrcmp(pool, pool->solvables[best].evr, s->evr) < 0)
+ if (evrcmp(pool, pool->solvables[best].evr, s->evr, EVRCMP_MATCH_RELEASE) < 0)
best = plist->elements[i];
}
}
@@ -386,7 +386,7 @@ policy_findupdatepackages(Solver *solv, Solvable *s, Queue *qs, int allowall)
{
if (!allowall)
{
- if (!solv->allowdowngrade && evrcmp(pool, s->evr, ps->evr) > 0)
+ if (!solv->allowdowngrade && evrcmp(pool, s->evr, ps->evr, EVRCMP_MATCH_RELEASE) > 0)
continue;
if (!solv->allowarchchange && s->arch != ps->arch && policy_illegal_archchange(pool, s, ps))
continue;
diff --git a/src/pool.c b/src/pool.c
index 9394cd7..6e05c64 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -558,7 +558,7 @@ pool_addrelproviders(Pool *pool, Id d)
else
{
int f = flags == 5 ? 5 : flags == 2 ? pflags : (flags ^ 5) & (pflags | 5);
- if ((f & (1 << (1 + evrcmp(pool, pevr, evr)))) != 0)
+ if ((f & (1 << (1 + evrcmp(pool, pevr, evr, EVRCMP_MATCH_RELEASE)))) != 0)
break;
}
}
diff --git a/src/solver.c b/src/solver.c
index 4b3d8ad..3b919f6 100644
--- a/src/solver.c
+++ b/src/solver.c
@@ -3155,7 +3155,7 @@ printsolutions(Solver *solv, Queue *job)
if (sd)
{
int gotone = 0;
- if (!solv->allowdowngrade && evrcmp(pool, s->evr, sd->evr) > 0)
+ if (!solv->allowdowngrade && evrcmp(pool, s->evr, sd->evr, EVRCMP_MATCH_RELEASE) > 0)
{
POOL_DEBUG(SAT_DEBUG_RESULT, "- allow downgrade of %s to %s\n", solvable2str(pool, s), solvable2str(pool, sd));
gotone = 1;