1 |
from installclass import getBaseInstallClass |
2 |
from rhpl.translate import N_, _ |
3 |
|
4 |
import logging |
5 |
log = logging.getLogger("anaconda") |
6 |
|
7 |
from constants import * |
8 |
|
9 |
import os |
10 |
import iutil |
11 |
import string |
12 |
import rhpl |
13 |
|
14 |
baseclass = getBaseInstallClass() |
15 |
|
16 |
|
17 |
class Script: |
18 |
def __repr__(self): |
19 |
str = ("(s: '%s' i: %s c: %d)") % \ |
20 |
(self.script, self.interp, self.inChroot) |
21 |
return string.replace(str, "\n", "|") |
22 |
|
23 |
def __init__(self, script, interp, inChroot, logfile = None): |
24 |
self.script = script |
25 |
self.interp = interp |
26 |
self.inChroot = inChroot |
27 |
self.logfile = logfile |
28 |
|
29 |
def run(self, chroot, serial): |
30 |
scriptRoot = "/" |
31 |
if self.inChroot: |
32 |
scriptRoot = chroot |
33 |
|
34 |
path = scriptRoot + "/tmp/sme-script" |
35 |
|
36 |
f = open(path, "w") |
37 |
f.write(self.script) |
38 |
f.close() |
39 |
os.chmod(path, 0700) |
40 |
|
41 |
if self.logfile is not None: |
42 |
messages = self.logfile |
43 |
elif serial: |
44 |
messages = "/tmp/sme-script.log" |
45 |
else: |
46 |
messages = "/dev/tty3" |
47 |
|
48 |
rc = iutil.execWithRedirect(self.interp, |
49 |
[self.interp,"/tmp/sme-script"], |
50 |
stdout = messages, stderr = messages, |
51 |
root = scriptRoot) |
52 |
|
53 |
if rc != 0: |
54 |
log.info("WARNING - Error code %s encountered running a sme script", rc) |
55 |
|
56 |
os.unlink(path) |
57 |
|
58 |
class InstallClass(baseclass): |
59 |
name = N_("Upgrade Existing System") |
60 |
pixmap = "upgrade.png" |
61 |
sortPriority = 999999 |
62 |
|
63 |
parentClass = ( _("Upgrade"), "upgrade.png" ) |
64 |
|
65 |
def requiredDisplayMode(self): |
66 |
return 't' |
67 |
|
68 |
def setSteps(self, dispatch): |
69 |
dispatch.setStepList( |
70 |
"language", |
71 |
"keyboard", |
72 |
"findrootparts", |
73 |
"findinstall", |
74 |
"installtype", |
75 |
"partitionobjinit", |
76 |
"upgrademount", |
77 |
"upgrademigfind", |
78 |
"upgrademigratefs", |
79 |
"upgradecontinue", |
80 |
"reposetup", |
81 |
"upgbootloader", |
82 |
"checkdeps", |
83 |
"dependencies", |
84 |
"postselection", |
85 |
"install", |
86 |
"migratefilesystems", |
87 |
"preinstallconfig", |
88 |
"installpackages", |
89 |
"postinstallconfig", |
90 |
"instbootloader", |
91 |
"dopostaction", |
92 |
"methodcomplete", |
93 |
"copylogs", |
94 |
"complete" |
95 |
) |
96 |
|
97 |
if iutil.getPPCMachine() == "iSeries": |
98 |
dispatch.skipStep("bootloadersetup", skip = 0) |
99 |
|
100 |
if rhpl.getArch() != "i386" and rhpl.getArch() != "x86_64": |
101 |
dispatch.skipStep("bootloader") |
102 |
dispatch.skipStep("bootloaderadvanced") |
103 |
|
104 |
if rhpl.getArch() != "i386" and rhpl.getArch() != "x86_64": |
105 |
dispatch.skipStep("upgbootloader") |
106 |
|
107 |
def postAction(self, anaconda, serial): |
108 |
win = anaconda.intf.waitWindow(_("Post Upgrade Script"), |
109 |
_("The post upgrade script is running...")) |
110 |
|
111 |
script = ( "/sbin/syslogd &\n" |
112 |
"sleep 2\n" |
113 |
"/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): |
124 |
baseclass.__init__(self, expert) |