[PATCH] Mostly backwards compat. change to how distroverpkg config. works. BZ 1002977.

James Antill james at and.org
Tue Oct 15 19:33:25 UTC 2013


 This is for rel-eng, now instead of just looking at the version of the
package which provides the "distro. release provide" we try to parse the
version out of the packages provides. This allows random verisons for
the package, which is apparently useful.

 Speed of config. loading doesn't seem to be measurable. One change is
that .conf.distroverpkg is now a list to accomodate the new provide vs.
the old one. Also if anyone had a package providing redhat-release = blah,
$releasever is now "blah" instead of whatever the package version was.
---
 docs/yum.conf.5 |   12 +++++++++---
 yum/config.py   |   20 ++++++++++++++++++--
 2 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
index cb7ab14..ea4dba0 100644
--- a/docs/yum.conf.5
+++ b/docs/yum.conf.5
@@ -284,9 +284,15 @@ Command-line option: \fB\-\-installroot\fP
 
 .IP
 \fBdistroverpkg\fR
-The package used by yum to determine the "version" of the distribution. This
-can be any installed package. Default is `redhat-release'. You can see what
-provides this manually by using: "yum whatprovides redhat-release".
+The package used by yum to determine the "version" of the distribution, this
+sets $releasever for use in config. files. This
+can be any installed package. Default is `system-release(releasever)',
+`redhat-release'. Yum will now look at the version provided by the provide,
+and if that is non-empty then will use the full V(-R), otherwise it uses the
+version of the package.
+ You can see what provides this manually by using: 
+"yum whatprovides 'system-release(releasever)' redhat-release" and you can see
+what $releasever is most easily by using: "yum version".
 
 .IP
 \fBdiskspacecheck\fR
diff --git a/yum/config.py b/yum/config.py
index 52e539d..65f0dae 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -38,6 +38,7 @@ if not _use_iniparse:
     from ConfigParser import NoSectionError, NoOptionError, ParsingError
     from ConfigParser import ConfigParser
 import rpmUtils.transaction
+import rpmUtils.miscutils
 import Errors
 import types
 from misc import get_uuid, read_in_items_from_dot_dir
@@ -713,7 +714,7 @@ class StartupConf(BaseConfig):
     debuglevel = IntOption(2, -4, 10)
     errorlevel = IntOption(2, 0, 10)
 
-    distroverpkg = Option('redhat-release')
+    distroverpkg = ListOption(['system-release(releasever)', 'redhat-release'])
     installroot = Option('/')
     config_file_path = Option('/etc/yum/yum.conf')
     plugins = BoolOption(False)
@@ -1175,7 +1176,10 @@ def _getsysver(installroot, distroverpkg):
     ts = rpmUtils.transaction.initReadOnlyTransaction(root=installroot)
     ts.pushVSFlags(~(rpm._RPMVSF_NOSIGNATURES|rpm._RPMVSF_NODIGESTS))
     try:
-        idx = ts.dbMatch('provides', distroverpkg)
+        for distroverpkg_prov in distroverpkg:
+            idx = ts.dbMatch('provides', distroverpkg_prov)
+            if idx.count():
+                break
     except TypeError, e:
         # This is code for "cannot open rpmdb"
         # this is for pep 352 compliance on python 2.6 and above :(
@@ -1198,6 +1202,18 @@ def _getsysver(installroot, distroverpkg):
         except StopIteration:
             raise Errors.YumBaseError("Error: rpmdb failed release provides. Try: rpm --rebuilddb")
         releasever = hdr['version']
+
+        off = hdr[getattr(rpm, 'RPMTAG_PROVIDENAME')].index(distroverpkg_prov)
+        flag = hdr[getattr(rpm, 'RPMTAG_PROVIDEFLAGS')][off]
+        flag = rpmUtils.miscutils.flagToString(flag)
+        ver  = hdr[getattr(rpm, 'RPMTAG_PROVIDEVERSION')][off]
+        if flag == 'EQ' and ver:
+            releasever = rpmUtils.miscutils.stringToVersion(releasever)
+            if releasever[2]:
+                releasever = "%s-%s" % (releasever[1], releasever[2]) # No epoch
+            else:
+                releasever = releasever[1] # No epoch or release, just version
+
         del hdr
     del idx
     del ts
-- 
1.7.7.6



More information about the Yum-devel mailing list