Репозиторий Sisyphus
Последнее обновление: 20 сентября 2018 | Пакетов: 18652 | Посещений: 12236052
en ru br
Репозитории ALT
S:0.5.15lorg2-alt58
5.1: 0.5.15lorg2-alt33.M50P.1
4.1: 0.5.15lorg2-alt20.M41.1
4.0: 0.5.15lorg2-alt18.M40.1
+updates:0.5.15lorg2-alt18
3.0: 0.5.15cnc6-alt16
www.altlinux.org/Changes

Группа :: Система/Настройка/Пакеты
Пакет: apt

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: apt-0.5.15lorg2-alt-rpmSystem-DistroVer.patch
Скачать


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;
 }
 
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin