from installclass import BaseInstallClass from rhpl.translate import N_, _ from rhpl.log import log from constants import * import os import iutil import string import security class Script: def __repr__(self): str = ("(s: '%s' i: %s c: %d)") % \ (self.script, self.interp, self.inChroot) return string.replace(str, "\n", "|") def __init__(self, script, interp, inChroot, logfile = None): self.script = script self.interp = interp self.inChroot = inChroot 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) 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) if rc != 0: log("WARNING - Error code %s encountered running a sme script", rc) os.unlink(path) class InstallClass(BaseInstallClass): name = N_("Upgrade Existing System") pixmap = "upgrade.png" sortPriority = 999999 parentClass = ( _("Upgrade"), "upgrade.png" ) def requiredDisplayMode(self): return 't' def setSteps(self, dispatch): dispatch.setStepList( "language", "keyboard", "installtype", "findrootparts", "findinstall", "partitionobjinit", "upgrademount", "upgradecontinue", "upgrademigfind", "upgrademigratefs", "readcomps", "findpackages", "checkdeps", "dependencies", "install", "migratefilesystems", "preinstallconfig", "installpackages", "postinstallconfig", "instbootloader", "copylogs", "dopostaction", "methodcomplete", "complete" ) if iutil.getPPCMachine() == "iSeries": dispatch.skipStep("bootloadersetup", skip = 0) if iutil.getArch() != "i386" and iutil.getArch() != "x86_64": dispatch.skipStep("bootloader") dispatch.skipStep("bootloaderadvanced") if iutil.getArch() != "i386" and iutil.getArch() != "x86_64": dispatch.skipStep("upgbootloader") def postAction(self, rootPath, serial, intf): win = intf.waitWindow(_("Post Upgrade Script"), _("The post upgrade script is running...")) 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) win.pop() def setInstallData(self, id): BaseInstallClass.setInstallData(self, id) id.upgrade.set(1) def __init__(self, expert): BaseInstallClass.__init__(self, expert)