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