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") |
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", |
110 |
win = anaconda.intf.waitWindow(_("Post Upgrade Script"), |
win = anaconda.intf.waitWindow(_("Post Upgrade Script"), |
111 |
_("The post upgrade script is running...")) |
_("The post upgrade script is running...")) |
112 |
|
|
113 |
script = ( "#! /bin/sh\n/sbin/syslogd ; sleep 2; /sbin/e-smith/signal-event post-upgrade\n" ) |
script = ( "#!/bin/sh\nmkdir -p /var/lib/dhcp; /sbin/syslogd ; sleep 2; /sbin/e-smith/signal-event post-upgrade\n" ) |
114 |
s = Script(script, interp="/bin/sh", inChroot=1) |
s = Script(script, interp="/bin/sh", inChroot=1) |
115 |
log.info("%s", s) |
log.info("%s", s) |
116 |
s.run(anaconda.rootPath, serial) |
s.run(anaconda.rootPath, serial) |