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