summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2009-03-30 13:21:46 -0400
committerChris Lumens <clumens@redhat.com>2009-03-31 10:22:14 -0400
commit1bd3e8408a6e3173ac86a7f3ab678422e3a81a7e (patch)
tree1ca30344ceaa75cbdcdfc409a81ffb0cca11df2b
parentdc8cbf05ee52ab1b03f3ac1ab24fd8667d99865b (diff)
downloadanaconda-1bd3e8408a6e3173ac86a7f3ab678422e3a81a7e.tar.gz
anaconda-1bd3e8408a6e3173ac86a7f3ab678422e3a81a7e.tar.xz
anaconda-1bd3e8408a6e3173ac86a7f3ab678422e3a81a7e.zip
Move %pre processing to much earlier in the install process.
Also, rename the kickstart processing functions to make more sense.
-rwxr-xr-xanaconda9
-rw-r--r--kickstart.py56
2 files changed, 36 insertions, 29 deletions
diff --git a/anaconda b/anaconda
index f47f50a6b..4dcf113ef 100755
--- a/anaconda
+++ b/anaconda
@@ -692,9 +692,8 @@ if __name__ == "__main__":
# for a couple specific commands that'll be useful in setting up the
# interface.
if opts.ksfile:
- from kickstart import earlyProcessKickstartFile
anaconda.isKickstart = True
- earlyKS = earlyProcessKickstartFile(anaconda, opts.ksfile)
+ earlyKS = kickstart.earlyCommandPass(anaconda, opts.ksfile)
else:
earlyKS = None
@@ -719,7 +718,8 @@ if __name__ == "__main__":
screen = SnackScreen()
anaconda.intf = rescue.RescueInterface(screen)
- kickstart.processKickstartFile(anaconda, opts.ksfile, earlyKS)
+ kickstart.preScriptPass(anaconda, opts.ksfile)
+ kickstart.fullCommandPass(anaconda, opts.ksfile, earlyKS)
anaconda.intf = None
screen.finish()
@@ -931,7 +931,8 @@ if __name__ == "__main__":
anaconda.id.keyboard.activate()
if anaconda.isKickstart:
- kickstart.processKickstartFile(anaconda, opts.ksfile, earlyKS)
+ kickstart.preScriptPass(anaconda, opts.ksfile)
+ kickstart.fullCommandPass(anaconda, opts.ksfile, earlyKS)
# We need to copy the VNC-related kickstart stuff into the new ksdata
anaconda.id.ksdata.vnc(enabled=earlyKS.vnc.enabled, host=earlyKS.vnc.host,
password=earlyKS.vnc.password, port=earlyKS.vnc.port)
diff --git a/kickstart.py b/kickstart.py
index b1ac3ba35..844e58c61 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -1042,7 +1042,7 @@ class EarlyKSHandler(superclass):
self.maskAllExcept(["vnc", "displaymode", "text", "cmdline",
"graphical", "rescue", "ignoredisk"])
-class KickstartPreParser(KickstartParser):
+class AnacondaPreParser(KickstartParser):
# A subclass of KickstartParser that only looks for %pre scripts and
# sets them up to be run. All other scripts and commands are ignored.
def __init__ (self, handler, followIncludes=True, errorsAreFatal=True,
@@ -1103,7 +1103,35 @@ class AnacondaKSParser(KickstartParser):
KickstartParser.handleCommand(self, lineno, args)
-def earlyProcessKickstartFile(anaconda, file):
+def preScriptPass(anaconda, file):
+ # The second pass through kickstart file processing - look for %pre scripts
+ # and run them. This must come in a separate pass in case a script
+ # generates an included file that has commands for later.
+ ksparser = AnacondaPreParser(AnacondaKSHandler(anaconda))
+
+ try:
+ ksparser.readKickstart(file)
+ except IOError, e:
+ if anaconda.intf:
+ anaconda.intf.kickstartErrorWindow("Could not open kickstart file or included file named %s" % e.filename)
+ sys.exit(0)
+ else:
+ raise
+ except KickstartError, e:
+ if anaconda.intf:
+ anaconda.intf.kickstartErrorWindow(e.__str__())
+ sys.exit(0)
+ else:
+ raise
+
+ # run %pre scripts
+ runPreScripts(anaconda, ksparser.handler.scripts)
+
+def earlyCommandPass(anaconda, file):
+ # The first pass through kickstart file processing - look for the subset
+ # of commands listed in EarlyKSHandler and set attributes based on those.
+ # This has to be a separate pass because it needs to take place before
+ # anaconda even knows what interface to run.
try:
file = preprocessKickstart(file)
except KickstartError, msg:
@@ -1128,28 +1156,7 @@ def earlyProcessKickstartFile(anaconda, file):
# And return the handler object so we can get information out of it.
return handler
-def processKickstartFile(anaconda, file, earlyKS):
- # parse the %pre
- ksparser = KickstartPreParser(AnacondaKSHandler(anaconda))
-
- try:
- ksparser.readKickstart(file)
- except IOError, e:
- if anaconda.intf:
- anaconda.intf.kickstartErrorWindow("Could not open kickstart file or included file named %s" % e.filename)
- sys.exit(0)
- else:
- raise
- except KickstartError, e:
- if anaconda.intf:
- anaconda.intf.kickstartErrorWindow(e.__str__())
- sys.exit(0)
- else:
- raise
-
- # run %pre scripts
- runPreScripts(anaconda, ksparser.handler.scripts)
-
+def fullCommandPass(anaconda, file, earlyKS):
# We need to make sure storage is active before the rest of the kickstart
# file is processed. But before we initialize storage, we have to tell it
# which disks to avoid, and we only get that information from the earlier
@@ -1159,7 +1166,6 @@ def processKickstartFile(anaconda, file, earlyKS):
anaconda.id.storage.exclusiveDisks = earlyKS.ignoredisk.onlyuse
storage.storageInitialize(anaconda)
- # now read the kickstart file for real
handler = AnacondaKSHandler(anaconda)
ksparser = AnacondaKSParser(handler)