[rhel7-branch 1/2] Use simple_replace to edit langpacks.conf (#1165980)
bcl
installerbot-noreply at redhat.com
Wed Jun 17 00:17:38 UTC 2015
From: "Brian C. Lane" <bcl at redhat.com>
langpack_locales may already exist in the config file, so use
simple_replace to edit or add it so that it doesn't end up with
duplicate lines.
Resolves: rhbz#1165980
---
pyanaconda/packaging/yumpayload.py | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index 6574f5e..a51ba38 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -41,6 +41,7 @@
import sys
import time
from pyanaconda.iutil import execReadlines
+from pyanaconda.simpleconfig import simple_replace
from functools import wraps
import logging
@@ -250,9 +251,14 @@ def _writeLangpacksConfig(self):
iutil.mkdirChain(os.path.dirname(_yum_installer_langpack_conf))
shutil.copy2(_yum_target_langpack_conf,
_yum_installer_langpack_conf)
- with open(_yum_installer_langpack_conf, "a") as f:
- f.write("# Added by Anaconda\n")
- f.write("langpack_locales = %s\n" % ", ".join(langs))
+
+ try:
+ # langpacks.conf is an INI style config file, read it and
+ # Add or change the langpack_locales entry without changing anything else.
+ keys=[("langpack_locales", "langpack_locales="+", ".join(langs))]
+ simple_replace(_yum_installer_langpack_conf, keys)
+ except IOError as msg:
+ log.error ("Error setting langpack_locales: %s", msg)
def _copyLangpacksConfigToTarget(self):
shutil.copy2(_yum_installer_langpack_conf,
--
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/e46aba84ae398d994992c59eb9b91c067ca72519
More information about the anaconda-patches
mailing list