]> git.pld-linux.org Git - packages/poldek.git/blob - poldek-rpm54.patch
- add rpm 5.4.x support
[packages/poldek.git] / poldek-rpm54.patch
1 From 8cf145343137ceee3a4355ab02e2160481efb5c1 Mon Sep 17 00:00:00 2001
2 From: Marcin Banasiak <marcin.banasiak@gmail.com>
3 Date: Wed, 29 Aug 2012 20:52:58 +0200
4 Subject: [PATCH 1/5] Drop support for ancient rpm versions
5
6 ---
7  configure.ac           |   8 ++-
8  pm/rpm/pm_rpm.h        |   4 ++
9  pm/rpm/rpm.c           |   5 +-
10  pm/rpm/rpmdb_depdirs.c |   3 -
11  pm/rpm/rpmdb_it.c      | 164 ++++++++-----------------------------------------
12  pm/rpm/signature4.c    |  72 ----------------------
13  6 files changed, 36 insertions(+), 220 deletions(-)
14
15 diff --git a/configure.ac b/configure.ac
16 index 64eac04..5f14b64 100644
17 --- a/configure.ac
18 +++ b/configure.ac
19 @@ -79,6 +79,7 @@ if test -n "$GCC"; then
20    )
21  fi
22  
23 +PKG_PROG_PKG_CONFIG()
24  
25  PKG_CHECK_MODULES(CHECK, check >= 0.9.4, have_check=yes, have_check=no)
26   
27 @@ -196,7 +197,12 @@ AC_CHECK_HEADERS([sys/filio.h])
28  
29  dnl RH rpm needs this
30  CPPFLAGS="-I/usr/include/rpm $CPPFLAGS"
31 -AC_CHECK_HEADER([rpm/rpmlib.h],,AC_MSG_ERROR(["missing required rpmlib.h"]))
32 +AC_CHECK_HEADER([rpm/rpmdb.h],,AC_MSG_ERROR(["missing required rpmlib.h"]))
33 +
34 +AC_CHECK_TYPE([rpmmi],
35 +             [AC_DEFINE([HAVE_RPMMI], 1, [rpm with database iterator])],
36 +             [],
37 +             [[#include <rpm/rpmtypes.h>]])
38  
39  AC_MSG_CHECKING([for rpm 4.x])
40  #RPMDBI_PACKAGES
41 diff --git a/pm/rpm/pm_rpm.h b/pm/rpm/pm_rpm.h
42 index a34dd60..8c6a179 100644
43 --- a/pm/rpm/pm_rpm.h
44 +++ b/pm/rpm/pm_rpm.h
45 @@ -22,6 +22,10 @@
46  # include <rpm/rpmcb.h>
47  #endif
48  
49 +#ifdef HAVE_RPMMI
50 +# include <rpm/rpmtypes.h>
51 +#endif
52 +
53  #if HAVE_RPMDSRPMLIB
54  # include <rpm/rpmds.h>
55  #endif
56 diff --git a/pm/rpm/rpm.c b/pm/rpm/rpm.c
57 index 512a8ea..73275af 100644
58 --- a/pm/rpm/rpm.c
59 +++ b/pm/rpm/rpm.c
60 @@ -253,14 +253,11 @@ char *pm_rpm_dbpath(void *pm_rpm, char *path, size_t size)
61  
62  time_t pm_rpm_dbmtime(void *pm_rpm, const char *dbpath) 
63  {
64 -    const char *file = "packages.rpm";
65 +    const char *file = "Packages";
66      char path[PATH_MAX];
67      struct stat st;
68  
69      pm_rpm = pm_rpm;
70 -#ifdef HAVE_RPM_4_0
71 -    file = "Packages";
72 -#endif
73      
74      snprintf(path, sizeof(path), "%s/%s", dbpath, file);
75       
76 diff --git a/pm/rpm/rpmdb_depdirs.c b/pm/rpm/rpmdb_depdirs.c
77 index 4898958..9eab1bf 100644
78 --- a/pm/rpm/rpmdb_depdirs.c
79 +++ b/pm/rpm/rpmdb_depdirs.c
80 @@ -76,10 +76,7 @@ int pm_rpm_dbdepdirs(void *pm_rpm, const char *rootdir, const char *dbpath,
81      return -1;
82  #endif    
83      
84 -    index = "requirename.rpm";
85 -#ifdef HAVE_RPM_4_0
86      index = "Requirename";
87 -#endif
88  
89  #ifdef HAVE_RPM_5
90      dbtype = DB_BTREE; /* XXX: should be detected at runtime */
91 diff --git a/pm/rpm/rpmdb_it.c b/pm/rpm/rpmdb_it.c
92 index 3578977..37c7ef2 100644
93 --- a/pm/rpm/rpmdb_it.c
94 +++ b/pm/rpm/rpmdb_it.c
95 @@ -10,10 +10,6 @@
96    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
97  */
98  
99 -/*
100 -  $Id$
101 -*/
102 -
103  #ifdef HAVE_CONFIG_H
104  # include "config.h"
105  #endif
106 @@ -30,21 +26,16 @@
107  /* remeber! don't touch any member */
108  struct rpmdb_it {
109      int                  tag;
110 -#ifdef HAVE_RPM_4_0
111 -    rpmdbMatchIterator   mi;
112 +#ifdef HAVE_RPMMI
113 +    rpmmi                mi;
114  #else
115 -    dbiIndexSet          matches;
116 -    int                  i;
117 -    int                  recno;
118 -#endif
119 +    rpmdbMatchIterator   mi;
120 +#endif /* HAVE_RPMMI */
121      
122      struct pm_dbrec      dbrec;
123      rpmdb                db; 
124  };
125  
126 -
127 -
128 -#ifdef HAVE_RPM_4_0
129  static
130  int rpmdb_it_init(rpmdb db, struct rpmdb_it *it, int tag, const char *arg)
131  {
132 @@ -94,154 +85,50 @@ int rpmdb_it_init(rpmdb db, struct rpmdb_it *it, int tag, const char *arg)
133              break;
134      }
135      
136 -    
137      DBGF("%p, %p\n", it, db);
138      it->tag = tag;
139      it->db = db;
140 +#ifdef HAVE_RPMMI
141 +    it->mi = rpmmiInit(db, rpmtag, arg, argsize);
142 +    return rpmmiCount(it->mi);
143 +#else
144      it->mi = rpmdbInitIterator(db, rpmtag, arg, argsize);
145      return rpmdbGetIteratorCount(it->mi);
146 +#endif /* HAVE_RPMMI */
147  }
148  
149 -#else  /* HAVE_RPM_4_0 */
150 -/* Ancient rpm3 */
151 -static
152 -int rpmdb_it_init(rpmdb db, struct rpmdb_it *it, int tag, const char *arg) 
153 -{
154 -    int rc, n;
155 -    
156 -    it->matches.count = 0;
157 -    it->matches.recs = NULL;
158 -    it->i = 0;
159 -    it->recno = 0;
160 -    it->db = db;
161 -    it->dbrec.hdr = NULL;
162 -    it->dbrec.recno = 0;
163 -    it->tag = tag;
164 -    
165 -    switch (tag) {
166 -        case PMTAG_RECNO:
167 -            it->recno = rpmdbFirstRecNum(db);
168 -            if (recno == 0)
169 -                return 0;
170 -            if (recno < 0)
171 -                n_die("%d: invalid recno", recno);
172 -            break;
173 -            
174 -        case PMTAG_NAME:
175 -            rc = rpmdbFindPackage(db, arg, &it->matches);
176 -            break;
177 -            
178 -        case PMTAG_FILE:
179 -        case PMTAG_DIRNAME:
180 -            rc = rpmdbFindByFile(db, arg, &it->matches);
181 -            break;
182 -
183 -        case PMTAG_CAP:
184 -            rc = rpmdbFindByProvides(db, arg, &it->matches);
185 -            break;
186 -            
187 -        case PMTAG_REQ:
188 -            rc = rpmdbFindByRequiredBy(db, arg, &it->matches);
189 -            break;
190 -            
191 -        case PMTAG_CNFL:
192 -            rc = rpmdbFindByConflicts(db, arg, &it->matches);
193 -            break;
194 -            
195 -        case PMTAG_OBSL:
196 -            n_die("missing feature"); /* don't remember in fact */
197 -            rc = rpmdbFindByConflicts(db, arg, &it->matches);
198 -            break;
199 -            
200 -        default:
201 -            n_assert(0);
202 -    }
203 -    if (rc < 0)
204 -        n_die("rpm database error");
205 -    
206 -    else if (rc != 0) {
207 -        n = 0;
208 -        it->matches.count = 0;
209 -        
210 -    } else if (rc == 0)
211 -        n = it->matches.count;
212 -
213 -    return n;
214 -}
215 -#endif /* HAVE_RPM_4_0 */
216 -
217 -
218  static
219  void rpmdb_it_destroy(struct rpmdb_it *it) 
220  {
221 -
222 -#ifdef HAVE_RPM_4_0
223 +#ifdef HAVE_RPMMI
224      rpmdbFreeIterator(it->mi);
225 +#else
226 +    rpmmiFree(it->mi);
227 +#endif /* HAVE_RPMMI */
228      it->mi = NULL;
229      it->dbrec.hdr = NULL;
230      DBGF("%p, %p\n", it, it->db);
231 -#else
232 -    if (it->dbrec.hdr != NULL) {
233 -        headerFree(it->dbrec.hdr);
234 -        it->dbrec.hdr = NULL;
235 -    }
236 -    
237 -    it->db = NULL;
238 -    if (it->tag != PMTAG_RECNO)
239 -        dbiFreeIndexRecord(it->matches);
240 -    it->matches.count = 0;
241 -    it->matches.recs = NULL;
242 -#endif    
243  }
244  
245  
246  static
247  const struct pm_dbrec *rpmdb_it_get(struct rpmdb_it *it)
248  {
249 -#ifdef HAVE_RPM_4_0
250 -    it->dbrec.hdr = rpmdbNextIterator(it->mi);
251 -    DBGF("%p, %p\n", it, it->db);
252 +#ifdef HAVE_RPMMI
253 +    it->dbrec.hdr = rpmmiNext(it->mi);
254      
255      if (it->dbrec.hdr == NULL)
256          return NULL;
257  
258 -    it->dbrec.recno = rpmdbGetIteratorOffset(it->mi);
259 +    it->dbrec.recno = rpmmiInstance(it->mi);
260  #else
261 +    it->dbrec.hdr = rpmdbNextIterator(it->mi);
262      
263 -    if (it->tag == PMTAG_RECNO) {
264 -        if (it->recno <= 0)
265 -            return NULL;
266 -        
267 -        n_assert(it->recno);
268 -        it->dbrec.recno = it->recno;
269 -        it->dbrec.hdr = rpmdbGetRecord(it->db, it->recno);
270 -        it->recno = rpmdbNextRecNum(db, it->recno);
271 -        it->i++;
272 -        return &it->dbrec;
273 -    }
274 -
275 -    if (it->i == it->matches.count) {
276 -        if (it->dbrec.hdr != NULL) 
277 -            headerFree(it->dbrec.hdr);
278 -        it->dbrec.hdr = NULL;
279 -        it->i++;
280 +    if (it->dbrec.hdr == NULL)
281          return NULL;
282 -    }
283  
284 -    if (it->i > it->matches.count)
285 -        n_die("rpm database error?");
286 -
287 -    if (it->dbrec.hdr != NULL)
288 -        headerFree(it->dbrec.hdr);
289 -    
290 -    it->dbrec.recno = it->matches.recs[it->i].recOffset;
291 -    it->dbrec.hdr = rpmdbGetRecord(it->db, it->dbrec.recno);
292 -    it->i++;
293 -    
294 -    if (it->dbrec.hdr == NULL)
295 -        n_die("rpm database error?");
296 -    
297 -#endif /* HAVE_RPM_4_0 */
298 +    it->dbrec.recno = rpmdbGetIteratorOffset(it->mi);
299 +#endif /* HAVE_RPMMI */
300  
301      return &it->dbrec;
302  }
303 @@ -249,14 +136,11 @@ const struct pm_dbrec *rpmdb_it_get(struct rpmdb_it *it)
304  static
305  int rpmdb_it_get_count(struct rpmdb_it *it)
306  {
307 -#ifdef HAVE_RPM_4_0
308 -    return rpmdbGetIteratorCount(it->mi);
309 +#ifdef HAVE_RPMMI
310 +    return rpmmiCount(it->mi);
311  #else
312 -    if (it->tag == PMTAG_RECNO)
313 -        return it->recno > 0 ? 1000:0; /* TODO howto do dbcount() with rpm3 */
314 -        
315 -    return it->matches.count;
316 -#endif /* HAVE_RPM_4_0 */
317 +    return rpmdbGetIteratorCount(it->mi);
318 +#endif /* HAVE_RPMMI */
319  }
320  
321  static 
322 diff --git a/pm/rpm/signature4.c b/pm/rpm/signature4.c
323 index e69970a..7321e3c 100644
324 --- a/pm/rpm/signature4.c
325 +++ b/pm/rpm/signature4.c
326 @@ -10,10 +10,6 @@
327    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
328  */
329  
330 -/*
331 -  $Id$
332 -*/
333 -
334  #ifdef HAVE_CONFIG_H
335  # include "config.h"
336  #endif
337 @@ -66,17 +62,6 @@ static int rpm_read_signature(FD_t fd, Header *sighp, int sig_type)
338      return 0;
339  }
340      
341 -/* rpmlib's rpmCheckSig reports success when GPG signature is missing,
342 -   so it is useless for real sig verification */
343 -#if !defined HAVE_RPM_4_0
344 -static int rpm_signatures(const char *path, unsigned *signature_flags, FD_t *fd)
345 -{
346 -    *signature_flags = VRFYSIG_DGST;
347 -    path = path;
348 -    return 1;
349 -}
350 -
351 -#else  /* 4.x series  */
352  static int rpm_signatures(const char *path, unsigned *signature_flags, FD_t *fd) 
353  {
354      unsigned        flags;
355 @@ -161,7 +146,6 @@ static int rpm_signatures(const char *path, unsigned *signature_flags, FD_t *fd)
356      *signature_flags = flags;
357      return 1;
358  }
359 -#endif 
360  
361  
362  
363 @@ -279,7 +263,6 @@ int do_verify_signature(const char *path, unsigned flags)
364  #endif
365  
366  
367 -#ifdef HAVE_RPM_4_0
368  static
369  int do_pm_rpm_verify_signature(void *pm_rpm, const char *path, unsigned flags) 
370  {
371 @@ -303,61 +286,6 @@ int do_pm_rpm_verify_signature(void *pm_rpm, const char *path, unsigned flags)
372      return do_verify_signature(path, rpmflags);
373  }
374  
375 -#else  /* HAVE_RPMCHECKSIG */
376 -extern int pm_rpm_execrpm(const char *cmd, char *const argv[],
377 -                          int ontty, int verbose_level);
378 -static
379 -int do_pm_rpm_verify_signature(void *pm_rpm, const char *path, unsigned flags) 
380 -{
381 -    struct pm_rpm *pm = pm_rpm;
382 -    char **argv;
383 -    char *cmd;
384 -    int i, n, nopts = 0;
385 -
386 -    pm_rpm_setup_commands(pm);
387 -    
388 -    n = 32;
389 -    argv = alloca((n + 1) * sizeof(*argv));
390 -    argv[n] = NULL;
391 -    n = 0;
392 -    
393 -    cmd = pm->rpm;
394 -    argv[n++] = n_basenam(pm->rpm);
395 -    argv[n++] = "-K";
396 -
397 -    nopts = n;
398 -    
399 -    if ((flags & PKGVERIFY_GPG) == 0)
400 -        argv[n++] = "--nogpg";
401 -
402 -    if ((flags & PKGVERIFY_PGP) == 0)
403 -        argv[n++] = "--nopgp";
404 -    
405 -    
406 -    if ((flags & PKGVERIFY_MD) == 0) {
407 -        argv[n++] = "--nomd5";
408 -    }
409 -    n_assert(n > nopts);        /* any PKGVERIFY_* given? */
410 -    
411 -    argv[n++] = (char*)path;
412 -    nopts = n;
413 -    argv[n++] = NULL;
414 -    
415 -    if (verbose > 1) {
416 -        char buf[1024], *p;
417 -        p = buf;
418 -        
419 -        for (i=0; i < nopts; i++) 
420 -            p += n_snprintf(p, &buf[sizeof(buf) - 1] - p, " %s", argv[i]);
421 -        *p = '\0';
422 -        msgn(1, _("Executing%s..."), buf);
423 -    }
424 -
425 -    return pm_rpm_execrpm(cmd, argv, 0, 4) == 0;
426 -}
427 -
428 -#endif /* HAVE_RPMCHECKSIG */
429 -
430  extern int pm_rpm_verbose;
431  int pm_rpm_verify_signature(void *pm_rpm, const char *path, unsigned flags) 
432  {
433 -- 
434 1.7.11.2
435
436
437 From dceacab14dec5f5f8a2cfeb426edee7191b0f578 Mon Sep 17 00:00:00 2001
438 From: Marcin Banasiak <marcin.banasiak@gmail.com>
439 Date: Fri, 31 Aug 2012 14:27:41 +0200
440 Subject: [PATCH 2/5] Fix build with rpm 5.4 (lp#1042200)
441
442 Currently poldek builds with rpm 5.4 and seems to work, but is not well
443 tested and some regressions may still occur.
444 ---
445  pkgdir/dir/dir.c    |  1 +
446  pkgroup.c           |  4 ----
447  pm/rpm/misc.c       | 17 +++++++++++++++--
448  pm/rpm/pm_rpm.h     | 22 ++++++++++++++++------
449  pm/rpm/rpm_pkg_ld.c |  1 -
450  pm/rpm/rpmdb_it.c   |  4 ++--
451  pm/rpm/rpmhdr.c     | 15 +++++++++++----
452  pm/rpm/rpmvercmp.c  | 29 +++++++++++++++++++++++++++--
453  pm/rpm/signature5.c |  6 +++---
454  9 files changed, 75 insertions(+), 24 deletions(-)
455
456 diff --git a/pkgdir/dir/dir.c b/pkgdir/dir/dir.c
457 index cfe16cb..69d9eef 100644
458 --- a/pkgdir/dir/dir.c
459 +++ b/pkgdir/dir/dir.c
460 @@ -18,6 +18,7 @@
461  # include "config.h"
462  #endif
463  
464 +#include <dirent.h>
465  #include <limits.h>
466  #include <stdint.h>
467  #include <stdio.h>
468 diff --git a/pkgroup.c b/pkgroup.c
469 index 21b29c5..62f124e 100644
470 --- a/pkgroup.c
471 +++ b/pkgroup.c
472 @@ -6,9 +6,6 @@
473    the Free Software Foundation (see file COPYING for details).
474  */
475  
476 -/*
477 -  $Id$
478 -*/
479  #ifdef HAVE_CONFIG_H
480  # include "config.h"
481  #endif
482 @@ -19,7 +16,6 @@
483  #include <string.h>
484  
485  #include <trurl/trurl.h>
486 -#include <rpm/rpmlib.h>
487  
488  #define ENABLE_TRACE 0
489  
490 diff --git a/pm/rpm/misc.c b/pm/rpm/misc.c
491 index 613ac1b..89ef808 100644
492 --- a/pm/rpm/misc.c
493 +++ b/pm/rpm/misc.c
494 @@ -21,18 +21,25 @@
495  #include <ctype.h>
496  #include <stdint.h>
497  #include <string.h>
498 +#include <stdio.h>
499  #include <time.h> /* rpmts.h with defined _RPMTS_INTERNAL needs ctime() */
500  
501  #include <trurl/nassert.h>
502  #include <trurl/nstr.h>
503  
504 -#include <rpm/rpmlib.h>
505 +#ifdef HAVE_RPM_5
506 +# include <rpm/rpmtypes.h>
507 +# include <rpm/rpmtag.h>
508 +# include <rpm/rpmio.h>
509 +#else
510 +# include <rpm/rpmlib.h>
511 +#endif
512  #include <rpm/rpmte.h>
513  #if HAVE_RPM_4_1
514  # define _RPMPRCO_INTERNAL
515  # include <rpm/rpmds.h>
516  #endif
517 -#define _RPMTS_INTERNAL
518 +//#define _RPMTS_INTERNAL
519  #include <rpm/rpmts.h>
520  
521  #include "capreq.h"
522 @@ -224,6 +231,8 @@ static int rpmioaccess_satisfies(const struct capreq *req)
523      return rc;
524  }
525  
526 +
527 +#if 0
528  static int rpmdiskspace_satisfies(const struct capreq *req)
529  {
530      const char *name = NULL;
531 @@ -307,6 +316,8 @@ static int rpmdiskspace_satisfies(const struct capreq *req)
532      
533      return rc;
534  }
535 +#endif
536 +
537  
538  int pm_rpm_satisfies(void *pm_rpm, const struct capreq *req)
539  {
540 @@ -320,8 +331,10 @@ int pm_rpm_satisfies(void *pm_rpm, const struct capreq *req)
541      if (rpmioaccess_satisfies(req))
542          return 1;
543  
544 +#if 0
545      if (rpmdiskspace_satisfies(req))
546         return 1;
547 +#endif
548  
549      if (pm->caps == NULL)
550          if ((pm->caps = load_internal_caps(pm_rpm)) == NULL)
551 diff --git a/pm/rpm/pm_rpm.h b/pm/rpm/pm_rpm.h
552 index 8c6a179..2494bf0 100644
553 --- a/pm/rpm/pm_rpm.h
554 +++ b/pm/rpm/pm_rpm.h
555 @@ -16,16 +16,21 @@
556  #include <sys/time.h>           /* timeval */
557  
558  #define _RPMPRCO_INTERNAL 1 /* see pm_rpmdsSysinfo */
559 -#include <rpm/rpmlib.h>
560 +
561 +#ifdef HAVE_RPM_5
562 +# include <rpm/rpmtypes.h>
563 +# include <rpm/rpmiotypes.h>
564 +# include <rpm/rpmtag.h>
565 +# include <rpm/pkgio.h>
566 +#else
567 +# include <rpm/rpmlib.h>
568 +# include <rpm/rpmurl.h>
569 +#endif /* HAVE_RPM_5 */
570  
571  #ifdef HAVE_RPM_RPMCB_H
572  # include <rpm/rpmcb.h>
573  #endif
574  
575 -#ifdef HAVE_RPMMI
576 -# include <rpm/rpmtypes.h>
577 -#endif
578 -
579  #if HAVE_RPMDSRPMLIB
580  # include <rpm/rpmds.h>
581  #endif
582 @@ -45,7 +50,6 @@
583  # include <rpm/rpmdb.h>
584  #endif
585  
586 -#include <rpm/rpmurl.h>
587  #include <rpm/rpmmacro.h>
588  
589  #ifdef RPM_MAJOR_VERSION
590 @@ -56,6 +60,12 @@
591  # if PM_RPMVER(RPM_FORMAT_VERSION,RPM_MAJOR_VERSION,RPM_MINOR_VERSION) >= PM_RPMVER(5,0,0)
592  #  define HAVE_RPM_VERSION_GE_5 1
593  # endif
594 +#else
595 +# include <rpm/rpmversion.h>
596 +# if defined(RPMLIB_VERSION) && RPMLIB_VERSION >= RPMLIB_VERSION_ENCODE(5,0,r,0,0,_)
597 +#  define HAVE_RPM_VERSION_GE_4_4_8 1
598 +#  define HAVE_RPM_VERSION_GE_5 1
599 +# endif
600  #endif 
601  
602  
603 diff --git a/pm/rpm/rpm_pkg_ld.c b/pm/rpm/rpm_pkg_ld.c
604 index dbed6f6..8423a62 100644
605 --- a/pm/rpm/rpm_pkg_ld.c
606 +++ b/pm/rpm/rpm_pkg_ld.c
607 @@ -21,7 +21,6 @@
608  
609  #ifdef HAVE_RPM_RPMEVR_H
610  # define _RPMEVR_INTERNAL 1
611 -# include <rpm/rpmevr.h>
612  #endif
613  
614  #include "i18n.h"
615 diff --git a/pm/rpm/rpmdb_it.c b/pm/rpm/rpmdb_it.c
616 index 37c7ef2..059db46 100644
617 --- a/pm/rpm/rpmdb_it.c
618 +++ b/pm/rpm/rpmdb_it.c
619 @@ -101,9 +101,9 @@ static
620  void rpmdb_it_destroy(struct rpmdb_it *it) 
621  {
622  #ifdef HAVE_RPMMI
623 -    rpmdbFreeIterator(it->mi);
624 -#else
625      rpmmiFree(it->mi);
626 +#else
627 +    rpmdbFreeIterator(it->mi);
628  #endif /* HAVE_RPMMI */
629      it->mi = NULL;
630      it->dbrec.hdr = NULL;
631 diff --git a/pm/rpm/rpmhdr.c b/pm/rpm/rpmhdr.c
632 index 360a6d5..5989553 100644
633 --- a/pm/rpm/rpmhdr.c
634 +++ b/pm/rpm/rpmhdr.c
635 @@ -29,12 +29,14 @@
636  #include "pm_rpm.h"
637  
638  #if defined(HAVE_RPM_4_0_4) || defined(HAVE_RPM_VERSION_GE_4_4_8)           /* missing prototypes in public headers */
639 +#ifndef HAVE_RPM_5
640  int headerGetRawEntry(Header h, int_32 tag,
641                        /*@null@*/ /*@out@*/ hTYP_t type,
642                        /*@null@*/ /*@out@*/ hPTR_t * p, 
643                        /*@null@*/ /*@out@*/ hCNT_t c);
644  char ** headerGetLangs(Header h);
645  #endif
646 +#endif
647  
648  
649  int pm_rpmhdr_get_string(Header h, int32_t tag, char *value, int size)
650 @@ -122,8 +124,9 @@ int pm_rpmhdr_get_raw_entry(Header h, int32_t tag, void *buf, int32_t *cnt)
651          return 0;
652      }
653  #endif
654 -    
655 -    if (tag == RPMTAG_GROUP && type == RPM_STRING_TYPE) { /* build by old rpm */
656 +
657 +#ifndef HAVE_RPM_5
658 +    if (tag == RPMTAG_GROUP && type == RPM_STRING_TYPE) { // build by old rpm
659          char **g;
660         
661          n_assert(*cnt == 1);
662 @@ -133,7 +136,8 @@ int pm_rpmhdr_get_raw_entry(Header h, int32_t tag, void *buf, int32_t *cnt)
663          g[1] = NULL;
664          *(char ***)buf = g;
665      }
666 -    
667 +#endif
668 +
669      DBGF("%d type=%d, cnt=%d\n", tag, type, *cnt);
670      return 1;
671  }
672 @@ -147,7 +151,10 @@ int pm_rpmhdr_loadfdt(FD_t fdt, Header *hdr, const char *path)
673  #else 
674      rpmRC rpmrc;
675      rpmts ts = rpmtsCreate();
676 -    rpmtsSetVSFlags(ts, _RPMVSF_NODIGESTS | _RPMVSF_NOSIGNATURES);
677 +    rpmtsSetVSFlags(ts, RPMVSF_NOSHA1HEADER | RPMVSF_NOMD5HEADER |
678 +                        RPMVSF_NOSHA1 | RPMVSF_NOMD5 |
679 +                        RPMVSF_NODSAHEADER | RPMVSF_NORSAHEADER |
680 +                        RPMVSF_NODSA | RPMVSF_NODSA);
681      rpmrc = rpmReadPackageFile(ts, fdt, path, hdr);
682      switch (rpmrc) {
683          case RPMRC_NOTTRUSTED:
684 diff --git a/pm/rpm/rpmvercmp.c b/pm/rpm/rpmvercmp.c
685 index c40d903..968489a 100644
686 --- a/pm/rpm/rpmvercmp.c
687 +++ b/pm/rpm/rpmvercmp.c
688 @@ -1,13 +1,32 @@
689 +/*
690 +  Copyright (C) 2000 - 2008 Pawel A. Gajda <mis@pld-linux.org>
691 +  Copyright (C) 2010 - 2012 Marcin Banasiak <marcin.banasiak@gmail.com>
692 +
693 +  This program is free software; you can redistribute it and/or modify
694 +  it under the terms of the GNU General Public License, version 2 as
695 +  published by the Free Software Foundation (see file COPYING for details).
696 +
697 +  You should have received a copy of the GNU General Public License along
698 +  with this program; if not, write to the Free Software Foundation, Inc.,
699 +  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
700 +*/
701 +
702  #ifdef HAVE_CONFIG_H
703  # include "config.h"
704  #endif 
705  
706 +#include <stdint.h>
707  #include <stdio.h>
708  #include <stdlib.h>
709  
710 +#ifdef HAVE_RPM_5
711 +# include <rpm/rpmtag.h>
712 +#endif
713 +
714  #define _RPMEVR_INTERNAL
715  #include <rpm/rpmevr.h>
716  
717 +#ifndef HAVE_RPM_5
718  static void parse(const char *evrstr, EVR_t evr)
719  {
720      rpmEVRparse(evrstr, evr);
721 @@ -20,6 +39,7 @@ static void parse(const char *evrstr, EVR_t evr)
722      if (evr->R == NULL)
723         evr->R = "0";
724  }
725 +#endif
726  
727  int main(int argc, char *argv[])
728  {
729 @@ -43,10 +63,15 @@ int main(int argc, char *argv[])
730  
731      evr1 = malloc(sizeof(struct EVR_s));
732      evr2 = malloc(sizeof(struct EVR_s));
733 -    
734 +
735 +#ifdef HAVE_RPM_5    
736 +    rpmEVRparse(v1, evr1);
737 +    rpmEVRparse(v2, evr2);
738 +#else
739      parse(v1, evr1);
740      parse(v2, evr2);
741 -    
742 +#endif
743 +
744      cmprc = rpmEVRcompare(evr1, evr2);
745      
746      printf("%s %s %s\n", v1, cmprc == 0 ?  "==" : cmprc > 0 ? ">" : "<", v2);
747 diff --git a/pm/rpm/signature5.c b/pm/rpm/signature5.c
748 index e954fa5..ac1f9e4 100644
749 --- a/pm/rpm/signature5.c
750 +++ b/pm/rpm/signature5.c
751 @@ -18,7 +18,7 @@
752  # include "config.h"
753  #endif
754  
755 -#ifndef HAVE_RPMPKGREAD          /* rpm 5.x */
756 +#ifndef HAVE_RPM_5          /* rpm 5.x */
757  # error "not rpm 5.x"
758  #endif
759  
760 @@ -31,10 +31,10 @@
761  #include <sys/stat.h>
762  #include <fcntl.h>
763  
764 +#include <rpm/rpmtypes.h>
765 +#include <rpm/rpmtag.h>
766  #include <rpm/rpmcb.h>
767 -#include <rpm/rpmlib.h>
768  #include <rpm/rpmio.h>
769 -#include <rpm/rpmurl.h>
770  #include <rpm/rpmmacro.h>
771  
772  #include <rpm/rpmts.h>
773 -- 
774 1.7.11.2
775
776
777 From 9e4fe82da2df9b43b22a2bf36f2da69bb3238e87 Mon Sep 17 00:00:00 2001
778 From: Marcin Banasiak <marcin.banasiak@gmail.com>
779 Date: Fri, 31 Aug 2012 14:44:09 +0200
780 Subject: [PATCH 3/5] Drop support for diskspace()
781
782 It was not a good idea to add support for diskspace() dependency in
783 poldek, which, I think, is designed for BuildRequires in spec files.
784 Package install size can be measured using RPMTAG_SIZE, so I see no
785 point in using diskspace() for this purpose.
786 ---
787  pm/rpm/misc.c | 102 +---------------------------------------------------------
788  1 file changed, 1 insertion(+), 101 deletions(-)
789
790 diff --git a/pm/rpm/misc.c b/pm/rpm/misc.c
791 index 89ef808..8a5c1bf 100644
792 --- a/pm/rpm/misc.c
793 +++ b/pm/rpm/misc.c
794 @@ -10,10 +10,6 @@
795    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
796  */
797  
798 -/*
799 -  $Id$
800 -*/
801 -
802  #ifdef HAVE_CONFIG_H
803  # include "config.h"
804  #endif
805 @@ -22,7 +18,6 @@
806  #include <stdint.h>
807  #include <string.h>
808  #include <stdio.h>
809 -#include <time.h> /* rpmts.h with defined _RPMTS_INTERNAL needs ctime() */
810  
811  #include <trurl/nassert.h>
812  #include <trurl/nstr.h>
813 @@ -34,13 +29,11 @@
814  #else
815  # include <rpm/rpmlib.h>
816  #endif
817 -#include <rpm/rpmte.h>
818 +
819  #if HAVE_RPM_4_1
820  # define _RPMPRCO_INTERNAL
821  # include <rpm/rpmds.h>
822  #endif
823 -//#define _RPMTS_INTERNAL
824 -#include <rpm/rpmts.h>
825  
826  #include "capreq.h"
827  #include "i18n.h"
828 @@ -231,94 +224,6 @@ static int rpmioaccess_satisfies(const struct capreq *req)
829      return rc;
830  }
831  
832 -
833 -#if 0
834 -static int rpmdiskspace_satisfies(const struct capreq *req)
835 -{
836 -    const char *name = NULL;
837 -    char *s, *e;
838 -    int rc = 0;
839 -    
840 -    name = capreq_name(req);
841 -        
842 -    if (strncmp(name, "diskspace(", sizeof("diskspace(")-1) == 0 &&
843 -       (e = strchr(name, ')')) != NULL) {
844 -       const char **fs = NULL;
845 -       char path[PATH_MAX];
846 -       rpmts ts;
847 -       rpmDiskSpaceInfo dsi = NULL;
848 -       int nfs = 0, pathlen, longest = 0;
849 -       
850 -       /* extract path */
851 -       s = strchr(name, '(');
852 -       n_strncpy(path, s+1, e-s);
853 -       pathlen = strlen(path);
854 -       
855 -       ts = rpmtsCreate();
856 -       
857 -       /* code copied from lib/depends.c */
858 -       rpmtsInitDSI(ts);
859 -       fs = ts->filesystems;
860 -       nfs = ts->filesystemCount;
861 -       
862 -       if (fs) {
863 -           int i;
864 -           
865 -           for (i = 0; i < nfs; i++) {
866 -               int fslen = strlen(fs[i]);
867 -               
868 -               if (fslen > pathlen)
869 -                   continue;
870 -               
871 -               if (strncmp(fs[i], path, fslen))
872 -                   continue;
873 -               
874 -               if (fslen > 1 && path[fslen] != '/' && path[fslen] != '\0')
875 -                   continue;
876 -               
877 -               if (fslen < longest)
878 -                   continue;
879 -               
880 -               longest = fslen;
881 -               dsi = ts->dsi + i;
882 -           }
883 -           
884 -           if (dsi) {
885 -               char *end = NULL;
886 -               long long needed = strtoll(capreq_ver(req), &end, 0);           
887 -               int x;
888 -               
889 -               if (end && *end) {
890 -                   if (strchr("Gg", end[0]) && strchr("Bb", end[1]) && !end[2])
891 -                       needed *= 1024 * 1024 * 1024;
892 -                   if (strchr("Mm", end[0]) && strchr("Bb", end[1]) && !end[2])
893 -                       needed *= 1024 * 1024;
894 -                   if (strchr("Kk", end[0]) && strchr("Bb", end[1]) && !end[2])
895 -                       needed *= 1024;
896 -               } else {
897 -                   /* assume Mb if no units given */
898 -                   needed *= 1024 * 1024;
899 -               }
900 -
901 -               needed = BLOCK_ROUND(needed, dsi->f_bsize);
902 -               x = (dsi->f_bavail - needed);
903 -
904 -               if ((req->cr_relflags & REL_LT) && x < 0)
905 -                   rc = 1;
906 -               else if ((req->cr_relflags & REL_GT) && x > 0)
907 -                   rc = 1;
908 -               else if ((req->cr_relflags & REL_EQ) && x == 0)
909 -                   rc = 1;
910 -           }
911 -       }       
912 -       rpmtsFree(ts);
913 -    }
914 -    
915 -    return rc;
916 -}
917 -#endif
918 -
919 -
920  int pm_rpm_satisfies(void *pm_rpm, const struct capreq *req)
921  {
922      struct pm_rpm *pm = pm_rpm;
923 @@ -331,11 +236,6 @@ int pm_rpm_satisfies(void *pm_rpm, const struct capreq *req)
924      if (rpmioaccess_satisfies(req))
925          return 1;
926  
927 -#if 0
928 -    if (rpmdiskspace_satisfies(req))
929 -       return 1;
930 -#endif
931 -
932      if (pm->caps == NULL)
933          if ((pm->caps = load_internal_caps(pm_rpm)) == NULL)
934              return 0;
935 -- 
936 1.7.11.2
937
938
939 From ec43fec423b9e577d7b5698185fb3b993dab57ed Mon Sep 17 00:00:00 2001
940 From: Marcin Banasiak <marcin.banasiak@gmail.com>
941 Date: Fri, 31 Aug 2012 15:48:52 +0200
942 Subject: [PATCH 4/5] Adjust autogen.sh and make snap for git
943
944 ---
945  Makefile.extra | 26 ++++++++++----------------
946  autogen.sh     | 13 +++----------
947  2 files changed, 13 insertions(+), 26 deletions(-)
948
949 diff --git a/Makefile.extra b/Makefile.extra
950 index 2c97511..9debaa1 100644
951 --- a/Makefile.extra
952 +++ b/Makefile.extra
953 @@ -1,17 +1,11 @@
954 -# $Id$
955 -
956  PROJ_DIR=$(shell pwd)
957  
958  copylibs:
959 -       ./getlib.sh trurlib copy
960 -       ./getlib.sh tndb copy
961 -
962 -removelibs:
963 -       ./getlib.sh trurlib link
964 -       ./getlib.sh tndb link
965 +       git submodule init
966 +       git submodule update
967  
968 -tarball: copylibs dist removelibs
969 -tarball-bz2: copylibs dist-bzip2 removelibs
970 +tarball: copylibs dist
971 +tarball-bz2: copylibs dist-bzip2
972  
973  rpm-package: tarball-bz2
974         rpmbuild -tb $(distdir).tar.bz2
975 @@ -50,21 +44,21 @@ backup:
976  arch : mclean backup 
977  
978  POTFILES_in:
979 -       -rm -f poldek-cvs*
980 +       -rm -f poldek-git*
981         -find . -type f -name \*.c | egrep -v '(poldek-.*/|Cellar/|intl/|trurlib/|tndb/|python/|tests/|conf_sections.c)'  | sed 's|^\./||' | LC_ALL=C sort > po/POTFILES.in
982  
983  misarch: mclean
984         $(MAKE) -C . backup cparch=1 backupdir=/z
985  
986  snap: tarball-bz2
987 -       @dts=`date +%Y%m%d.%H` && rm -rf $(PACKAGE)-cvs$$dts* && \
988 +       @dts=`date +%Y%m%d.%H` && rm -rf $(PACKAGE)-git$$dts* && \
989         tar xpjf $(distdir).tar.bz2 && \
990         echo "$$dts" > $(distdir)/0_THIS_IS_SNAPSHOT && \
991          perl -pi -e "s/VERSION_STATUS=.+$$/VERSION_STATUS=\"snap$$dts\"/" $(distdir)/configure $(distdir)/configure.in; \
992 -       mv -f $(distdir) $(PACKAGE)-$(VERSION)-cvs$$dts && \
993 -       tar cpjf $(PACKAGE)-$(VERSION)-cvs$$dts.tar.bz2 $(PACKAGE)-$(VERSION)-cvs$$dts && \
994 -       rm -rf $(PACKAGE)-$(VERSION)-cvs$$dts && \
995 -       echo "$(PACKAGE)-$(VERSION)-cvs$$dts.tar.bz2"
996 +       mv -f $(distdir) $(PACKAGE)-$(VERSION)-git$$dts && \
997 +       tar cpjf $(PACKAGE)-$(VERSION)-git$$dts.tar.bz2 $(PACKAGE)-$(VERSION)-git$$dts && \
998 +       rm -rf $(PACKAGE)-$(VERSION)-git$$dts && \
999 +       echo "$(PACKAGE)-$(VERSION)-git$$dts.tar.bz2"
1000  
1001  snap-rpm-package: snap
1002                 dts=`date +%Y%m%d.%H` && echo $$dts && ls -l $(PACKAGE)-$(VERSION)-cvs$$dts.tar.bz2 &&\
1003 diff --git a/autogen.sh b/autogen.sh
1004 index 6ec65b6..7248be0 100755
1005 --- a/autogen.sh
1006 +++ b/autogen.sh
1007 @@ -1,5 +1,4 @@
1008  #!/bin/sh
1009 -# $Id$
1010  
1011  if [ ! -f capreq.h ]; then
1012      cd `dirname $0`;
1013 @@ -19,16 +18,10 @@ runcmd () {
1014  }
1015  
1016  CONFOPTS="--enable-maintainer-mode --enable-compile-warnings"
1017 -
1018 -getlib_mode="link"
1019 -if [ -n "$1" -a "$1" = "makedist" ]; then
1020 -    rm -f trurlib tndb
1021 -    getlib_mode="cp"
1022 -    shift
1023 -fi
1024  CONFOPTS="$CONFOPTS $@"
1025 -runcmd ./getlib.sh trurlib $getlib_mode
1026 -runcmd ./getlib.sh tndb    $getlib_mode
1027 +
1028 +runcmd git submodule init
1029 +runcmd git submodule update
1030  
1031  # generate po/POTFILES.in
1032  make -f Makefile.extra POTFILES_in
1033 -- 
1034 1.7.11.2
1035
1036
1037 From c26ae4cfeb59d6529e8c8a0b545f88811ca14c58 Mon Sep 17 00:00:00 2001
1038 From: Marcin Banasiak <marcin.banasiak@gmail.com>
1039 Date: Fri, 31 Aug 2012 16:31:48 +0200
1040 Subject: [PATCH 5/5] rpm 5.x has RPMTAG_* in rpmtag.h
1041
1042 ---
1043  configure.ac | 65 +++++++++++++++++++++++++++++++++++-------------------------
1044  1 file changed, 38 insertions(+), 27 deletions(-)
1045
1046 diff --git a/configure.ac b/configure.ac
1047 index 5f14b64..1519149 100644
1048 --- a/configure.ac
1049 +++ b/configure.ac
1050 @@ -197,21 +197,15 @@ AC_CHECK_HEADERS([sys/filio.h])
1051  
1052  dnl RH rpm needs this
1053  CPPFLAGS="-I/usr/include/rpm $CPPFLAGS"
1054 -AC_CHECK_HEADER([rpm/rpmdb.h],,AC_MSG_ERROR(["missing required rpmlib.h"]))
1055 -
1056 -AC_CHECK_TYPE([rpmmi],
1057 -             [AC_DEFINE([HAVE_RPMMI], 1, [rpm with database iterator])],
1058 -             [],
1059 -             [[#include <rpm/rpmtypes.h>]])
1060 +AC_CHECK_HEADER([rpm/rpmdb.h], [], AC_MSG_ERROR(["missing required rpmdb.h"]))
1061  
1062  AC_MSG_CHECKING([for rpm 4.x])
1063 -#RPMDBI_PACKAGES
1064  AC_EGREP_CPP(yes,
1065 -     [#include <rpm/rpmlib.h>
1066 -      #ifdef RPMDBI_PACKAGES
1067 -       yes
1068 -      #endif
1069 -     ], is_rpm4=yes, is_rpm4=no)
1070 +    [#include <rpm/rpmlib.h>
1071 +     #ifdef RPMDBI_PACKAGES
1072 +       yes
1073 +     #endif
1074 +    ], is_rpm4=yes, is_rpm4=no)
1075  
1076  if test "${is_rpm4}." = "no." ; then
1077         AC_MSG_RESULT(no)
1078 @@ -242,17 +236,36 @@ else
1079                 [ #include <rpm/rpmlib.h>
1080                 ], have_tag_pubkeys=yes, have_tag_pubkeys=no)
1081  
1082 -       if test "${have_tag_pubkeys}." = "yes." ; then
1083 -               AC_DEFINE([HAVE_RPMTAG_PUBKEYS],1,["rpm with RPMTAG_PUBKEYS"])
1084 -       fi
1085 -
1086          AC_EGREP_CPP(RPMTAG_SUGGESTS,
1087                 [ #include <rpm/rpmlib.h>
1088                 ], have_tag_suggests=yes, have_tag_suggests=no)
1089 +fi
1090  
1091 -       if test "${have_tag_suggests}." = "yes." ; then
1092 -               AC_DEFINE([HAVE_RPMTAG_SUGGESTS],1,["rpm with RPMTAG_SUGGESTS support"])
1093 -       fi
1094 +AC_MSG_CHECKING([for rpm 5.x])
1095 +
1096 +PKG_CHECK_EXISTS([rpm >= 5.0], [is_rpm5=yes], [is_rpm5=no])
1097 +
1098 +if test "${is_rpm5}." = "yes."; then
1099 +    AC_MSG_RESULT(yes)
1100 +    AC_EGREP_CPP(RPMTAG_PUBKEYS,
1101 +                [ #include <rpm/rpmtag.h>
1102 +                ], have_tag_pubkeys=yes, have_tag_pubkeys=no)
1103 +
1104 +    AC_EGREP_CPP(RPMTAG_SUGGESTS,
1105 +                [ #include <rpm/rpmtag.h>
1106 +                ], have_tag_suggests=yes, have_tag_suggests=no)
1107 +
1108 +    AC_DEFINE([HAVE_RPM_5], [1], [])
1109 +else
1110 +    AC_MSG_RESULT(no)
1111 +fi
1112 +
1113 +if test "${have_tag_pubkeys}." = "yes." ; then
1114 +    AC_DEFINE([HAVE_RPMTAG_PUBKEYS], 1, [rpm with RPMTAG_PUBKEYS])
1115 +fi
1116 +
1117 +if test "${have_tag_suggests}." = "yes." ; then
1118 +    AC_DEFINE([HAVE_RPMTAG_SUGGESTS], 1, [rpm with RPMTAG_SUGGESTS support])
1119  fi
1120  
1121  dnl Checks for libraries.
1122 @@ -361,22 +374,20 @@ AC_CHECK_FUNCS(_rpmvercmp)
1123  dnl rpm 4.4.9
1124  AC_CHECK_HEADERS([rpm/rpmevr.h])
1125  
1126 -dnl
1127  dnl rpm 5.x
1128  dnl fnpyKey provider
1129  AC_CHECK_HEADERS([rpm/rpmcb.h])
1130  AC_CHECK_FUNCS(rpmpkgRead)
1131 -AC_MSG_CHECKING([for rpm 5.x])
1132 -if test "$ac_cv_func_rpmpkgRead." != "yes."; then
1133 -     AC_MSG_RESULT(no)   
1134 -else
1135 -     AC_DEFINE([HAVE_RPM_5], [1], [])
1136 -     AC_MSG_RESULT(yes)
1137 -fi
1138 +
1139  AC_CHECK_FUNCS(headerNVR)     # removed since 5.0
1140  AC_CHECK_FUNCS(headerNEVRA)  
1141  AC_CHECK_FUNCS(rpmErrorString)
1142  
1143 +AC_CHECK_TYPE([rpmmi],
1144 +             [AC_DEFINE([HAVE_RPMMI], 1, [rpm with database iterator])],
1145 +             [],
1146 +             [[#include <rpm/rpmtypes.h>]])
1147 +
1148  dnl  - removed enum (not macro) HEADER_MAGIC_YES
1149  if test "${is_rpm4}." = "yes." ; then
1150     AC_EGREP_CPP(HEADER_MAGIC_YES,
1151 -- 
1152 1.7.11.2
1153
This page took 0.204352 seconds and 3 git commands to generate.