1 |
from installclass import BaseInstallClass |
from installclass import BaseInstallClass |
2 |
from rhpl.translate import N_, _ |
from rhpl.translate import N_, _ |
3 |
from rhpl.log import log |
from rhpl.log import log |
4 |
|
from constants import * |
5 |
|
|
6 |
import os |
import os |
7 |
import iutil |
import iutil |
8 |
|
import string |
9 |
|
import security |
10 |
|
|
11 |
|
class Script: |
12 |
|
def __repr__(self): |
13 |
|
str = ("(s: '%s' i: %s c: %d)") % \ |
14 |
|
(self.script, self.interp, self.inChroot) |
15 |
|
return string.replace(str, "\n", "|") |
16 |
|
|
17 |
|
def __init__(self, script, interp, inChroot, logfile = None): |
18 |
|
self.script = script |
19 |
|
self.interp = interp |
20 |
|
self.inChroot = inChroot |
21 |
|
self.logfile = logfile |
22 |
|
|
23 |
|
def run(self, chroot, serial): |
24 |
|
scriptRoot = "/" |
25 |
|
if self.inChroot: |
26 |
|
scriptRoot = chroot |
27 |
|
|
28 |
|
path = scriptRoot + "/tmp/sme-script" |
29 |
|
|
30 |
|
f = open(path, "w") |
31 |
|
f.write(self.script) |
32 |
|
f.close() |
33 |
|
os.chmod(path, 0700) |
34 |
|
|
35 |
|
if self.logfile is not None: |
36 |
|
messages = self.logfile |
37 |
|
elif serial: |
38 |
|
messages = "/tmp/sme-script.log" |
39 |
|
else: |
40 |
|
messages = "/dev/tty3" |
41 |
|
|
42 |
|
rc = iutil.execWithRedirect(self.interp, |
43 |
|
[self.interp,"/tmp/sme-script"], |
44 |
|
stdout = messages, stderr = messages, |
45 |
|
root = scriptRoot) |
46 |
|
|
47 |
|
if rc != 0: |
48 |
|
log("WARNING - Error code %s encountered running a sme script", rc) |
49 |
|
|
50 |
|
os.unlink(path) |
51 |
|
|
52 |
class InstallClass(BaseInstallClass): |
class InstallClass(BaseInstallClass): |
53 |
name = N_("Upgrade Existing System") |
name = N_("Upgrade Existing System") |
63 |
dispatch.setStepList( |
dispatch.setStepList( |
64 |
"language", |
"language", |
65 |
"keyboard", |
"keyboard", |
66 |
|
"installtype", |
67 |
"findrootparts", |
"findrootparts", |
68 |
|
"findinstall", |
69 |
"partitionobjinit", |
"partitionobjinit", |
70 |
"upgrademount", |
"upgrademount", |
71 |
"upgrademigfind", |
"upgrademigfind", |
87 |
"complete" |
"complete" |
88 |
) |
) |
89 |
|
|
90 |
def postAction(self, rootPath, serial): |
if iutil.getPPCMachine() == "iSeries": |
91 |
if serial: |
dispatch.skipStep("bootloadersetup", skip = 0) |
92 |
messages = "/tmp/postupgrade.log" |
|
93 |
else: |
if iutil.getArch() != "i386" and iutil.getArch() != "x86_64": |
94 |
messages = "/dev/tty3" |
dispatch.skipStep("bootloader") |
95 |
args = [ "/usr/sbin/lokkit", "--quiet", "--nostart", "--selinux=disabled"] |
dispatch.skipStep("bootloaderadvanced") |
96 |
|
|
97 |
try: |
if iutil.getArch() != "i386" and iutil.getArch() != "x86_64": |
98 |
iutil.execWithRedirect(args[0], args, root=rootPath, |
dispatch.skipStep("upgbootloader") |
99 |
stdout=messages, stderr=messages) |
|
100 |
except RuntimeError, msg: |
def postAction(self, rootPath, serial, intf): |
101 |
log ("lokkit run failed: %s", msg) |
win = intf.waitWindow(_("Post Upgrade Script"), |
102 |
except OSError, (errno, msg): |
_("The post upgrade script is running...")) |
103 |
log ("lokkit run failed: %s", msg) |
|
104 |
|
script = ( "/sbin/syslogd &\n" |
105 |
path = rootPath + "/tmp/postupgrade.sh" |
"sleep 2\n" |
106 |
cmds = ["/sbin/syslogd &", "sleep 2", "/sbin/e-smith/signal-event post-upgrade"] |
"/sbin/e-smith/signal-event post-upgrade\n" ) |
107 |
|
s = Script(script, interp="/bin/sh", inChroot=1) |
108 |
f = open(path, "w") |
log("%s", s) |
109 |
f.writelines(cmds) |
s.run(rootPath, serial) |
110 |
f.close |
win.pop() |
|
os.chmod(path, 0700) |
|
|
|
|
|
rc = iutil.execWithRedirect("/bin/sh", ["/bin/sh", "/tmp/postupgrade.sh"], |
|
|
stdout=messages, stderr=messages, root=rootPath) |
|
|
if rc != 0: |
|
|
log("WARNING - Error code %s encountered running postupgrade script", rc) |
|
|
os.unlink(path) |
|
111 |
|
|
112 |
def setInstallData(self, id): |
def setInstallData(self, id): |
113 |
BaseInstallClass.setInstallData(self, id) |
BaseInstallClass.setInstallData(self, id) |