]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
add DISTTYPE_HAIKU, some small fixes
authorMichael Schroeder <mls@suse.de>
Tue, 16 Apr 2013 09:59:27 +0000 (11:59 +0200)
committerMichael Schroeder <mls@suse.de>
Tue, 16 Apr 2013 10:01:33 +0000 (12:01 +0200)
- ARCH_NOARCH -> ARCH_ANY
- use - as prerelease separator
- correct usage of solv_vercmp
- stringify REL_COMPAT, use != instead of <>

CREDITS
ext/repo_haiku.cpp
src/evr.c
src/libsolv.ver
src/pool.c
src/pool.h
src/poolid.c

diff --git a/CREDITS b/CREDITS
index 21bad106ff01377639563a423b48c64e0f6971e8..049bcaea36607b865e4f310743db15946f1c58c2 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -20,3 +20,6 @@ Michael Schroeder
   - mandriva/mageia support
   - archlinux support
 
+Ingo Weinhold
+  - haiku support
+
index 139bf501c7b6fce02bffd728e0d59c739d8bf44f..e5b448f3c6705f7cda6c0cb28485dae04565de78 100644 (file)
@@ -32,10 +32,9 @@ static BString haiku_version_to_string(const BPackageVersion &version)
         string << '.' << version.Micro();
     }
 
-  // append pre-release -- separate it with '/' to keep pool_evrcmp_str() happy
-  // (it expects only the release to be separated by '-')
+  // append pre-release
   if (!version.PreRelease().IsEmpty())
-    string << '/' << version.PreRelease();
+    string << '-' << version.PreRelease();
 
   // append revision
   if (version.Revision() != 0)
