]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Allow building without rpm database support
authorMichael Schroeder <mls@suse.de>
Thu, 8 Sep 2016 09:11:50 +0000 (11:11 +0200)
committerMichael Schroeder <mls@suse.de>
Thu, 8 Sep 2016 09:11:50 +0000 (11:11 +0200)
Useful for things like OBS that only need to parse packages.

CMakeLists.txt
bindings/solv.i
ext/CMakeLists.txt
ext/repo_rpmdb.c
src/solvversion.h.in
tools/CMakeLists.txt

index 0153a707f4f0a33edef9b0ad84d0875f1bd37178..82034e049268c4772c497f8cf6042549001d2976 100644 (file)
@@ -13,6 +13,7 @@ OPTION (ENABLE_TCL "Build the Tcl bindings?" OFF)
 OPTION (USE_VENDORDIRS "Install the bindings in vendor directories?" OFF)
 
 OPTION (ENABLE_RPMDB "Build with rpm database support?" OFF)
+OPTION (ENABLE_RPMPKG "Build with rpm package support?" OFF)
 OPTION (ENABLE_PUBKEY "Build with pubkey support?" OFF)
 OPTION (ENABLE_RPMDB_BYRPMHEADER "Build with rpmdb Header support?" OFF)
 OPTION (ENABLE_RPMMD "Build with rpmmd repository support?" OFF)
@@ -174,6 +175,10 @@ IF (MULTI_SEMANTICS)
 MESSAGE (STATUS "Enabling multi dist support")
 ENDIF (MULTI_SEMANTICS)
 
+IF (ENABLE_RPMDB)
+SET (ENABLE_RPMPKG ON)
+ENDIF (ENABLE_RPMDB)
+
 INCLUDE (CheckIncludeFile)
 IF (ENABLE_RPMDB)
   FIND_LIBRARY (RPMDB_LIBRARY NAMES rpmdb)
