Skip to content
This repository
Browse code

add repo_add_rpm_handle, add ENABLE_RPMDB_BYRPMHEADER so that we don'…

…t need to link against rpm if rpm_byrpmh is not needed
  • Loading branch information...
commit d5597d3b349415e684814541d33b1b460a0481b9 1 parent a9bc7b0
Michael Schroeder authored October 15, 2012
2  CMakeLists.txt
@@ -13,6 +13,7 @@ OPTION (USE_VENDORDIRS "Install the bindings in vendor directories?" OFF)
13 13
 
14 14
 OPTION (ENABLE_RPMDB "Build with rpm database support?" OFF)
15 15
 OPTION (ENABLE_RPMDB_PUBKEY "Build with rpmdb pubkey support?" OFF)
  16
+OPTION (ENABLE_RPMDB_BYRPMHEADER "Build with rpmdb Header support?" OFF)
16 17
 OPTION (ENABLE_RPMMD "Build with rpmmd repository support?" OFF)
17 18
 OPTION (ENABLE_SUSEREPO "Build with suse repository support?" OFF)
18 19
 OPTION (ENABLE_COMPS "Build with fedora comps support?" OFF)
@@ -77,6 +78,7 @@ MESSAGE (STATUS "Building for SUSE")
77 78
 ADD_DEFINITIONS (-DSUSE)
78 79
 SET (ENABLE_RPMDB ON)
79 80
 SET (ENABLE_RPMDB_PUBKEY ON)
  81
+SET (ENABLE_RPMDB_BYRPMHEADER ON)
80 82
 SET (ENABLE_RPMMD ON)
81 83
 SET (ENABLE_SUSEREPO ON)
82 84
 SET (ENABLE_HELIXREPO ON)
1  ext/libsolvext.ver
@@ -20,6 +20,7 @@ SOLV_1.0 {
20 20
 		repo_add_releasefile_products;
21 21
 		repo_add_repomdxml;
22 22
 		repo_add_rpm;
  23
+		repo_add_rpm_handle;
23 24
 		repo_add_rpmdb;
24 25
 		repo_add_rpmdb_pubkeys;
25 26
 		repo_add_rpmmd;
37  ext/repo_rpmdb.c
@@ -2034,6 +2034,39 @@ repo_add_rpm(Repo *repo, const char *rpm, int flags)
2034 2034
   return s - pool->solvables;
2035 2035
 }
2036 2036
 
  2037
+Id
  2038
+repo_add_rpm_handle(Repo *repo, void *rpmhandle, int flags)
  2039
+{
  2040
+  Pool *pool = repo->pool;
  2041
+  Repodata *data;
  2042
+  RpmHead *rpmhead = rpmhandle;
  2043
+  Solvable *s;
  2044
+  char *payloadformat;
  2045
+
  2046
+  data = repo_add_repodata(repo, flags);
  2047
+  if (headexists(rpmhead, TAG_PATCHESNAME))
  2048
+    {
  2049
+      pool_error(pool, -1, "is a patch rpm");
  2050
+      return 0;
  2051
+    }
  2052
+  payloadformat = headstring(rpmhead, TAG_PAYLOADFORMAT);
  2053
+  if (payloadformat && !strcmp(payloadformat, "drpm"))
  2054
+    {
  2055
+      /* this is a delta rpm */
  2056
+      pool_error(pool, -1, "is a delta rpm");
  2057
+      return 0;
  2058
+    }
  2059
+  s = pool_id2solvable(pool, repo_add_solvable(repo));
  2060
+  if (!rpm2solv(pool, repo, data, s, rpmhead, flags))
  2061
+    {
  2062
+      repo_free_solvable(repo, s - pool->solvables, 1);
  2063
+      return 0;
  2064
+    }
  2065
+  if (!(flags & REPO_NO_INTERNALIZE))
  2066
+    repodata_internalize(data);
  2067
+  return s - pool->solvables;
  2068
+}
  2069
+
2037 2070
 static inline void
2038 2071
 linkhash(const char *lt, char *hash)
2039 2072
 {
@@ -2575,6 +2608,8 @@ rpm_byfp(FILE *fp, const char *name, void **statep)
2575 2608
   return rpmhead;
2576 2609
 }
2577 2610
 
  2611
+#ifdef ENABLE_RPMDB_BYRPMHEADER
  2612
+
2578 2613
 void *
2579 2614
 rpm_byrpmh(Header h, void **statep)
2580 2615
 {
@@ -2613,6 +2648,8 @@ rpm_byrpmh(Header h, void **statep)
2613 2648
   return rpmhead;
2614 2649
 }
2615 2650
 
  2651
+#endif
  2652
+
2616 2653
 
2617 2654
 #ifdef ENABLE_RPMDB_PUBKEY
2618 2655
 
4  ext/repo_rpmdb.h
@@ -33,8 +33,8 @@ extern Id repo_add_pubkey(Repo *repo, const char *key, int flags);
33 33
 extern void *rpm_byrpmdbid(Id rpmdbid, const char *rootdir, void **statep);
34 34
 extern void *rpm_byfp(FILE *fp, const char *name, void **statep);
35 35
 extern void *rpm_byrpmh(struct headerToken_s *h, void **statep);
36  
-
  36
+extern int  rpm_installedrpmdbids(const char *rootdir, const char *index, const char *match, Queue *rpmdbidq);
37 37
 
38 38
 extern char *rpm_query(void *rpmhandle, Id what);
39 39
 extern void rpm_iterate_filelist(void *rpmhandle, int flags, void (*cb)(void *, const char *, int, const char *), void *cbdata);
40  
-extern int  rpm_installedrpmdbids(const char *rootdir, const char *index, const char *match, Queue *rpmdbidq);
  40
+extern Id   repo_add_rpm_handle(Repo *repo, void *rpmhandle, int flags);

0 notes on commit d5597d3

Please sign in to comment.
Something went wrong with that request. Please try again.