diff options
author | tv <tv@971eb68f-4bfb-0310-8326-d2484c010a4c> | 2011-11-09 13:02:36 +0000 |
---|---|---|
committer | tv <tv@971eb68f-4bfb-0310-8326-d2484c010a4c> | 2011-11-09 13:02:36 +0000 |
commit | d6b5de7c498e8764e10d7a96d703a1bfb86e29cb (patch) | |
tree | 0f3f81a365ad3f9bb2fc085f8daacdcacfd406a0 /RPM4 | |
parent | c055ca58aee2af8c7fffee548010d6cfc5a093ce (diff) | |
download | perl-RPM4-d6b5de7c498e8764e10d7a96d703a1bfb86e29cb.tar perl-RPM4-d6b5de7c498e8764e10d7a96d703a1bfb86e29cb.tar.gz perl-RPM4-d6b5de7c498e8764e10d7a96d703a1bfb86e29cb.tar.bz2 perl-RPM4-d6b5de7c498e8764e10d7a96d703a1bfb86e29cb.tar.xz perl-RPM4-d6b5de7c498e8764e10d7a96d703a1bfb86e29cb.zip |
add rpm-4.9 support (tv, 2011-08)
git-svn-id: svn+ssh://haiku.zarb.org/home/projects/rpm4/svn/trunk@150 971eb68f-4bfb-0310-8326-d2484c010a4c
Diffstat (limited to 'RPM4')
-rw-r--r-- | RPM4/NEWS | 1 | ||||
-rw-r--r-- | RPM4/src/Makefile.PL | 6 | ||||
-rw-r--r-- | RPM4/src/RPM4.xs | 142 | ||||
-rw-r--r-- | RPM4/src/RPM4sign.c | 7 |
4 files changed, 147 insertions, 9 deletions
@@ -1,3 +1,4 @@ - add rpm-4.6 support (pixel, 2009-01-20) - add rpm-4.8 support (Dexter Morgan, 2011-02) +- add rpm-4.9 support (tv, 2011-08) - drop support for rpm-4.4.x (spaghetti...) diff --git a/RPM4/src/Makefile.PL b/RPM4/src/Makefile.PL index 0f2f904..c87d9b3 100644 --- a/RPM4/src/Makefile.PL +++ b/RPM4/src/Makefile.PL @@ -35,6 +35,10 @@ foreach (qw( 4.4.2 4.8.0 4.8.1 + 4.9.0 + 4.9.1 + 4.9.1.1 + 4.9.1.2 )) { $v = $_; $v =~ s/\./_/g; @@ -85,7 +89,7 @@ WriteMakefile( VERSION_FROM => '../lib/RPM4.pm', OBJECT => "RPM4.o RPM4sign.o $obj", INC => "-I$rpmheaderlocation", - LIBS => "-lrpm -lrpmio -lrpmbuild -lpopt -lz -lbz2 $ldd", + LIBS => "-lrpmsign -lrpm -lrpmio -lrpmbuild -lpopt -lz -lbz2 $ldd", 'CCFLAGS' => "-Wall $fl", depend => { "RPM4.xs" => join(" ", @rpmconstantfiles) }, ); diff --git a/RPM4/src/RPM4.xs b/RPM4/src/RPM4.xs index a76161b..72c9722 100644 --- a/RPM4/src/RPM4.xs +++ b/RPM4/src/RPM4.xs @@ -66,6 +66,9 @@ #include "rpmversion.h" +#ifdef RPM4_9_0 +#include <rpm/rpmspec.h> +#endif #include <rpm/header.h> #include <rpm/rpmio.h> #include <rpm/rpmdb.h> @@ -96,6 +99,10 @@ static unsigned char header_magic[8] = { 0x8e, 0xad, 0xe8, 0x01, 0x00, 0x00, 0x00, 0x00 }; +#ifdef RPM4_9_0 +typedef struct Package_s * Package; +#endif + #define CHECK_RPMDS_IX(dep) if (rpmdsIx((dep)) < 0) croak("You call RPM4::Header::Dependencies method after lastest next() of before init()") #define bless_rpmds "RPM4::Header::Dependencies" @@ -406,11 +413,15 @@ void _newspec(rpmts ts, char * filename, SV * svpassphrase, SV * svrootdir, SV * verify = SvIV(svverify); if (filename) { +#ifdef RPM4_9_0 + spec = rpmSpecParse(filename, RPMSPEC_ANYARCH|RPMSPEC_FORCE, NULL); +#else if (!parseSpec(ts, filename, rootdir , NULL ,0, passphrase, cookies, anyarch, force )) spec = rpmtsSetSpec(ts, NULL); +#endif #ifdef HHACK } else { spec = newSpec(); @@ -431,7 +442,11 @@ void _newspec(rpmts ts, char * filename, SV * svpassphrase, SV * svrootdir, SV * int _specbuild(rpmts ts, rpmSpec spec, SV * sv_buildflags) { rpmBuildFlags buildflags = sv2rpmbuildflags(sv_buildflags); if (buildflags == RPMBUILD_NONE) croak("No action given for build"); +#ifdef RPM4_9_0 + return rpmSpecBuild(spec, buildflags); +#else return buildSpec(ts, spec, buildflags, 0); +#endif } void _installsrpms(rpmts ts, char * filename) { @@ -749,7 +764,26 @@ void buildhost() PREINIT: PPCODE: +#ifdef RPM4_9_0 + //croak("buildhost exists only in rpm < 4.9"); + static char hostname[1024]; + static int oneshot = 0; + struct hostent *hbn; + + if (! oneshot) { + (void) gethostname(hostname, sizeof(hostname)); + hbn = gethostbyname(hostname); + if (hbn) + strcpy(hostname, hbn->h_name); + else + rpmlog(RPMLOG_WARNING, + _("Could not canonicalize hostname: %s\n"), hostname); + oneshot = 1; + } + XPUSHs(sv_2mortal(newSVpv(hostname,0))); +#else XPUSHs(sv_2mortal(newSVpv(buildHost(),0))); +#endif # Dump to file functions: void @@ -1361,8 +1395,10 @@ rpmdbrebuild(rootdir = NULL) PREINIT: rpmts ts = rpmtsCreate(); CODE: - if (rootdir) + if (!rootdir) rootdir="/"; + if (rootdir) { rpmtsSetRootDir(ts, rootdir); + } /* 0 on success */ RETVAL = rpmtsRebuildDB(ts); ts = rpmtsFree(ts); @@ -1471,8 +1507,12 @@ Ts_injectheader(db, header) PREINIT: rpmdb rdb; CODE: +#ifdef RPM4_9_0 + croak("injectheader>rpmdbAdd exists only in rpm < 4.9"); +#else rdb = rpmtsGetRdb(db); RETVAL = rpmdbAdd(rdb, 0, header, db, NULL); +#endif OUTPUT: RETVAL @@ -1486,9 +1526,14 @@ Ts_deleteheader(db, sv_offset) CODE: offset = SvUV(sv_offset); rdb = rpmtsGetRdb(db); - if (offset) + if (offset) { +#ifdef RPM4_9_0 + croak("injectheader>rpmdbAdd exists only in rpm < 4.9"); + RETVAL = 0; +#else RETVAL = rpmdbRemove(rdb, 0, offset, db, NULL); - else +#endif + } else RETVAL = 1; OUTPUT: RETVAL @@ -1515,7 +1560,14 @@ Ts_traverse(ts, callback = NULL, sv_tagname = NULL, sv_tagvalue = NULL, keylen = #ifdef HDLISTDEBUG PRINTF_CALL; #endif +#ifdef RPM4_9_0 + croak("traverse is no more supported with rpm 4.9"); +#else +#ifdef RPM4_9_0 + ts = rpmtsLink(ts); +#else ts = rpmtsLink(ts, "RPM4 Db::traverse()"); +#endif if (sv_tagname == NULL || !SvOK(sv_tagname)) { tag = RPMDBI_PACKAGES; /* Assume search into installed packages */ } else { @@ -1544,7 +1596,11 @@ Ts_traverse(ts, callback = NULL, sv_tagname = NULL, sv_tagvalue = NULL, keylen = SV **isv = av_fetch(av_exclude, i, 0); exclude[i] = SvUV(*isv); } +#ifdef RPM4_9_0 + rpmtsPrunedIterator(ts, exclude, av_len(av_exclude) + 1); +#else rpmdbPruneIterator(mi, exclude, av_len(av_exclude) + 1, 0); +#endif } while (rc && ((header = rpmdbNextIterator(mi)) != NULL)) { RETVAL++; @@ -1575,6 +1631,7 @@ Ts_traverse(ts, callback = NULL, sv_tagname = NULL, sv_tagvalue = NULL, keylen = } else RETVAL = -1; ts = rpmtsFree(ts); +#endif OUTPUT: RETVAL @@ -1716,7 +1773,11 @@ Ts_traverse_transaction(ts, callback, type = 0) rpmtsi pi; rpmte Te; CODE: +#ifdef RPM4_9_0 + ts = rpmtsLink(ts); +#else ts = rpmtsLink(ts, "RPM4 Db::traverse_transaction()"); +#endif pi = rpmtsiInit(ts); RETVAL = 0; while ((Te = rpmtsiNext(pi, type)) != NULL) { @@ -1773,7 +1834,11 @@ Ts_transrun(ts, callback, ...) rpmInstallFlags install_flags = INSTALL_NONE; rpmps ps; CODE: +#ifdef RPM4_9_0 + ts = rpmtsLink(ts); +#else ts = rpmtsLink(ts, "RPM4 Db::transrun()"); +#endif if (!SvOK(callback)) { /* undef value */ rpmtsSetNotifyCallback(ts, rpmShowProgress, @@ -2633,7 +2698,11 @@ Spec_new(perlclass, specfile = NULL, ...) i++; if (sv_isobject(ST(i)) && (SvTYPE(SvRV(ST(i))) == SVt_PVMG)) { ts = (rpmts)SvIV((SV*)SvRV(ST(i))); +#ifdef RPM4_9_0 + ts = rpmtsLink(ts); +#else ts = rpmtsLink(ts, bless_spec); +#endif } else { croak( "transaction is not a blessed SV reference" ); XSRETURN_UNDEF; @@ -2672,15 +2741,24 @@ Spec_DESTROY(spec) #ifdef HDRPMMEM PRINTF_FREE(bless_spec, spec, -1); #endif +#ifdef RPM4_9_0 + rpmSpecFree(spec); +#else freeSpec(spec); +#endif void Spec_srcheader(spec) rpmSpec spec PPCODE: +#ifdef RPM4_9_0 + Header header = rpmSpecSourceHeader(spec); + XPUSHs(sv_2mortal(sv_setref_pv(newSVpv("", 0), bless_header, (void *)headerLink(header)))); +#else if ( ! spec->sourceHeader) initSourceHeader(spec); XPUSHs(sv_2mortal(sv_setref_pv(newSVpv("", 0), bless_header, (void *)headerLink(spec->sourceHeader)))); +#endif void Spec_binheader(spec) @@ -2688,8 +2766,19 @@ Spec_binheader(spec) PREINIT: Package pkg; PPCODE: +#ifdef RPM4_9_0 +/* we could use something like: + rpmSpecPkgIter iter = rpmSpecPkgIterInit(spec); + while ((pkg = rpmSpecPkgIterNext(iter)) != NULL) + (...) + + but it's unused... +*/ + croak("binheader is no more supported with rpm 4.9"); +#else for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) XPUSHs(sv_2mortal(sv_setref_pv(newSVpv("", 0), bless_header, (void *)headerLink(pkg->header)))); +#endif void Spec_srcrpm(spec) @@ -2697,6 +2786,9 @@ Spec_srcrpm(spec) PREINIT: const char *name, *version, *release; PPCODE: +#ifdef RPM4_9_0 + croak("srcrpm is no more supported with rpm 4.9"); +#else (void) headerNVR(spec->packages->header, &name, &version, &release); XPUSHs(sv_2mortal(newSVpvf("%s/%s-%s-%s.%ssrc.rpm", rpmGetPath("%{_srcrpmdir}", NULL), @@ -2706,6 +2798,7 @@ Spec_srcrpm(spec) headerFreeTag(spec->packages->header, name, RPM_STRING_TYPE); headerFreeTag(spec->packages->header, version, RPM_STRING_TYPE); headerFreeTag(spec->packages->header, release, RPM_STRING_TYPE); +#endif void Spec_binrpm(spec) @@ -2716,6 +2809,9 @@ Spec_binrpm(spec) char * binRpm; char * path; PPCODE: +#ifdef RPM4_9_0 + croak("binrpm is no more supported with rpm 4.9"); +#else for(pkg = spec->packages; pkg != NULL; pkg = pkg->next) { if (pkg->fileList == NULL) continue; @@ -2728,6 +2824,7 @@ Spec_binrpm(spec) free(path); free(binRpm); } +#endif void Spec_check(spec, ts = NULL) @@ -2739,19 +2836,28 @@ Spec_check(spec, ts = NULL) PPCODE: PUTBACK; if (ts) +#ifdef RPM4_9_0 + ts = rpmtsLink(ts); +#else ts = rpmtsLink(ts, "Spec_check"); +#endif else ts = rpmtsCreate(); - +#ifndef RPM4_9_0 if ( ! spec->sourceHeader) initSourceHeader(spec); - - if (!headerIsEntry(spec->sourceHeader, RPMTAG_REQUIRENAME) - && !headerIsEntry(spec->sourceHeader, RPMTAG_CONFLICTNAME)) +#endif +#ifdef RPM4_9_0 + Header header = rpmSpecSourceHeader(spec); +#else + Header header = spec->sourceHeader; +#endif + if (!headerIsEntry(header, RPMTAG_REQUIRENAME) + && !headerIsEntry(header, RPMTAG_CONFLICTNAME)) /* XSRETURN_UNDEF; */ return; - (void) rpmtsAddInstallElement(ts, spec->sourceHeader, NULL, 0, NULL); + (void) rpmtsAddInstallElement(ts, header, NULL, 0, NULL); if(rpmtsCheck(ts)) croak("Can't check rpmts"); /* any better idea ? */ @@ -2779,7 +2885,11 @@ const char * Spec_specfile(spec) rpmSpec spec CODE: +#ifdef RPM4_9_0 + croak("specfile exists only in rpm < 4.9"); +#else RETVAL = spec->specFile; +#endif OUTPUT: RETVAL @@ -2790,11 +2900,15 @@ Spec_sources(spec, is = 0) PREINIT: struct Source *srcPtr; PPCODE: +#ifdef RPM4_9_0 + croak("sources exists only in rpm < 4.9"); +#else for (srcPtr = spec->sources; srcPtr != NULL; srcPtr = srcPtr->next) { if (is && !(srcPtr->flags & is)) continue; XPUSHs(sv_2mortal(newSVpv(srcPtr->source, 0))); } +#endif void Spec_sources_url(spec, is = 0) @@ -2803,11 +2917,15 @@ Spec_sources_url(spec, is = 0) PREINIT: struct Source * srcPtr; PPCODE: +#ifdef RPM4_9_0 +// XPUSHs(sv_2mortal(newSVpv(get_name(pkg->h, RPMTAG_URL), 0))); +#else for (srcPtr = spec->sources; srcPtr != NULL; srcPtr = srcPtr->next) { if (is && !(srcPtr->flags & is)) continue; XPUSHs(sv_2mortal(newSVpv(srcPtr->fullSource, 0))); } +#endif void Spec_icon(spec) @@ -2815,6 +2933,9 @@ Spec_icon(spec) PREINIT: Package pkg; PPCODE: +#ifdef RPM4_9_0 + croak("icon exists only in rpm < 4.9"); +#else for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) { char * dest = NULL; int len; @@ -2825,6 +2946,7 @@ Spec_icon(spec) memcpy(dest, pkg->icon->source, len); XPUSHs(sv_2mortal(newSVpv(dest, len))); } +#endif void Spec_icon_url(spec) @@ -2832,6 +2954,9 @@ Spec_icon_url(spec) PREINIT: Package pkg; PPCODE: +#ifdef RPM4_9_0 + croak("icon_url exists only in rpm < 4.9"); +#else for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) { char * dest = NULL; int len; @@ -2842,6 +2967,7 @@ Spec_icon_url(spec) memcpy(dest, pkg->icon->fullSource, len); XPUSHs(sv_2mortal(newSVpv(dest, len))); } +#endif MODULE = RPM4 PACKAGE = RPM4::Db::_Problems PREFIX = ps_ diff --git a/RPM4/src/RPM4sign.c b/RPM4/src/RPM4sign.c index a8b13c3..114dcd9 100644 --- a/RPM4/src/RPM4sign.c +++ b/RPM4/src/RPM4sign.c @@ -9,11 +9,17 @@ #undef Stat #include <rpm/rpmcli.h> +#ifdef RPM4_9_0 +#include <rpm/rpmsign.h> +#endif #include "RPM4.h" /* Hight level function */ int rpmsign(char *passphrase, const char *rpm) { +#ifdef RPM4_9_0 + return rpmPkgSign(rpm, NULL, passphrase); +#else QVA_t qva = &rpmQVKArgs; ARGV_t file = NULL; @@ -23,5 +29,6 @@ int rpmsign(char *passphrase, const char *rpm) { qva->passPhrase = passphrase; return rpmcliSign(NULL, qva, file); +#endif } |