Skip Menu |

This queue is for tickets about the RPM2 CPAN distribution.

Report information
The Basics
Id: 41452
Status: resolved
Priority: 0/
Queue: RPM2

People
Owner: Nobody in particular
Requestors: matteo.corti [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.67
Fixed in: (no value)



Subject: Broken with RPM 4.6
RPM 4.6 contains serveral changes which break RPM2 gcc -std=gnu99 -c -I/usr/include/rpm -D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -g -DVERSION=\"0.67\" -DXS_VERSION=\"0.67\" -fPIC "-I/usr/lib/perl5/5.10.0/i386-linux-thread-multi/CORE" -DRPM2_RPM41 RPM2.c RPM2.xs:12:18: error: misc.h: No such file or directory RPM2.xs: In function ‘_populate_header_tags’: RPM2.xs:134: error: ‘rpmTagTableSize’ undeclared (first use in this function) RPM2.xs:134: error: (Each undeclared identifier is reported only once RPM2.xs:134: error: for each function it appears in.) RPM2.xs:135: error: ‘rpmTagTable’ undeclared (first use in this function) RPM2.xs: In function ‘XS_RPM2__C__Header_tag_by_id’: RPM2.xs:410: warning: implicit declaration of function ‘headerGetEntry’ RPM2.xs:454: warning: implicit declaration of function ‘headerFreeData’ RPM2.xs: In function ‘XS_RPM2__C__Header__header_sprintf’: RPM2.xs:480: warning: implicit declaration of function ‘headerSprintf’ RPM2.xs:480: error: ‘rpmTagTable’ undeclared (first use in this function) RPM2.xs:480: error: ‘rpmHeaderFormats’ undeclared (first use in this function) RPM2.xs:480: warning: assignment makes pointer from integer without a cast RPM2.xs:482: warning: implicit declaration of function ‘_free’ RPM2.xs:482: warning: assignment makes pointer from integer without a cast RPM2.xs: In function ‘XS_RPM2__C__Transaction__run’: RPM2.xs:612: warning: passing argument 2 of ‘rpmtsSetNotifyCallback’ from incompatible pointer type make: *** [RPM2.o] Error 1
Subject: [PATCH] Support for RPM 4.6
From: lubo.rintel [...] gooddata.com
On Fri Dec 05 03:02:06 2008, CORTI wrote: Show quoted text
> RPM 4.6 contains serveral changes which break RPM2
Thank you for the report, Matteo. I prepared the fix for RPM 4.6 for the Fedora perl-RPM2 package. It is back in rawhide now [1] and will be submitted as an update for F-10 in a few days. [1] http://koji.fedoraproject.org/koji/buildinfo?buildID=74413 If you don't use Fedora, you can patch the 0.67 distribution with the diff attached to this file. A few notes: I've not given it much testing besides the standard test suite. You're feedback and any issues you'll find will be greatly appreciated. Its API is RPM 4.4-ish, therefore completely compatible with perl RPM2 module for older RPM versions.
Port of RPM2 perl module to RPM 4.6. Two deprecated functions remain, all tests pass. Lubomir Rintel <lkundrak@v3.sk> diff -up RPM2-0.67/Makefile.PL.rpm46 RPM2-0.67/Makefile.PL --- RPM2-0.67/Makefile.PL.rpm46 2008-12-12 01:07:41.000000000 +0100 +++ RPM2-0.67/Makefile.PL 2008-12-12 01:07:41.000000000 +0100 @@ -27,7 +27,13 @@ $libs .= " -lelf"; my @defines; # detect which rpm is running. ugly but necessary... for now. -if (-e '/usr/include/rpm/rpmts.h') { +# ^^^ (Poor you, if only you knew I'll make it much worse -- lkundrak) +if (`pkg-config rpm --modversion` =~ /^(\d+)\.(\d+).*/) { + my ($major, $minor) = ($1, $2); + ($major, $minor) = (4,6) if $major >= 4 and $minor > 6; + push @defines, "-DRPM2_RPM$major$minor"; +} +elsif (-e '/usr/include/rpm/rpmts.h') { push @defines, '-DRPM2_RPM41'; } else { diff -up RPM2-0.67/README.rpm46 RPM2-0.67/README --- RPM2-0.67/README.rpm46 2006-09-24 19:20:03.000000000 +0200 +++ RPM2-0.67/README 2008-12-12 01:07:41.000000000 +0100 @@ -21,4 +21,4 @@ This module requires these other modules COPYRIGHT AND LICENCE Copyright (C) 2006 Chip Turner - +Copyright (C) 2008 Lubomir Rintel diff -up RPM2-0.67/RPM2.pm.rpm46 RPM2-0.67/RPM2.pm --- RPM2-0.67/RPM2.pm.rpm46 2006-09-24 19:23:15.000000000 +0200 +++ RPM2-0.67/RPM2.pm 2008-12-12 01:07:41.000000000 +0100 @@ -795,6 +795,7 @@ Initial release =head1 AUTHOR Chip Turner E<lt>cturner@pattern.net<gt> +Lubomir Rintel E<lt>lkundrak@v3.sk<gt> =head1 LICENSE diff -up RPM2-0.67/RPM2.xs.rpm46 RPM2-0.67/RPM2.xs --- RPM2-0.67/RPM2.xs.rpm46 2008-12-12 01:07:41.000000000 +0100 +++ RPM2-0.67/RPM2.xs 2008-12-12 01:07:41.000000000 +0100 @@ -2,21 +2,26 @@ #include "rpmlib.h" #include "rpmcli.h" -#ifdef RPM2_RPM41 +#ifndef RPM2_RPM40 #include "rpmts.h" #include "rpmte.h" #endif #include "header.h" #include "rpmdb.h" +#if defined(RPM2_RPM40) || defined(RPM2_RPM41) #include "misc.h" +#else +#define _RPM_4_4_COMPAT +#include "rpmlegacy.h" +#endif #include "EXTERN.h" #include "perl.h" #include "XSUB.h" -#if !defined(RPM2_RPM41) && !defined(RPM2_RPM40) -#error Must define one of RPM2_RPM41 or RPM2_RPM40; perhaps Makefile.PL could not guess your RPM API version? +#if !defined(RPM2_RPM41) && !defined(RPM2_RPM40) && !defined(RPM2_RPM46) +#error Seems like Makefile.PL could not guess your RPM API version. #endif /* Chip, this is somewhat stripped down from the default callback used by @@ -29,9 +34,14 @@ */ void * _null_callback( const void * arg, - const rpmCallbackType what, + const rpmCallbackType what, +#if defined(RPM2_RPM40) || defined(RPM2_RPM41) const unsigned long amount, - const unsigned long total, + const unsigned long total, +#else + const rpm_loff_t amount, + const rpm_loff_t total, +#endif fnpyKey key, rpmCallbackData data) { @@ -129,11 +139,23 @@ void * _null_callback( void _populate_header_tags(HV *href) { +#if defined(RPM2_RPM40) || defined(RPM2_RPM41) int i = 0; for (i = 0; i < rpmTagTableSize; i++) { hv_store(href, rpmTagTable[i].name, strlen(rpmTagTable[i].name), newSViv(rpmTagTable[i].val), 0); +#else + rpmtd names; + const char *name; + + names = rpmtdNew(); + rpmTagGetNames(names, 1); + while ((name = rpmtdNextString(names)) != NULL) { + const char *sname = name + strlen("RPMTAG_"); + hv_store(href, name, strlen(name), + newSViv(rpmTagGetValue(name + strlen("RPMTAG_"))), 0); } +#endif } void @@ -158,7 +180,7 @@ BOOT: constants = perl_get_hv("RPM2::constants", TRUE); /* not the 'standard' way of doing perl constants, but a lot easier to maintain */ -#ifdef RPM2_RPM41 +#ifndef RPM2_RPM40 REGISTER_CONSTANT(RPMVSF_DEFAULT); REGISTER_CONSTANT(RPMVSF_NOHDRCHK); REGISTER_CONSTANT(RPMVSF_NEEDPAYLOAD); @@ -183,10 +205,13 @@ double rpm_api_version(pkg) char * pkg CODE: -#if defined(RPM2_RPM41) && ! defined(RPM2_RPM40) +#ifdef RPM2_RPM46 + RETVAL = (double)4.6; +#endif +#ifdef RPM2_RPM41 RETVAL = (double)4.1; #endif -#if ! defined(RPM2_RPM41) && defined(RPM2_RPM40) +#ifdef RPM2_RPM40 RETVAL = (double)4.0; #endif OUTPUT: @@ -229,7 +254,7 @@ _read_package_info(fp, vsflags) FILE *fp int vsflags PREINIT: -#ifdef RPM2_RPM41 +#ifndef RPM2_RPM40 rpmts ts; #endif Header ret; @@ -237,7 +262,7 @@ _read_package_info(fp, vsflags) rpmRC rc; FD_t fd; PPCODE: -#ifdef RPM2_RPM41 +#ifndef RPM2_RPM40 ts = rpmtsCreate(); #endif @@ -249,7 +274,7 @@ _read_package_info(fp, vsflags) */ fd = fdDup(fileno(fp)); -#ifdef RPM2_RPM41 +#ifndef RPM2_RPM40 rpmtsSetVSFlags(ts, vsflags); rc = rpmReadPackageFile(ts, fd, "filename or other identifier", &ret); #else @@ -271,7 +296,7 @@ _read_package_info(fp, vsflags) else { croak("error reading package"); } -#ifdef RPM2_RPM41 +#ifndef RPM2_RPM40 ts = rpmtsFree(ts); #endif @@ -355,6 +380,11 @@ _init_iterator(db, rpmtag, key, len) char *key size_t len CODE: + /* See rpmdbInitIterator() code for explanation of this */ + if (rpmtag == RPMDBI_PACKAGES) { + len = sizeof (key); + } + RETVAL = rpmdbInitIterator(db, rpmtag, key && *key ? key : NULL, len); OUTPUT: RETVAL @@ -403,7 +433,11 @@ tag_by_id(h, tag) int tag PREINIT: void *ret = NULL; +#if defined(RPM2_RPM40) || defined(RPM2_RPM41) int type; +#else + rpmTagType type; +#endif int n; int ok; PPCODE: @@ -513,9 +547,18 @@ _header_sprintf(h, format) PREINIT: char * s; PPCODE: +#if defined(RPM2_RPM40) || defined(RPM2_RPM41) s = headerSprintf(h, format, rpmTagTable, rpmHeaderFormats, NULL); +#else + s = headerFormat(h, format, NULL); +#endif PUSHs(sv_2mortal(newSVpv((char *)s, 0))); +/* By the way, the #if below is completely useless, free() would work for both */ +#if defined(RPM2_RPM40) || defined(RPM2_RPM41) s = _free(s); +#else + free(s); +#endif MODULE = RPM2 PACKAGE = RPM2::C::Transaction diff -up RPM2-0.67/test.pl.rpm46 RPM2-0.67/test.pl --- RPM2-0.67/test.pl.rpm46 2008-12-12 01:07:41.000000000 +0100 +++ RPM2-0.67/test.pl 2008-12-12 01:07:41.000000000 +0100 @@ -126,7 +126,7 @@ ok(RPM2->expand_macro("%rpm2_test_macro" RPM2->delete_macro("rpm2_test_macro"); ok(RPM2->expand_macro("%rpm2_test_macro") eq "%rpm2_test_macro"); -ok(RPM2->rpm_api_version == 4.1 or RPM2->rpm_api_version == 4.0); +ok(RPM2->rpm_api_version =~ /4.[016]/); ok(RPM2->rpm_api_version == 4.0 or RPM2->vsf_nosha1 == 65536); #
This is fixed in 0.68