1 |
from installclass import getBaseInstallClass |
2 |
from rhpl.translate import N_, _ |
3 |
from constants import * |
4 |
import os |
5 |
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 |
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") |
62 |
pixmap = "upgrade.png" |
63 |
sortPriority = 999999 |
64 |
|
65 |
parentClass = ( _("Upgrade"), "upgrade.png" ) |
66 |
|
67 |
def requiredDisplayMode(self): |
68 |
return 't' |
69 |
|
70 |
def setSteps(self, dispatch): |
71 |
dispatch.setStepList( |
72 |
"language", |
73 |
"keyboard", |
74 |
"findrootparts", |
75 |
"findinstall", |
76 |
"partitionobjinit", |
77 |
"upgrademount", |
78 |
"upgrademigfind", |
79 |
"upgrademigratefs", |
80 |
"upgradecontinue", |
81 |
"upgbootloader", |
82 |
"reposetup", |
83 |
"postselection", |
84 |
"confirmupgrade", |
85 |
"install", |
86 |
"migratefilesystems", |
87 |
"preinstallconfig", |
88 |
"installpackages", |
89 |
"postinstallconfig", |
90 |
"instbootloader", |
91 |
"copylogs", |
92 |
"methodcomplete", |
93 |
"dopostaction", |
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 = ( "#!/bin/sh\nmkdir -p /var/lib/dhcp; /sbin/syslogd ; sleep 2; /sbin/e-smith/signal-event post-upgrade\n" ) |
112 |
s = Script(script, interp="/bin/sh", inChroot=1) |
113 |
log.info("%s", s) |
114 |
s.run(anaconda.rootPath, serial) |
115 |
win.pop() |
116 |
|
117 |
def setInstallData(self, anaconda): |
118 |
baseclass.setInstallData(self, anaconda) |
119 |
anaconda.id.setUpgrade(True) |
120 |
|
121 |
def __init__(self, expert): |
122 |
baseclass.__init__(self, expert) |