1 |
from installclass import BaseInstallClass |
from installclass import getBaseInstallClass |
2 |
from rhpl.translate import N_, _ |
from rhpl.translate import N_, _ |
3 |
from rhpl.log import log |
from constants import * |
|
|
|
4 |
import os |
import os |
5 |
import iutil |
import iutil |
6 |
|
import rhpl |
7 |
|
|
8 |
|
baseclass = getBaseInstallClass() |
9 |
|
|
10 |
|
import logging |
11 |
|
log = logging.getLogger("anaconda") |
12 |
|
|
13 |
|
import string |
14 |
|
|
15 |
|
class Script: |
16 |
|
def __repr__(self): |
17 |
|
str = ("(s: '%s' i: %s c: %d)") % \ |
18 |
|
(self.script, self.interp, self.inChroot) |
19 |
|
return string.replace(str, "\n", "|") |
20 |
|
|
21 |
|
def __init__(self, script, interp, inChroot, logfile = None): |
22 |
|
self.script = script |
23 |
|
self.interp = interp |
24 |
|
self.inChroot = inChroot |
25 |
|
self.logfile = logfile |
26 |
|
|
27 |
|
def run(self, chroot, serial): |
28 |
|
import tempfile |
29 |
|
import os.path |
30 |
|
|
31 |
|
if self.inChroot: |
32 |
|
scriptRoot = chroot |
33 |
|
else: |
34 |
|
scriptRoot = "/" |
35 |
|
|
36 |
|
(fd, path) = tempfile.mkstemp("", "sme-script-", scriptRoot + "/tmp") |
37 |
|
|
38 |
class InstallClass(BaseInstallClass): |
os.write(fd, self.script) |
39 |
|
os.close(fd) |
40 |
|
os.chmod(path, 0700) |
41 |
|
|
42 |
|
if self.logfile is not None: |
43 |
|
messages = self.logfile |
44 |
|
elif serial: |
45 |
|
messages = "%s.log" % path |
46 |
|
else: |
47 |
|
messages = "/dev/tty3" |
48 |
|
|
49 |
|
rc = iutil.execWithRedirect(self.interp, ["/tmp/%s" % os.path.basename(path)], |
50 |
|
stdin = messages, stdout = messages, stderr = messages, |
51 |
|
root = scriptRoot) |
52 |
|
|
53 |
|
if rc != 0: |
54 |
|
log.error("WARNING - Error code %s encountered running a sme script", rc) |
55 |
|
|
56 |
|
os.unlink(path) |
57 |
|
if serial or self.logfile is not None: |
58 |
|
os.chmod("%s" % messages, 0600) |
59 |
|
|
60 |
|
class InstallClass(baseclass): |
61 |
name = N_("Upgrade Existing System") |
name = N_("Upgrade Existing System") |
62 |
pixmap = "upgrade.png" |
pixmap = "upgrade.png" |
63 |
sortPriority = 999999 |
sortPriority = 999999 |
72 |
"language", |
"language", |
73 |
"keyboard", |
"keyboard", |
74 |
"findrootparts", |
"findrootparts", |
75 |
|
"findinstall", |
76 |
|
"installtype", |
77 |
"partitionobjinit", |
"partitionobjinit", |
78 |
"upgrademount", |
"upgrademount", |
79 |
"upgrademigfind", |
"upgrademigfind", |
80 |
"upgrademigratefs", |
"upgrademigratefs", |
81 |
"upgradecontinue", |
"upgradecontinue", |
82 |
"readcomps", |
"reposetup", |
83 |
"findpackages", |
"upgbootloader", |
84 |
"checkdeps", |
"checkdeps", |
85 |
"dependencies", |
"dependencies", |
86 |
|
"postselection", |
87 |
"install", |
"install", |
88 |
"migratefilesystems", |
"migratefilesystems", |
89 |
"preinstallconfig", |
"preinstallconfig", |
96 |
"complete" |
"complete" |
97 |
) |
) |
98 |
|
|
99 |
def postAction(self, rootPath, serial): |
if iutil.getPPCMachine() == "iSeries": |
100 |
if serial: |
dispatch.skipStep("bootloadersetup", skip = 0) |
|
messages = "/tmp/postupgrade.log" |
|
|
else: |
|
|
messages = "/dev/tty3" |
|
|
args = [ "/usr/sbin/lokkit", "--quiet", "--nostart", "--selinux=disabled"] |
|
|
|
|
|
try: |
|
|
iutil.execWithRedirect(args[0], args, root=rootPath, |
|
|
stdout=messages, stderr=messages) |
|
|
except RuntimeError, msg: |
|
|
log ("lokkit run failed: %s", msg) |
|
|
except OSError, (errno, msg): |
|
|
log ("lokkit run failed: %s", msg) |
|
|
|
|
|
path = rootPath + "/tmp/postupgrade.sh" |
|
|
cmds = ["/sbin/syslogd &", "sleep 2", "/sbin/e-smith/signal-event post-upgrade"] |
|
|
|
|
|
f = open(path, "w") |
|
|
f.writelines(cmds) |
|
|
f.close |
|
|
os.chmod(path, 0700) |
|
101 |
|
|
102 |
rc = iutil.execWithRedirect("/bin/sh", ["/bin/sh", "/tmp/postupgrade.sh"], |
if rhpl.getArch() != "i386" and rhpl.getArch() != "x86_64": |
103 |
stdout=messages, stderr=messages, root=rootPath) |
dispatch.skipStep("bootloader") |
104 |
if rc != 0: |
dispatch.skipStep("bootloaderadvanced") |
105 |
log("WARNING - Error code %s encountered running postupgrade script", rc) |
|
106 |
os.unlink(path) |
if rhpl.getArch() != "i386" and rhpl.getArch() != "x86_64": |
107 |
|
dispatch.skipStep("upgbootloader") |
108 |
def setInstallData(self, id): |
|
109 |
BaseInstallClass.setInstallData(self, id) |
def postAction(self, anaconda, serial): |
110 |
id.upgrade.set(1) |
win = anaconda.intf.waitWindow(_("Post Upgrade Script"), |
111 |
|
_("The post upgrade script is running...")) |
112 |
|
|
113 |
|
script = ( "#!/bin/sh\nmkdir -p /var/lib/dhcp; /sbin/syslogd ; sleep 2; /sbin/e-smith/signal-event post-upgrade\n" ) |
114 |
|
s = Script(script, interp="/bin/sh", inChroot=1) |
115 |
|
log.info("%s", s) |
116 |
|
s.run(anaconda.rootPath, serial) |
117 |
|
win.pop() |
118 |
|
|
119 |
|
def setInstallData(self, anaconda): |
120 |
|
baseclass.setInstallData(self, anaconda) |
121 |
|
anaconda.id.setUpgrade(True) |
122 |
|
|
123 |
def __init__(self, expert): |
def __init__(self, expert): |
124 |
BaseInstallClass.__init__(self, expert) |
baseclass.__init__(self, expert) |