summaryrefslogtreecommitdiffstats
path: root/anaconda
blob: b519106bc1f68ac4f3a211f6b1936d4ec3fa7885 (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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#!/usr/bin/python

import sys, os

# Python passed my path as argv[0]!
# if sys.argv[0][-7:] == "syslogd":
if sys.argv[1] == "--syslogd":
    from syslogd import Syslogd
    root = sys.argv[2]
    output = sys.argv[3]
    syslog = Syslogd (root, open (output, "w+"))

if (os.path.exists('isys')):
    sys.path.append('isys')

import gettext
import traceback
import string

import isys
import iutil

setverPath = None

gettext.bindtextdomain("anaconda", "/usr/share/locale")
gettext.textdomain("anaconda")
_ = gettext.gettext

(args, extra) = isys.getopt(sys.argv[1:], 'GTtdr:fm:', 
          [ 'gui', 'text', 'test', 'debug', 'method=', 'rootpath=',
	    'testpath=', 'mountfs', 'traceonly', 'kickstart=',
            'lang=', 'keymap=', 'kbdtype=', 'module=',
	    'expert', 'serial' ])

# remove the arguments - gnome_init doesn't understand them
for arg in sys.argv[1:]:
    sys.argv.remove (arg)
sys.argc = 1

mode = None
test = 0
debug = 0
rootPath = '/mnt/sysimage'
localInstall = 0
forceMount = 0
mode = 'g'
method = None
traceOnly = 0
mouseInfo = None
x = None
kickstart = None
serial = 0
expert = 0
lang = None
keymap = None
kbdtpye = None
extraModules = []

for n in args:
    (str, arg) = n

    if (str == '-G' or str == '--gui'):
	mode = 'g'
    elif (str == '-T' or str == '--text'):
	mode = 't'
    elif (str == '-t' or str == '--test'):
	test = 1
    elif (str == '--module'):
	(path, subdir, name) = string.split(arg, ":")
	extraModules.append((path, subdir, name))
    elif (str == '-m' or str == '--method'):
	method = arg
    elif (str == '-d' or str == '--debug'):
	debug = 1
    elif (str == '--kickstart'):
	kickstart = arg
	mode = 't'
    elif (str == '-r' or str == '--rootpath'):
	rootPath = arg
	localInstall = 1
    elif (str == '--mountfs'):
	forceMount = 1
    elif (str == '--traceonly'):
	traceOnly = 1
    elif (str == '--expert'):
	expert = 1
    elif (str == '--serial'):
	serial = 1
    elif (str == '--lang'):
        lang = arg
    elif (str == '--keymap'):
        keymap = arg
    elif (str == '--kbdtype'):
        kbdtype = arg

if (not method):
    print "no install method specified"
    sys.exit(1)

if (debug):
    import pdb
    pdb.set_trace()

if (not test and not localInstall and os.getpid() > 50):
    print "you're running me on a live system! that's incredibly stupid."
    sys.exit(1)

if (os.path.exists('rpmmodule')):
    sys.path.append('rpmmodule')
    sys.path.append('libfdisk')
    sys.path.append('balkan')
    sys.path.append('kudzu')
    sys.path.append('gnome-map')
#elif (mode == None):
#      try:
#          f = open('/dev/fb0', 'r')
#  	f.close()
#  	mode = 'g'
#      except:
#  	mode = 't'

import rpm
import lilo
from todo import ToDo
import isys
from installclass import DefaultInstall
from kickstart import Kickstart

if (not test):
    if (iutil.memInstalled() < 30000):
	mode = 't'

if (mode == 'g' and not os.environ.has_key('DISPLAY')):
    import xserver
    try:
        result = xserver.startX ()
    except RuntimeError:
	print "X startup failed, falling back to text mode"
        mode = 't'
    else:
        (mouseInfo, x) = (result)

if (mode == 'g'):
    if not test and not localInstall:
        for i in ( "imrc", "im_palette.pal", "gtk" ):
            os.symlink ("../mnt/source/RedHat/instimage/etc/" + i, "/etc/" + i)
    from gui import InstallInterface
elif (mode == 't'):
    from text import InstallInterface
else:
    print "No mode was specified"
    sys.exit(1)

if traceOnly:
    # prints a list of all the modules imported
    import pdb
    import image
    import harddrive
    import urlinstall
    import mimetools
    import mimetypes
    import syslogd
    for module in sys.__dict__['modules'].keys ():
        if module not in [ "__builtin__", "__main__" ]:
            foo = repr (sys.__dict__['modules'][module])
            bar = string.split (foo, "'")
            if len (bar) > 3:
                print bar[3]
        
    sys.exit(0)

# imports after setting up the path
if (method[0:5] == "dir:/"):
    from image import InstallMethod
    method = InstallMethod(method[5:])
elif (method[0:6] == "ftp://" or method[0:7] == "http://"):
    from urlinstall import InstallMethod
    method = InstallMethod(method)
elif (method[0:5] == "hd://"):
    method = method[5:]
    i = string.index(method, '/')
    dir = method[i:]
    driveAndType = method[0:i]

    i = string.index(driveAndType, ":")
    drive = driveAndType[0:i]
    type = driveAndType[i + 1:]

    from harddrive import InstallMethod
    method = InstallMethod(drive, type, dir)
else:
    print "unknown install method:", method
    sys.exit(1)

intf = InstallInterface()

# set the default actions
installPackages = 1
setupFilesystems = 1

if localInstall:
    installPackages = 1
    setupFilesystems = 0
if test:
    installPackages = 0
    setupFilesystems = 0
if forceMount:
    setupFilesystems = 1

if kickstart:
    instClass = Kickstart(kickstart)
else:
    instClass = DefaultInstall()

if lang:
    instClass.addToSkipList("language")
    instClass.setLanguage(lang)
            
if keymap:
    instClass.addToSkipList("keyboard")
    instClass.setKeyboard(keymap)

if iutil.getArch() == "sparc":
    import kudzu
    mice = kudzu.probe (kudzu.CLASS_MOUSE, kudzu.BUS_UNSPEC, kudzu.PROBE_ONE);
    if mice:
	(mouseDev, driver, descr) = mice[0]
	if mouseDev == 'sunmouse':
	    instClass.addToSkipList("mouse")
	    instClass.setMouseType("Sun - Mouse", "sunmouse")

try:
    todo = ToDo(intf, method, rootPath, installSystem = installPackages,
                setupFilesystems = setupFilesystems, mouse = mouseInfo,
		instClass = instClass, x = x, expert = expert, serial = serial,
		extraModules = extraModules)
    intf.run(todo, test = test)
except:
    (type, value, tb) = sys.exc_info()
    from string import joinfields
    list = traceback.format_exception (type, value, tb)
    text = joinfields (list, "")
    rc = intf.exceptionWindow (_("Exception Occured"), text)
    intf.__del__ ()
    if rc:
        import pdb
        pdb.post_mortem (tb)
    os._exit (1)

del intf