/[smeserver]/cdrom.image/updates/instdata.py
ViewVC logotype

Annotation of /cdrom.image/updates/instdata.py

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download) (as text)
Mon Aug 15 21:45:20 2005 UTC (19 years, 4 months ago) by charlieb
Branch: MAIN
Content type: text/x-python
Avoid delay while video adaptor, monitor and mouse are probed.

1 charlieb 1.1 #
2     # instdata.py - central store for all configuration data needed to install
3     #
4     # Erik Troan <ewt@redhat.com>
5     #
6     # Copyright 2001-2002 Red Hat, Inc.
7     #
8     # This software may be freely redistributed under the terms of the GNU
9     # library public license.
10     #
11     # You should have received a copy of the GNU Library Public License
12     # along with this program; if not, write to the Free Software
13     # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
14     #
15    
16     import os
17     import string
18     import language
19     import network
20     import firewall
21     import security
22     import timezone
23     import desktop
24     import users
25     import fsset
26     import bootloader
27     import partitions
28     import partedUtils
29     import hdrlist
30     import zfcp
31     from flags import *
32     from constants import *
33    
34     from rhpl.simpleconfig import SimpleConfigFile
35     import rhpl.keyboard as keyboard
36    
37     class Boolean:
38     def set(self, val):
39     self.val = val
40    
41     def get(self):
42     return self.val
43    
44     def __init__(self, val = 0):
45     self.val = val
46    
47     # Collector class for all data related to an install/upgrade.
48    
49     class InstallData:
50    
51     def reset(self):
52     # Reset everything except:
53     #
54     # - The mouse
55     # - The install language
56     # - The keyboard
57    
58     self.langSupport = language.Language()
59     self.instClass = None
60     self.network = network.Network()
61     self.zfcp = zfcp.ZFCP()
62     self.firewall = firewall.Firewall()
63     self.security = security.Security()
64     self.timezone = timezone.Timezone()
65     self.accounts = users.Accounts()
66     self.rootPassword = users.RootPassword ()
67     self.auth = users.Authentication()
68     self.desktop = desktop.Desktop()
69     self.grpset = None
70     self.upgrade = Boolean()
71     # XXX move fsset and/or diskset into Partitions object?
72     self.fsset.reset()
73     self.diskset = partedUtils.DiskSet()
74     self.partitions = partitions.Partitions()
75     self.bootloader = bootloader.getBootloader()
76     self.dependencies = []
77     self.handleDeps = CHECK_DEPS
78     self.dbpath = None
79     self.upgradeRoot = None
80     self.rootParts = None
81     self.upgradeSwapInfo = None
82     self.upgradeDeps = ""
83     self.upgradeRemove = []
84     self.upgradeInfoFound = None
85     self.configFileData = self.tmpData
86     self.firstboot = FIRSTBOOT_DEFAULT
87    
88     def setInstallProgressClass(self, c):
89     self.instProgress = c
90    
91     # expects a Keyboard object
92     def setKeyboard(self, keyboard):
93     self.keyboard = keyboard
94    
95     # expects a Mouse object
96     def setMouse(self, mouse):
97     self.mouse = mouse
98    
99     # expects a VideoCardInfo object
100     def setVideoCard(self, video):
101     self.videocard = video
102    
103     # expects a Monitor object
104     def setMonitor(self, monitor):
105     self.monitor = monitor
106    
107     # expects a XF86Config object
108     def setXSetup(self, xsetup):
109     self.xsetup = xsetup
110    
111     # expects 0/1
112     def setHeadless(self, isHeadless):
113     self.isHeadless = isHeadless
114    
115     def write(self, instPath):
116     self.langSupport.write (instPath)
117    
118     # if not self.isHeadless:
119     # self.keyboard.write (instPath)
120     self.keyboard.write (instPath)
121    
122     self.timezone.write (instPath)
123     self.auth.write (instPath)
124     self.firewall.write (instPath)
125     self.security.write (instPath)
126     self.rootPassword.write (instPath, self.auth)
127     self.accounts.write (instPath, self.auth)
128    
129     def writeKS(self, filename):
130     # make it so only root can read, could have password
131     f = open(filename, "w", 0600)
132    
133     f.write("# Kickstart file automatically generated by anaconda.\n\n")
134     if self.upgrade.get():
135     f.write("upgrade\n");
136     else:
137     f.write("install\n");
138    
139     # figure out the install method and write out a line
140     if self.methodstr.startswith('ftp://') or self.methodstr.startswith('http://'):
141     f.write("url --url %s\n" % (self.methodstr,))
142     elif self.methodstr.startswith('cdrom://'):
143     f.write("cdrom\n")
144     elif self.methodstr.startswith('hd://'):
145     pidx = string.find(self.methodstr, '//') + 2
146     didx = string.find(self.methodstr[pidx:], '/')
147     partition = string.split(self.methodstr[pidx:pidx+didx], ':')[0]
148     dir = self.methodstr[pidx+didx+1:]
149     f.write("harddrive --partition=%s --dir=%s\n" % (partition, dir))
150     elif self.methodstr.startswith('nfs:/') or self.methodstr.startswith('nfsiso:'):
151     (method, tmpmntpt) = string.split(self.methodstr, ':')
152     # clean up extra '/' at front
153     if tmpmntpt[1] == '/':
154     rawmntpt = tmpmntpt[1:]
155     else:
156     rawmntpt = tmpmntpt
157     mntpt = os.path.normpath(rawmntpt)
158    
159     # find mntpt in /proc/mounts so we can get NFS server info
160     fproc = open("/proc/mounts", "r")
161     lines = fproc.readlines()
162     fproc.close()
163    
164     for l in lines:
165     minfo = string.split(l)
166     if len(minfo) > 1 and minfo[1] == mntpt:
167     nfsinfo = minfo[0]
168     (srv, dir) = string.split(nfsinfo, ':')
169     f.write("nfs --server=%s --dir=%s\n" % (srv, dir))
170     break
171    
172     self.instLanguage.writeKS(f)
173     self.langSupport.writeKS(f)
174     if not self.isHeadless:
175     self.keyboard.writeKS(f)
176     self.xsetup.writeKS(f, self.desktop)
177     self.network.writeKS(f)
178     self.zfcp.writeKS(f)
179     self.rootPassword.writeKS(f, self.auth)
180     self.firewall.writeKS(f)
181     self.security.writeKS(f)
182     self.auth.writeKS(f)
183     self.timezone.writeKS(f)
184     self.bootloader.writeKS(f)
185     self.partitions.writeKS(f)
186     self.writePackagesKS(f)
187    
188     f.write("\n%post\n")
189     self.accounts.writeKScommands(f, self.auth)
190    
191     def writePackagesKS(self, f):
192     f.write("\n%packages")
193     if self.handleDeps == IGNORE_DEPS:
194     f.write(" --ignoredeps\n")
195     elif self.handleDeps == RESOLVE_DEPS:
196     f.write(" --resolvedeps\n")
197     else:
198     f.write("\n")
199     packages = {}
200     forcedoff = {}
201     forcedon = {}
202     for group in self.grpset.groups.values():
203     if group.isSelected():
204     if (group.isSelected(justManual = 1) and group.id != "base"
205     and group.id != "core"):
206     f.write("@ %s\n" % group.id)
207    
208     # handle metapkgs. this is a little weird
209     for (pkgnevra, pkg) in group.packages.items():
210     if pkg["meta"] == 0:
211     continue
212     metapkg = self.grpset.groups[pkgnevra]
213     # if it's optional and turned on, put it in the ks.cfg
214     if (metapkg.isSelected() and
215     pkg["type"] == hdrlist.PKGTYPE_OPTIONAL):
216     f.write("@ %s\n" %(metapkg.id,))
217     # if it's default and turned off, then turn off the
218     # component packages (we dont' have a -@grp syntax)
219     elif (not metapkg.isSelected() and
220     pkg["type"] == hdrlist.PKGTYPE_DEFAULT):
221     for (pkgnevra, pkg) in metapkg.packages.items():
222     name = self.grpset.hdrlist[pkgnevra].name
223     forcedoff[name] = 1
224    
225     # handle packages
226     for (pkgnevra, pkg) in group.packages.items():
227     if pkg["meta"] != 0:
228     continue
229     name = self.grpset.hdrlist[pkgnevra].name
230     # if it's in base or core, it really should be installed
231     if group.id == "base" or group.id == "core":
232     packages[name] = 1
233     else:
234     if pkg["type"] == hdrlist.PKGTYPE_MANDATORY:
235     packages[name] = 1
236     else:
237     if ((pkg["type"] == hdrlist.PKGTYPE_DEFAULT) and
238     (pkg["state"] in hdrlist.ON_STATES)):
239     packages[name] = 1
240     elif ((pkg["type"] == hdrlist.PKGTYPE_DEFAULT) and
241     (pkg["state"] in hdrlist.OFF_STATES)):
242     forcedoff[name] = 1
243     elif ((pkg["type"] == hdrlist.PKGTYPE_OPTIONAL) and
244     (pkg["state"] in hdrlist.ON_STATES)):
245     forcedon[name] = 1
246     elif ((pkg["type"] == hdrlist.PKGTYPE_OPTIONAL) and
247     (pkg["state"] not in hdrlist.ON_STATES)):
248     pass
249    
250     for pkg in self.grpset.hdrlist.values():
251     if ((pkg.isSelected() and pkg.manual_state == 2) or
252     (forcedon.has_key(pkg.name))):
253     f.write("%s\n" % pkg.name)
254     if ((not pkg.isSelected() and pkg.manual_state == -2) or
255     forcedoff.has_key(pkg.name)):
256     f.write("-%s\n" %(pkg.name))
257    
258     def __init__(self, extraModules, floppyDevice, configFileData, methodstr):
259     self.instLanguage = language.InstallTimeLanguage()
260     self.keyboard = keyboard.Keyboard()
261     self.tmpData = configFileData
262    
263     self.configFileData = None
264     self.mouse = None
265     self.monitor = None
266     self.videocard = None
267     self.xsetup = None
268     self.isHeadless = 0
269     self.extraModules = extraModules
270     self.floppyDevice = floppyDevice
271     self.fsset = fsset.FileSystemSet()
272     self.excludeDocs = 0
273     try:
274     f = open("/proc/cmdline")
275     line = f.readline()
276     if line.find(" excludedocs") != -1:
277     self.excludeDocs = 1
278     close(f)
279     except:
280     pass
281    
282     # FIXME: this is a major hack to get the comps package installed
283     self.compspkg = None
284    
285     self.methodstr = methodstr
286     self.reset()

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed