[PATCH 3/3] Move %pre processing to much earlier in the install process.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Also, rename the kickstart processing functions to make more sense.
---
 anaconda     |    8 ++++----
 kickstart.py |   56 +++++++++++++++++++++++++++++++-------------------------
 2 files changed, 35 insertions(+), 29 deletions(-)

diff --git a/anaconda b/anaconda
index f47f50a..e7fc97d 100755
--- a/anaconda
+++ b/anaconda
@@ -692,9 +692,9 @@ 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)
+        kickstart.preScriptPass(anaconda, opts.ksfile)
+        earlyKS = kickstart.earlyCommandPass(anaconda, opts.ksfile)
     else:
         earlyKS = None
 
@@ -719,7 +719,7 @@ if __name__ == "__main__":
             screen = SnackScreen()
             anaconda.intf = rescue.RescueInterface(screen)
 
-            kickstart.processKickstartFile(anaconda, opts.ksfile, earlyKS)
+            kickstart.fullCommandPass(anaconda, opts.ksfile, earlyKS)
 
             anaconda.intf = None
             screen.finish()
@@ -931,7 +931,7 @@ if __name__ == "__main__":
         anaconda.id.keyboard.activate()
 
     if anaconda.isKickstart:
-        kickstart.processKickstartFile(anaconda, opts.ksfile, earlyKS)
+        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 cd2985a..ddaa92d 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -1039,7 +1039,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,
@@ -1100,7 +1100,35 @@ class AnacondaKSParser(KickstartParser):
 
         KickstartParser.handleCommand(self, lineno, args)
 
-def earlyProcessKickstartFile(anaconda, file):
+def preScriptPass(anaconda, file):
+    # The first pass through kickstart file processing - look for %pre scripts
+    # and run them.  This must come first and 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 second 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:
@@ -1125,28 +1153,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
@@ -1156,7 +1163,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)
 
-- 
1.6.1.3

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux