]> git.pld-linux.org Git - packages/libextractor.git/blob - libextractor-rpm5.patch
- updated to 1.3
[packages/libextractor.git] / libextractor-rpm5.patch
1 diff --git a/configure.ac b/configure.ac
2 index 192a838..4ddd127 100644
3 --- a/configure.ac
4 +++ b/configure.ac
5 @@ -200,12 +200,11 @@ AC_CHECK_LIB(bz2, BZ2_decompress,
6           AM_CONDITIONAL(HAVE_BZ2, false))],
7           AM_CONDITIONAL(HAVE_BZ2, false))
8  
9 -AC_CHECK_LIB(rpm, rpmReadPackageFile,
10 -        [AC_CHECK_HEADERS([rpm/rpmlib.h],
11 -          AM_CONDITIONAL(HAVE_LIBRPM, true)
12 -          AC_DEFINE(HAVE_LIBRPM,1,[Have librpm]),
13 -         AM_CONDITIONAL(HAVE_LIBRPM, false))],
14 -         AM_CONDITIONAL(HAVE_LIBRPM, false))
15 +PKG_CHECK_MODULES(RPM, rpm,
16 +                 AM_CONDITIONAL(HAVE_LIBRPM, true)
17 +                 AC_DEFINE([HAVE_LIBRPM],[1], "RPM..."),
18 +                 AM_CONDITIONAL(HAVE_LIBRPM, false)
19 +                 )
20  
21  AC_CHECK_LIB(mpeg2, mpeg2_init,
22          [AC_CHECK_HEADERS([mpeg2dec/mpeg2.h],
23 --- libextractor-1.0.1/src/plugins/Makefile.am.orig     2012-12-01 16:30:21.501145332 +0100
24 +++ libextractor-1.0.1/src/plugins/Makefile.am  2012-12-01 16:50:19.671120357 +0100
25 @@ -1,6 +1,7 @@
26  INCLUDES = \
27   -I$(top_srcdir)/src/include \
28 - -I$(top_srcdir)/src/common 
29 + -I$(top_srcdir)/src/common \
30 + $(RPM_CFLAGS)
31  
32  
33  # install plugins under:
34 --- libextractor-1.3/src/plugins/rpm_extractor.c.orig   2013-11-28 22:16:45.000000000 +0100
35 +++ libextractor-1.3/src/plugins/rpm_extractor.c        2013-12-26 20:29:36.083607762 +0100
36 @@ -25,9 +25,10 @@
37  #include "platform.h"
38  #include "extractor.h"
39  #include <stdint.h>
40 -#include <rpm/rpmlib.h>
41 -#include <rpm/rpmts.h>
42 -#include <rpm/rpmlog.h>
43 +#include <rpmcli.h>
44 +#include <rpmio.h>
45 +#include <rpmts.h>
46 +#include <rpmlog.h>
47  #if SOMEBSD
48  #include <pthread_np.h>
49  #else
50 @@ -128,6 +129,7 @@ pipe_feeder (void * args)
51   * LOG callback called by librpm.  Does nothing, we
52   * just need this to override the default behavior.
53   */
54 +#ifdef RPMLOG_DEFAULT
55  static int
56  discard_log_callback (rpmlogRec rec,
57                       void *ctx)
58 @@ -135,6 +137,9 @@ discard_log_callback (rpmlogRec rec,
59    /* do nothing! */
60    return 0;
61  }
62 +#else
63 +static void discard_log_callback() { }
64 +#endif
65  
66  
67  /**
68 @@ -240,6 +245,12 @@ static struct Matches tests[] = {
69    {0, 0}
70  };
71  
72 +#ifndef H_RPMTAG
73 +static int headerNext(HeaderIterator hi, HE_t he, /*@unused@*/ unsigned int flags)
74 +{
75 +  return headerNextIterator(hi, &he->tag, &he->t, &he->p.ptr, &he->c);
76 +}
77 +#endif
78  
79  /**
80   * Main entry method for the 'application/x-rpm' extraction plugin.
81 @@ -255,7 +266,7 @@ EXTRACTOR_rpm_extract_method (struct EXT
82    const char *str;
83    Header hdr;
84    HeaderIterator hi;
85 -  rpmtd p;
86 +  HE_t p;
87    int i;
88    FD_t fdi;
89    rpmRC rc;
90 @@ -286,7 +297,11 @@ EXTRACTOR_rpm_extract_method (struct EXT
91        CLOSE (parg.pi[1]);
92        return;
93      }
94 +#ifdef RPMLOG_DEFAULT
95    rpmlogSetCallback (&discard_log_callback, NULL);
96 +#else
97 +  rpmlogSetCallback (&discard_log_callback);
98 +#endif
99    fdi = fdDup (parg.pi[0]);
100    ts = rpmtsCreate();
101    rc = rpmReadPackageFile (ts, fdi, "GNU libextractor", &hdr);
102 @@ -314,19 +329,38 @@ EXTRACTOR_rpm_extract_method (struct EXT
103        goto END;
104      }
105    pthread_mutex_unlock (&parg.lock);
106 +#ifdef H_RPMTAG
107 +  hi = headerInit (hdr);
108 +#else
109    hi = headerInitIterator (hdr);
110 -  p = rpmtdNew ();
111 -  while (1 == headerNext (hi, p))
112 +#endif
113 +  p = (HE_t)memset(alloca(sizeof(*p)), 0, sizeof(*p));
114 +  while (1 == headerNext (hi, p, 0))
115      for (i = 0; 0 != tests[i].rtype; i++)
116        {
117         if (tests[i].rtype != p->tag)
118           continue;
119 -       switch (p->type)
120 +       switch (p->t)
121           {
122 +         case RPM_STRING_TYPE:
123 +           {
124 +               pthread_mutex_lock (&parg.lock);
125 +               if (0 != ec->proc (ec->cls, 
126 +                                "rpm",
127 +                                tests[i].type,
128 +                                EXTRACTOR_METAFORMAT_UTF8,
129 +                                "text/plain",
130 +                                p->p.str,
131 +                                strlen (p->p.str) +1)) {
132 +                 pthread_mutex_unlock (&parg.lock);
133 +                 return;
134 +               }
135 +               pthread_mutex_unlock (&parg.lock);
136 +           }
137 +           break;
138           case RPM_STRING_ARRAY_TYPE:
139           case RPM_I18NSTRING_TYPE:
140 -         case RPM_STRING_TYPE:
141 -           while (NULL != (str = rpmtdNextString (p)))
142 +           for(p->ix = 0; p->ix < p->c; p->ix++) 
143               {
144                 pthread_mutex_lock (&parg.lock);
145                 if (0 != ec->proc (ec->cls,
146 @@ -334,8 +368,8 @@ EXTRACTOR_rpm_extract_method (struct EXT
147                                    tests[i].type,
148                                    EXTRACTOR_METAFORMAT_UTF8,
149                                    "text/plain",
150 -                                  str,
151 -                                  strlen (str) + 1))
152 +                                  p->p.argv[p->ix],
153 +                                  strlen (p->p.argv[p->ix]) + 1))
154  
155                   {
156                     pthread_mutex_unlock (&parg.lock);
157 @@ -344,12 +378,12 @@ EXTRACTOR_rpm_extract_method (struct EXT
158                 pthread_mutex_unlock (&parg.lock);
159               }
160             break;
161 -         case RPM_INT32_TYPE:
162 +         case RPM_UINT32_TYPE:
163             {
164               if (p->tag == RPMTAG_BUILDTIME)
165                 {
166                   char tmp[30];
167 -                 uint32_t *v = rpmtdNextUint32 (p);
168 +                 uint32_t *v = p->p.ui32p;
169                   time_t tp = (time_t) *v;
170  
171                   ctime_r (&tp, tmp);
172 @@ -371,7 +405,7 @@ EXTRACTOR_rpm_extract_method (struct EXT
173               else
174                 {
175                   char tmp[14];
176 -                 uint32_t *s = rpmtdNextUint32 (p);
177 +                 uint32_t *s = p->p.ui32p;
178  
179                   snprintf (tmp,
180                             sizeof (tmp),
181 @@ -398,7 +432,6 @@ EXTRACTOR_rpm_extract_method (struct EXT
182           }
183        }
184   CLEANUP:
185 -  rpmtdFree (p);
186    headerFreeIterator (hi);
187  
188   END:
This page took 0.11203 seconds and 3 git commands to generate.