- clean up system type definition, use -DSUSE=1 when building for suse
authorMichael Schroeder <mls@suse.de>
Wed, 11 Apr 2012 13:48:06 +0000 (15:48 +0200)
committerMichael Schroeder <mls@suse.de>
Wed, 11 Apr 2012 13:48:06 +0000 (15:48 +0200)
CMakeLists.txt
examples/solv.c
package/libsolv.spec.in
src/pool.c

index 0acd289..54b70bb 100644 (file)
@@ -53,25 +53,66 @@ INSTALL( FILES ${CMAKE_MODULE_PATH}/FindLibSolv.cmake DESTINATION ${CMAKE_INSTAL
 
 INCLUDE (${CMAKE_SOURCE_DIR}/VERSION.cmake)
 
-FIND_PACKAGE (EXPAT REQUIRED)
-FIND_PACKAGE (ZLIB REQUIRED)
-IF (ENABLE_LZMA_COMPRESSION)
-FIND_PACKAGE (LZMA REQUIRED)
-ENDIF (ENABLE_LZMA_COMPRESSION)
+SET (have_system x)
 
 IF (FEDORA)
 MESSAGE(STATUS "Building for Fedora")
 ADD_DEFINITIONS (-DFEDORA)
 SET (ENABLE_RPMDB ON)
 SET (ENABLE_RPMMD ON)
+SET (have_system ${have_system}x)
 ENDIF (FEDORA)
 
 IF (DEBIAN)
 MESSAGE (STATUS "Building for Debian")
 ADD_DEFINITIONS (-DDEBIAN)
 SET (ENABLE_DEBIAN ON)
+SET (have_system ${have_system}x)
 ENDIF (DEBIAN)
 
+IF (SUSE)
+MESSAGE (STATUS "Building for SUSE")
+ADD_DEFINITIONS (-DSUSE)
+SET (ENABLE_RPMDB ON)
+SET (ENABLE_RPMDB_PUBKEY ON)
+SET (ENABLE_RPMMD ON)
+SET (ENABLE_SUSEREPO ON)
+SET (ENABLE_HELIXREPO ON)
+SET (have_system ${have_system}x)
+ENDIF (SUSE)
+
+IF (ARCHLINUX)
+MESSAGE (STATUS "Building for Archlinux")
+ADD_DEFINITIONS (-DARCHLINUX)
+SET (ENABLE_ARCHREPO ON)
+SET (have_system ${have_system}x)
+ENDIF (ARCHLINUX)
+
+IF (MANDRIVA)
+MESSAGE (STATUS "Building for Mandriva/Mageia")
+ADD_DEFINITIONS (-DMANDRIVA)
+SET (ENABLE_MDKREPO ON)
+SET (have_system ${have_system}x)
+ENDIF (MANDRIVA)
+
+IF (${have_system} STREQUAL x)
+    MESSAGE (STATUS "Building for no system")
+    ADD_DEFINITIONS (-DNOSYSTEM)
+ENDIF (${have_system} STREQUAL x)
+IF (${have_system} STRGREATER xx)
+    MESSAGE (FATAL_ERROR "Can only compile for one system type.")
+ENDIF (${have_system} STRGREATER xx)
+
+IF (ENABLE_ARCHREPO)
+SET (ENABLE_LZMA_COMPRESSION ON)
+ENDIF (ENABLE_ARCHREPO)
+
+FIND_PACKAGE (EXPAT REQUIRED)
+FIND_PACKAGE (ZLIB REQUIRED)
+IF (ENABLE_LZMA_COMPRESSION)
+FIND_PACKAGE (LZMA REQUIRED)
+ENDIF (ENABLE_LZMA_COMPRESSION)
+
 IF (RPM5)
 MESSAGE (STATUS "Enabling RPM 5 support")
 ADD_DEFINITIONS (-DRPM5)
@@ -87,22 +128,6 @@ MESSAGE (STATUS "Enabling multi dist support")
 ADD_DEFINITIONS (-DMULTI_SEMANTICS)
 ENDIF (MULTI_SEMANTICS)
 
-# compat: enable some database types
-IF (NOT ENABLE_RPMDB AND
-    NOT ENABLE_RPMMD AND
-    NOT ENABLE_SUSEREPO AND
-    NOT ENABLE_HELIXREPO AND
-    NOT ENABLE_MDKREPO AND
-    NOT ENABLE_ARCHREPO AND
-    NOT ENABLE_DEBIAN)
-    SET (ENABLE_RPMDB ON)
-    SET (ENABLE_RPMDB_PUBKEY ON)
-    SET (ENABLE_RPMMD ON)
-    SET (ENABLE_SUSEREPO ON)
-    SET (ENABLE_HELIXREPO ON)
-    SET (ENABLE_DEBIAN ON)
-ENDIF ()
-
 IF (ENABLE_RPMDB)
   FIND_LIBRARY (RPMDB_LIBRARY NAMES rpmdb)
 
index ce976e4..d19939f 100644 (file)
@@ -81,7 +81,8 @@
 
 #ifdef FEDORA
 # define REPOINFO_PATH "/etc/yum.repos.d"
-#else
+#endif
+#ifdef SUSE
 # define REPOINFO_PATH "/etc/zypp/repos.d"
 # define PRODUCTS_PATH "/etc/products.d"
 # define SOFTLOCKS_PATH "/var/lib/zypp/SoftLocks"
@@ -196,6 +197,7 @@ yum_substitute(Pool *pool, char *line)
 #define TYPE_PLAINDIR  3
 #define TYPE_DEBIAN     4
 
+#ifndef NOSYSTEM
 static int
 read_repoinfos_sort(const void *ap, const void *bp)
 {
@@ -203,12 +205,14 @@ read_repoinfos_sort(const void *ap, const void *bp)
   const struct repoinfo *b = bp;
   return strcmp(a->alias, b->alias);
 }
+#endif
 
-#ifndef DEBIAN
+#if defined(SUSE) || defined(FEDORA)
 
 struct repoinfo *
-read_repoinfos(Pool *pool, const char *reposdir, int *nrepoinfosp)
+read_repoinfos(Pool *pool, int *nrepoinfosp)
 {
+  const char *reposdir = REPOINFO_PATH;
   char buf[4096];
   char buf2[4096], *kp, *vp, *kpe;
   DIR *dir;
@@ -337,10 +341,12 @@ read_repoinfos(Pool *pool, const char *reposdir, int *nrepoinfosp)
   return repoinfos;
 }
 
-#else
+#endif
+
+#ifdef DEBIAN
 
 struct repoinfo *
-read_repoinfos(Pool *pool, const char *reposdir, int *nrepoinfosp)
+read_repoinfos(Pool *pool, int *nrepoinfosp)
 {
   FILE *fp;
   char buf[4096];
@@ -453,6 +459,16 @@ read_repoinfos(Pool *pool, const char *reposdir, int *nrepoinfosp)
 
 #endif
 
+#ifdef NOSYSTEM
+struct repoinfo *
+read_repoinfos(Pool *pool, int *nrepoinfosp)
+{
+  *nrepoinfosp = 0;
+  return 0;
+}
+#endif
+
+
 void
 free_repoinfos(struct repoinfo *repoinfos, int nrepoinfos)
 {
@@ -1620,13 +1636,13 @@ read_repos(Pool *pool, struct repoinfo *repoinfos, int nrepoinfos)
   Repodata *data;
   int badchecksum;
   int dorefresh;
-#if defined(ENABLE_DEBIAN) && defined(DEBIAN)
+#if defined(ENABLE_DEBIAN)
   FILE *fpr;
   int j;
 #endif
 
   repo = repo_create(pool, "@System");
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
   printf("rpm database:");
   if (stat("/var/lib/rpm/Packages", &stb))
     memset(&stb, 0, sizeof(&stb));
@@ -1636,21 +1652,25 @@ read_repos(Pool *pool, struct repoinfo *repoinfos, int nrepoinfos)
   if (stat("/var/lib/dpkg/status", &stb))
     memset(&stb, 0, sizeof(&stb));
 #endif
+#ifdef NOSYSTEM
+  printf("no installed database:");
+  memset(&stb, 0, sizeof(&stb));
+#endif
   calc_checksum_stat(&stb, REPOKEY_TYPE_SHA256, installedcookie);
   if (usecachedrepo(repo, 0, installedcookie, 0))
     printf(" cached\n");
   else
     {
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
       FILE *ofp;
       int done = 0;
 #endif
       printf(" reading\n");
 
-#if defined(ENABLE_SUSEREPO) && defined(PRODUCTS_PATH)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
+# if defined(ENABLE_SUSEREPO) && defined(PRODUCTS_PATH)
       repo_add_products(repo, PRODUCTS_PATH, 0, REPO_NO_INTERNALIZE);
-#endif
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+# endif
       if ((ofp = fopen(calccachepath(repo, 0), "r")) != 0)
        {
          Repo *ref = repo_create(pool, "@System.old");
@@ -1664,10 +1684,9 @@ read_repos(Pool *pool, struct repoinfo *repoinfos, int nrepoinfos)
        }
       if (!done)
         repo_add_rpmdb(repo, 0, 0, REPO_REUSE_REPODATA);
-#else
-# if defined(ENABLE_DEBIAN) && defined(DEBIAN)
-        repo_add_debdb(repo, 0, REPO_REUSE_REPODATA);
-# endif
+#endif
+#if defined(ENABLE_DEBIAN) && defined(DEBIAN)
+      repo_add_debdb(repo, 0, REPO_REUSE_REPODATA);
 #endif
       writecachedrepo(repo, 0, 0, installedcookie);
     }
@@ -1875,7 +1894,7 @@ read_repos(Pool *pool, struct repoinfo *repoinfos, int nrepoinfos)
          break;
 #endif
 
-#if defined(ENABLE_DEBIAN) && defined(DEBIAN)
+#if defined(ENABLE_DEBIAN)
         case TYPE_DEBIAN:
          printf("debian repo '%s':", cinfo->alias);
          fflush(stdout);
@@ -2313,7 +2332,7 @@ yesno(const char *str)
     }
 }
 
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
 
 struct fcstate {
   FILE **newpkgsfps;
@@ -2757,7 +2776,7 @@ main(int argc, char **argv)
   pool->nscallback = nscallback;
   // pool_setdebuglevel(pool, 2);
   setarch(pool);
-  repoinfos = read_repoinfos(pool, REPOINFO_PATH, &nrepoinfos);
+  repoinfos = read_repoinfos(pool, &nrepoinfos);
 
   if (mainmode == MODE_REPOLIST)
     {
@@ -2851,10 +2870,11 @@ main(int argc, char **argv)
        {
          int l;
           l = strlen(argv[i]);
-#ifndef DEBIAN
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
          if (l <= 4 || strcmp(argv[i] + l - 4, ".rpm"))
            continue;
-#else
+#endif
+#if defined(ENABLE_DEBIAN) && defined(DEBIAN)
          if (l <= 4 || strcmp(argv[i] + l - 4, ".deb"))
            continue;
 #endif
@@ -2868,7 +2888,7 @@ main(int argc, char **argv)
          if (!commandlinerepo)
            commandlinerepo = repo_create(pool, "@commandline");
          p = 0;
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
          p = repo_add_rpm(commandlinerepo, (const char *)argv[i], REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE);
 #endif
 #if defined(ENABLE_DEBIAN) && defined(DEBIAN)
@@ -3035,7 +3055,7 @@ main(int argc, char **argv)
   addsoftlocks(pool, &job);
 #endif
 
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
 rerunsolver:
 #endif
   for (;;)
@@ -3121,7 +3141,7 @@ rerunsolver:
   printf("Transaction summary:\n\n");
   transaction_print(trans);
 
-#if !defined(FEDORA) && !defined(DEBIAN)
+#if defined(SUSE)
   if (1)
     {
       DUChanges duc[4];
@@ -3323,7 +3343,7 @@ rerunsolver:
       putchar('\n');
     }
 
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
   if (newpkgs)
     {
       Queue conflicts;
@@ -3362,7 +3382,7 @@ rerunsolver:
   transaction_order(trans, 0);
   for (i = 0; i < trans->steps.count; i++)
     {
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
       const char *evr, *evrp, *nvra;
 #endif
       Solvable *s;
@@ -3376,7 +3396,7 @@ rerunsolver:
        {
        case SOLVER_TRANSACTION_ERASE:
          printf("erase %s\n", pool_solvid2str(pool, p));
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
          if (!s->repo->rpmdbid || !s->repo->rpmdbid[p - s->repo->start])
            continue;
          /* strip epoch from evr */
@@ -3404,7 +3424,7 @@ rerunsolver:
            continue;
          rewind(fp);
          lseek(fileno(fp), 0, SEEK_SET);
-#if defined(ENABLE_RPMDB) && !defined(DEBIAN)
+#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
          runrpm(type == SOLVER_TRANSACTION_MULTIINSTALL ? "-i" : "-U", "/dev/fd/3", fileno(fp));
 #endif
 #if defined(ENABLE_DEBIAN) && defined(DEBIAN)
index bd867d4..deb0875 100644 (file)
@@ -166,6 +166,9 @@ CMAKE_FLAGS=
 %if 0%{?fedora_version} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
 CMAKE_FLAGS="-DFEDORA=1"
 %endif
+%if 0%{?suse_version}
+CMAKE_FLAGS="-DSUSE=1"
+%endif
 
 cmake   $CMAKE_FLAGS \
        -DCMAKE_INSTALL_PREFIX=%{_prefix} \
index 7b9210e..4a1383c 100644 (file)
@@ -56,9 +56,12 @@ pool_create(void)
 
   queue_init(&pool->vendormap);
 
-#ifdef DEBIAN 
+#if defined(DEBIAN)
   pool->disttype = DISTTYPE_DEB;
   pool->noarchid = ARCH_ALL;
+#elif defined(ARCHLINUX)
+  pool->disttype = DISTTYPE_ARCH;
+  pool->noarchid = ARCH_ANY;
 #else
   pool->disttype = DISTTYPE_RPM;
   pool->noarchid = ARCH_NOARCH;