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