1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
#
# dispatch.py: install/upgrade master flow control
#
# Erik Troan <ewt@redhat.com>
#
# Copyright 2001 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# library public license.
#
# You should have received a copy of the GNU Library Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
import string
from types import *
from constants import *
from packages import readPackages, checkDependencies, doInstall
from packages import handleX11Packages, writeConfiguration, writeXConfiguration
from packages import writeKSConfiguration, turnOnFilesystems
from packages import queryUpgradeContinue
from autopart import doAutoPartition
from partitioning import partitionMethodSetup, partitionObjectsInitialize
from floppy import makeBootdisk
from bootloader import partitioningComplete, writeBootloader
from bootloader import bootloaderSetupChoices
from flags import flags
from upgrade import upgradeFindPackages, upgradeMountFilesystems
from upgrade import upgradeSwapSuggestion
# These are all of the install steps, in order. Note that upgrade and
# install steps are the same thing! Upgrades skip install steps, while
# installs skip upgrade steps.
#
# items are one of
#
# ( name, tuple)
# ( name, Function, tuple)
#
# in the second case, the function is called directly from the dispatcher
installSteps = [
( "language", ("intf", "id.instLanguage") ),
( "keyboard", ("id.instLanguage", "id.keyboard") ),
( "mouse", ("id.mouse", ) ),
( "welcome", () ),
( "reconfigwelcome", () ),
( "reconfigkeyboard", ("id.instLanguage", "id.keyboard" ) ),
( "installtype", ("dispatch", "id", "method", "intf") ),
( "findinstall", ("dispatch", "intf", "id", "instPath") ),
( "partitionmethod", ("id",) ),
( "partitionobjinit", partitionObjectsInitialize, ("id", "dir") ),
( "partitionmethodsetup", partitionMethodSetup, ("id", "dispatch") ),
( "autopartition", ("id", "id.diskset", "intf") ),
( "autopartitionexecute", doAutoPartition, ("dir", "id", "intf")),
( "fdisk", ("id.useFdisk", "id.diskset", "id.partrequests")),
( "partition", ("id.fsset", "id.diskset", "id.partrequests", "intf")),
( "upgrademount", upgradeMountFilesystems, ("intf", "id.upgradeRoot",
"id.fsset", "instPath")),
( "upgradecontinue", queryUpgradeContinue, ("intf", "dir")),
( "upgradeswapsuggestion", upgradeSwapSuggestion, ("dispatch", "id",
"instPath") ),
( "addswap", ("intf", "id.fsset", "instPath", "id.upgradeSwapInfo") ),
( "partitiondone", partitioningComplete, ("dispatch", "id.bootloader",
"id.fsset", "id.diskset",
"id.partrequests") ),
( "bootloadersetup", bootloaderSetupChoices, ("dispatch", "id.bootloader",
"id.fsset", "id.diskset") ),
( "bootloader", ("dispatch", "id.bootloader", "id.fsset", "id.diskset") ),
( "network", ("id.network",) ),
( "firewall", ("id.network", "id.firewall") ),
( "languagesupport", ("id.langSupport", ) ),
( "timezone", ("id.instLanguage", "id.timezone", ) ),
( "accounts", ("id.rootPassword", "id.accounts", ) ),
( "authentication", ("id.auth", ) ),
( "readcomps", readPackages, ("intf", "method", "id" )),
( "findpackages", upgradeFindPackages, ("intf", "method", "id",
"instPath")),
( "package-selection", ("id.comps", "dispatch") ),
( "indivpackage", ("id.comps", "id.hdList", ) ),
( "handleX11pkgs", handleX11Packages, ("dir", "intf", "dispatch",
"id", "instPath" )),
( "videocard", ("dispatch", "id.xconfig", "id.videocard")),
( "checkdeps", checkDependencies, ("dir", "intf", "dispatch",
"id", "instPath" )),
( "dependencies", ("id.comps", "id.dependencies",) ),
( "confirminstall", () ),
( "confirmupgrade", () ),
( "install", ("dir", "intf", "id", ) ),
( "enablefilesystems", turnOnFilesystems, ( "dir", "id.fsset",
"id.diskset", "id.upgrade",
"instPath") ),
( "installpackages", doInstall, ( "method", "id", "intf", "instPath" )),
( "writeconfig", writeConfiguration, ("id", "instPath" )),
( "instbootloader", writeBootloader, ("intf", "instPath", "id.fsset",
"id.bootloader", "id.langSupport",
"id.comps") ),
( "bootdisk", ("dir", "dispatch") ),
( "makebootdisk", makeBootdisk, ("intf", "id.floppyDevice",
"id.hdList", "instPath") ),
( "monitor", ("id.xconfig", "id.monitor") ),
( "xcustom", ("id.xconfig", "id.monitor", "id.videocard",
"id.desktop", "id.comps") ),
( "writexconfig", writeXConfiguration, ("id", "instPath")),
( "writeksconfig", writeKSConfiguration, ("id", "instPath")),
( "complete", () ),
( "reconfigcomplete", () )
]
class Dispatcher:
def gotoPrev(self):
self.dir = -1
self.moveStep()
def gotoNext(self):
self.dir = 1
self.moveStep()
def canGoBack(self):
# begin with the step before this one. If all steps are skipped,
# we can not go backwards from this screen
i = self.step - 1
while i >= self.firstStep:
if not self.skipSteps.has_key(installSteps[i][0]):
return 1
i = i - 1
return 0
def setStepList(self, *steps):
# only remove non-permanently skipped steps from our skip list
for step, state in self.skipSteps.items():
if state == 1:
del self.skipSteps[step]
stepExists = {}
for step in installSteps:
name = step[0]
if not name in steps:
self.skipSteps[name] = 1
stepExists[name] = 1
for name in steps:
if not stepExists.has_key(name):
raise KeyError, ("step %s does not exist" % name)
def stepInSkipList(self, step):
return self.skipSteps.has_key(step)
def skipStep(self, stepToSkip, skip = 1, permanent = 0):
for step in installSteps:
name = step[0]
if name == stepToSkip:
if skip:
if permanent:
self.skipSteps[name] = 2
else:
self.skipSteps[name] = 1
elif self.skipSteps.has_key(name):
del self.skipSteps[name]
return
raise KeyError, ("unknown step %s" % stepToSkip)
def moveStep(self):
if self.step == None:
self.step = self.firstStep
else:
self.step = self.step + self.dir
if self.step == len(installSteps):
return None
while ((self.step >= self.firstStep
and self.step < len(installSteps))
and (self.skipSteps.has_key(installSteps[self.step][0])
or (type(installSteps[self.step][1]) == FunctionType))):
info = installSteps[self.step]
if ((type(info[1]) == FunctionType)
and (not self.skipSteps.has_key(info[0]))):
(func, args) = info[1:]
rc = apply(func, self.bindArgs(args))
if rc == DISPATCH_BACK:
self.dir = -1
elif rc == DISPATCH_FORWARD:
self.dir = 1
# if anything else, leave self.dir alone
self.step = self.step + self.dir
if self.step == len(installSteps):
return None
if (self.step < 0):
# pick the first step not in the skip list
self.step = 0
while self.skipSteps.has_key(installSteps[self.step][0]):
self.step = self.step + 1
elif self.step >= len(installSteps):
self.step = len(installSteps) - 1
while self.skipSteps.has_key(installSteps[self.step][0]):
self.step = self.step - 1
def bindArgs(self, args):
newArgs = ()
for arg in args:
obj = self
for item in string.split(arg, '.'):
if not obj.__dict__.has_key(item):
print "cannot find %s in %s" % (item, obj)
obj = obj.__dict__[item]
newArgs = newArgs + (obj,)
return newArgs
def currentStep(self):
if self.step == None:
self.gotoNext()
elif self.step == len(installSteps):
return (None, None)
stepInfo = installSteps[self.step]
step = stepInfo[0]
args = self.bindArgs(stepInfo[1])
return (step, args)
def __init__(self, intf, id, method, instPath):
self.dir = DISPATCH_FORWARD
self.step = None
self.skipSteps = {}
self.id = id
self.flags = flags
self.intf = intf
self.method = method
self.dispatch = self
self.instPath = instPath
self.firstStep = 0
|