Hi,

vanilla net-snmp 5.7.rc1 does not compile on Fedora 15 and rawhide. I
have quick & dirty specific patches in distro RPMs to make it work there.

Now I finally got polished patches from Panu Matilainen, one of current
RPM developers, which adds support of all RPM versions between 4.1 and
4.9 to Net-SNMP. It works well on everything between Fedora 15 and
RHEL4. I haven't tested anything older, it's still possible it works
there too.

The patch itself is not that complicated, but I'd appreciate some
testing on non-Red Hat systems like SuSE and Mandriva. Any volunteers?

Jan
commit a48abfb23573eee78cc58774ad7eb67b6a8a1185
Author: Panu Matilainen <[email protected]>
Date:   Wed Jun 15 10:29:08 2011 +0300

    Clean up rpm config checks
    
    - Remove checks for rpm private libraries, these are not net-snmp's
      headache. These checks are very outdated and if they were truly
      necessary, net-snmp rpm support wouldn't have been buildable
      in years.
    - Check for rpmGetPath() instead of Fopen() for rpmio library as
      net-snmp actually uses that function, making direct linking necessary.

diff --git a/configure.d/config_os_libs1 b/configure.d/config_os_libs1
index 41e617e..56a24fe 100644
--- a/configure.d/config_os_libs1
+++ b/configure.d/config_os_libs1
@@ -33,43 +33,8 @@ if test "x$with_rpm" != "xno"; then
   # FWIW librpm.la, librpmio.la, and libpopt.la have correct dependencies.
   _rpmlibs=""
 
-  # zlib is required for newer versions of rpm
-  _cppflags="${CPPFLAGS}"
-  _ldflags="${LDFLAGS}"
-
-  # check for zlib
-  if test "x${with_zlib}" != "xno" -a -d "${with_zlib}"; then
-    CPPFLAGS="${CPPFLAGS} -I${with_zlib}/include"
-    LDFLAGS="${LDFLAGS} -L${with_zlib}/lib"
-  fi
-
-  # dunno if this is needed for rpm-4.0.x, earlier probably needs.
-  AC_CHECK_HEADER(zlib.h,
-      NETSNMP_SEARCH_LIBS(gzread, z,,
-          CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}, $LMIBLIBS, _rpmlibs),
-      CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags})
-
-  # two variants of bzip2 need checking.
-  if test "x${with_bzip2}" != "xno"; then
-    if test -d "${with_bzip2}"; then
-      CPPFLAGS="${CPPFLAGS} -I${with_bzip2}/include"
-      LDFLAGS="${LDFLAGS} -L${with_bzip2}/lib"
-    fi
-    NETSNMP_SEARCH_LIBS(bzread, bz2,,, $LMIBLIBS, _rpmlibs)
-    NETSNMP_SEARCH_LIBS(BZ2_bzread, bz2,,, $LMIBLIBS, _rpmlibs)
-  fi
-
-  # two variants of db1 need checking.
-  NETSNMP_SEARCH_LIBS(dbopen, [db1 db],,, $LMIBLIBS, _rpmlibs)
-
-  # two variants of db3 need checking.
-  NETSNMP_SEARCH_LIBS(db_create, [db-3.1 db-3.0],,, $LMIBLIBS, _rpmlibs)
-  
-  # rpm-3.0.5 and later needs popt.
-  NETSNMP_SEARCH_LIBS(poptParseArgvString, popt,,, $LMIBLIBS, _rpmlibs)
-  
   # rpm-4.0.x needs rpmio.
-  NETSNMP_SEARCH_LIBS(Fopen, rpmio,,, $LMIBLIBS, _rpmlibs)
+  NETSNMP_SEARCH_LIBS(rpmGetPath, rpmio,,, $LMIBLIBS, _rpmlibs)
   
   # rpm-4.0.3 librpmdb actually contains what we need.
   NETSNMP_SEARCH_LIBS(rpmdbOpen, rpmdb,,, $LMIBLIBS, _rpmlibs)
commit cd4ea8ec9cc6395a81ed1282c403c2ec06578fa6
Author: Panu Matilainen <[email protected]>
Date:   Wed Jun 15 10:34:30 2011 +0300

    Remove support for truly ancient rpm versions, fixing build with newer ones
    
    - This works on all versions of rpm >= 4.1, still giving span of
      nearly a decade for older rpm versions while making it work
      with current versions also.

diff --git a/agent/mibgroup/host/data_access/swinst_rpm.c b/agent/mibgroup/host/data_access/swinst_rpm.c
index 743e3eb..4dfb769 100644
--- a/agent/mibgroup/host/data_access/swinst_rpm.c
+++ b/agent/mibgroup/host/data_access/swinst_rpm.c
@@ -32,7 +32,8 @@
 #ifdef HAVE_RPMGETPATH		/* HAVE_RPM_RPMMACRO_H */
 #include <rpm/rpmmacro.h>
 #endif
