diff --git a/configure.ac b/configure.ac index 192a838..4ddd127 100644 --- a/configure.ac +++ b/configure.ac @@ -200,12 +200,11 @@ AC_CHECK_LIB(bz2, BZ2_decompress, AM_CONDITIONAL(HAVE_BZ2, false))], AM_CONDITIONAL(HAVE_BZ2, false)) -AC_CHECK_LIB(rpm, rpmReadPackageFile, - [AC_CHECK_HEADERS([rpm/rpmlib.h], - AM_CONDITIONAL(HAVE_LIBRPM, true) - AC_DEFINE(HAVE_LIBRPM,1,[Have librpm]), - AM_CONDITIONAL(HAVE_LIBRPM, false))], - AM_CONDITIONAL(HAVE_LIBRPM, false)) +PKG_CHECK_MODULES(RPM, rpm, + AM_CONDITIONAL(HAVE_LIBRPM, true) + AC_DEFINE([HAVE_LIBRPM],[1], "RPM..."), + AM_CONDITIONAL(HAVE_LIBRPM, false) + ) AC_CHECK_LIB(mpeg2, mpeg2_init, [AC_CHECK_HEADERS([mpeg2dec/mpeg2.h], --- libextractor-1.0.1/src/plugins/Makefile.am.orig 2012-12-01 16:30:21.501145332 +0100 +++ libextractor-1.0.1/src/plugins/Makefile.am 2012-12-01 16:50:19.671120357 +0100 @@ -1,6 +1,7 @@ INCLUDES = \ -I$(top_srcdir)/src/include \ - -I$(top_srcdir)/src/common + -I$(top_srcdir)/src/common \ + $(RPM_CFLAGS) # install plugins under: --- libextractor-1.3/src/plugins/rpm_extractor.c.orig 2013-11-28 22:16:45.000000000 +0100 +++ libextractor-1.3/src/plugins/rpm_extractor.c 2013-12-26 20:29:36.083607762 +0100 @@ -25,9 +25,10 @@ #include "platform.h" #include "extractor.h" #include -#include -#include -#include +#include +#include +#include +#include #if SOMEBSD #include #else @@ -128,6 +129,7 @@ pipe_feeder (void * args) * LOG callback called by librpm. Does nothing, we * just need this to override the default behavior. */ +#ifdef RPMLOG_DEFAULT static int discard_log_callback (rpmlogRec rec, void *ctx) @@ -135,6 +137,9 @@ discard_log_callback (rpmlogRec rec, /* do nothing! */ return 0; } +#else +static void discard_log_callback() { } +#endif /** @@ -240,6 +245,12 @@ static struct Matches tests[] = { {0, 0} }; +#ifndef H_RPMTAG +static int headerNext(HeaderIterator hi, HE_t he, /*@unused@*/ unsigned int flags) +{ + return headerNextIterator(hi, &he->tag, &he->t, &he->p.ptr, &he->c); +} +#endif /** * Main entry method for the 'application/x-rpm' extraction plugin. @@ -255,7 +266,7 @@ EXTRACTOR_rpm_extract_method (struct EXT const char *str; Header hdr; HeaderIterator hi; - rpmtd p; + HE_t p; int i; FD_t fdi; rpmRC rc; @@ -286,7 +297,11 @@ EXTRACTOR_rpm_extract_method (struct EXT CLOSE (parg.pi[1]); return; } +#ifdef RPMLOG_DEFAULT rpmlogSetCallback (&discard_log_callback, NULL); +#else + rpmlogSetCallback (&discard_log_callback); +#endif fdi = fdDup (parg.pi[0]); ts = rpmtsCreate(); rc = rpmReadPackageFile (ts, fdi, "GNU libextractor", &hdr); @@ -314,19 +329,38 @@ EXTRACTOR_rpm_extract_method (struct EXT goto END; } pthread_mutex_unlock (&parg.lock); +#ifdef H_RPMTAG + hi = headerInit (hdr); +#else hi = headerInitIterator (hdr); - p = rpmtdNew (); - while (1 == headerNext (hi, p)) +#endif + p = (HE_t)memset(alloca(sizeof(*p)), 0, sizeof(*p)); + while (1 == headerNext (hi, p, 0)) for (i = 0; 0 != tests[i].rtype; i++) { if (tests[i].rtype != p->tag) continue; - switch (p->type) + switch (p->t) { + case RPM_STRING_TYPE: + { + pthread_mutex_lock (&parg.lock); + if (0 != ec->proc (ec->cls, + "rpm", + tests[i].type, + EXTRACTOR_METAFORMAT_UTF8, + "text/plain", + p->p.str, + strlen (p->p.str) +1)) { + pthread_mutex_unlock (&parg.lock); + return; + } + pthread_mutex_unlock (&parg.lock); + } + break; case RPM_STRING_ARRAY_TYPE: case RPM_I18NSTRING_TYPE: - case RPM_STRING_TYPE: - while (NULL != (str = rpmtdNextString (p))) + for(p->ix = 0; p->ix < p->c; p->ix++) { pthread_mutex_lock (&parg.lock); if (0 != ec->proc (ec->cls, @@ -334,8 +368,8 @@ EXTRACTOR_rpm_extract_method (struct EXT tests[i].type, EXTRACTOR_METAFORMAT_UTF8, "text/plain", - str, - strlen (str) + 1)) + p->p.argv[p->ix], + strlen (p->p.argv[p->ix]) + 1)) { pthread_mutex_unlock (&parg.lock); @@ -344,12 +378,12 @@ EXTRACTOR_rpm_extract_method (struct EXT pthread_mutex_unlock (&parg.lock); } break; - case RPM_INT32_TYPE: + case RPM_UINT32_TYPE: { if (p->tag == RPMTAG_BUILDTIME) { char tmp[30]; - uint32_t *v = rpmtdNextUint32 (p); + uint32_t *v = p->p.ui32p; time_t tp = (time_t) *v; ctime_r (&tp, tmp); @@ -371,7 +405,7 @@ EXTRACTOR_rpm_extract_method (struct EXT else { char tmp[14]; - uint32_t *s = rpmtdNextUint32 (p); + uint32_t *s = p->p.ui32p; snprintf (tmp, sizeof (tmp), @@ -398,7 +432,6 @@ EXTRACTOR_rpm_extract_method (struct EXT } } CLEANUP: - rpmtdFree (p); headerFreeIterator (hi); END: