1 |
slords |
1.1 |
from installclass import BaseInstallClass |
2 |
|
|
from rhpl.translate import N_, _ |
3 |
|
|
from rhpl.log import log |
4 |
slords |
1.2 |
from constants import * |
5 |
slords |
1.1 |
|
6 |
|
|
import os |
7 |
slords |
1.2 |
import string |
8 |
slords |
1.1 |
import iutil |
9 |
slords |
1.2 |
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 |
slords |
1.1 |
|
52 |
|
|
class InstallClass(BaseInstallClass): |
53 |
|
|
name = N_("Upgrade Existing System") |
54 |
|
|
pixmap = "upgrade.png" |
55 |
|
|
sortPriority = 999999 |
56 |
|
|
|
57 |
|
|
parentClass = ( _("Upgrade"), "upgrade.png" ) |
58 |
|
|
|
59 |
|
|
def requiredDisplayMode(self): |
60 |
|
|
return 't' |
61 |
|
|
|
62 |
|
|
def setSteps(self, dispatch): |
63 |
|
|
dispatch.setStepList( |
64 |
|
|
"language", |
65 |
|
|
"keyboard", |
66 |
|
|
"findrootparts", |
67 |
slords |
1.2 |
"findinstall", |
68 |
|
|
"installtype", |
69 |
slords |
1.1 |
"partitionobjinit", |
70 |
|
|
"upgrademount", |
71 |
|
|
"upgrademigfind", |
72 |
|
|
"upgrademigratefs", |
73 |
|
|
"upgradecontinue", |
74 |
slords |
1.2 |
"bootloadersetup", |
75 |
slords |
1.1 |
"readcomps", |
76 |
|
|
"findpackages", |
77 |
|
|
"checkdeps", |
78 |
|
|
"dependencies", |
79 |
|
|
"install", |
80 |
|
|
"migratefilesystems", |
81 |
|
|
"preinstallconfig", |
82 |
|
|
"installpackages", |
83 |
|
|
"postinstallconfig", |
84 |
|
|
"instbootloader", |
85 |
|
|
"dopostaction", |
86 |
|
|
"methodcomplete", |
87 |
|
|
"copylogs", |
88 |
|
|
"complete" |
89 |
|
|
) |
90 |
|
|
|
91 |
|
|
def postAction(self, rootPath, serial): |
92 |
slords |
1.2 |
# Hack to disable SELinux on upgrade |
93 |
|
|
sec = security.Security() |
94 |
|
|
sec.setSELinux(0) |
95 |
|
|
sec.write(rootPath) |
96 |
|
|
|
97 |
|
|
script = "/sbin/syslogd &\nsleep 2\n/sbin/e-smith/signal-event post-upgrade\n" |
98 |
|
|
s = Script(script, interp="/bin/sh", inChroot=1) |
99 |
|
|
log("%s", s) |
100 |
|
|
s.run(rootPath, serial) |
101 |
slords |
1.1 |
|
102 |
|
|
def setInstallData(self, id): |
103 |
|
|
BaseInstallClass.setInstallData(self, id) |
104 |
|
|
id.upgrade.set(1) |
105 |
|
|
|
106 |
|
|
def __init__(self, expert): |
107 |
|
|
BaseInstallClass.__init__(self, expert) |