1 |
from installclass import BaseInstallClass |
from installclass import getBaseInstallClass |
2 |
from rhpl.translate import N_, _ |
from rhpl.translate import N_, _ |
|
from rhpl.log import log |
|
3 |
from constants import * |
from constants import * |
|
|
|
4 |
import os |
import os |
5 |
import iutil |
import iutil |
6 |
|
import rhpl |
7 |
|
|
8 |
|
baseclass = getBaseInstallClass() |
9 |
|
|
10 |
|
import logging |
11 |
|
log = logging.getLogger("anaconda") |
12 |
|
|
13 |
import string |
import string |
|
import security |
|
14 |
|
|
15 |
class Script: |
class Script: |
16 |
def __repr__(self): |
def __repr__(self): |
25 |
self.logfile = logfile |
self.logfile = logfile |
26 |
|
|
27 |
def run(self, chroot, serial): |
def run(self, chroot, serial): |
28 |
scriptRoot = "/" |
import tempfile |
29 |
if self.inChroot: |
import os.path |
30 |
scriptRoot = chroot |
|
31 |
|
if self.inChroot: |
32 |
path = scriptRoot + "/tmp/sme-script" |
scriptRoot = chroot |
33 |
|
else: |
34 |
f = open(path, "w") |
scriptRoot = "/" |
35 |
f.write(self.script) |
|
36 |
f.close() |
(fd, path) = tempfile.mkstemp("", "sme-script-", scriptRoot + "/tmp") |
37 |
os.chmod(path, 0700) |
|
38 |
|
os.write(fd, self.script) |
39 |
|
os.close(fd) |
40 |
|
os.chmod(path, 0700) |
41 |
|
|
42 |
if self.logfile is not None: |
if self.logfile is not None: |
43 |
messages = self.logfile |
messages = self.logfile |
44 |
elif serial: |
elif serial: |
45 |
messages = "/tmp/sme-script.log" |
messages = "%s.log" % path |
46 |
else: |
else: |
47 |
messages = "/dev/tty3" |
messages = "/dev/tty3" |
48 |
|
|
49 |
rc = iutil.execWithRedirect(self.interp, |
rc = iutil.execWithRedirect(self.interp, ["/tmp/%s" % os.path.basename(path)], |
50 |
[self.interp,"/tmp/sme-script"], |
stdin = messages, stdout = messages, stderr = messages, |
51 |
stdout = messages, stderr = messages, |
root = scriptRoot) |
|
root = scriptRoot) |
|
52 |
|
|
53 |
if rc != 0: |
if rc != 0: |
54 |
log("WARNING - Error code %s encountered running a sme script", rc) |
log.error("WARNING - Error code %s encountered running a sme script", rc) |
55 |
|
|
56 |
os.unlink(path) |
os.unlink(path) |
57 |
|
if serial or self.logfile is not None: |
58 |
|
os.chmod("%s" % messages, 0600) |
59 |
|
|
60 |
class InstallClass(BaseInstallClass): |
class InstallClass(baseclass): |
61 |
name = N_("Upgrade Existing System") |
name = N_("Upgrade Existing System") |
62 |
pixmap = "upgrade.png" |
pixmap = "upgrade.png" |
63 |
sortPriority = 999999 |
sortPriority = 999999 |
68 |
return 't' |
return 't' |
69 |
|
|
70 |
def setSteps(self, dispatch): |
def setSteps(self, dispatch): |
71 |
dispatch.setStepList( |
dispatch.setStepList( |
72 |
"language", |
"language", |
73 |
"keyboard", |
"keyboard", |
74 |
|
"installtype", |
75 |
"findrootparts", |
"findrootparts", |
76 |
"findinstall", |
"findinstall", |
|
"installtype", |
|
77 |
"partitionobjinit", |
"partitionobjinit", |
78 |
"upgrademount", |
"upgrademount", |
79 |
"upgrademigfind", |
"upgrademigfind", |
80 |
"upgrademigratefs", |
"upgrademigratefs", |
81 |
"upgradecontinue", |
"upgradecontinue", |
82 |
"bootloadersetup", |
"reposetup", |
83 |
"readcomps", |
"upgbootloader", |
|
"findpackages", |
|
84 |
"checkdeps", |
"checkdeps", |
85 |
"dependencies", |
"dependencies", |
86 |
"install", |
"postselection", |
87 |
|
"confirminstall", |
88 |
|
"install", |
89 |
"migratefilesystems", |
"migratefilesystems", |
90 |
"preinstallconfig", |
"preinstallconfig", |
91 |
"installpackages", |
"installpackages", |
94 |
"dopostaction", |
"dopostaction", |
95 |
"methodcomplete", |
"methodcomplete", |
96 |
"copylogs", |
"copylogs", |
97 |
"complete" |
"complete" |
98 |
) |
) |
99 |
|
|
100 |
if iutil.getPPCMachine() == "iSeries": |
if iutil.getPPCMachine() == "iSeries": |
101 |
dispatch.skipStep("bootloadersetup", skip = 0) |
dispatch.skipStep("bootloadersetup", skip = 0) |
102 |
|
|
103 |
if iutil.getArch() != "i386" and iutil.getArch() != "x86_64": |
if rhpl.getArch() != "i386" and rhpl.getArch() != "x86_64": |
104 |
dispatch.skipStep("bootloader") |
dispatch.skipStep("bootloader") |
105 |
dispatch.skipStep("bootloaderadvanced") |
dispatch.skipStep("bootloaderadvanced") |
106 |
|
|
107 |
if iutil.getArch() != "i386" and iutil.getArch() != "x86_64": |
if rhpl.getArch() != "i386" and rhpl.getArch() != "x86_64": |
108 |
dispatch.skipStep("upgbootloader") |
dispatch.skipStep("upgbootloader") |
109 |
|
|
110 |
def postAction(self, rootPath, serial, intf): |
def postAction(self, anaconda, serial): |
111 |
win = intf.waitWindow(_("Post Upgrade Script"), |
win = anaconda.intf.waitWindow(_("Post Upgrade Script"), |
112 |
_("The post upgrade script is running...")) |
_("The post upgrade script is running...")) |
113 |
|
|
114 |
script = ( "/sbin/syslogd &\n" |
script = ( "#!/bin/sh\nmkdir -p /var/lib/dhcp; /sbin/syslogd ; sleep 2; /sbin/e-smith/signal-event post-upgrade\n" ) |
|
"sleep 2\n" |
|
|
"/sbin/e-smith/signal-event post-upgrade\n" ) |
|
115 |
s = Script(script, interp="/bin/sh", inChroot=1) |
s = Script(script, interp="/bin/sh", inChroot=1) |
116 |
log("%s", s) |
log.info("%s", s) |
117 |
s.run(rootPath, serial) |
s.run(anaconda.rootPath, serial) |
118 |
win.pop() |
win.pop() |
119 |
|
|
120 |
def setInstallData(self, id): |
def setInstallData(self, anaconda): |
121 |
BaseInstallClass.setInstallData(self, id) |
baseclass.setInstallData(self, anaconda) |
122 |
id.upgrade.set(1) |
anaconda.id.setUpgrade(True) |
123 |
|
|
124 |
def __init__(self, expert): |
def __init__(self, expert): |
125 |
BaseInstallClass.__init__(self, expert) |
baseclass.__init__(self, expert) |