-#ifdef HAVE_RPM_RPMDB_H
+#ifdef HAVE_RPM_RPMTS_H
+#include <rpm/rpmts.h>
 #include <rpm/rpmdb.h>
 #endif
 
@@ -64,18 +65,10 @@ netsnmp_swinst_arch_init(void)
     rpmdbpath = rpmGetPath( "%{_dbpath}", NULL );
     dbpath = rpmdbpath;
 #else
-#ifdef RPMVAR_DBPATH
-    rpmReadConfigFiles( NULL, NULL, NULL, 0 );
-    rpmdbpath = rpmGetVar( RPMVAR_DBPATH );
-    dbpath = rpmdbpath;
-#else
     dbpath = "/var/lib/rpm";   /* Most likely */
 #endif
-#endif
 
     snprintf( pkg_directory, SNMP_MAXPATH, "%s/Packages", dbpath );
-    if (-1 == stat( pkg_directory, &stat_buf ))
-        snprintf( pkg_directory, SNMP_MAXPATH, "%s/packages.rpm", dbpath );
     SNMP_FREE(rpmdbpath);
     dbpath = NULL;
     if (-1 == stat( pkg_directory, &stat_buf )) {
@@ -96,13 +89,9 @@ netsnmp_swinst_arch_shutdown(void)
 int
 netsnmp_swinst_arch_load( netsnmp_container *container, u_int flags)
 {
-    rpmdb                 db;
+    rpmts                 ts;
 
-#if defined(RPMDBI_PACKAGES)
     rpmdbMatchIterator    mi;
-#else
-    int                   offset;
-#endif
     Header                h;
     char                 *n, *v, *r, *g;
     int32_t              *t;
@@ -111,17 +100,14 @@ netsnmp_swinst_arch_load( netsnmp_container *container, u_int flags)
     int                   rc, i = 1;
     netsnmp_swinst_entry *entry;
 
-    if (rpmdbOpen("", &db, O_RDONLY, 0644))
+    ts = rpmtsCreate();
+    rpmtsSetVSFlags( ts, (_RPMVSF_NOSIGNATURES|_RPMVSF_NODIGESTS));
+
+    mi = rpmtsInitIterator( ts, RPMDBI_PACKAGES, NULL, 0);
+    if (mi == NULL)
 	NETSNMP_LOGONCE((LOG_ERR, "rpmdbOpen() failed\n"));
 
-#if defined(RPMDBI_PACKAGES)
-    mi = rpmdbInitIterator( db, RPMDBI_PACKAGES, NULL, 0);
     while (NULL != (h = rpmdbNextIterator( mi )))
-#else
-    for (offset  = rpmdbFirstRecNum( db );
-         offset != 0;
-         offset  = rpmdbNextRecNum(  db, offset ))
-#endif
     {
 
         entry = netsnmp_swinst_entry_create( i++ );
@@ -129,11 +115,7 @@ netsnmp_swinst_arch_load( netsnmp_container *container, u_int flags)
             continue;   /* error already logged by function */
         rc = CONTAINER_INSERT(container, entry);
 
-#if defined(RPMDBI_PACKAGES)
         h = headerLink( h );
-#else
-        h = rpmdbGetRecord( db, offset );
-#endif
         headerGetEntry( h, RPMTAG_NAME,        NULL, (void**)&n, NULL);
         headerGetEntry( h, RPMTAG_VERSION,     NULL, (void**)&v, NULL);
         headerGetEntry( h, RPMTAG_RELEASE,     NULL, (void**)&r, NULL);
@@ -154,10 +136,8 @@ netsnmp_swinst_arch_load( netsnmp_container *container, u_int flags)
 
         headerFree( h );
     }
-#if defined(RPMDBI_PACKAGES)
     rpmdbFreeIterator( mi );
-#endif
-    rpmdbClose( db );
+    rpmtsFree( ts );
 
     DEBUGMSGTL(("swinst:load:arch", "loaded %d entries\n",
                 (int)CONTAINER_SIZE(container)));
diff --git a/configure.d/config_os_headers b/configure.d/config_os_headers
index cdee3ad..90b5554 100644
--- a/configure.d/config_os_headers
+++ b/configure.d/config_os_headers
@@ -90,7 +90,8 @@ AC_CHECK_HEADERS([openssl/des.h  openssl/hmac.h ] dnl
 
 # RPM subdirectory path                   (Agent)
 if test "x$with_rpm" != "xno"; then
-  AC_CHECK_HEADERS(rpm/rpmdb.h   rpm/rpmfileutil.h)
+  AC_CHECK_HEADERS([rpm/rpmts.h   rpm/rpmfileutil.h], [], [],
+		   [[#include <rpm/rpmlib.h>]])
 fi
 
 
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to