Upstream-Status: Pending

Add RPM5 configuration support

Update the cmake configuration to detect additional files needed by RPM5.

Original work by Qing He <qing.he@intel.com>.

Merged and updated to make this more likely to be accepted upstream.

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>

diff -ur git.orig/CMakeLists.txt git/CMakeLists.txt
--- git.orig/CMakeLists.txt	2011-03-16 16:16:29.152786178 -0500
+++ git/CMakeLists.txt	2011-03-16 16:29:43.532032285 -0500
@@ -50,7 +50,16 @@
 ADD_DEFINITIONS( -DMULTI_SEMANTICS)
 ENDIF ( MULTI_SEMANTICS )
 
-IF ( NOT DEBIAN )
+if ( RPM5 )
+MESSAGE(STATUS "Enabling RPM 5 support")
+ADD_DEFINITIONS( -DRPM5)
+
+FIND_PACKAGE(PkgConfig REQUIRED)
+PKG_CHECK_MODULES(RPM REQUIRED rpm)
+INCLUDE_DIRECTORIES( ${RPM_INCLUDE_DIRS} )
+ENDIF ( RPM5 )
+
+IF ( RPM5 OR NOT DEBIAN )
 FIND_LIBRARY(RPMDB_LIBRARY NAMES rpmdb)
 IF ( NOT RPMDB_LIBRARY )
 FIND_LIBRARY(RPMDB_LIBRARY NAMES rpm)
@@ -59,13 +68,17 @@
 IF ( RPMIO_LIBRARY )
 SET( RPMDB_LIBRARY ${RPMIO_LIBRARY} ${RPMDB_LIBRARY} )
 ENDIF ( RPMIO_LIBRARY )
-IF ( FEDORA )
+FIND_LIBRARY(RPMMISC_LIBRARY NAMES rpmmisc)
+IF ( RPMMISC_LIBRARY )
+SET ( RPMDB_LIBRARY ${RPMMISC_LIBRARY} ${RPMDB_LIBRARY} )
+ENDIF ( RPMMISC_LIBRARY )
+IF ( RPM5 OR FEDORA )
 FIND_LIBRARY(DB_LIBRARY NAMES db)
 IF ( DB_LIBRARY )
 SET( RPMDB_LIBRARY ${DB_LIBRARY} ${RPMDB_LIBRARY} )
 ENDIF ( DB_LIBRARY )
-ENDIF ( FEDORA )
-ENDIF ( NOT DEBIAN )
+ENDIF ( RPM5 OR FEDORA )
+ENDIF ( RPM5 OR NOT DEBIAN )
 
 INCLUDE ( CheckFunctionExists )
 INCLUDE ( TestBigEndian )
diff -ur git.orig/ext/repo_rpmdb.c git/ext/repo_rpmdb.c
--- git.orig/ext/repo_rpmdb.c	2011-03-16 18:03:55.401907738 -0500
+++ git/ext/repo_rpmdb.c	2011-03-16 18:04:47.472989651 -0500
@@ -3039,7 +3039,11 @@
   repodata_set_str(data, s - s->repo->pool->solvables, PUBKEY_KEYID, keyid);
   if (dig->pubkey.userid)
     setutf8string(data, s - s->repo->pool->solvables, SOLVABLE_SUMMARY, dig->pubkey.userid);
+#ifndef RPM5
   (void)pgpFreeDig(dig);
+#else
+  (void)pgpDigFree(dig);
+#endif
   sat_free((void *)pkts);
   return 1;
 }
