- get rid of DEBINA_SEMANTICS, add pool->noarchid, add DISTTYPE_ARCH
authorMichael Schroeder <mls@suse.de>
Tue, 3 Apr 2012 08:53:26 +0000 (10:53 +0200)
committerMichael Schroeder <mls@suse.de>
Tue, 3 Apr 2012 08:53:26 +0000 (10:53 +0200)
CMakeLists.txt
src/evr.c
src/policy.c
src/pool.c
src/pool.h
src/poolarch.c
src/poolid.c
src/rules.c

index 02b1eec..0acd289 100644 (file)
@@ -68,7 +68,7 @@ ENDIF (FEDORA)
 
 IF (DEBIAN)
 MESSAGE (STATUS "Building for Debian")
-ADD_DEFINITIONS (-DDEBIAN -DDEBIAN_SEMANTICS)
+ADD_DEFINITIONS (-DDEBIAN)
 SET (ENABLE_DEBIAN ON)
 ENDIF (DEBIAN)
 
index cdd7bd8..a27ed09 100644 (file)
--- a/src/evr.c
+++ b/src/evr.c
 
 
 
-#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 */
index 3e8a6ed..7465565 100644 (file)
@@ -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;
index fc873d9..92238d5 100644 (file)
@@ -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
index 9d5b7f4..79d4183 100644 (file)
@@ -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)
index e41f7d1..4299445 100644 (file)
@@ -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 */
index b4a5173..1b19872 100644 (file)
@@ -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:
index 59a04a0..00d5c33 100644 (file)
@@ -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);