Permalink
Browse files

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...
1 parent a9bc7b0 commit d5597d3b349415e684814541d33b1b460a0481b9 @mlschroe mlschroe committed Oct 15, 2012
Showing with 42 additions and 2 deletions.
  1. +2 −0 CMakeLists.txt
  2. +1 −0 ext/libsolvext.ver
  3. +37 −0 ext/repo_rpmdb.c
  4. +2 −2 ext/repo_rpmdb.h
View
@@ -13,6 +13,7 @@ OPTION (USE_VENDORDIRS "Install the bindings in vendor directories?" OFF)
OPTION (ENABLE_RPMDB "Build with rpm database support?" OFF)
OPTION (ENABLE_RPMDB_PUBKEY "Build with rpmdb pubkey support?" OFF)
+OPTION (ENABLE_RPMDB_BYRPMHEADER "Build with rpmdb Header support?" OFF)
OPTION (ENABLE_RPMMD "Build with rpmmd repository support?" OFF)
OPTION (ENABLE_SUSEREPO "Build with suse repository support?" OFF)
OPTION (ENABLE_COMPS "Build with fedora comps support?" OFF)
@@ -77,6 +78,7 @@ MESSAGE (STATUS "Building for SUSE")
ADD_DEFINITIONS (-DSUSE)
SET (ENABLE_RPMDB ON)
SET (ENABLE_RPMDB_PUBKEY ON)
+SET (ENABLE_RPMDB_BYRPMHEADER ON)
SET (ENABLE_RPMMD ON)
SET (ENABLE_SUSEREPO ON)
SET (ENABLE_HELIXREPO ON)
View
@@ -20,6 +20,7 @@ SOLV_1.0 {
repo_add_releasefile_products;
repo_add_repomdxml;
repo_add_rpm;
+ repo_add_rpm_handle;
repo_add_rpmdb;
repo_add_rpmdb_pubkeys;
repo_add_rpmmd;
View
@@ -2034,6 +2034,39 @@ repo_add_rpm(Repo *repo, const char *rpm, int flags)
return s - pool->solvables;
}
+Id
+repo_add_rpm_handle(Repo *repo, void *rpmhandle, int flags)
+{
+ Pool *pool = repo->pool;
+ Repodata *data;
+ RpmHead *rpmhead = rpmhandle;
+ Solvable *s;
+ char *payloadformat;
+
+ data = repo_add_repodata(repo, flags);
+ if (headexists(rpmhead, TAG_PATCHESNAME))
+ {
+ pool_error(pool, -1, "is a patch rpm");
+ return 0;
+ }
+ payloadformat = headstring(rpmhead, TAG_PAYLOADFORMAT);
+ if (payloadformat && !strcmp(payloadformat, "drpm"))
+ {
+ /* this is a delta rpm */
+ pool_error(pool, -1, "is a delta rpm");
+ return 0;
+ }
+ s = pool_id2solvable(pool, repo_add_solvable(repo));
+ if (!rpm2solv(pool, repo, data, s, rpmhead, flags))
+ {
+ repo_free_solvable(repo, s - pool->solvables, 1);
+ return 0;
+ }
+ if (!(flags & REPO_NO_INTERNALIZE))
+ repodata_internalize(data);
+ return s - pool->solvables;
+}
+
static inline void
linkhash(const char *lt, char *hash)
{
@@ -2575,6 +2608,8 @@ rpm_byfp(FILE *fp, const char *name, void **statep)
return rpmhead;
}
+#ifdef ENABLE_RPMDB_BYRPMHEADER
+
void *
rpm_byrpmh(Header h, void **statep)
{
@@ -2613,6 +2648,8 @@ rpm_byrpmh(Header h, void **statep)
return rpmhead;
}
+#endif
+
#ifdef ENABLE_RPMDB_PUBKEY
View
@@ -33,8 +33,8 @@ extern Id repo_add_pubkey(Repo *repo, const char *key, int flags);
extern void *rpm_byrpmdbid(Id rpmdbid, const char *rootdir, void **statep);
extern void *rpm_byfp(FILE *fp, const char *name, void **statep);
extern void *rpm_byrpmh(struct headerToken_s *h, void **statep);
-
+extern int rpm_installedrpmdbids(const char *rootdir, const char *index, const char *match, Queue *rpmdbidq);
extern char *rpm_query(void *rpmhandle, Id what);
extern void rpm_iterate_filelist(void *rpmhandle, int flags, void (*cb)(void *, const char *, int, const char *), void *cbdata);
-extern int rpm_installedrpmdbids(const char *rootdir, const char *index, const char *match, Queue *rpmdbidq);
+extern Id repo_add_rpm_handle(Repo *repo, void *rpmhandle, int flags);

0 comments on commit d5597d3

Please sign in to comment.