Apply apt-0.5.15lorg2-alt-rpmSystem-DistroVer.patch

Added in commit e97a90d:
0.5.15lorg2-alt3

- Resolved a few issues introduced after cnc6.
This commit is contained in:
Gleb Fotengauer-Malinovskiy 2014-05-16 19:48:12 +04:00
parent 4947a45206
commit 9de85d7c9d
2 changed files with 37 additions and 92 deletions

View File

@ -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;
}

View File

@ -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;
}