75 lines
2.2 KiB
Diff
75 lines
2.2 KiB
Diff
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;
|
|
}
|
|
|