/[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.2 - (hide annotations) (download) (as text)
Mon Aug 15 21:49:12 2005 UTC (19 years, 2 months ago) by charlieb
Branch: MAIN
Changes since 1.1: +2 -3 lines
Content type: text/x-python
Commit of vanilla files from anaconda 10.1.1.19.

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

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