1 |
from installclass import getBaseInstallClass |
from installclass import getBaseInstallClass |
2 |
from rhpl.translate import N_, _ |
from rhpl.translate import N_, _ |
|
|
|
|
import logging |
|
|
log = logging.getLogger("anaconda") |
|
|
|
|
3 |
from constants import * |
from constants import * |
|
|
|
4 |
import os |
import os |
5 |
import iutil |
import iutil |
|
import string |
|
6 |
import rhpl |
import rhpl |
7 |
|
|
8 |
baseclass = getBaseInstallClass() |
baseclass = getBaseInstallClass() |
9 |
|
|
10 |
|
import logging |
11 |
|
log = logging.getLogger("anaconda") |
12 |
|
|
13 |
|
import string |
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.info("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(baseclass): |
class InstallClass(baseclass): |
61 |
name = N_("Upgrade Existing System") |
name = N_("Upgrade Existing System") |
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", |
82 |
"reposetup", |
"reposetup", |
83 |
"upgbootloader", |
"upgbootloader", |
84 |
"checkdeps", |
"checkdeps", |
85 |
"dependencies", |
"dependencies", |
86 |
"postselection", |
"postselection", |
87 |
"install", |
"confirmupgrade", |
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) |
111 |
win = anaconda.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.info("%s", s) |
log.info("%s", s) |
117 |
s.run(anaconda.rootPath, serial) |
s.run(anaconda.rootPath, serial) |