summaryrefslogtreecommitdiffstats
path: root/instdata.py
blob: 75cf2f88cc2dad795f8059e891c7daf838e13758 (plain)
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
#
# instdata.py - central store for all configuration data needed to install
#
# Erik Troan <ewt@redhat.com>
#
# Copyright 2001-2002 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 network
import firewall
import timezone
import desktop
import users
import fsset
import bootloader
import partitions
import partedUtils
from flags import *
from constants import *

from rhpl.simpleconfig import SimpleConfigFile
import rhpl.keyboard as keyboard

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.handleDeps = CHECK_DEPS
        self.dbpath = None
        self.upgradeRoot = None
        self.upgradeSwapInfo = None
        self.upgradeDeps = ""
        self.configFileData = self.tmpData
        self.firstboot = FIRSTBOOT_DEFAULT

    def setInstallProgressClass(self, c):
	self.instProgress = c

    # expects a Keyboard object
    def setKeyboard(self, keyboard):
        self.keyboard = keyboard

    # 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.desktop)
	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")
        if self.handleDeps == IGNORE_DEPS:
            f.write(" --ignoredeps\n")
        elif self.handleDeps == RESOLVE_DEPS:
            f.write(" --resolvedeps\n")
        else:
            f.write("\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 = keyboard.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()