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;
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++)
;
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)
#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
}
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];
}
}
{
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;
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;
}
}
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;
pd->version = 0;
pd->release = 0;
/* use highest evr */
- if (!s->evr || evrcmp(pool, s->evr, evr) <= 0)
+ if (!s->evr || evrcmp(pool, s->evr, evr, EVRCMP_MATCH_RELEASE) <= 0)
s->evr = evr;
break;
case STATE_EPOCH: