summaryrefslogtreecommitdiffstats
path: root/anaconda
blob: 09d420f6d5ce25960543cdd467891b9f426133b1 (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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
#!/usr/bin/python

import sys, os, signal
signal.signal(signal.SIGINT, signal.SIG_DFL)

# For anaconda in test mode
if (os.path.exists('isys')):
    sys.path.append('edd')
    sys.path.append('libfdisk')
    sys.path.append('balkan')
    sys.path.append('gnome-map')
    sys.path.append('isys')
    sys.path.append('textw')
    sys.path.append('iw')
    sys.path.append('installclasses')
    sys.path.append('edd')
else:
    sys.path.append('/usr/lib/anaconda')
    sys.path.append('/usr/lib/anaconda/textw')
    sys.path.append('/usr/lib/anaconda/iw')
    sys.path.append('/usr/lib/anaconda/installclasses')

os.environ['HOME'] = '/tmp'
os.environ["LC_NUMERIC"] = "C"

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

import traceback
import string

import isys
if isys.isPsudoTTY(0):
    os.environ["TERM"] = "kon"

import iutil
from translate import _
from exception import handleException

setverPath = None

if os.environ.has_key ("ANACONDAARGS"):
    theargs = string.split (os.environ["ANACONDAARGS"])
else:
    theargs = sys.argv[1:]
try:
    (args, extra) = isys.getopt(theargs, 'GTRxtdr:fm:', 
          [ 'gui', 'text', 'reconfig', 'xmode', 'test', 'debug', 'nofallback',
            'method=', 'rootpath=', 'pcic=', "overhead=",
	    'testpath=', 'mountfs', 'traceonly', 'kickstart=',
            'lang=', 'keymap=', 'kbdtype=', 'module=', 'class=',
	    'expert', 'serial', 'lowres', 'nofb', 'rescue'])
except TypeError, msg:
    print "Error:", msg
    sys.exit(-1)

# save because we're about to munge argv
[execname] = string.split(sys.argv[0], '/')[-1:]

savedargs = []

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

os.environ["ANACONDAARGS"] = string.join(savedargs)

#
# default root to install into if doing a normal install
#
rootPath = '/mnt/sysimage'

extraModules = []

# display mode is either 'g' for graphical or 't' for text
display_mode = 'g'
forced_display_mode = None

# Force text mode on ia64
#if iutil.getArch() == 'ia64':
#    forced_display_mode = 't'

# booleans - value is 0 for false or non-zero for true
# test           - in test mode?
# xmode          - bring up text mode in a X terminal window?
# debug          - in debug mode?
# serial         - install via serial port (?)
# expert         - in expert mode?
# traceOnly      - print out loaded modules
# forceMount     - ? used ?
# localInstall   - install to chroot
# reconfigOnly   - allow user to reconfig installed box w/o reinstall
# nofallback     - don't fall back to text mode on gui startup failure
# runres         - resolution to run 
# rescue	 - run rescue mode instead
test = 0
xmode = 0
debug = 0
serial = 0
expert = 0
traceOnly = 0
forceMount = 0
localInstall = 0
reconfigOnly = 0
nofallback = 0
rescue = 0
overhead = 0
runres = '800x600'
nofbmode = 0

#
# x          - xserver info (?)
# lang       - language to use for install/machine default
# method     - install method (not used if reconfigOnly is true)
# keymap     - kbd map
# kbdtype    - type of keyboard (84 key, 101 key, etc)
# kickstart  - ?
# mouseInfo  - type of mouse
# progmode   - either 'reconfig', 'rescue', or 'install'
#
x = None
lang = None
method = None
keymap = None
kbdtpye = None
kickstart = None
mouseInfo = None
progmode = None
customClass = None
pcicController = None

#
# parse off command line arguments
#
for n in args:
    (str, arg) = n

    if (str == '-G' or str == '--gui'):
	forced_display_mode = 'g'
    elif (str == '-T' or str == '--text'):
	forced_display_mode = 't'
    elif (str == '-R' or str == '--reconfig'):
	reconfigOnly = 1
        progmode = 'reconfig'
    elif (str == '-x' or str == '--xmode'):
	xmode = 1
    elif (str == '-t' or str == '--test'):
	test = 1
    elif (str == '--pcic'):
	pcicController = arg
    elif (str == '--overhead'):
	overhead = int(arg)
    elif (str == '--rescue'):
        progmode = 'rescue'
    elif (str == '--nofallback'):
	nofallback = 1
    elif (str == '--module'):
	(path, subdir, name) = string.split(arg, ":")
	extraModules.append((path, subdir, name))
    elif (str == '-m' or str == '--method'):
	method = arg
        reconfigOnly = 0
        progmode = 'install'
	if method[0] == '@':
	    filename = method[1:]
	    f = open(filename, "r")
	    method = f.readline()
	    method = method[:len(method) - 1]
	    del f
	    os.unlink(filename)
    elif (str == '-d' or str == '--debug'):
	debug = 1
    elif (str == '--kickstart'):
	kickstart = arg
	forced_display_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
    elif (str == '--class'):
        customClass = arg
    elif (str == '--lowres'):
        runres = '640x480'
    elif (str == '--nofb'):
        nofbmode = 1

#
# must specify install, rescue or reconfig mode
#
if (progmode == None):
    print "Must specify either --reconfig or --method for program mode"
    sys.exit(1)

if (progmode == 'rescue'):
    import rescue
    rescue.runRescue(serial)
    # shouldn't get back here
    sys.exit(1)

#
# if not just reconfiguring box, must have install method
#
if (not reconfigOnly  and not method):
    print "no install method specified"
    sys.exit(1)

if (debug):
    import pdb
    pdb.set_trace()
#
# don't let a developer reinstall their box unknowingly
#
if (not reconfigOnly and not test and not localInstall and os.getpid() > 90):
    print "you're running me on a live system! that's incredibly stupid."
    sys.exit(1)

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

iutil.setMemoryOverhead(overhead)

#
# override display mode if machine cannot nicely run X
#
if (not test):
    if (iutil.memInstalled() < isys.MIN_GUI_RAM):
	forced_display_mode = 't'

if iutil.memInstalled() < isys.MIN_RAM:
    from snack import *

    screen = SnackScreen()
    ButtonChoiceWindow(screen, _('Fatal Error'),
			_('You do not have enough RAM to install Red Hat '
			  'Linux on this machine.\n'
			  '\n'
			  'Press <return> to reboot your system.\n'), 
			  buttons = (_("OK"),))
    screen.finish()
    sys.exit(0)

#
# handle class passed from loader
#
instClass = None
if customClass:
    import installclass

    classes = installclass.availableClasses(showHidden=1)
    for (className, objectClass, logo) in classes:
	if className == customClass:
		instClass = objectClass(expert)
                reqmode = instClass.requiredDisplayMode()
                if reqmode:
                    forced_display_mode = reqmode

    if not instClass:
	raise TypeError, "installation class "+customClass+" not available"
	sys.exit(0)

#
# if in reconfig mode set display mode based on inittab default runlevel
#
# but always let command line specified mode override defaults
#
if (forced_display_mode == None):
    if (reconfigOnly != 0):
        if (iutil.getDefaultRunlevel() == '5' and
            os.access("/etc/X11/XF86Config", os.R_OK)):
                display_mode = 'g'
        else:
                display_mode = 't'
    else:
        display_mode = 'g'
else:
    display_mode = forced_display_mode

#
# startup X server is we're not already running under an X session
#
startXServer = 0
if (display_mode == 'g' and not os.environ.has_key('DISPLAY')):
    startXServer = 1
    import xserver
    try:
        if (reconfigOnly == 0):
            result = xserver.startX (runres, nofbmode)
        else:
            result = xserver.start_existing_X ()
            
    except RuntimeError:
	print " X startup failed, falling back to text mode"
        display_mode = 't'
    else:
        (mouseInfo, x) = (result)

#
# setup links required by graphical mode if installing and verify display mode
#
if (display_mode == 'g'):
    if not test and not localInstall and not reconfigOnly:
        for i in ( "imrc", "im_palette.pal", "gtk" ):
            try:
                os.symlink ("../mnt/runtime/etc/" + i, "/etc/" + i)
            except:
                pass
    if nofallback:
        from gui import InstallInterface
    else:
        try:
            from gui import InstallInterface
        except:
            # if we're not going to really go into GUI mode, we need to get back
            # to vc1 where the text install is going to pop up.
            if startXServer:
                isys.vtActivate (1)
            print "GUI installer startup failed, falling back to text mode."
            display_mode = 't'
            from text import InstallInterface
elif (display_mode == 't'):
    from text import InstallInterface
else:
    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
    import installclass
    import re

    installclass.availableClasses()

    if iutil.getArch() == "i386":
	import edd

    if display_mode == 't':
        from newtpyfsedit import fsedit        
    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)

#
# if no instClass declared by user figure it out based on other cmdline args
#
if not instClass:
    if kickstart:
        instClass = Kickstart(kickstart, serial)
    elif reconfigOnly:
        instClass = ReconfigStation(expert)
    else:
        instClass = DefaultInstall(expert)

# we like to have a way to shoot text mode back at a display
if xmode:
    os.environ["TERM"] = "xterm"
    from gtk import *
    from gnome.zvt import *

    def child_died (widget, *args):
        mainquit()

    win = GtkWindow ()
    zvt = ZvtTerm (80, 24)
    zvt.connect ("child_died", child_died)
    zvt.set_del_key_swap(TRUE)
    win.add (zvt)
    win.show_all ()
    child = zvt.forkpty()
    if child != 0:
        mainloop()
        try:
            pid, status = os.waitpid(child, 0)
        except OSError:
            pass
        sys.exit (0)

#print runres
if display_mode == "t":
    intf = InstallInterface ()
else:
    intf = InstallInterface (runres = runres, nofbmode = nofbmode)

# imports after setting up the path
if not reconfigOnly:
    if (method[0:8] == "cdrom://"):
        from image import CdromInstallMethod
        method = CdromInstallMethod(method[8:], intf.messageWindow,
				    intf.progressWindow)
    elif (method[0:5] == "nfs:/"):
        from image import NfsInstallMethod
        method = NfsInstallMethod(method[5:])
    elif (method[0:6] == "ftp://" or method[0:7] == "http://"):
        from urlinstall import UrlInstallMethod
        method = UrlInstallMethod(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 HardDriveInstallMethod
        method = HardDriveInstallMethod(drive, type, dir, intf.messageWindow)
    elif (method[0:8] == "oldhd://"):
        method = method[8:]
        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 OldHardDriveInstallMethod
        method = OldHardDriveInstallMethod(drive, type, dir)
    else:
        print "unknown install method:", method
        sys.exit(1)

#
# do some final sanity checking before going off into the great wide wonder
#
if reconfigOnly and method != None:
    print "Conflicting options: cannot reconfig and install simultaneously!\n"
    sys.exit(1)

# 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 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")

if reconfigOnly:
    installPackages = 0
    setupFilesystems = 0
    rootPath = '/'

todo = ToDo(intf, method, rootPath, installSystem = installPackages,
	    setupFilesystems = setupFilesystems, mouse = mouseInfo,
	    instClass = instClass, x = x, expert = expert,
	    serial = serial, reconfigOnly = reconfigOnly, test = test,
	    extraModules = extraModules, pcicController = pcicController)

try:
    intf.run(todo, test = test)
except SystemExit, code:
    intf.shutdown()
except:
    handleException(todo, sys.exc_info())

del intf