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 |
61 |
|
|
62 |
def setSteps(self, dispatch): |
def setSteps(self, dispatch): |
63 |
dispatch.setStepList( |
dispatch.setStepList( |
|
"betanag", |
|
64 |
"language", |
"language", |
65 |
"keyboard", |
"keyboard", |
66 |
|
"installtype", |
67 |
"findrootparts", |
"findrootparts", |
68 |
"findinstall", |
"findinstall", |
|
"installtype", |
|
69 |
"partitionobjinit", |
"partitionobjinit", |
70 |
"upgrademount", |
"upgrademount", |
71 |
"upgrademigfind", |
"upgrademigfind", |
72 |
"upgrademigratefs", |
"upgrademigratefs", |
73 |
"upgradecontinue", |
"upgradecontinue", |
74 |
"reposetup", |
"readcomps", |
75 |
"upgbootloader", |
"findpackages", |
76 |
"checkdeps", |
"checkdeps", |
77 |
"dependencies", |
"dependencies", |
|
"postselection", |
|
78 |
"install", |
"install", |
79 |
"migratefilesystems", |
"migratefilesystems", |
80 |
"preinstallconfig", |
"preinstallconfig", |
90 |
if iutil.getPPCMachine() == "iSeries": |
if iutil.getPPCMachine() == "iSeries": |
91 |
dispatch.skipStep("bootloadersetup", skip = 0) |
dispatch.skipStep("bootloadersetup", skip = 0) |
92 |
|
|
93 |
if rhpl.getArch() != "i386" and rhpl.getArch() != "x86_64": |
if iutil.getArch() != "i386" and iutil.getArch() != "x86_64": |
94 |
dispatch.skipStep("bootloader") |
dispatch.skipStep("bootloader") |
95 |
dispatch.skipStep("bootloaderadvanced") |
dispatch.skipStep("bootloaderadvanced") |
96 |
|
|
97 |
if rhpl.getArch() != "i386" and rhpl.getArch() != "x86_64": |
if iutil.getArch() != "i386" and iutil.getArch() != "x86_64": |
98 |
dispatch.skipStep("upgbootloader") |
dispatch.skipStep("upgbootloader") |
99 |
|
|
100 |
def postAction(self, anaconda, serial): |
def postAction(self, rootPath, serial, intf): |
101 |
win = anaconda.intf.waitWindow(_("Post Upgrade Script"), |
win = intf.waitWindow(_("Post Upgrade Script"), |
102 |
_("The post upgrade script is running...")) |
_("The post upgrade script is running...")) |
103 |
|
|
104 |
script = ( "#!/bin/sh\nmkdir -p /var/lib/dhcp; /sbin/syslogd ; sleep 2; /sbin/e-smith/signal-event post-upgrade\n" ) |
script = ( "/sbin/syslogd &\n" |
105 |
|
"sleep 2\n" |
106 |
|
"/sbin/e-smith/signal-event post-upgrade\n" ) |
107 |
s = Script(script, interp="/bin/sh", inChroot=1) |
s = Script(script, interp="/bin/sh", inChroot=1) |
108 |
log.info("%s", s) |
log("%s", s) |
109 |
s.run(anaconda.rootPath, serial) |
s.run(rootPath, serial) |
110 |
win.pop() |
win.pop() |
111 |
|
|
112 |
def setInstallData(self, anaconda): |
def setInstallData(self, id): |
113 |
baseclass.setInstallData(self, anaconda) |
BaseInstallClass.setInstallData(self, id) |
114 |
anaconda.id.setUpgrade(True) |
id.upgrade.set(1) |
115 |
|
|
116 |
def __init__(self, expert): |
def __init__(self, expert): |
117 |
baseclass.__init__(self, expert) |
BaseInstallClass.__init__(self, expert) |