diff options
author | Chris Lumens <clumens@redhat.com> | 2007-03-01 20:16:08 +0000 |
---|---|---|
committer | Chris Lumens <clumens@redhat.com> | 2007-03-01 20:16:08 +0000 |
commit | ec566298ebcdfda1f998eb1e7a161a8d8c2222c3 (patch) | |
tree | 892b55acd59acdf64ff6dfb41902c625ef5724e5 /kickstart.py | |
parent | 6c7e2d821ea36c17920069fef33d6e6f5d7f1ea4 (diff) | |
download | anaconda-ec566298ebcdfda1f998eb1e7a161a8d8c2222c3.tar.gz anaconda-ec566298ebcdfda1f998eb1e7a161a8d8c2222c3.tar.xz anaconda-ec566298ebcdfda1f998eb1e7a161a8d8c2222c3.zip |
Support multiple %ksappend lines (#222201).
Diffstat (limited to 'kickstart.py')
-rw-r--r-- | kickstart.py | 83 |
1 files changed, 40 insertions, 43 deletions
diff --git a/kickstart.py b/kickstart.py index a569224ba..cffd45d31 100644 --- a/kickstart.py +++ b/kickstart.py @@ -13,6 +13,7 @@ import iutil import isys import os +import tempfile from partitioning import * from autopart import * from fsset import * @@ -841,44 +842,50 @@ def processKickstartFile(anaconda, file): anaconda.id.setKsdata(handler) -# -# look through ksfile and if it contains a line: +# look through ksfile and if it contains any lines: # # %ksappend <url> # -# pull <url> down and append to /tmp/ks.cfg. This is run before we actually -# parse the complete kickstart file. +# pull <url> down and stick it in /tmp/ks.cfg in place of the %ksappend line. +# This is run before we actually parse the complete kickstart file. # # Main use is to have the ks.cfg you send to the loader be minimal, and then # use %ksappend to pull via https anything private (like passwords, etc) in # the second stage. -# def pullRemainingKickstartConfig(ksfile): + # Open the input kickstart file and read it all into a list. try: - f = open(ksfile, "r") + inF = open(ksfile, "r") except: - raise KickstartError ("Unable to open ks file %s for append" % ksfile) + raise KickstartError ("Unable to open ks file %s for reading" % ksfile) + + lines = inF.readlines() + inF.close() - lines = f.readlines() - f.close() + # Now open an output kickstart file that we are going to write to one + # line at a time. + (outF, outName) = tempfile.mkstemp("-ks.cfg", "", "/tmp") - url = None for l in lines: - ll = l.strip() - if string.find(ll, "%ksappend") == -1: - continue + url = None - try: - (xxx, ksurl) = string.split(ll, ' ') - except: - raise KickstartError ("Illegal url for %%ksappend - %s" % ll) + ll = l.strip() + if string.find(ll, "%ksappend") == -1: + outF.write(l) + continue + + # Try to pull down the remote file. + try: + ksurl = string.split(ll, ' ')[1] + except: + raise KickstartError ("Illegal url for %%ksappend: %s" % ll) - log.info("Attempting to pull second part of ks.cfg from url %s" % ksurl) + log.info("Attempting to pull additional part of ks.cfg from url %s" % ksurl) - try: - url = grabber.urlopen (ksurl) - except grabber.URLGrabError, e: - raise KickstartError ("IOError: %s" % e.strerror) + try: + url = grabber.urlopen (ksurl) + except grabber.URLGrabError, e: + raise KickstartError ("IOError: %s" % e.strerror) else: # sanity check result - sometimes FTP doesnt # catch a file is missing @@ -890,27 +897,17 @@ def pullRemainingKickstartConfig(ksfile): if clen < 1: raise KickstartError ("IOError: -1:File not found") - break - - # if we got something then rewrite /tmp/ks.cfg with new information - if url is not None: - os.rename("/tmp/ks.cfg", "/tmp/ks.cfg-part1") - - # insert contents of original /tmp/ks.cfg w/o %ksappend line - f = open("/tmp/ks.cfg", 'w+') - for l in lines: - ll = l.strip() - if string.find(ll, "%ksappend") != -1: - continue - f.write(l) - - # now write part we just grabbed - f.write(url.read()) - f.close() - - # close up url and we're done - url.close() - + # If that worked, now write the remote file to the output kickstart + # file in one burst. Then close everything up to get ready to read + # farther ahead in the input file. This allows multiple %ksappend + # lines to exist. + if url is not None: + outF.write(url.read()) + url.close() + + # All done - move the temp output file to the expected location. + outF.close() + os.rename(outname, "/tmp/ks.cfg") return None def runPostScripts(anaconda): |