Blame SOURCES/BZ-1281593-yum-fs-vars.patch

eb5f31
commit 22271bf34e71bbfc75d0a59354fc0108e004f36c
eb5f31
Author: James Antill <james@and.org>
eb5f31
Date:   Mon Jun 9 16:09:32 2014 -0400
eb5f31
eb5f31
    Read FS yumvars before yum.conf setup, and reread if installroot changed.
eb5f31
eb5f31
diff --git a/yum/config.py b/yum/config.py
eb5f31
index 6e0ecdc..1b5a11d 100644
eb5f31
--- a/yum/config.py
eb5f31
+++ b/yum/config.py
eb5f31
@@ -1022,6 +1022,23 @@ class VersionGroupConf(BaseConfig):
eb5f31
     pkglist = ListOption()
eb5f31
     run_with_packages = BoolOption(False)
eb5f31
 
eb5f31
+def _read_yumvars(yumvars, root):
eb5f31
+    # Read the FS yumvars
eb5f31
+    try:
eb5f31
+        dir_fsvars = root + "/etc/yum/vars/"
eb5f31
+        fsvars = os.listdir(dir_fsvars)
eb5f31
+    except OSError:
eb5f31
+        fsvars = []
eb5f31
+    for fsvar in fsvars:
eb5f31
+        if os.path.islink(dir_fsvars + fsvar):
eb5f31
+            continue
eb5f31
+        try:
eb5f31
+            val = open(dir_fsvars + fsvar).readline()
eb5f31
+            if val and val[-1] == '\n':
eb5f31
+                val = val[:-1]
eb5f31
+        except (OSError, IOError):
eb5f31
+            continue
eb5f31
+        yumvars[fsvar] = val
eb5f31
 
eb5f31
 def readStartupConfig(configfile, root, releasever=None):
eb5f31
     """Parse Yum's main configuration file and return a
eb5f31
@@ -1044,6 +1061,7 @@ def readStartupConfig(configfile, root, releasever=None):
eb5f31
     confpp_obj = ConfigPreProcessor(configfile)
eb5f31
 
eb5f31
     yumvars = _getEnvVar()
eb5f31
+    _read_yumvars(yumvars, yumconf.installroot)
eb5f31
     confpp_obj._vars = yumvars
eb5f31
     startupconf.yumvars = yumvars
eb5f31
 
eb5f31
@@ -1102,22 +1120,12 @@ def readMainConfig(startupconf):
eb5f31
         ir_path = varReplace(ir_path, yumvars)
eb5f31
         setattr(yumconf, option, ir_path)
eb5f31
     
eb5f31
-    # Read the FS yumvars
eb5f31
-    try:
eb5f31
-        dir_fsvars = yumconf.installroot + "/etc/yum/vars/"
eb5f31
-        fsvars = os.listdir(dir_fsvars)
eb5f31
-    except OSError:
eb5f31
-        fsvars = []
eb5f31
-    for fsvar in fsvars:
eb5f31
-        if os.path.islink(dir_fsvars + fsvar):
eb5f31
-            continue
eb5f31
-        try:
eb5f31
-            val = open(dir_fsvars + fsvar).readline()
eb5f31
-            if val and val[-1] == '\n':
eb5f31
-                val = val[:-1]
eb5f31
-        except (OSError, IOError):
eb5f31
-            continue
eb5f31
-        yumvars[fsvar] = val
eb5f31
+    if StartupConf.installroot.default != yumconf.installroot:
eb5f31
+        #  Note that this isn't perfect, in that if the initial installroot has
eb5f31
+        # X=Y, and X doesn't exist in the new installroot ... then we'll still
eb5f31
+        # have X afterwards (but if the new installroot has X=Z, that will be
eb5f31
+        # the value after this).
eb5f31
+        _read_yumvars(yumvars, yumconf.installroot)
eb5f31
 
eb5f31
     # These can use the above FS yumvars
eb5f31
     for option in ('cachedir', 'logfile', 'persistdir'):
eb5f31
commit 1ccd91f4b195737d6bb1bdfabcbf3714de1d9b85
eb5f31
Author: James Antill <james@and.org>
eb5f31
Date:   Mon Jun 16 15:16:25 2014 -0400
eb5f31
eb5f31
    Fix merge typo. with FS vars. before yum.conf
eb5f31
eb5f31
diff --git a/yum/config.py b/yum/config.py
eb5f31
index 1b5a11d..8eab5bc 100644
eb5f31
--- a/yum/config.py
eb5f31
+++ b/yum/config.py
eb5f31
@@ -1061,7 +1061,7 @@ def readStartupConfig(configfile, root, releasever=None):
eb5f31
     confpp_obj = ConfigPreProcessor(configfile)
eb5f31
 
eb5f31
     yumvars = _getEnvVar()
eb5f31
-    _read_yumvars(yumvars, yumconf.installroot)
eb5f31
+    _read_yumvars(yumvars, startupconf.installroot)
eb5f31
     confpp_obj._vars = yumvars
eb5f31
     startupconf.yumvars = yumvars
eb5f31
 
eb5f31
commit 6148c8a10b22763592c141ce9ee6d85dce5816f7
eb5f31
Author: Michal Domonkos <mdomonko@redhat.com>
eb5f31
Date:   Thu Apr 21 16:08:19 2016 +0200
eb5f31
eb5f31
    Honor FS yumvars over defaults for special vars. BZ 1327561
eb5f31
    
eb5f31
    This fixes up commit 22271bf, which caused FS yumvars like $releasever
eb5f31
    to be unintentionally replaced by the default values (unless the
eb5f31
    installroot was redefined by yumconf, which caused us to reread them).
eb5f31
eb5f31
diff --git a/yum/config.py b/yum/config.py
eb5f31
index 954700b..2ef5fa4 100644
eb5f31
--- a/yum/config.py
eb5f31
+++ b/yum/config.py
eb5f31
@@ -1114,12 +1114,12 @@ def readMainConfig(startupconf):
eb5f31
     
eb5f31
     # ' xemacs syntax hack
eb5f31
 
eb5f31
-    # Set up substitution vars
eb5f31
+    # Set up substitution vars but make sure we always prefer FS yumvars
eb5f31
     yumvars = startupconf.yumvars
eb5f31
-    yumvars['basearch'] = startupconf.basearch
eb5f31
-    yumvars['arch'] = startupconf.arch
eb5f31
-    yumvars['releasever'] = startupconf.releasever
eb5f31
-    yumvars['uuid'] = startupconf.uuid
eb5f31
+    yumvars.setdefault('basearch', startupconf.basearch)
eb5f31
+    yumvars.setdefault('arch', startupconf.arch)
eb5f31
+    yumvars.setdefault('releasever', startupconf.releasever)
eb5f31
+    yumvars.setdefault('uuid', startupconf.uuid)
eb5f31
     # Note: We don't setup the FS yumvars here, because we want to be able to
eb5f31
     #       use the core yumvars in persistdir. Which is the base of FS yumvars.
eb5f31
     
eb5f31
commit 1897df3c1477afd8f221833120092f35c26f5a9d
eb5f31
Author: Michal Domonkos <mdomonko@redhat.com>
eb5f31
Date:   Thu Apr 21 16:23:47 2016 +0200
eb5f31
eb5f31
    Cosmetic: remove outdated comment
eb5f31
    
eb5f31
    It was no longer true after commit ade6d16.
eb5f31
eb5f31
diff --git a/yum/config.py b/yum/config.py
eb5f31
index 2ef5fa4..84be564 100644
eb5f31
--- a/yum/config.py
eb5f31
+++ b/yum/config.py
eb5f31
@@ -1120,8 +1120,6 @@ def readMainConfig(startupconf):
eb5f31
     yumvars.setdefault('arch', startupconf.arch)
eb5f31
     yumvars.setdefault('releasever', startupconf.releasever)
eb5f31
     yumvars.setdefault('uuid', startupconf.uuid)
eb5f31
-    # Note: We don't setup the FS yumvars here, because we want to be able to
eb5f31
-    #       use the core yumvars in persistdir. Which is the base of FS yumvars.
eb5f31
     
eb5f31
     # Read [main] section
eb5f31
     yumconf = YumConf()