@@ -254,7 +259,8 @@ FOREACH (VAR
 ENDFOREACH (VAR)
 
 FOREACH (VAR
-  ENABLE_RPMDB ENABLE_PUBKEY ENABLE_RPMMD ENABLE_RPMDB_BYRPMHEADER ENABLE_SUSEREPO ENABLE_COMPS
+  ENABLE_RPMDB ENABLE_RPMPKG ENABLE_PUBKEY ENABLE_RPMMD ENABLE_RPMDB_BYRPMHEADER
+  ENABLE_SUSEREPO ENABLE_COMPS
   ENABLE_HELIXREPO ENABLE_MDKREPO ENABLE_ARCHREPO ENABLE_DEBIAN ENABLE_HAIKU
   ENABLE_LZMA_COMPRESSION ENABLE_BZIP2_COMPRESSION ENABLE_PGPVRFY ENABLE_APPDATA)
   IF(${VAR})
index b21fbbcacfe2eed6b6666183c9fb453aabb9a54c..0d6184012ee0b2951dbcb64dd6db8ebd8d9af57c 100644 (file)
@@ -634,7 +634,7 @@ typedef int bool;
 #include "selection.h"
 
 #include "repo_write.h"
-#ifdef ENABLE_RPMDB
+#if defined(ENABLE_RPMDB) || defined(ENABLE_RPMPKG)
 #include "repo_rpmdb.h"
 #endif
 #ifdef ENABLE_PUBKEY
@@ -1990,6 +1990,8 @@ rb_eval_string(
   bool add_rpmdb_reffp(FILE *reffp, int flags = 0) {
     return repo_add_rpmdb_reffp($self, reffp, flags) == 0;
   }
+#endif
+#ifdef ENABLE_RPMPKG
   %newobject add_rpm;
   XSolvable *add_rpm(const char *name, int flags = 0) {
     return new_XSolvable($self->pool, repo_add_rpm($self, name, flags));
index ec5f20cc9b0ffbc1a12c22ea2da8337d9bf73d1f..586eda84e3824f409b8a0b8ae8319f5ccd1f9af3 100644 (file)
@@ -4,12 +4,12 @@ SET (libsolvext_SRCS
 SET (libsolvext_HEADERS
     tools_util.h solv_xfopen.h testcase.h)
 
-IF (ENABLE_RPMDB)
+IF (ENABLE_RPMDB OR ENABLE_RPMPKG)
     SET (libsolvext_SRCS ${libsolvext_SRCS}
         pool_fileconflicts.c repo_rpmdb.c)
     SET (libsolvext_HEADERS ${libsolvext_HEADERS}
         pool_fileconflicts.h repo_rpmdb.h)
-ENDIF (ENABLE_RPMDB)
+ENDIF (ENABLE_RPMDB OR ENABLE_RPMPKG)
 
 IF (ENABLE_PUBKEY)
     SET (libsolvext_SRCS ${libsolvext_SRCS}
@@ -45,12 +45,12 @@ ENDIF (ENABLE_SUSEREPO)
 
 # old cmake does not support parenthetical expressions...
 IF (ENABLE_COMPLEX_DEPS)
-IF (ENABLE_SUSEREPO OR ENABLE_RPMMD OR ENABLE_RPMDB)
+IF (ENABLE_SUSEREPO OR ENABLE_RPMMD OR ENABLE_RPMDB OR ENABLE_RPMPKG)
     SET (libsolvext_SRCS ${libsolvext_SRCS}
        pool_parserpmrichdep.c)
     SET (libsolvext_HEADERS ${libsolvext_HEADERS}
        pool_parserpmrichdep.h)
-ENDIF (ENABLE_SUSEREPO OR ENABLE_RPMMD OR ENABLE_RPMDB)
+ENDIF (ENABLE_SUSEREPO OR ENABLE_RPMMD OR ENABLE_RPMDB OR ENABLE_RPMPKG)
 ENDIF (ENABLE_COMPLEX_DEPS)
 
 IF (SUSE)
index 5ec5f595cb055a0870a254be74737ecb06500093..034198c67faaa903a19aaf0cb0a2f8681be0b6b0 100644 (file)
@@ -24,6 +24,8 @@
 #include <stdint.h>
 #include <errno.h>
 
+#ifdef ENABLE_RPMDB
+
 #include <rpm/rpmio.h>
 #include <rpm/rpmpgp.h>
 #ifndef RPM5
@@ -39,6 +41,8 @@
 # endif
 #endif
 
+#endif
+
 #include "pool.h"
 #include "repo.h"
 #include "hash.h"
@@ -1083,6 +1087,12 @@ rpmhead2solv(Pool *pool, Repo *repo, Repodata *data, Solvable *s, RpmHead *rpmhe
   return 1;
 }
 
+static inline unsigned int
+getu32(const unsigned char *dp)
+{
+  return dp[0] << 24 | dp[1] << 16 | dp[2] << 8 | dp[3];
+}
+
 
 /******************************************************************/
 /*  Rpm Database stuff
@@ -1095,13 +1105,17 @@ struct rpmdbstate {
   RpmHead *rpmhead;    /* header storage space */
   int rpmheadsize;
 
+#ifdef ENABLE_RPMDB
   int dbopened;
   DB_ENV *dbenv;       /* database environment */
   DB *db;              /* packages database */
   int byteswapped;     /* endianess of packages database */
   int is_ostree;       /* read-only db that lives in /usr/share/rpm */
+#endif
 };
 
+#ifdef ENABLE_RPMDB
+
 struct rpmdbentry {
   Id rpmdbid;
   Id nameoff;
@@ -1110,11 +1124,6 @@ struct rpmdbentry {
 #define ENTRIES_BLOCK 255
 #define NAMEDATA_BLOCK 1023
 
-static inline unsigned int
-getu32(const unsigned char *dp)
-{
-  return dp[0] << 24 | dp[1] << 16 | dp[2] << 8 | dp[3];
-}
 
 static inline Id
 db2rpmdbid(unsigned char *db, int byteswapped)
@@ -1250,6 +1259,46 @@ closedbenv(struct rpmdbstate *state)
   state->dbenv = 0;
 }
 
+#endif
+
+static void
+freestate(struct rpmdbstate *state)
+{
+  /* close down */
+  if (!state)
+    return;
+#ifdef ENABLE_RPMDB
+  if (state->db)
+    state->db->close(state->db, 0);
+  if (state->dbenv)
+    closedbenv(state);
+#endif
+  if (state->rootdir)
+    solv_free(state->rootdir);
+  solv_free(state->rpmhead);
+}
+
+void *
+rpm_state_create(Pool *pool, const char *rootdir)
+{
+  struct rpmdbstate *state;
+  state = solv_calloc(1, sizeof(*state));
+  state->pool = pool;
+  if (rootdir)
+    state->rootdir = solv_strdup(rootdir);
+  return state;
+}
+
+void *
+rpm_state_free(void *state)
+{
+  freestate(state);
+  return solv_free(state);
+}
+
+
+#ifdef ENABLE_RPMDB
+
 static int
 openpkgdb(struct rpmdbstate *state)
 {
@@ -1455,39 +1504,6 @@ getrpm_cursor(struct rpmdbstate *state, DBC *dbc)
   return 0;
 }
 
-static void
-freestate(struct rpmdbstate *state)
-{
-  /* close down */
-  if (!state)
-    return;
-  if (state->db)
-    state->db->close(state->db, 0);
-  if (state->dbenv)
-    closedbenv(state);
-  if (state->rootdir)
-    solv_free(state->rootdir);
-  solv_free(state->rpmhead);
-}
-
-void *
-rpm_state_create(Pool *pool, const char *rootdir)
-{
-  struct rpmdbstate *state;
-  state = solv_calloc(1, sizeof(*state));
-  state->pool = pool;
-  if (rootdir)
-    state->rootdir = solv_strdup(rootdir);
-  return state;
-}
-
-void *
-rpm_state_free(void *state)
-{
-  freestate(state);
-  return solv_free(state);
-}
-
 static int
 count_headers(struct rpmdbstate *state)
 {
@@ -2072,6 +2088,8 @@ repo_add_rpmdb_reffp(Repo *repo, FILE *fp, int flags)
   return res;
 }
 
+#endif
+
 Id
 repo_add_rpm(Repo *repo, const char *rpm, int flags)
 {
@@ -2595,6 +2613,8 @@ rpm_query_num(void *rpmhandle, Id what, unsigned long long notfound)
   return notfound;
 }
 
+#ifdef ENABLE_RPMDB
+
 int
 rpm_installedrpmdbids(void *rpmstate, const char *index, const char *match, Queue *rpmdbidq)
 {
@@ -2624,6 +2644,8 @@ rpm_byrpmdbid(void *rpmstate, Id rpmdbid)
   return r <= 0 ? 0 : state->rpmhead;
 }
 
+#endif
+
 void *
 rpm_byfp(void *rpmstate, FILE *fp, const char *name)
 {
index 75dc63f1c82e6c6b9ad3d83929d85467f7abb838..9f59d75c155ffa3a4dfcdda023189f4148104eec 100644 (file)
@@ -28,6 +28,7 @@ extern int solv_version_patch;
 #cmakedefine LIBSOLV_FEATURE_COMPLEX_DEPS
 #cmakedefine LIBSOLV_FEATURE_MULTI_SEMANTICS
 
+#cmakedefine LIBSOLVEXT_FEATURE_RPMPKG
 #cmakedefine LIBSOLVEXT_FEATURE_RPMDB
 #cmakedefine LIBSOLVEXT_FEATURE_RPMDB_BYRPMHEADER
 #cmakedefine LIBSOLVEXT_FEATURE_PUBKEY
index 16fa09727ab1949c47ab22dc030ab9ffdf03d8a4..6b592f7f69a776b8ef6e56c67ca3a9be4a45e482 100644 (file)
@@ -10,15 +10,18 @@ IF (ENABLE_RPMDB)
 ADD_EXECUTABLE (rpmdb2solv rpmdb2solv.c)
 TARGET_LINK_LIBRARIES (rpmdb2solv toolstuff libsolvext libsolv ${SYSTEM_LIBRARIES})
 
-ADD_EXECUTABLE (rpms2solv rpms2solv.c)
-TARGET_LINK_LIBRARIES (rpms2solv toolstuff libsolvext libsolv ${SYSTEM_LIBRARIES})
-
 ADD_EXECUTABLE (findfileconflicts findfileconflicts.c)
 TARGET_LINK_LIBRARIES (findfileconflicts libsolvext libsolv ${SYSTEM_LIBRARIES})
 
-SET (tools_list ${tools_list} rpmdb2solv rpms2solv)
+SET (tools_list ${tools_list} rpmdb2solv)
 ENDIF (ENABLE_RPMDB)
 
+IF (ENABLE_RPMPKG)
+ADD_EXECUTABLE (rpms2solv rpms2solv.c)
+TARGET_LINK_LIBRARIES (rpms2solv toolstuff libsolvext libsolv ${SYSTEM_LIBRARIES})
+SET (tools_list ${tools_list} rpms2solv)
+ENDIF (ENABLE_RPMPKG)
+
 IF (ENABLE_RPMMD)
 ADD_EXECUTABLE (repomdxml2solv repomdxml2solv.c)
 TARGET_LINK_LIBRARIES (repomdxml2solv toolstuff libsolvext libsolv ${SYSTEM_LIBRARIES})