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 |
|
4 |
|
import logging |
5 |
|
log = logging.getLogger("anaconda") |
6 |
|
|
7 |
|
from constants import * |
8 |
|
|
9 |
import os |
import os |
10 |
import iutil |
import iutil |
11 |
|
import string |
12 |
|
import rhpl |
13 |
|
|
14 |
|
baseclass = getBaseInstallClass() |
15 |
|
|
16 |
|
|
17 |
class InstallClass(BaseInstallClass): |
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") |
name = N_("Upgrade Existing System") |
60 |
pixmap = "upgrade.png" |
pixmap = "upgrade.png" |
61 |
sortPriority = 999999 |
sortPriority = 999999 |
70 |
"language", |
"language", |
71 |
"keyboard", |
"keyboard", |
72 |
"findrootparts", |
"findrootparts", |
73 |
|
"findinstall", |
74 |
|
"installtype", |
75 |
"partitionobjinit", |
"partitionobjinit", |
76 |
"upgrademount", |
"upgrademount", |
77 |
"upgrademigfind", |
"upgrademigfind", |
78 |
"upgrademigratefs", |
"upgrademigratefs", |
79 |
"upgradecontinue", |
"upgradecontinue", |
80 |
"readcomps", |
"reposetup", |
81 |
"findpackages", |
"upgbootloader", |
82 |
"checkdeps", |
"checkdeps", |
83 |
"dependencies", |
"dependencies", |
84 |
|
"postselection", |
85 |
"install", |
"install", |
86 |
"migratefilesystems", |
"migratefilesystems", |
87 |
"preinstallconfig", |
"preinstallconfig", |
94 |
"complete" |
"complete" |
95 |
) |
) |
96 |
|
|
97 |
def postAction(self, rootPath, serial): |
if iutil.getPPCMachine() == "iSeries": |
98 |
if serial: |
dispatch.skipStep("bootloadersetup", skip = 0) |
99 |
messages = "/tmp/postupgrade.log" |
|
100 |
else: |
if rhpl.getArch() != "i386" and rhpl.getArch() != "x86_64": |
101 |
messages = "/dev/tty3" |
dispatch.skipStep("bootloader") |
102 |
args = [ "/usr/sbin/lokkit", "--quiet", "--nostart", "--selinux=disabled"] |
dispatch.skipStep("bootloaderadvanced") |
103 |
|
|
104 |
try: |
if rhpl.getArch() != "i386" and rhpl.getArch() != "x86_64": |
105 |
iutil.execWithRedirect(args[0], args, root=rootPath, |
dispatch.skipStep("upgbootloader") |
106 |
stdout=messages, stderr=messages) |
|
107 |
except RuntimeError, msg: |
def postAction(self, anaconda, serial): |
108 |
log ("lokkit run failed: %s", msg) |
win = anaconda.intf.waitWindow(_("Post Upgrade Script"), |
109 |
except OSError, (errno, msg): |
_("The post upgrade script is running...")) |
110 |
log ("lokkit run failed: %s", msg) |
|
111 |
|
script = ( "/sbin/syslogd &\n" |
112 |
path = rootPath + "/tmp/postupgrade.sh" |
"sleep 2\n" |
113 |
cmds = ["/sbin/syslogd &", "sleep 2", "/sbin/e-smith/signal-event post-upgrade"] |
"/sbin/e-smith/signal-event post-upgrade\n" ) |
114 |
|
s = Script(script, interp="/bin/sh", inChroot=1) |
115 |
f = open(path, "w") |
log.info("%s", s) |
116 |
f.writelines(cmds) |
s.run(anaconda.rootPath, serial) |
117 |
f.close |
win.pop() |
118 |
os.chmod(path, 0700) |
|
119 |
|
def setInstallData(self, anaconda): |
120 |
rc = iutil.execWithRedirect("/bin/sh", ["/bin/sh", "/tmp/postupgrade.sh"], |
baseclass.setInstallData(self, anaconda) |
121 |
stdout=messages, stderr=messages, root=rootPath) |
anaconda.id.setUpgrade(True) |
|
if rc != 0: |
|
|
log("WARNING - Error code %s encountered running postupgrade script", rc) |
|
|
os.unlink(path) |
|
|
|
|
|
def setInstallData(self, id): |
|
|
BaseInstallClass.setInstallData(self, id) |
|
|
id.upgrade.set(1) |
|
122 |
|
|
123 |
def __init__(self, expert): |
def __init__(self, expert): |
124 |
BaseInstallClass.__init__(self, expert) |
baseclass.__init__(self, expert) |