diff --git a/apt-0.5.15lorg2-alt-rpmSystem-DistroVer.patch b/apt-0.5.15lorg2-alt-rpmSystem-DistroVer.patch deleted file mode 100644 index 3742018..0000000 --- a/apt-0.5.15lorg2-alt-rpmSystem-DistroVer.patch +++ /dev/null @@ -1,74 +0,0 @@ -diff -upk.orig apt-0.5.15lorg2.orig/apt-pkg/rpm/rpmsystem.cc apt-0.5.15lorg2/apt-pkg/rpm/rpmsystem.cc ---- apt-0.5.15lorg2.orig/apt-pkg/rpm/rpmsystem.cc 2006-02-06 19:11:06 +0000 -+++ apt-0.5.15lorg2/apt-pkg/rpm/rpmsystem.cc 2006-04-01 16:14:46 +0000 -@@ -248,31 +248,50 @@ signed rpmSystem::Score(Configuration co - string rpmSystem::DistroVer(Configuration const &Cnf) - { - string DistroVerPkg = _config->Find("Apt::DistroVerPkg"); -- string DistroVersion = ""; -+ string DistroVersion; - -+ if (DistroVerPkg.empty()) -+ return DistroVersion; - -- if (! DistroVerPkg.empty()) { -- rpmts ts; -- char *version; -- int type, count, rc; -- rpmdbMatchIterator iter; -- -- ts = rpmtsCreate(); -- rpmtsSetVSFlags(ts, (rpmVSFlags_e)-1); -- rpmtsSetRootDir(ts, NULL); -- rc = rpmtsOpenDB(ts, O_RDWR); -- -- Header hdr; -- iter = rpmtsInitIterator(ts, (rpmTag)RPMDBI_LABEL, DistroVerPkg.c_str(), 0); -- while ((hdr = rpmdbNextIterator(iter)) != NULL) { -- headerGetEntry(hdr, RPMTAG_VERSION, &type, (void **)&version, &count); -- DistroVersion = version; -+#if RPM_VERSION >= 0x040100 -+ rpmts ts; -+ ts = rpmtsCreate(); -+ rpmtsSetVSFlags(ts, (rpmVSFlags_e)-1); -+ rpmtsSetRootDir(ts, NULL); -+ if (rpmtsOpenDB(ts, O_RDONLY)) -+ return DistroVersion; -+#else -+ rpmdb DB; -+ string RootDir = _config->Find("RPM::RootDir"); -+ const char *RootDirStr = RootDir.empty() ? NULL : RootDir.c_str(); -+ if (rpmdbOpen(RootDirStr, &DB, O_RDONLY, 0644)) -+ return DistroVersion; -+#endif -+ -+ rpmdbMatchIterator iter; -+#if RPM_VERSION >= 0x040100 -+ iter = rpmtsInitIterator(ts, (rpmTag)RPMDBI_LABEL, DistroVerPkg.c_str(), 0); -+#else -+ iter = rpmdbInitIterator(DB, RPMDBI_LABEL, DistroVerPkg.c_str(), 0); -+#endif -+ Header hdr; -+ while ((hdr = rpmdbNextIterator(iter)) != NULL) { -+ void *version; -+ int type, count; -+ -+ if (headerGetEntry(hdr, RPMTAG_VERSION, &type, &version, &count)) { -+ DistroVersion = (char *)version; -+ headerFreeData(&version, (rpmTagType)type); - break; - } -- rpmdbFreeIterator(iter); -- rpmtsFree(ts); - } -- -+ rpmdbFreeIterator(iter); -+#if RPM_VERSION >= 0x040100 -+ rpmtsFree(ts); -+#else -+ rpmdbClose(DB); -+#endif -+ - return DistroVersion; - } - diff --git a/apt/apt-pkg/rpm/rpmsystem.cc b/apt/apt-pkg/rpm/rpmsystem.cc index 69169c7..97436d1 100644 --- a/apt/apt-pkg/rpm/rpmsystem.cc +++ b/apt/apt-pkg/rpm/rpmsystem.cc @@ -248,31 +248,50 @@ signed rpmSystem::Score(Configuration const &Cnf) string rpmSystem::DistroVer(Configuration const &Cnf) { string DistroVerPkg = _config->Find("Apt::DistroVerPkg"); - string DistroVersion = ""; + string DistroVersion; + if (DistroVerPkg.empty()) + return DistroVersion; - if (! DistroVerPkg.empty()) { - rpmts ts; - char *version; - int type, count, rc; - rpmdbMatchIterator iter; +#if RPM_VERSION >= 0x040100 + rpmts ts; + ts = rpmtsCreate(); + rpmtsSetVSFlags(ts, (rpmVSFlags_e)-1); + rpmtsSetRootDir(ts, NULL); + if (rpmtsOpenDB(ts, O_RDONLY)) + return DistroVersion; +#else + rpmdb DB; + string RootDir = _config->Find("RPM::RootDir"); + const char *RootDirStr = RootDir.empty() ? NULL : RootDir.c_str(); + if (rpmdbOpen(RootDirStr, &DB, O_RDONLY, 0644)) + return DistroVersion; +#endif - ts = rpmtsCreate(); - rpmtsSetVSFlags(ts, (rpmVSFlags_e)-1); - rpmtsSetRootDir(ts, NULL); - rc = rpmtsOpenDB(ts, O_RDWR); + rpmdbMatchIterator iter; +#if RPM_VERSION >= 0x040100 + iter = rpmtsInitIterator(ts, (rpmTag)RPMDBI_LABEL, DistroVerPkg.c_str(), 0); +#else + iter = rpmdbInitIterator(DB, RPMDBI_LABEL, DistroVerPkg.c_str(), 0); +#endif + Header hdr; + while ((hdr = rpmdbNextIterator(iter)) != NULL) { + void *version; + int type, count; - Header hdr; - iter = rpmtsInitIterator(ts, (rpmTag)RPMDBI_LABEL, DistroVerPkg.c_str(), 0); - while ((hdr = rpmdbNextIterator(iter)) != NULL) { - headerGetEntry(hdr, RPMTAG_VERSION, &type, (void **)&version, &count); - DistroVersion = version; + if (headerGetEntry(hdr, RPMTAG_VERSION, &type, &version, &count)) { + DistroVersion = (char *)version; + headerFreeData(&version, (rpmTagType)type); break; } - rpmdbFreeIterator(iter); - rpmtsFree(ts); } - + rpmdbFreeIterator(iter); +#if RPM_VERSION >= 0x040100 + rpmtsFree(ts); +#else + rpmdbClose(DB); +#endif + return DistroVersion; }