@@ -59,7 +58,6 @@ static void add_dependency(Repo *repo, Offset &dependencies, const char *name,
       {
         versionId = pool_rel2id(pool, pool_str2id(pool, compatVersion, 1),
           versionId, REL_COMPAT, 1);
-        versionId = MAKERELDEP(versionId);
       }
 
     dependency = pool_rel2id(pool, dependency, versionId, flags, 1);
@@ -152,7 +150,7 @@ static Id add_package_info_to_repo(Repo *repo, Repodata *repoData,
   name << packageInfo.Name();
   solvable->name = pool_str2id(pool, name, 1);
   if (packageInfo.Architecture() == B_PACKAGE_ARCHITECTURE_ANY)
-    solvable->arch = ARCH_NOARCH;
+    solvable->arch = ARCH_ANY;
   else
     solvable->arch = pool_str2id(pool,
       BPackageInfo::kArchitectureNames[packageInfo.Architecture()], 1);
index d24b8392d772c63bfa9a39ee271094e57d7cf3f7..30dacfb642410b7b739ac184a2502680d4b4bf26 100644 (file)
--- a/src/evr.c
+++ b/src/evr.c
@@ -198,7 +198,7 @@ solv_vercmp_rpm_notilde(const char *s1, const char *q1, const char *s2, const ch
 
 #endif
 
-#if defined(HAIKU)
+#if defined(HAIKU) || defined(MULTI_SEMANTICS)
 
 static int
 solv_cmp_version_part_haiku(const char *s1, const char *q1, const char *s2,
@@ -268,9 +268,9 @@ solv_vercmp_haiku(const char *s1, const char *q1, const char *s2, const char *q2
   int cmp;
 
   /* find pre-release separator */
-  while (pre1 != q1 && *pre1 != '/')
+  while (pre1 != q1 && *pre1 != '-')
     pre1++;
-  while (pre2 != q2 && *pre2 != '/')
+  while (pre2 != q2 && *pre2 != '-')
     pre2++;
 
   /* compare main versions */
@@ -285,8 +285,6 @@ solv_vercmp_haiku(const char *s1, const char *q1, const char *s2, const char *q2
     return -1;
 
   return solv_cmp_version_part_haiku(pre1 + 1, q1, pre2 + 1, q2);
-  cmp = solv_cmp_version_part_haiku(pre1 + 1, q1, pre2 + 1, q2);
-  return cmp == 0 ? 0 : cmp < 0 ? -1 : 1; /* must return -1, 0, or 1 */
 }
 
 #endif /* HAIKU */
@@ -310,11 +308,15 @@ solv_vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
 }
 
 #if defined(MULTI_SEMANTICS)
-# define solv_vercmp (*(pool->disttype == DISTTYPE_DEB ? &solv_vercmp_deb : &solv_ver##cmp_rpm))
+# define solv_vercmp (*(pool->disttype == DISTTYPE_DEB ? &solv_vercmp_deb : \
+                        pool->disttype == DISTTYPE_HAIKU ? solv_vercmp_haiku : \
+                        &solv_ver##cmp_rpm))
 #elif defined(DEBIAN)
 # define solv_vercmp solv_vercmp_deb
 #elif defined(ARCHLINUX)
 # define solv_vercmp solv_vercmp_rpm_notilde
+#elif defined(HAIKU)
+# define solv_vercmp solv_vercmp_haiku
 #else
 # define solv_vercmp solv_vercmp_rpm
 #endif
index 3a7bda3d1783d754eca2ddbe78ea0f5486831a3e..a0115dfca8fd4ca600893f5a099955de94f0da28 100644 (file)
@@ -259,6 +259,7 @@ SOLV_1.0 {
                solv_timems;
                solv_vercmp;
                solv_vercmp_deb;
+               solv_vercmp_haiku;
                solv_vercmp_rpm;
                solv_vercmp_rpm_notilde;
                solv_version;
index f5dfc408a0989d92199f1548ee404c814cfc8b08..9eddb2b120bb5d070566a98d54e5e4ad5392b5ce 100644 (file)
@@ -62,6 +62,10 @@ pool_create(void)
 #elif defined(ARCHLINUX)
   pool->disttype = DISTTYPE_ARCH;
   pool->noarchid = ARCH_ANY;
+#elif defined(HAIKU)
+  pool->disttype = DISTTYPE_HAIKU;
+  pool->noarchid = ARCH_ANY;
+  pool->obsoleteusesprovides = 1;
 #else
   pool->disttype = DISTTYPE_RPM;
   pool->noarchid = ARCH_NOARCH;
@@ -142,6 +146,8 @@ pool_setdisttype(Pool *pool, int disttype)
     pool->noarchid = ARCH_ALL;
   if (disttype == DISTTYPE_ARCH)
     pool->noarchid = ARCH_ANY;
+  if (disttype == DISTTYPE_HAIKU)
+    pool->noarchid = ARCH_ANY;
   pool->solvables[SYSTEMSOLVABLE].arch = pool->noarchid;
 }
 #endif
@@ -599,6 +605,11 @@ pool_match_nevr_rel(Pool *pool, Solvable *s, Id d)
   return 0;
 }
 
+#if defined(HAIKU) || defined(MULTI_SEMANTICS)
+/* forward declaration */
+static int pool_match_flags_evr_rel_compat(Pool *pool, Reldep *range, int flags, int evr);
+#endif
+
 /* match (flags, evr) against provider (pflags, pevr) */
 static inline int
 pool_match_flags_evr(Pool *pool, int pflags, Id pevr, int flags, int evr)
@@ -611,19 +622,14 @@ pool_match_flags_evr(Pool *pool, int pflags, Id pevr, int flags, int evr)
     return 1;          /* both rels show in the same direction */
   if (pevr == evr)
     return (flags & pflags & REL_EQ) ? 1 : 0;
+#if defined(HAIKU) || defined(MULTI_SEMANTICS)
   if (ISRELDEP(pevr))
     {
-      Reldep *range = GETRELDEP(pool, pevr);
-      if (range->flags != REL_COMPAT)
-        return 0;      /* unsupported */
-      /* range->name is the backwards compatibility version, range->evr the
-         actual version. If flags are '>=' or '>', we match the compatibility
-         version as well, otherwise only the actual version. */
-      if (!(flags & REL_GT) || (flags & REL_LT))
-        return pool_match_flags_evr(pool, REL_EQ, range->evr, flags, evr);
-      return pool_match_flags_evr(pool, REL_LT | REL_EQ, range->evr, flags, evr) && 
-        pool_match_flags_evr(pool, REL_GT | REL_EQ, range->name, REL_EQ, evr);
+      Reldep *rd = GETRELDEP(pool, pevr);
+      if (rd->flags == REL_COMPAT)
+       return pool_match_flags_evr_rel_compat(pool, rd, flags, evr);
     }
+#endif
   switch (pool_evrcmp(pool, pevr, evr, EVRCMP_DEPCMP))
     {
     case -2:
@@ -642,6 +648,20 @@ pool_match_flags_evr(Pool *pool, int pflags, Id pevr, int flags, int evr)
   return 0;
 }
 
+#if defined(HAIKU) || defined(MULTI_SEMANTICS)
+static int
+pool_match_flags_evr_rel_compat(Pool *pool, Reldep *range, int flags, int evr)
+{
+  /* range->name is the backwards compatibility version, range->evr the
+     actual version. If flags are '>=' or '>', we match the compatibility
+     version as well, otherwise only the actual version. */
+  if (!(flags & REL_GT) || (flags & REL_LT))
+    return pool_match_flags_evr(pool, REL_EQ, range->evr, flags, evr);
+  return pool_match_flags_evr(pool, REL_LT | REL_EQ, range->evr, flags, evr) &&
+         pool_match_flags_evr(pool, REL_GT | REL_EQ, range->name, REL_EQ, evr);
+}
+#endif
+
 /* match two dependencies (d1 = provider) */
 
 int
index b40c88d5b18c098524b97df480faa1495ca9269c..6545b499a98bbcd40572858b833f28d62e19c833 100644 (file)
@@ -155,6 +155,7 @@ struct _Pool {
 #define DISTTYPE_RPM   0
 #define DISTTYPE_DEB   1
 #define DISTTYPE_ARCH   2
+#define DISTTYPE_HAIKU  3
 
 #define SOLV_FATAL                     (1<<0)
 #define SOLV_ERROR                     (1<<1)
index 6dc2c1b8a082ed98e426a8dbf1a02e63e631e7cc..bd24e35400ff3c07661fce6052b46a30ce4606ec 100644 (file)
@@ -154,16 +154,23 @@ pool_id2rel(const Pool *pool, Id id)
   switch (rd->flags)
     {
     case 0: case 2: case 3:
-    case 5: case 6: case 7:
-      return rels[rd->flags];
+    case 6: case 7:
 #if !defined(DEBIAN) && !defined(MULTI_SEMANTICS)
     case 1: case 4:
+#endif
+#if !defined(HAIKU) && !defined(MULTI_SEMANTICS)
+    case 5:
+#endif
       return rels[rd->flags];
-#else
+#if defined(DEBIAN) || defined(MULTI_SEMANTICS)
     case 1:
       return pool->disttype == DISTTYPE_DEB ? " >> " : rels[rd->flags];
     case 4:
       return pool->disttype == DISTTYPE_DEB ? " << " : rels[rd->flags];
+#endif
+#if defined(HAIKU) || defined(MULTI_SEMANTICS)
+    case 5:
+      return pool->disttype == DISTTYPE_HAIKU ? " != " : rels[rd->flags];
 #endif
     case REL_AND:
       return " & ";
@@ -179,6 +186,8 @@ pool_id2rel(const Pool *pool, Id id)
       return " FILECONFLICT ";
     case REL_COND:
       return " IF ";
+    case REL_COMPAT:
+      return " compat >= ";
     default:
       break;
     }