#!/usr/bin/python import sys, getopt, os import gettext import traceback import string gettext.bindtextdomain("anaconda", "/usr/share/locale") gettext.textdomain("anaconda") _ = gettext.gettext (args, extra) = getopt.getopt(sys.argv[1:], 'GTtdr:fm:', [ 'gui', 'text', 'test', 'debug', 'method=', 'rootpath=', 'testpath=', 'mountfs', 'traceonly' ]) # 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 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 == '-m' or str == '--method'): method = arg elif (str == '-d' or str == '--debug'): debug = 1 elif (str == '-r' or str == '--rootpath'): rootPath = arg localInstall = 1 elif (str == '--mountfs'): forceMount = 1 elif (str == '--traceonly'): traceOnly = 1 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('isys') sys.path.append('libfdisk') sys.path.append('balkan') #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 if (mode == 'g' and not os.environ.has_key('DISPLAY')): os.environ['DISPLAY'] = ':1' serverPath = None try: f = open('/dev/fb0', 'r') f.close() serverPath = '/usr/X11R6/bin/XF86_FBDev' except: # serverPath = '/usr/X11R6/bin/XF86_VGA16' serverPath = '/usr/X11R6/bin/XF86_SVGA' isys.makeDevInode("psaux", "/tmp/psaux") if (not test): for i in ( "imrc", "im_palette.pal" ): os.symlink ("../mnt/source/RedHat/instimage/etc/" + i, "/etc/" + i) f = open ('/tmp/XF86Config', 'w') f.write (""" Section "Files" RgbPath "/usr/X11R6/lib/X11/rgb" FontPath "/usr/X11R6/lib/X11/fonts/misc/" FontPath "/usr/X11R6/lib/X11/fonts/Type1/" FontPath "/usr/X11R6/lib/X11/fonts/Speedo/" FontPath "/usr/X11R6/lib/X11/fonts/75dpi/" FontPath "/usr/X11R6/lib/X11/fonts/100dpi/" EndSection Section "ServerFlags" EndSection Section "Keyboard" Protocol "Standard" AutoRepeat 500 5 LeftAlt Meta RightAlt Meta ScrollLock Compose RightCtl Control XkbKeymap "xfree86(us)" XkbKeycodes "xfree86" XkbTypes "default" XkbCompat "default" XkbSymbols "us(pc101)" XkbGeometry "pc" XkbRules "xfree86" XkbModel "pc101" XkbLayout "us" EndSection Section "Pointer" Protocol "ps/2" Device "/tmp/psaux" Emulate3Buttons Emulate3Timeout 50 EndSection Section "Monitor" Identifier "Monitor" VendorName "Vendor" ModelName "Model" HorizSync 31.5 - 79.0 VertRefresh 40-150 # XXX fix me descr Modeline "640x480" 25.175 640 664 760 800 480 491 493 525 # 640x480 @ 72 Hz, 36.5 kHz hsync Modeline "640x480" 31.5 640 680 720 864 480 488 491 521 # 640x480 @ 75 Hz, 37.50 kHz hsync ModeLine "640x480" 31.5 640 656 720 840 480 481 484 500 -HSync -VSync EndSection Section "Device" Identifier "Device" VendorName "Vendor" BoardName "Board" EndSection Section "Screen" Driver "vga16" Device "Device" Monitor "Monitor" Subsection "Display" Modes "640x480" ViewPort 0 0 EndSubsection EndSection Section "Screen" Driver "svga" Device "Device" Monitor "Monitor" Subsection "Display" Depth 8 Modes "640x480" ViewPort 0 0 Virtual 640 480 EndSubsection EndSection Section "Screen" Driver "fbdev" Device "Device" Monitor "Monitor" Subsection "Display" Depth 16 Modes "default" EndSubsection EndSection """) f.close () server = os.fork() if (not server): os.execv(serverPath, [serverPath, ':1', '-xf86config', '/tmp/XF86Config', 'vt5']) child = os.fork() if (child): os.waitpid(child, 0) os.kill(server, 15) sys.exit(0) if (mode == 'g'): from gui import InstallInterface elif (mode == 't'): from text import InstallInterface else: print "No mode was specified" sys.exit(1) if traceOnly: import pdb import image import harddrive 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:5] == "hd://"): method = method[5:] i = string.index(method, '/') dir = method[i:] drive = method[0:i] from harddrive import InstallMethod method = InstallMethod(drive, 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 try: todo = ToDo(intf, method, rootPath, installSystem = installPackages, setupFilesystems = setupFilesystems) intf.run(todo) 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