# # instdata.py - central store for all configuration data needed to install # # Erik Troan # # 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 language import kbd import network import firewall import timezone import desktop import users import fsset import bootloader import partitions import partedUtils from flags import * from simpleconfig import SimpleConfigFile class Boolean: def set(self, val): self.val = val def get(self): return self.val def __init__(self, val = 0): self.val = val # Collector class for all data related to an install/upgrade. class InstallData: def reset(self): # Reset everything except: # # - The mouse # - The install language # - The keyboard self.langSupport = language.Language() self.instClass = None self.network = network.Network() self.firewall = firewall.Firewall() self.timezone = timezone.Timezone() self.accounts = users.Accounts() self.rootPassword = users.RootPassword () self.auth = users.Authentication() self.desktop = desktop.Desktop() self.hdList = None self.comps = None self.upgrade = Boolean() # XXX move fsset and/or diskset into Partitions object? self.fsset.reset() self.diskset = partedUtils.DiskSet() self.partitions = partitions.Partitions() self.bootloader = bootloader.getBootloader() self.dependencies = [] self.dbpath = None self.upgradeRoot = None self.upgradeSwapInfo = None self.upgradeDeps = "" self.configFileData = self.tmpData def setInstallProgressClass(self, c): self.instProgress = c # expects a Mouse object def setMouse(self, mouse): self.mouse = mouse # expects a VideoCardInfo object def setVideoCard(self, video): self.videocard = video # expects a Monitor object def setMonitor(self, monitor): self.monitor = monitor # expects a XF86Config object def setXconfig(self, xconfig): self.xconfig = xconfig def write(self, instPath): self.langSupport.write (instPath) self.mouse.write(instPath) self.keyboard.write (instPath) self.network.write (instPath) self.timezone.write (instPath) self.auth.write (instPath) self.firewall.write (instPath) self.rootPassword.write (instPath, self.auth) self.accounts.write (instPath, self.auth) def writeKS(self, filename): # make it so only root can read, could have password f = open(filename, "w", 0600) f.write("# Kickstart file automatically generated by anaconda.\n\n") if self.upgrade.get(): f.write("upgrade\n"); else: f.write("install\n"); self.instLanguage.writeKS(f) self.langSupport.writeKS(f) self.keyboard.writeKS(f) self.mouse.writeKS(f) self.xconfig.writeKS(f) self.network.writeKS(f) self.rootPassword.writeKS(f, self.auth) self.firewall.writeKS(f) self.auth.writeKS(f) self.timezone.writeKS(f) self.bootloader.writeKS(f) self.partitions.writeKS(f) f.write("\n%packages\n") packages = {} for comp in self.comps: if comp.isSelected(): if comp.isSelected(justManual = 1) and comp.name != "Base": f.write("@ %s\n" % comp.name) for pkg in comp.packages(): packages[pkg] = 1 for pkg in self.hdList.values(): if not packages.has_key(pkg) and pkg.isSelected(): f.write("%s\n" % pkg.name) if pkg.wasForcedOff(): f.write("-%s\n" %(pkg.name)) f.write("\n%post\n") self.accounts.writeKScommands(f, self.auth) def __init__(self, extraModules, floppyDevice, configFileData): self.instLanguage = language.InstallTimeLanguage() self.keyboard = kbd.Keyboard() self.tmpData = configFileData self.configFileData = None self.mouse = None self.monitor = None self.videocard = None self.xconfig = None self.extraModules = extraModules self.floppyDevice = floppyDevice self.fsset = fsset.FileSystemSet() self.reset()