--- cdrom.image/updates/smeupgradeclass.py 2005/07/31 16:38:19 1.3 +++ cdrom.image/updates/smeupgradeclass.py 2008/03/15 18:11:42 1.10.2.4 @@ -1,12 +1,16 @@ -from installclass import BaseInstallClass +from installclass import getBaseInstallClass from rhpl.translate import N_, _ -from rhpl.log import log from constants import * - import os -import string import iutil -import security +import rhpl + +baseclass = getBaseInstallClass() + +import logging +log = logging.getLogger("anaconda") + +import string class Script: def __repr__(self): @@ -21,35 +25,39 @@ class Script: self.logfile = logfile def run(self, chroot, serial): - scriptRoot = "/" - if self.inChroot: - scriptRoot = chroot - - path = scriptRoot + "/tmp/sme-script" - - f = open(path, "w") - f.write(self.script) - f.close() - os.chmod(path, 0700) + import tempfile + import os.path + + if self.inChroot: + scriptRoot = chroot + else: + scriptRoot = "/" + + (fd, path) = tempfile.mkstemp("", "sme-script-", scriptRoot + "/tmp") + + os.write(fd, self.script) + os.close(fd) + os.chmod(path, 0700) if self.logfile is not None: messages = self.logfile - elif serial: - messages = "/tmp/sme-script.log" - else: - messages = "/dev/tty3" - - rc = iutil.execWithRedirect(self.interp, - [self.interp,"/tmp/sme-script"], - stdout = messages, stderr = messages, - root = scriptRoot) + elif serial: + messages = "%s.log" % path + else: + messages = "/dev/tty3" + + rc = iutil.execWithRedirect(self.interp, ["/tmp/%s" % os.path.basename(path)], + stdin = messages, stdout = messages, stderr = messages, + root = scriptRoot) if rc != 0: - log("WARNING - Error code %s encountered running a sme script", rc) + log.error("WARNING - Error code %s encountered running a sme script", rc) os.unlink(path) + if serial or self.logfile is not None: + os.chmod("%s" % messages, 0600) -class InstallClass(BaseInstallClass): +class InstallClass(baseclass): name = N_("Upgrade Existing System") pixmap = "upgrade.png" sortPriority = 999999 @@ -71,11 +79,11 @@ class InstallClass(BaseInstallClass): "upgrademigfind", "upgrademigratefs", "upgradecontinue", - "bootloadersetup", - "readcomps", - "findpackages", + "reposetup", + "upgbootloader", "checkdeps", "dependencies", + "postselection", "install", "migratefilesystems", "preinstallconfig", @@ -88,22 +96,29 @@ class InstallClass(BaseInstallClass): "complete" ) - def postAction(self, rootPath, serial): - # Hack to disable SELinux on upgrade - sec = security.Security() - sec.setSELinux(0) - sec.write(rootPath) - - script = ( "/sbin/syslogd &\n" - "sleep 2\n" - "/sbin/e-smith/signal-event post-upgrade\n" ) - s = Script(script, interp="/bin/sh", inChroot=1) - log("%s", s) - s.run(rootPath, serial) + if iutil.getPPCMachine() == "iSeries": + dispatch.skipStep("bootloadersetup", skip = 0) + + if rhpl.getArch() != "i386" and rhpl.getArch() != "x86_64": + dispatch.skipStep("bootloader") + dispatch.skipStep("bootloaderadvanced") - def setInstallData(self, id): - BaseInstallClass.setInstallData(self, id) - id.upgrade.set(1) + if rhpl.getArch() != "i386" and rhpl.getArch() != "x86_64": + dispatch.skipStep("upgbootloader") + + def postAction(self, anaconda, serial): + win = anaconda.intf.waitWindow(_("Post Upgrade Script"), + _("The post upgrade script is running...")) + + script = ( "#!/bin/sh\nmkdir -p /var/lib/dhcp; /sbin/syslogd ; sleep 2; /sbin/e-smith/signal-event post-upgrade\n" ) + s = Script(script, interp="/bin/sh", inChroot=1) + log.info("%s", s) + s.run(anaconda.rootPath, serial) + win.pop() + + def setInstallData(self, anaconda): + baseclass.setInstallData(self, anaconda) + anaconda.id.setUpgrade(True) def __init__(self, expert): - BaseInstallClass.__init__(self, expert) + baseclass.__init__(self, expert)