RE: Terminate a CDROM install from %pre

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

 



I looked further up in the code and ultimately the situation seems to be
that the anaconda state
machine will not allow an error event (other than a python exception) to
cause it to exit.  If it did
allow such a short circuiting of the process, it would of course require
the exit code of the
script to actually be returned (well its inverse).    The seems to be true
of the text ui and
gui code.

Cheers...james

P.S. The code in question is in text.py and gui.py.  In text.py it is in
the InstallInterface.run() run method
for those curious.




                                                                                                                           
                    james.oden@xxxxxxxxxx                                                                                  
                    m                            To:     kickstart-list@xxxxxxxxxx                                         
                    Sent by:                     cc:                                                                       
                    kickstart-list-admin@        Subject:     RE: Terminate a CDROM install from %pre                      
                    redhat.com                                                                                             
                                                                                                                           
                                                                                                                           
                    04/02/03 05:22 PM                                                                                      
                    Please respond to                                                                                      
                    kickstart-list                                                                                         
                                                                                                                           
                                                                                                                           





OK, Here is the code from the kickstart.py file that acutally runs a script
(%pre or %post) in anaconda:

    def run(self, chroot, serial):
        scriptRoot = "/"
        if self.inChroot:
            scriptRoot = chroot

        path = scriptRoot + "/tmp/ks-script"

        f = open(path, "w")
        f.write(self.script)
        f.close()
        os.chmod(path, 0700)

        if serial:
            messages = "/tmp/ks-script.log"
        else:
            messages = "/dev/tty3"

        rc = iutil.execWithRedirect(self.interp,
                                    [self.interp,"/tmp/ks-script"],
                                    stdout = messages, stderr = messages,
                                    root = scriptRoot)

        if rc != 0:
            log("WARNING - Error code %s encountered running a kickstart
%%pre/%%post script"
, rc)

        os.unlink(path)

This code essentialy does the following:

     1) Write the script out to /tmp/ks-script or /tmp/ks-script in the
chrooted enviroment.
     2) Set  output from the script  to go to /dev/tty3 or in case of a
serial install to /tmp/ks-script.log.
     3) Run the written out script.
     4) Print a warning if an error was returned.
     5) Remove the script that was written out.

Note there is no return of the status of the script.  So there is the first
problem.

Now here is the code that actually calls the Script.run() methods for %pre
scripts:

        log("Running kickstart %%pre script(s)")
        for script in self.preScripts:
            script.run("/", self.serial)
        log("All kickstart %%pre script(s) have been run")

Note again, it does not check the return code and marches merrily along.
Now this bit of code is in
KickstartBase.setInstallData(), and I am not sure where it is called, but
probably it would need to return
an error to whatever called it, to get the thing to stop properly.  At
anyrate its easy to see that there was no
intention of even caring about return codes from %pre scripts (or %post
scripts for that matter), which I
thinks is the wrong thing to do, or at least there should be an option to
request it to do this, but in most
cases if the %pre goes bad, I don't want the install to continue.  In our
case when %pre goes bad
usually shortly there after anaconda goes completley off the rails and we
get a python exception.

cheers...james



_______________________________________________
Kickstart-list mailing list
Kickstart-list@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/kickstart-list







[Index of Archives]     [Red Hat General]     [CentOS Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux