diff options
-rwxr-xr-x | Makefile.PL | 4 | ||||
-rw-r--r-- | URPM.xs | 62 |
2 files changed, 60 insertions, 6 deletions
diff --git a/Makefile.PL b/Makefile.PL index 0308b27..3274db1 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -51,6 +51,10 @@ ChangeLog: my @rpmflags; my $ldflags = `pkg-config --libs rpm`; +if ($hversion ge hexversion("4.9.0") && $hversion lt hexversion("5.0")) { + # rpm.org version 4.9.0 + push @rpmflags, "-DRPM490"; +} if ($hversion ge hexversion("4.4.90") && $hversion lt hexversion("5.0")) { # rpm.org version push @rpmflags, "-DRPM_ORG"; @@ -1394,12 +1394,20 @@ static void *rpmRunTransactions_callback(__attribute__((unused)) const void *h, i = POPi; fd = fdDup(i); if (fd) { +#ifdef RPM490 + fd = fdLink(fd); +#else fd = fdLink(fd, "persist perl-URPM"); +#endif Fcntl(fd, F_SETFD, (void *)1); /* necessary to avoid forked/execed process to lock removable */ } PUTBACK; } else if (callback == td->callback_close) { +#ifdef RPM490 + fd = fdFree(fd); +#else fd = fdFree(fd, "persist perl-URPM"); +#endif if (fd) { Fclose(fd); fd = NULL; @@ -2850,7 +2858,11 @@ Db_traverse(db,callback) rpmdbMatchIterator mi; int count = 0; CODE: +#ifdef RPM490 + db->ts = rpmtsLink(db->ts); +#else db->ts = rpmtsLink(db->ts, "URPM::DB::traverse"); +#endif ts_nosignature(db->ts); mi = rpmtsInitIterator(db->ts, RPMDBI_PACKAGES, NULL, 0); while ((header = rpmdbNextIterator(mi))) { @@ -2900,7 +2912,11 @@ Db_traverse_tag(db,tag,names,callback) STRLEN str_len; SV **isv = av_fetch(names_av, i, 0); char *name = SvPV(*isv, str_len); +#ifdef RPM490 + db->ts = rpmtsLink(db->ts); +#else db->ts = rpmtsLink(db->ts, "URPM::DB::traverse_tag"); +#endif ts_nosignature(db->ts); mi = rpmtsInitIterator(db->ts, rpmtag, name, str_len); while ((header = rpmdbNextIterator(mi))) { @@ -2942,8 +2958,11 @@ Db_traverse_tag_find(db,tag,name,callback) CODE: int rpmtag = rpmtag_from_string(tag); int found = 0; - +#ifdef RPM490 + db->ts = rpmtsLink(db->ts); +#else db->ts = rpmtsLink(db->ts, "URPM::DB::traverse_tag"); +#endif ts_nosignature(db->ts); mi = rpmtsInitIterator(db->ts, rpmtag, name, 0); while ((header = rpmdbNextIterator(mi))) { @@ -2980,7 +2999,11 @@ Db_create_transaction(db, prefix="/") CODE: /* this is *REALLY* dangerous to create a new transaction while another is open, so use the db transaction instead. */ +#ifdef RPM490 + db->ts = rpmtsLink(db->ts); +#else db->ts = rpmtsLink(db->ts, "URPM::DB::create_transaction"); +#endif ++db->count; RETVAL = db; OUTPUT: @@ -3306,7 +3329,11 @@ Trans_run(trans, data, ...) if (repa) free(repa); } rpmtsSetFlags(trans->ts, transFlags); +#ifdef RPM490 + trans->ts = rpmtsLink(trans->ts); +#else trans->ts = rpmtsLink(trans->ts, "URPM::Transaction::run"); +#endif rpmtsSetNotifyCallback(trans->ts, rpmRunTransactions_callback, &td); if (rpmtsRun(trans->ts, NULL, probFilter) > 0) { rpmps ps = rpmtsProblems(trans->ts); @@ -3792,8 +3819,11 @@ Urpm_import_pubkey_file(db, filename) size_t pktlen = 0; int rc; CODE: - +#ifdef RPM490 + rpmts ts = rpmtsLink(db->ts); +#else rpmts ts = rpmtsLink(db->ts, "URPM::import_pubkey_file"); +#endif rpmtsClean(ts); if ((rc = pgpReadPkts(filename, (uint8_t ** ) &pkt, &pktlen)) <= 0) { @@ -3900,6 +3930,7 @@ Urpm_spec2srcheader(specfile) rpmts ts = rpmtsCreate(); URPM__Package pkg; Spec spec = NULL; + Header header = NULL; PPCODE: /* ensure the config is in memory with all macro */ read_config_files(0); @@ -3907,16 +3938,31 @@ Urpm_spec2srcheader(specfile) #define SPEC_ANYARCH 1 /* Do not verify whether sources exist */ #define SPEC_FORCE 1 +#ifdef RPM490 + spec = rpmSpecParse(specfile, SPEC_ANYARCH|SPEC_FORCE, NULL); + header = rpmSpecSourceHeader(spec); + if (spec) { +#else if (!parseSpec(ts, specfile, "/", NULL, 0, NULL, NULL, SPEC_ANYARCH, SPEC_FORCE)) { +#endif SV *sv_pkg; +#ifndef RPM490 + // FIXME: has disappeared in rpm-4.9.0rpmSpecParse + // (See http://www.rpm.org/wiki/Releases/4.9.0) spec = rpmtsSetSpec(ts, NULL); + header = spec->sourceHeader; +#endif #ifdef RPM_ORG - if (! spec->sourceHeader) +#ifndef RPM490 + if (! header) +#endif #endif +#ifndef RPM490 initSourceHeader(spec); +#endif pkg = (URPM__Package)malloc(sizeof(struct s_Package)); memset(pkg, 0, sizeof(struct s_Package)); - headerPutString(spec->sourceHeader, RPMTAG_SOURCERPM, ""); + headerPutString(header, RPMTAG_SOURCERPM, ""); { struct rpmtd_s td = { @@ -3926,14 +3972,18 @@ Urpm_spec2srcheader(specfile) .count = 1, }; /* parseSpec() sets RPMTAG_ARCH to %{_target_cpu} whereas we really a header similar to .src.rpm header */ - headerMod(spec->sourceHeader, &td); + headerMod(header, &td); } - pkg->h = headerLink(spec->sourceHeader); + pkg->h = headerLink(header); sv_pkg = sv_newmortal(); sv_setref_pv(sv_pkg, "URPM::Package", (void*)pkg); XPUSHs(sv_pkg); +#ifdef RPM490 + spec = rpmSpecFree(spec); +#else spec = freeSpec(spec); +#endif } else { XPUSHs(&PL_sv_undef); /* apparently rpmlib sets errno this when given a bad spec. */ |