summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2012-04-03 10:53:26 +0200
committerMichael Schroeder <mls@suse.de>2012-04-03 10:53:26 +0200
commit17ea16d7e5d7842b593855a4bb7acf349f0d2e03 (patch)
tree157cd93f972d603aaafa52525672412f704f453e /src
parentd1275e7fcce9d4fc23f418d3b841d8940d2cc163 (diff)
downloadlibsolv-17ea16d7e5d7842b593855a4bb7acf349f0d2e03.tar.gz
libsolv-17ea16d7e5d7842b593855a4bb7acf349f0d2e03.tar.bz2
libsolv-17ea16d7e5d7842b593855a4bb7acf349f0d2e03.zip
- get rid of DEBINA_SEMANTICS, add pool->noarchid, add DISTTYPE_ARCH
Diffstat (limited to 'src')
-rw-r--r--src/evr.c36
-rw-r--r--src/policy.c7
-rw-r--r--src/pool.c26
-rw-r--r--src/pool.h3
-rw-r--r--src/poolarch.c6
-rw-r--r--src/poolid.c23
-rw-r--r--src/rules.c17
7 files changed, 68 insertions, 50 deletions
diff --git a/src/evr.c b/src/evr.c
index cdd7bd8..a27ed09 100644
--- a/src/evr.c
+++ b/src/evr.c
@@ -18,15 +18,11 @@
-#if defined(DEBIAN_SEMANTICS) || defined(MULTI_SEMANTICS)
-
-#ifdef MULTI_SEMANTICS
-# define solv_vercmp solv_vercmp_deb
-#endif
+#if defined(DEBIAN) || defined(MULTI_SEMANTICS)
/* debian type version compare */
int
-solv_vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
+solv_vercmp_deb(const char *s1, const char *q1, const char *s2, const char *q2)
{
int r, c1, c2;
while (1)
@@ -64,19 +60,15 @@ solv_vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
}
}
-#ifdef MULTI_SEMANTICS
-# undef solv_vercmp
#endif
-#endif
-
-#if !defined(DEBIAN_SEMANTICS) || defined(MULTI_SEMANTICS)
+#if !defined(DEBIAN) || defined(MULTI_SEMANTICS)
/* rpm type version compare */
/* note: the code assumes that *q1 and *q2 are not alphanumeric! */
int
-solv_vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
+solv_vercmp_rpm(const char *s1, const char *q1, const char *s2, const char *q2)
{
int r = 0;
const char *e1, *e2;
@@ -134,8 +126,26 @@ solv_vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
#endif
+
+/*
+ * the solv_vercmp variant your system uses.
+ */
+int
+solv_vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
+{
+#ifdef DEBIAN
+ return solv_vercmp_deb(s1, q1, s2, q2);
+#else
+ return solv_vercmp_rpm(s1, q1, s2, q2);
+#endif
+}
+
#if defined(MULTI_SEMANTICS)
-# define solv_vercmp (*(pool->disttype == DISTTYPE_DEB ? &solv_vercmp_deb : &solv_ver##cmp))
+# define solv_vercmp (*(pool->disttype == DISTTYPE_DEB ? &solv_vercmp_deb : &solv_ver##cmp_rpm))
+#elif defined(DEBIAN)
+# define solv_vercmp solv_vercmp_deb
+#else
+# define solv_vercmp solv_vercmp_rpm
#endif
/* edition (e:v-r) compare */
diff --git a/src/policy.c b/src/policy.c
index 3e8a6ed..7465565 100644
--- a/src/policy.c
+++ b/src/policy.c
@@ -681,13 +681,8 @@ policy_illegal_archchange(Solver *solv, Solvable *s1, Solvable *s2)
}
/* we allow changes to/from noarch */
-#ifndef DEBIAN_SEMANTICS
- if (a1 == a2 || a1 == ARCH_NOARCH || a2 == ARCH_NOARCH)
+ if (a1 == a2 || a1 == pool->noarchid || a2 == pool->noarchid)
return 0;
-#else
- if (a1 == a2 || a1 == ARCH_ALL || a2 == ARCH_ALL)
- return 0;
-#endif
if (!pool->id2arch)
return 0;
a1 = a1 <= pool->lastarch ? pool->id2arch[a1] : 0;
diff --git a/src/pool.c b/src/pool.c
index fc873d9..92238d5 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -54,21 +54,26 @@ pool_create(void)
pool->nsolvables = 2;
memset(pool->solvables, 0, 2 * sizeof(Solvable));
+ queue_init(&pool->vendormap);
+
+#ifdef DEBIAN
+ pool->disttype = DISTTYPE_DEB;
+ pool->noarchid = ARCH_ALL;
+#else
+ pool->disttype = DISTTYPE_RPM;
+ pool->noarchid = ARCH_NOARCH;
+#endif
+
/* initialize the system solvable */
s = pool->solvables + SYSTEMSOLVABLE;
s->name = SYSTEM_SYSTEM;
- s->arch = ARCH_NOARCH;
+ s->arch = pool->noarchid;
s->evr = ID_EMPTY;
- queue_init(&pool->vendormap);
-
pool->debugmask = SOLV_DEBUG_RESULT; /* FIXME */
#ifdef FEDORA
pool->obsoleteusescolors = 1;
#endif
-#ifdef DEBIAN
- pool->disttype = DISTTYPE_DEB;
-#endif
#ifdef RPM5
pool->forbidselfconflicts = 1;
pool->obsoleteusesprovides = 1;
@@ -125,6 +130,13 @@ void
pool_setdisttype(Pool *pool, int disttype)
{
pool->disttype = disttype;
+ if (disttype == DISTTYPE_RPM)
+ pool->noarchid == ARCH_NOARCH;
+ if (disttype == DISTTYPE_DEB)
+ pool->noarchid == ARCH_ALL;
+ if (disttype == DISTTYPE_ARCH)
+ pool->noarchid == ARCH_ANY;
+ pool->solvables[SYSTEMSOLVABLE].arch = pool->noarchid;
}
#endif
@@ -511,7 +523,7 @@ pool_queuetowhatprovides(Pool *pool, Queue *q)
#if defined(MULTI_SEMANTICS)
# define EVRCMP_DEPCMP (pool->disttype == DISTTYPE_DEB ? EVRCMP_COMPARE : EVRCMP_MATCH_RELEASE)
-#elif defined(DEBIAN_SEMANTICS)
+#elif defined(DEBIAN)
# define EVRCMP_DEPCMP EVRCMP_COMPARE
#else
# define EVRCMP_DEPCMP EVRCMP_MATCH_RELEASE
diff --git a/src/pool.h b/src/pool.h
index 9d5b7f4..79d4183 100644
--- a/src/pool.h
+++ b/src/pool.h
@@ -129,6 +129,8 @@ struct _Pool {
int noinstalledobsoletes; /* true: ignore obsoletes of installed packages */
int forbidselfconflicts; /* true: packages which conflict with itself are not installable */
+ Id noarchid; /* ARCH_NOARCH, ARCH_ALL, ARCH_ANY, ... */
+
/* hash for rel unification */
Hashtable relhashtbl; /* hashtable: (name,evr,op)Hash -> Id */
Hashmask relhashmask;
@@ -144,6 +146,7 @@ struct _Pool {
#define DISTTYPE_RPM 0
#define DISTTYPE_DEB 1
+#define DISTTYPE_ARCH 2
#define SOLV_FATAL (1<<0)
#define SOLV_ERROR (1<<1)
diff --git a/src/poolarch.c b/src/poolarch.c
index e41f7d1..4299445 100644
--- a/src/poolarch.c
+++ b/src/poolarch.c
@@ -99,11 +99,7 @@ pool_setarchpolicy(Pool *pool, const char *arch)
pool->lastarch = 0;
return;
}
-#ifndef DEBIAN_SEMANTICS
- id = ARCH_NOARCH;
-#else
- id = ARCH_ALL;
-#endif
+ id = pool->noarchid;
lastarch = id + 255;
id2arch = solv_calloc(lastarch + 1, sizeof(Id));
id2arch[id] = 1; /* the "noarch" class */
diff --git a/src/poolid.c b/src/poolid.c
index b4a5173..1b19872 100644
--- a/src/poolid.c
+++ b/src/poolid.c
@@ -135,18 +135,10 @@ pool_id2str(const Pool *pool, Id id)
static const char *rels[] = {
" ! ",
-#ifndef DEBIAN_SEMANTICS
" > ",
-#else
- " >> ",
-#endif
" = ",
" >= ",
-#ifndef DEBIAN_SEMANTICS
" < ",
-#else
- " << ",
-#endif
" <> ",
" <= ",
" <=> "
@@ -163,9 +155,18 @@ pool_id2rel(const Pool *pool, Id id)
rd = GETRELDEP(pool, id);
switch (rd->flags)
{
- case 0: case 1: case 2: case 3:
- case 4: case 5: case 6: case 7:
- return rels[rd->flags & 7];
+ case 0: case 2: case 3:
+ case 5: case 6: case 7:
+ return rels[rd->flags];
+#if !defined(DEBIAN) && !defined(MULTI_SEMANTICS)
+ case 1: case 4:
+ return rels[rd->flags];
+#else
+ case 1:
+ return pool->disttype == DISTTYPE_DEB ? " >> " : rels[rd->flags];
+ case 4:
+ return pool->disttype == DISTTYPE_DEB ? " << " : rels[rd->flags];
+#endif
case REL_AND:
return " & ";
case REL_OR:
diff --git a/src/rules.c b/src/rules.c
index 59a04a0..00d5c33 100644
--- a/src/rules.c
+++ b/src/rules.c
@@ -1464,15 +1464,16 @@ jobtodisablelist(Solver *solv, Id how, Id what, Queue *q)
Reldep *rd = GETRELDEP(pool, what);
if (rd->flags == REL_EQ && select == SOLVER_SOLVABLE_NAME)
{
-#if !defined(DEBIAN_SEMANTICS)
- const char *evr = pool_id2str(pool, rd->evr);
- if (strchr(evr, '-'))
- set |= SOLVER_SETEVR;
+ if (pool->disttype != DISTTYPE_DEB)
+ {
+ const char *evr = pool_id2str(pool, rd->evr);
+ if (strchr(evr, '-'))
+ set |= SOLVER_SETEVR;
+ else
+ set |= SOLVER_SETEV;
+ }
else
- set |= SOLVER_SETEV;
-#else
- set |= SOLVER_SETEVR;
-#endif
+ set |= SOLVER_SETEVR;
}
if (rd->flags <= 7 && ISRELDEP(rd->name))
rd = GETRELDEP(pool, rd->name);