On Wed, 2015-11-25 at 12:27 -0500, Chris Lumens wrote:
First, switch to using preprocessKickstartFromString, which is new
in
pykickstart. We can then have parse-kickstart work entirely in terms
of
strings instead of filenames, which means it doesn't need to write
anything out to ks.info anymore. However we do still need to write
the
processed kickstart file somewhere for the rest of anaconda to read.
Luckily we were always copying it to /run/install/ks.cfg so just use
that path name.
---
anaconda.spec.in | 2 +-
dracut/anaconda-lib.sh | 2 --
dracut/parse-kickstart | 20 +++++++++++++-------
tests/dracut_tests/parse-kickstart_test.py | 7 +------
4 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/anaconda.spec.in b/anaconda.spec.in
index 2a4de90..c344037 100644
--- a/anaconda.spec.in
+++ b/anaconda.spec.in
@@ -21,7 +21,7 @@ Source0: %{name}-%{version}.tar.bz2
# Also update in AM_GNU_GETTEXT_VERSION in configure.ac
%define gettextver 0.19.1
%define intltoolver 0.31.2-3
-%define pykickstartver 2.20
+%define pykickstartver 2.21
%define dnfver 0.6.4
%define partedver 1.8.1
%define pypartedver 2.5-2
diff --git a/dracut/anaconda-lib.sh b/dracut/anaconda-lib.sh
index e625609..4405b73 100755
--- a/dracut/anaconda-lib.sh
+++ b/dracut/anaconda-lib.sh
@@ -217,8 +217,6 @@ set_neednet() {
parse_kickstart() {
/sbin/parse-kickstart $1 > /etc/cmdline.d/80-kickstart.conf
unset CMDLINE # re-read the commandline
- . /tmp/ks.info # save the parsed kickstart
- [ -e "$parsed_kickstart" ] && cp $parsed_kickstart
/run/install/ks.cfg
}
# print a list of net devices that dracut says are set up.
diff --git a/dracut/parse-kickstart b/dracut/parse-kickstart
index ab602e1..015f689 100755
--- a/dracut/parse-kickstart
+++ b/dracut/parse-kickstart
@@ -30,7 +30,7 @@ import logging
import shutil
import uuid
import glob
-from pykickstart.parser import KickstartParser, preprocessKickstart
+from pykickstart.parser import KickstartParser,
preprocessKickstartToString
from pykickstart.sections import NullSection
from pykickstart.version import returnClassForVersion
from pykickstart.errors import KickstartError
@@ -584,15 +584,13 @@ def process_kickstart(ksfile):
parser.registerSection(NullSection(handler,
sectionOpen="%addon"))
parser.registerSection(NullSection(handler,
sectionOpen="%anaconda"))
log.info("processing kickstart file %s", ksfile)
- processed_file = preprocessKickstart(ksfile)
+ s = preprocessKickstartToString(ksfile)
try:
- parser.readKickstart(processed_file)
+ parser.readKickstartFromString(s)
except KickstartError as e:
log.error(str(e))
- with open(TMPDIR+"/ks.info", "a") as f:
- f.write('parsed_kickstart="%s"\n' % processed_file)
log.info("finished parsing kickstart")
- return processed_file, handler.output
+ return s, handler.output
if __name__ == '__main__':
log = init_logger()
@@ -607,7 +605,15 @@ if __name__ == '__main__':
except IndexError:
pass
+ KSCFGDIR = TMPDIR
+ else:
+ KSCFGDIR = "/run/install"
+
for path in sys.argv[1:]:
- outfile, output = process_kickstart(path)
+ s, output = process_kickstart(path)
+
+ with open(KSCFGDIR + "/ks.cfg", "w") as f:
+ f.write(s)
+
for line in (l for l in output if l):
print(line)
diff --git a/tests/dracut_tests/parse-kickstart_test.py
b/tests/dracut_tests/parse-kickstart_test.py
index 0f8705f..ddee47e 100644
--- a/tests/dracut_tests/parse-kickstart_test.py
+++ b/tests/dracut_tests/parse-kickstart_test.py
@@ -35,12 +35,7 @@ class BaseTestCase(unittest.TestCase):
# remove the testing directory
if self.tmpdir and os.path.isdir(self.tmpdir):
try:
- with open(self.tmpdir + "/ks.info") as f:
- for line in f:
- if line.startswith("parsed_kickstart="):
- filename =
line.partition("=")[2].strip().replace('"', "")
- os.remove(filename)
- break
+ os.remove(self.tmpdir + "/ks.cfg")
except OSError:
pass
ACK.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic