/[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.6 - (hide annotations) (download) (as text)
Fri Jun 9 05:03:00 2006 UTC (18 years, 6 months ago) by gordonr
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +0 -0 lines
Content type: text/x-python
FILE REMOVED
See bug 1510 - all changes should be in the anaconda CVS repository

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 slords 1.5 self.keyboard.write (instPath)
118 charlieb 1.1 self.timezone.write (instPath)
119     self.auth.write (instPath)
120     self.firewall.write (instPath)
121     self.security.write (instPath)
122     self.rootPassword.write (instPath, self.auth)
123     self.accounts.write (instPath, self.auth)
124    
125     def writeKS(self, filename):
126     # make it so only root can read, could have password
127     f = open(filename, "w", 0600)
128    
129     f.write("# Kickstart file automatically generated by anaconda.\n\n")
130     if self.upgrade.get():
131     f.write("upgrade\n");
132     else:
133     f.write("install\n");
134    
135     # figure out the install method and write out a line
136     if self.methodstr.startswith('ftp://') or self.methodstr.startswith('http://'):
137     f.write("url --url %s\n" % (self.methodstr,))
138     elif self.methodstr.startswith('cdrom://'):
139     f.write("cdrom\n")
140     elif self.methodstr.startswith('hd://'):
141     pidx = string.find(self.methodstr, '//') + 2
142     didx = string.find(self.methodstr[pidx:], '/')
143     partition = string.split(self.methodstr[pidx:pidx+didx], ':')[0]
144     dir = self.methodstr[pidx+didx+1:]
145     f.write("harddrive --partition=%s --dir=%s\n" % (partition, dir))
146     elif self.methodstr.startswith('nfs:/') or self.methodstr.startswith('nfsiso:'):
147     (method, tmpmntpt) = string.split(self.methodstr, ':')
148     # clean up extra '/' at front
149     if tmpmntpt[1] == '/':
150     rawmntpt = tmpmntpt[1:]
151     else:
152     rawmntpt = tmpmntpt
153     mntpt = os.path.normpath(rawmntpt)
154    
155     # find mntpt in /proc/mounts so we can get NFS server info
156     fproc = open("/proc/mounts", "r")
157     lines = fproc.readlines()
158     fproc.close()
159    
160     for l in lines:
161     minfo = string.split(l)
162     if len(minfo) > 1 and minfo[1] == mntpt:
163     nfsinfo = minfo[0]
164     (srv, dir) = string.split(nfsinfo, ':')
165     f.write("nfs --server=%s --dir=%s\n" % (srv, dir))
166     break
167    
168     self.instLanguage.writeKS(f)
169     self.langSupport.writeKS(f)
170 slords 1.5 self.keyboard.writeKS(f)
171 charlieb 1.1 if not self.isHeadless:
172     self.xsetup.writeKS(f, self.desktop)
173     self.network.writeKS(f)
174     self.zfcp.writeKS(f)
175     self.rootPassword.writeKS(f, self.auth)
176     self.firewall.writeKS(f)
177     self.security.writeKS(f)
178     self.auth.writeKS(f)
179     self.timezone.writeKS(f)
180     self.bootloader.writeKS(f)
181     self.partitions.writeKS(f)
182     self.writePackagesKS(f)
183    
184     f.write("\n%post\n")
185     self.accounts.writeKScommands(f, self.auth)
186    
187     def writePackagesKS(self, f):
188     f.write("\n%packages")
189     if self.handleDeps == IGNORE_DEPS:
190     f.write(" --ignoredeps\n")
191     elif self.handleDeps == RESOLVE_DEPS:
192     f.write(" --resolvedeps\n")
193     else:
194     f.write("\n")
195     packages = {}
196     forcedoff = {}
197     forcedon = {}
198     for group in self.grpset.groups.values():
199     if group.isSelected():
200     if (group.isSelected(justManual = 1) and group.id != "base"
201     and group.id != "core"):
202     f.write("@ %s\n" % group.id)
203    
204     # handle metapkgs. this is a little weird
205     for (pkgnevra, pkg) in group.packages.items():
206     if pkg["meta"] == 0:
207     continue
208     metapkg = self.grpset.groups[pkgnevra]
209     # if it's optional and turned on, put it in the ks.cfg
210     if (metapkg.isSelected() and
211     pkg["type"] == hdrlist.PKGTYPE_OPTIONAL):
212     f.write("@ %s\n" %(metapkg.id,))
213     # if it's default and turned off, then turn off the
214     # component packages (we dont' have a -@grp syntax)
215     elif (not metapkg.isSelected() and
216     pkg["type"] == hdrlist.PKGTYPE_DEFAULT):
217     for (pkgnevra, pkg) in metapkg.packages.items():
218     name = self.grpset.hdrlist[pkgnevra].name
219     forcedoff[name] = 1
220    
221     # handle packages
222     for (pkgnevra, pkg) in group.packages.items():
223     if pkg["meta"] != 0:
224     continue
225     name = self.grpset.hdrlist[pkgnevra].name
226     # if it's in base or core, it really should be installed
227     if group.id == "base" or group.id == "core":
228     packages[name] = 1
229     else:
230     if pkg["type"] == hdrlist.PKGTYPE_MANDATORY:
231     packages[name] = 1
232     else:
233     if ((pkg["type"] == hdrlist.PKGTYPE_DEFAULT) and
234     (pkg["state"] in hdrlist.ON_STATES)):
235     packages[name] = 1
236     elif ((pkg["type"] == hdrlist.PKGTYPE_DEFAULT) and
237     (pkg["state"] in hdrlist.OFF_STATES)):
238     forcedoff[name] = 1
239     elif ((pkg["type"] == hdrlist.PKGTYPE_OPTIONAL) and
240     (pkg["state"] in hdrlist.ON_STATES)):
241     forcedon[name] = 1
242     elif ((pkg["type"] == hdrlist.PKGTYPE_OPTIONAL) and
243     (pkg["state"] not in hdrlist.ON_STATES)):
244     pass
245    
246     for pkg in self.grpset.hdrlist.values():
247     if ((pkg.isSelected() and pkg.manual_state == 2) or
248     (forcedon.has_key(pkg.name))):
249     f.write("%s\n" % pkg.name)
250     if ((not pkg.isSelected() and pkg.manual_state == -2) or
251     forcedoff.has_key(pkg.name)):
252     f.write("-%s\n" %(pkg.name))
253    
254     def __init__(self, extraModules, floppyDevice, configFileData, methodstr):
255     self.instLanguage = language.InstallTimeLanguage()
256     self.keyboard = keyboard.Keyboard()
257     self.tmpData = configFileData
258    
259     self.configFileData = None
260     self.mouse = None
261     self.monitor = None
262     self.videocard = None
263     self.xsetup = None
264     self.isHeadless = 0
265     self.extraModules = extraModules
266     self.floppyDevice = floppyDevice
267     self.fsset = fsset.FileSystemSet()
268     self.excludeDocs = 0
269     try:
270     f = open("/proc/cmdline")
271     line = f.readline()
272     if line.find(" excludedocs") != -1:
273     self.excludeDocs = 1
274     close(f)
275     except:
276     pass
277    
278     # FIXME: this is a major hack to get the comps package installed
279     self.compspkg = None
280    
281     self.methodstr = methodstr
282     self.reset()

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