home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2000 July / CD 3 / redhat-6.2.iso / RedHat / instimage / usr / lib / anaconda / text.py < prev    next >
Encoding:
Python Source  |  2000-03-08  |  40.9 KB  |  1,199 lines

  1. from snack import *
  2. import sys
  3. import isys
  4. import os
  5. import stat
  6. import iutil
  7. import rpm
  8. import time
  9. import gettext_rh
  10. import glob
  11. import signal
  12. from translate import _, cat
  13.  
  14. from textw.constants import *
  15. from textw.lilo import LiloWindow
  16. from textw.lilo import LiloAppendWindow
  17. from textw.lilo import LiloImagesWindow
  18. from textw.silo import SiloWindow
  19. from textw.silo import SiloAppendWindow
  20. from textw.silo import SiloImagesWindow
  21. from textw.userauth import RootPasswordWindow
  22. from textw.userauth import UsersWindow
  23. from textw.userauth import AuthConfigWindow
  24. from textw.partitioning import PartitionMethod
  25. from textw.partitioning import LoopSizeWindow
  26. from textw.partitioning import ManualPartitionWindow
  27. from textw.partitioning import AutoPartitionWindow
  28. from textw.partitioning import PartitionWindow
  29. from textw.partitioning import TurnOnSwapWindow
  30. from textw.partitioning import FormatWindow
  31. from textw.packages import PackageGroupWindow
  32. from textw.packages import IndividualPackageWindow
  33. from textw.packages import PackageDepWindow
  34. from textw.timezone import TimezoneWindow
  35. import installclass
  36.  
  37. class LanguageWindow:
  38.     def __call__(self, screen, todo):
  39.         languages = todo.language.available ()
  40.         descriptions = languages.keys ()
  41.         descriptions.sort ()
  42.         current = todo.language.get ()
  43.         for lang in descriptions:
  44.             if languages[lang] == current:
  45.                 default = descriptions.index (lang)
  46.             
  47.         height = min((screen.height - 16, len(descriptions)))
  48.         if todo.reconfigOnly:
  49.             buttons = [_("Ok"), _("Back")]
  50.         else:
  51.             buttons = [_("Ok")]
  52.                
  53.         (button, choice) = \
  54.             ListboxChoiceWindow(screen, _("Language Selection"),
  55.             _("What language would you like to use during the "
  56.               "installation process?"), descriptions, 
  57.             buttons, width = 30, default = default, scroll = 1,
  58.                                 height = height)
  59.  
  60.     if (button == string.lower(_("Back"))): return INSTALL_BACK
  61.  
  62.         choice = descriptions[choice]
  63.         lang = languages [choice]
  64.         newlangs = [lang]
  65.     if len(lang) > 2:
  66.             newlangs.append(lang[:2])
  67.         cat.setlangs (newlangs)
  68.         todo.language.set (choice)
  69.     if not todo.serial:
  70.         font = todo.language.getFont(choice)
  71.         if font != "None":
  72.         try:
  73.             isys.loadFont(font)
  74.         except SystemError, (errno, msg):
  75.             todo.log("Could not load font %s: %s" % (font, msg))
  76.         return INSTALL_OK
  77.  
  78. class MouseDeviceWindow:
  79.     def __call__(self, screen, todo):
  80.     choices = { _("/dev/ttyS0 (COM1 under DOS)") : "ttyS0",
  81.             _("/dev/ttyS1 (COM2 under DOS)") : "ttyS1",
  82.             _("/dev/ttyS2 (COM3 under DOS)") : "ttyS2",
  83.             _("/dev/ttyS3 (COM4 under DOS)") : "ttyS3" }
  84.  
  85.     i = 0
  86.     default = 0
  87.     mouse = todo.mouse.getDevice()
  88.     if (mouse[0:4] != "ttyS"): return INSTALL_NOOP
  89.  
  90.     l = choices.keys()
  91.     l.sort()
  92.     for choice in l:
  93.         if choices[choice] == mouse:
  94.         default = i
  95.         break
  96.         i = i + 1
  97.  
  98.     (button, result) = ListboxChoiceWindow(screen, _("Device"),
  99.             _("What device is your mouse located on? %s %i") % (mouse, default), l,
  100.             [ _("Ok"), _("Back") ], default = default )
  101.     if (button == string.lower(_("Back"))): return INSTALL_BACK
  102.  
  103.     todo.mouse.setDevice(choices[l[result]])
  104.  
  105.     #import sys; sys.exit(0)
  106.  
  107.     return INSTALL_OK
  108.  
  109. class MouseWindow:
  110.     def __call__(self, screen, todo):
  111.     if todo.serial:
  112.         return INSTALL_NOOP
  113.         mice = todo.mouse.available ().keys ()
  114.         mice.sort ()
  115.     (default, emulate) = todo.mouse.get ()
  116.     if default == "Sun - Mouse":
  117.         return INSTALL_NOOP
  118.         default = mice.index (default)
  119.  
  120.     bb = ButtonBar(screen, [_("OK"), _("Back")])
  121.     t = TextboxReflowed(40, 
  122.         _("Which model mouse is attached to this computer?"))
  123.     l = Listbox(8, scroll = 1, returnExit = 0)
  124.  
  125.         key = 0
  126.         for mouse in mice:
  127.         l.append(mouse, key)
  128.         key = key + 1
  129.     l.setCurrent(default)
  130.  
  131.     c = Checkbox(_("Emulate 3 Buttons?"), isOn = emulate)
  132.  
  133.     g = GridForm(screen, _("Mouse Selection"), 1, 4)
  134.     g.add(t, 0, 0)
  135.     g.add(l, 0, 1, padding = (0, 1, 0, 1))
  136.     g.add(c, 0, 2, padding = (0, 0, 0, 1))
  137.     g.add(bb, 0, 3, growx = 1)
  138.  
  139.     rc = g.runOnce()
  140.  
  141.         button = bb.buttonPressed(rc)
  142.         
  143.         if button == string.lower (_("Back")):
  144.             return INSTALL_BACK
  145.  
  146.     choice = l.current()
  147.     emulate = c.selected()
  148.  
  149.         todo.mouse.set(mice[choice], emulate)
  150.  
  151.     oldDev = todo.mouse.getDevice()
  152.     if (oldDev):
  153.         newDev = todo.mouse.available()[mice[choice]][2]
  154.         if ((oldDev[0:4] == "ttyS" and newDev[0:4] == "ttyS") or
  155.         (oldDev == newDev)):
  156.         pass
  157.         else:
  158.         todo.mouse.setDevice(newDev)
  159.  
  160.     return INSTALL_OK
  161.  
  162. class KeyboardWindow:
  163.     def __call__(self, screen, todo):
  164.     if todo.serial:
  165.         return INSTALL_NOOP
  166.         keyboards = todo.keyboard.available ()
  167.         keyboards.sort ()
  168.         default = keyboards.index (todo.keyboard.get ())
  169.  
  170.         (button, choice) = \
  171.             ListboxChoiceWindow(screen, _("Keyboard Selection"),
  172.                                 _("Which model keyboard is attached to this computer?"), keyboards, 
  173.                                 buttons = [_("OK"), _("Back")], width = 30, scroll = 1, height = 8,
  174.                                 default = default)
  175.         
  176.         if button == string.lower (_("Back")):
  177.             return INSTALL_BACK
  178.         todo.keyboard.set (keyboards[choice])
  179.     if not todo.serial:
  180.             if todo.reconfigOnly:
  181.                 iutil.execWithRedirect ("/bin/loadkeys",
  182.                                         ["/bin/loadkeys", keyboards[choice]],
  183.                     stderr = "/dev/null")
  184.             else:
  185.                 try:
  186.                     isys.loadKeymap(keyboards[choice])
  187.                 except SystemError, (errno, msg):
  188.             todo.log("Could not install keymap %s: %s" % (keyboards[choice], msg))
  189.         return INSTALL_OK
  190.     
  191. class InstallPathWindow:
  192.     def __call__ (self, screen, todo, intf):
  193.     from fstab import NewtFstab
  194.  
  195.         # see if kickstart specified install type
  196.     showScreen = 1
  197.     if (todo.instClass.installType == "install"):
  198.             intf.steps = intf.commonSteps + intf.installSteps
  199.             todo.upgrade = 0
  200.         showScreen = 0
  201.     elif (todo.instClass.installType == "upgrade"):
  202.             intf.steps = intf.commonSteps + intf.upgradeSteps
  203.             todo.upgrade = 1
  204.         showScreen = 0
  205.  
  206.     if not showScreen:
  207.         todo.fstab = NewtFstab(todo.setupFilesystems, 
  208.                        todo.serial, 0, 0,
  209.                        todo.intf.waitWindow,
  210.                        todo.intf.messageWindow)
  211.  
  212.         return INSTALL_NOOP
  213.  
  214.     if (todo.upgrade):
  215.         default = 4
  216.         orig = None
  217.     else:
  218.         instClass = todo.getClass()
  219.         orig = None
  220.         if isinstance(instClass, installclass.GNOMEWorkstation):
  221.         orig = 0
  222.         elif isinstance(instClass, installclass.KDEWorkstation):
  223.         orig = 1
  224.         elif isinstance(instClass, installclass.Server):
  225.         orig = 2
  226.         elif isinstance(instClass, installclass.CustomInstall):
  227.         orig = 3
  228.         if (orig):
  229.         default = orig
  230.         else:
  231.         default = 0
  232.  
  233.     choices = [ _("Install GNOME Workstation"), 
  234.             _("Install KDE Workstation"),
  235.             _("Install Server System"),
  236.             _("Install Custom System"),
  237.             _("Upgrade Existing Installation") ]
  238.     (button, choice) = ListboxChoiceWindow(screen, _("Installation Type"),
  239.             _("What type of system would you like to install?"),
  240.                 choices, [(_("OK"), "ok"), (_("Back"), "back")],
  241.                 width = 40, default = default)
  242.  
  243.         if button == "back":
  244.             return INSTALL_BACK
  245.  
  246.     needNewDruid = 0
  247.  
  248.     if (choice == 4):
  249.             intf.steps = intf.commonSteps + intf.upgradeSteps
  250.             todo.upgrade = 1
  251.         else:
  252.             intf.steps = intf.commonSteps + intf.installSteps
  253.             todo.upgrade = 0
  254.         if (choice == 0 and orig != 0):
  255.         todo.setClass(installclass.GNOMEWorkstation(todo.expert))
  256.         needNewDruid = 1
  257.         elif (choice == 1 and orig != 1):
  258.         todo.setClass(installclass.KDEWorkstation(todo.expert))
  259.         needNewDruid = 1
  260.         elif (choice == 2 and orig != 2):
  261.         todo.setClass(installclass.Server(todo.expert))
  262.         needNewDruid = 1
  263.         elif (choice == 3 and orig != 3):
  264.         todo.setClass(installclass.CustomInstall(todo.expert))
  265.         needNewDruid = 1
  266.  
  267.     if needNewDruid or not todo.fstab:
  268.         todo.fstab = NewtFstab(todo.setupFilesystems, 
  269.                        todo.serial, 0, 0,
  270.                        todo.intf.waitWindow,
  271.                        todo.intf.messageWindow)
  272.  
  273.         return INSTALL_OK
  274.  
  275. class UpgradeExamineWindow:
  276.     def __call__ (self, dir, screen, todo):
  277.     if dir == -1:
  278.         # Hack to let backing out of upgrades work properly
  279.         from fstab import NewtFstab
  280.         if todo.fstab:
  281.         todo.fstab.turnOffSwap()
  282.         todo.fstab = NewtFstab(todo.setupFilesystems, 
  283.                        todo.serial, 0, 0,
  284.                        todo.intf.waitWindow,
  285.                        todo.intf.messageWindow)
  286.         return INSTALL_NOOP
  287.  
  288.         parts = todo.upgradeFindRoot ()
  289.  
  290.         if not parts:
  291.             ButtonChoiceWindow(screen, _("Error"),
  292.                                _("You don't have any Linux partitions. You "
  293.                                  "can't upgrade this system!"),
  294.                                [ _("Back") ], width = 50)
  295.             return INSTALL_BACK
  296.         
  297.         if len (parts) > 1:
  298.             height = min (len (parts), 12)
  299.             if height == 12:
  300.                 scroll = 1
  301.             else:
  302.                 scroll = 0
  303.  
  304.             (button, choice) = \
  305.                 ListboxChoiceWindow(screen, _("System to Upgrade"),
  306.                                     _("What partition holds the root partition "
  307.                                       "of your installation?"), parts, 
  308.                                     [ _("OK"), _("Back") ], width = 30,
  309.                                     scroll = scroll, height = height)
  310.             if button == string.lower (_("Back")):
  311.                 return INSTALL_BACK
  312.             else:
  313.                 root = parts[choice]
  314.         else:
  315.             root = parts[0]
  316.  
  317.         todo.upgradeFindPackages (root)
  318.  
  319. class CustomizeUpgradeWindow:
  320.     def __call__ (self, screen, todo, indiv):
  321.         rc = ButtonChoiceWindow (screen, _("Customize Packages to Upgrade"),
  322.                                  _("The packages you have installed, "
  323.                                    "and any other packages which are "
  324.                                    "needed to satisfy their "
  325.                                    "dependencies, have been selected "
  326.                                    "for installation. Would you like "
  327.                                    "to customize the set of packages "
  328.                                    "that will be upgraded?"),
  329.                                  buttons = [ _("Yes"), _("No"), _("Back") ])
  330.  
  331.         if rc == string.lower (_("Back")):
  332.             return INSTALL_BACK
  333.  
  334.         if rc == string.lower (_("No")):
  335.             indiv.set (0)
  336.         else:
  337.             indiv.set (1)
  338.  
  339.         return INSTALL_OK
  340.  
  341.  
  342. class WelcomeWindow:
  343.     def __call__(self, screen):
  344.         rc = ButtonChoiceWindow(screen, _("Red Hat Linux"), 
  345.                                 _("Welcome to Red Hat Linux!\n\n"
  346.                                   "This installation process is outlined in detail in the "
  347.                                   "Official Red Hat Linux Installation Guide available from "
  348.                                   "Red Hat Software. If you have access to this manual, you "
  349.                                   "should read the installation section before continuing.\n\n"
  350.                                   "If you have purchased Official Red Hat Linux, be sure to "
  351.                                   "register your purchase through our web site, "
  352.                                   "http://www.redhat.com/."),
  353.                                 buttons = [_("OK"), _("Back")], width = 50)
  354.  
  355.     if rc == string.lower(_("Back")):
  356.         return INSTALL_BACK
  357.  
  358.         return INSTALL_OK
  359.  
  360. class ReconfigWelcomeWindow:
  361.     def __call__(self, screen):
  362.         rc = ButtonChoiceWindow(screen, _("Red Hat Linux"), 
  363.                                 _("Welcome to the Red Hat Linux!\n\n"
  364.                                   "You have entered reconfiguration mode, "
  365.                                   "which will allow you to configure "
  366.                                   "site-specific options of your computer."
  367.                                   "\n\n"
  368.                                   "To exit without changing your setup "
  369.                                   "select the ""Cancel"" button below."),
  370.                                 buttons = [_("OK"), _("Cancel")], width = 50)
  371.  
  372.     if rc == string.lower(_("Cancel")):
  373.             screen.finish()
  374.         os._exit(0)
  375.  
  376.         return INSTALL_OK
  377.  
  378. class NetworkWindow:
  379.     def setsensitive (self):
  380.         if self.cb.selected ():
  381.             sense = FLAGS_SET
  382.         else:
  383.             sense = FLAGS_RESET
  384.  
  385.         for n in self.ip, self.nm, self.gw, self.ns:
  386.             n.setFlags (FLAG_DISABLED, sense)
  387.  
  388.     def calcNM (self):
  389.         ip = self.ip.value ()
  390.         if ip and not self.nm.value ():
  391.             try:
  392.                 mask = isys.inet_calcNetmask (ip)
  393.             except ValueError:
  394.                 return
  395.  
  396.             self.nm.set (mask)
  397.  
  398.     def calcGW (self):
  399.         ip = self.ip.value ()
  400.         nm = self.nm.value ()
  401.         if ip and nm:
  402.             try:
  403.                 (net, bcast) = isys.inet_calcNetBroad (ip, nm)
  404.             except ValueError:
  405.                 return
  406.  
  407.             if not self.gw.value ():
  408.                 gw = isys.inet_calcGateway (bcast)
  409.                 self.gw.set (gw)
  410.             if not self.ns.value ():
  411.                 ns = isys.inet_calcNS (net)
  412.                 self.ns.set (ns)
  413.  
  414.     def __call__(self, screen, todo):
  415.  
  416.  
  417.         devices = todo.network.available ()
  418.         if not devices:
  419.             return INSTALL_NOOP
  420.  
  421.         if todo.network.readData:
  422.             # XXX expert mode, allow changing network settings here
  423.             return INSTALL_NOOP
  424.         
  425.     list = devices.keys ()
  426.     list.sort()
  427.         dev = devices[list[0]]
  428.  
  429.         firstg = Grid (1, 1)
  430.         boot = dev.get ("bootproto")
  431.         
  432.         if not boot:
  433.             boot = "dhcp"
  434.         self.cb = Checkbox (_("Use bootp/dhcp"),
  435.                             isOn = (boot == "dhcp"))
  436.         firstg.setField (self.cb, 0, 0, anchorLeft = 1)
  437.  
  438.         secondg = Grid (2, 4)
  439.         secondg.setField (Label (_("IP address:")), 0, 0, anchorLeft = 1)
  440.     secondg.setField (Label (_("Netmask:")), 0, 1, anchorLeft = 1)
  441.     secondg.setField (Label (_("Default gateway (IP):")), 0, 2, anchorLeft = 1)
  442.         secondg.setField (Label (_("Primary nameserver:")), 0, 3, anchorLeft = 1)
  443.  
  444.         self.ip = Entry (16)
  445.         self.ip.set (dev.get ("ipaddr"))
  446.         self.nm = Entry (16)
  447.         self.nm.set (dev.get ("netmask"))
  448.         self.gw = Entry (16)
  449.         self.gw.set (todo.network.gateway)
  450.         self.ns = Entry (16)
  451.         self.ns.set (todo.network.primaryNS)
  452.  
  453.         self.cb.setCallback (self.setsensitive)
  454.         self.ip.setCallback (self.calcNM)
  455.         self.nm.setCallback (self.calcGW)
  456.  
  457.         secondg.setField (self.ip, 1, 0, (1, 0, 0, 0))
  458.     secondg.setField (self.nm, 1, 1, (1, 0, 0, 0))
  459.     secondg.setField (self.gw, 1, 2, (1, 0, 0, 0))
  460.         secondg.setField (self.ns, 1, 3, (1, 0, 0, 0))
  461.  
  462.         bb = ButtonBar (screen, ((_("OK"), "ok"), (_("Back"), "back")))
  463.  
  464.         toplevel = GridForm (screen, _("Network Configuration"), 1, 3)
  465.         toplevel.add (firstg, 0, 0, (0, 0, 0, 1), anchorLeft = 1)
  466.         toplevel.add (secondg, 0, 1, (0, 0, 0, 1))
  467.         toplevel.add (bb, 0, 2, growx = 1)
  468.  
  469.         self.setsensitive ()
  470.  
  471.         while 1:
  472.             result = toplevel.run ()
  473.             if self.cb.selected ():
  474.                 dev.set (("bootproto", "dhcp"))
  475.                 dev.unset ("ipaddr", "netmask", "network", "broadcast")
  476.             else:
  477.                 try:
  478.                     (network, broadcast) = isys.inet_calcNetBroad (self.ip.value (), self.nm.value ())
  479.                 except:
  480.                     ButtonChoiceWindow(screen, _("Invalid information"),
  481.                                        _("You must enter valid IP information to continue"),
  482.                                        buttons = [ _("OK") ])
  483.                     continue
  484.  
  485.                 dev.set (("bootproto", "static"))
  486.                 dev.set (("ipaddr", self.ip.value ()), ("netmask", self.nm.value ()),
  487.                          ("network", network), ("broadcast", broadcast))
  488.                 todo.network.gateway = self.gw.value ()
  489.                 todo.network.primaryNS = self.ns.value ()
  490.             screen.popWindow()
  491.             break
  492.                      
  493.         dev.set (("onboot", "yes"))
  494.  
  495.         rc = bb.buttonPressed (result)
  496.  
  497.         todo.log ("\"" + dev.get ("device") + "\"")
  498.  
  499.         if rc == "back":
  500.             return INSTALL_BACK
  501.         return INSTALL_OK
  502.  
  503. class HostnameWindow:
  504.     def __call__(self, screen, todo):
  505.         entry = Entry (24)
  506.         if todo.network.hostname != "localhost.localdomain":
  507.             entry.set (todo.network.hostname)
  508.         rc, values = EntryWindow(screen, _("Hostname Configuration"),
  509.              _("The hostname is the name of your computer.  If your "
  510.                "computer is attached to a network, this may be "
  511.                "assigned by your network administrator."),
  512.              [(_("Hostname"), entry)], buttons = [ _("OK"), _("Back")])
  513.  
  514.         if rc == string.lower (_("Back")):
  515.             return INSTALL_BACK
  516.  
  517.         todo.network.hostname = entry.value ()
  518.         
  519.         return INSTALL_OK
  520.  
  521. class BootDiskWindow:
  522.     def __call__(self, screen, todo):
  523.     # we *always* do this for loopback installs
  524.     if todo.fstab.rootOnLoop():
  525.         return INSTALL_NOOP
  526.  
  527.     buttons = [ _("Yes"), _("No"), _("Back") ]
  528.     text =  _("A custom boot disk provides a way of booting into your "
  529.           "Linux system without depending on the normal bootloader. "
  530.           "This is useful if you don't want to install lilo on your "
  531.           "system, another operating system removes lilo, or lilo "
  532.           "doesn't work with your hardware configuration. A custom "
  533.           "boot disk can also be used with the Red Hat rescue image, "
  534.           "making it much easier to recover from severe system "
  535.           "failures.\n\n"
  536.           "Would you like to create a boot disk for your system?")
  537.  
  538.     if iutil.getArch () == "sparc":
  539.         floppy = todo.silo.hasUsableFloppy()
  540.         if floppy == 0:
  541.         todo.bootdisk = 0
  542.         return INSTALL_NOOP
  543.         text = string.replace (text, "lilo", "silo")
  544.         if floppy == 1:
  545.         buttons = [ _("No"), _("Yes"), _("Back") ]
  546.         text = string.replace (text, "\n\n",
  547.                        _("\nOn SMCC made Ultra machines floppy booting "
  548.                      "probably does not work\n\n"))
  549.  
  550.     rc = ButtonChoiceWindow(screen, _("Bootdisk"), text, buttons = buttons)
  551.  
  552.     if rc == string.lower (_("Yes")):
  553.         todo.bootdisk = 1
  554.     
  555.     if rc == string.lower (_("No")):
  556.         todo.bootdisk = 0
  557.  
  558.     if rc == string.lower (_("Back")):
  559.         return INSTALL_BACK
  560.     return INSTALL_OK
  561.  
  562. class XConfigWindow:
  563.     def __call__(self, screen, todo):
  564.         #
  565.         # if in reconfigOnly mode we query existing rpm db
  566.         # if X not installed, just skip this step
  567.         #
  568.         if todo.reconfigOnly:
  569. #            import rpm
  570. #            db = rpm.opendb()
  571. #            rc = db.findbyname ("XFree86")
  572. #            if len(rc) == 0:
  573. #                return None
  574.  
  575. #
  576. #       for now ignore request to configure X11 in reconfig mode
  577. #
  578.             return None
  579.         
  580.         else:
  581.             # we need to get the package list here for things like
  582.             # workstation install - which will not have read the
  583.             # package list yet.
  584.             todo.getCompsList ()
  585.  
  586.             if not todo.hdList.packages.has_key('XFree86') or \
  587.                not todo.hdList.packages['XFree86'].selected:
  588.                 return None
  589.  
  590.         todo.x.probe (probeMonitor = 0)
  591.  
  592.         if todo.x.server:
  593.             rc = ButtonChoiceWindow (screen, _("X probe results"),
  594.                                      todo.x.probeReport (),
  595.                                      buttons = [ _("OK"), _("Back") ])
  596.         
  597.             if rc == string.lower (_("Back")):
  598.                 return INSTALL_BACK
  599.  
  600.         todo._cardindex = -1
  601.             return INSTALL_OK
  602.  
  603.     if todo.serial:
  604.         # if doing serial installation and no card was probed,
  605.         # assume no card is present (typical case).
  606.         return INSTALL_NOOP
  607.  
  608.     # if we didn't find a server, we need the user to choose...
  609.     carddb = todo.x.cards()
  610.     cards = carddb.keys ()
  611.     cards.sort ()
  612.     cards.append (_("Unlisted Card"))
  613.  
  614.     servers = [ "Mono", "VGA16", "SVGA", "S3", "Mach32", "Mach8", "8514", "P9000", "AGX",
  615.             "W32", "W32", "Mach64", "I128", "S3V", "3DLabs" ]
  616.     server = None
  617.  
  618.     rc = INSTALL_NOOP
  619.     while rc != INSTALL_OK:
  620.         (rc, choice) = ListboxChoiceWindow(screen, _("Video Card Selection"),
  621.                            _("Which video card do you have?"),
  622.                            cards,
  623.                            buttons = [_("OK"), _("Back")],
  624.                            width = 70, scroll = 1,
  625.                            height = screen.height - 14)
  626.         if rc == string.lower (_("Back")):
  627.         return INSTALL_BACK
  628.  
  629.         todo._cardindex = -1
  630.  
  631.         if cards[choice] == _("Unlisted Card"):
  632.         (rc , choice) = \
  633.             ListboxChoiceWindow(screen, _("X Server Selection"), _("Choose a server"),
  634.                     servers,
  635.                     buttons = [ (_("Ok"), "ok"), (_("Back"), "back") ],
  636.                     scroll = 1,
  637.                     height = screen.height - 14)
  638.  
  639.         if (rc == "back"):
  640.             rc = INSTALL_BACK
  641.         else:
  642.             rc = INSTALL_OK
  643.             server = servers[choice]
  644.         else:
  645.         todo._cardindex = choice
  646.         rc = INSTALL_OK
  647.  
  648.     if server:
  649.         todo.x.setVidcard ( { "NAME" : "Generic " + server,
  650.                   "SERVER" : server } )
  651.     else:
  652.         card = carddb[cards[choice]]
  653.  
  654.             depth = 0
  655.             while depth < 16 and card.has_key ("SEE"):
  656.                 card = carddb[card["SEE"]]
  657.                 depth = depth + 1
  658.  
  659.         todo.x.setVidcard (card)
  660.     
  661.     return INSTALL_OK
  662.  
  663.  
  664. class XconfiguratorWindow:
  665.     def __call__ (self, screen, todo):
  666.         if not todo.x.server: return INSTALL_NOOP
  667.  
  668.     # if serial install, we can't run it.
  669.     if todo.serial:
  670.         todo.x.skip = 1
  671.         return INSTALL_NOOP
  672.  
  673.         # if Xconfigurator isn't installed, we can't run it.
  674.         if not os.access (todo.instPath + '/usr/X11R6/bin/Xconfigurator',
  675.                           os.X_OK): return INSTALL_NOOP
  676.  
  677.         f = open (todo.instPath + "/tmp/SERVER", "w")
  678.         f.write ("%s %d\n" % (todo.x.server, todo._cardindex))
  679.         f.close ()
  680.  
  681.         screen.suspend ()
  682.         iutil.execWithRedirect ("/usr/X11R6/bin/Xconfigurator",
  683.                                 ["xconfigurator", "--continue"],
  684.                                 root = todo.instPath)
  685.         screen.resume ()
  686.     todo.x.skip = 1
  687.         return INSTALL_NOOP
  688.         
  689. class BeginInstallWindow:
  690.     def __call__ (self, screen, todo):
  691.         rc = ButtonChoiceWindow (screen, _("Installation to begin"),
  692.                                 _("A complete log of your installation will be in "
  693.                                   "/tmp/install.log after rebooting your system. You "
  694.                                   "may want to keep this file for later reference."),
  695.                                 buttons = [ _("OK"), _("Back") ])
  696.         if rc == string.lower (_("Back")):
  697.             return INSTALL_BACK
  698.         return INSTALL_OK
  699.  
  700. class InstallWindow:
  701.     def __call__ (self, screen, todo):
  702.         if todo.doInstall ():
  703.             return INSTALL_BACK
  704.         return INSTALL_OK
  705.  
  706. class FinishedWindow:
  707.     def __call__ (self, screen, todo):
  708.         if not todo.reconfigOnly:
  709.             rc = ButtonChoiceWindow (screen, _("Complete"), 
  710.                      _("Congratulations, installation is complete.\n\n"
  711.                        "Press return to reboot, and be sure to remove your "
  712.                "boot medium as the system reboots, or your system "
  713.                "will rerun the install. For information on fixes which "
  714.                        "are available for this release of Red Hat Linux, "
  715.                        "consult the "
  716.                        "Errata available from http://www.redhat.com/errata.\n\n"
  717.                        "Information on configuring and using your Red Hat "
  718.                "Linux system is contained in the Red Hat Linux "
  719.                "manuals."),
  720.                     [ _("OK") ])
  721.         else:
  722.             todo.writeConfiguration()
  723.             
  724.             rc = ButtonChoiceWindow (screen, _("Complete"), 
  725.                        _("Congratulations, configuration is complete.\n\n"
  726.                          " For information on fixes which "
  727.                          "are available for this release of Red Hat Linux, "
  728.                          "consult the "
  729.                          "Errata available from http://www.redhat.com.\n\n"
  730.                          "Information on further configuring your system is "
  731.                          "available "
  732.                          "in the post install chapter of the Official Red Hat "
  733.                          "Linux User's Guide."),
  734.                       [ _("OK") ])
  735.  
  736.         return INSTALL_OK
  737.  
  738.  
  739. class ReconfigFinishedWindow:
  740.     def __call__ (self, screen, todo):
  741.  
  742.         todo.writeConfiguration()
  743.             
  744.         rc = ButtonChoiceWindow (screen, _("Complete"), 
  745.                                  _("Congratulations, configuration is complete.\n\n"
  746.                                    " For information on fixes which "
  747.                                    "are available for this release of Red Hat Linux, "
  748.                                    "consult the "
  749.                                    "Errata available from http://www.redhat.com.\n\n"
  750.                                    "Information on further configuring your system is "
  751.                                    "available "
  752.                                    "in the post install chapter of the Official Red Hat "
  753.                                    "Linux User's Guide."),
  754.                                  [ _("OK") ])
  755.  
  756.         return INSTALL_OK
  757.  
  758. class BootdiskWindow:
  759.     def __call__ (self, screen, todo):
  760.         if not todo.needBootdisk():
  761.             return INSTALL_NOOP
  762.  
  763.         rc = ButtonChoiceWindow (screen, _("Bootdisk"),
  764.              _("Insert a blank floppy in the first floppy drive. "
  765.                "All data on this disk will be erased during creation "
  766.                "of the boot disk."),
  767.              [ _("OK"), _("Skip") ])                
  768.         if rc == string.lower (_("Skip")):
  769.             return INSTALL_OK
  770.             
  771.         while 1:
  772.             try:
  773.                 todo.makeBootdisk ()
  774.             except:
  775.                 rc = ButtonChoiceWindow (screen, _("Error"),
  776.             _("An error occured while making the boot disk. "
  777.               "Please make sure that there is a formatted floppy "
  778.               "in the first floppy drive."),
  779.               [ _("OK"), _("Skip")] )
  780.                 if rc == string.lower (_("Skip")):
  781.                     break
  782.                 continue
  783.             else:
  784.                 break
  785.             
  786.         return INSTALL_OK
  787.  
  788. class InstallProgressWindow:
  789.     def completePackage(self, header):
  790.         def formatTime(amt):
  791.             hours = amt / 60 / 60
  792.             amt = amt % (60 * 60)
  793.             min = amt / 60
  794.             amt = amt % 60
  795.             secs = amt
  796.  
  797.             return "%01d:%02d.%02d" % (int(hours) ,int(min), int(secs))
  798.  
  799.            self.numComplete = self.numComplete + 1
  800.     self.sizeComplete = self.sizeComplete + header[rpm.RPMTAG_SIZE]
  801.     self.numCompleteW.setText("%12d" % self.numComplete)
  802.     self.sizeCompleteW.setText("%10dM" % (self.sizeComplete / (1024 * 1024)))
  803.     self.numRemainingW.setText("%12d" % (self.numTotal - self.numComplete))
  804.     self.sizeRemainingW.setText("%10dM" % ((self.sizeTotal - self.sizeComplete) / (1024 * 1024)))
  805.     self.total.set(self.sizeComplete)
  806.  
  807.     elapsedTime = time.time() - self.timeStarted 
  808.     self.timeCompleteW.setText("%12s" % formatTime(elapsedTime))
  809.     finishTime = (float (self.sizeTotal) / self.sizeComplete) * elapsedTime;
  810.     self.timeTotalW.setText("%12s" % formatTime(finishTime))
  811.     remainingTime = finishTime - elapsedTime;
  812.     self.timeRemainingW.setText("%12s" % formatTime(remainingTime))
  813.  
  814.     self.g.draw()
  815.     self.screen.refresh()
  816.  
  817.     def setPackageScale(self, amount, total):
  818.     self.s.set(int(((amount * 1.0)/ total) * 100))
  819.     self.g.draw()
  820.     self.screen.refresh()
  821.  
  822.     def setPackage(self, header):
  823.     self.name.setText("%s-%s-%s" % (header[rpm.RPMTAG_NAME],
  824.                                         header[rpm.RPMTAG_VERSION],
  825.                                         header[rpm.RPMTAG_RELEASE]))
  826.     self.size.setText("%dk" % (header[rpm.RPMTAG_SIZE] / 1024))
  827.     summary = header[rpm.RPMTAG_SUMMARY]
  828.     if (summary != None):
  829.         self.summ.setText(summary)
  830.     else:
  831.             self.summ.setText("(none)")
  832.  
  833.     self.g.draw()
  834.     self.screen.refresh()
  835.  
  836.     def __init__(self, screen, total, totalSize):
  837.     self.screen = screen
  838.         toplevel = GridForm(self.screen, _("Package Installation"), 1, 5)
  839.         
  840.         name = _("Name   : ")
  841.         size = _("Size   : ")
  842.         sum =  _("Summary: ")
  843.         
  844.         width = 40 + max (len (name), len (size), len (sum))
  845.     self.name = Label(" " * 40)
  846.     self.size = Label(" ")
  847.     detail = Grid(2, 2)
  848.     detail.setField(Label(name), 0, 0, anchorLeft = 1)
  849.     detail.setField(Label(size), 0, 1, anchorLeft = 1)
  850.     detail.setField(self.name, 1, 0, anchorLeft = 1)
  851.     detail.setField(self.size, 1, 1, anchorLeft = 1)
  852.     toplevel.add(detail, 0, 0)
  853.  
  854.     summary = Grid(2, 1)
  855.     summlabel = Label(sum)
  856.     self.summ = Textbox(40, 2, "", wrap = 1)
  857.     summary.setField(summlabel, 0, 0)
  858.     summary.setField(self.summ, 1, 0)
  859.     toplevel.add(summary, 0, 1)
  860.  
  861.     self.s = Scale (width, 100)
  862.     toplevel.add (self.s, 0, 2, (0, 1, 0, 1))
  863.  
  864.     overall = Grid(4, 4)
  865.     # don't ask me why, but if this spacer isn"t here then the 
  866.         # grid code gets unhappy
  867.     overall.setField (Label (" "), 0, 0, anchorLeft = 1)
  868.     overall.setField (Label (_("    Packages")), 1, 0, anchorLeft = 1)
  869.     overall.setField (Label (_("       Bytes")), 2, 0, anchorLeft = 1)
  870.     overall.setField (Label (_("        Time")), 3, 0, anchorLeft = 1)
  871.  
  872.     overall.setField (Label (_("Total    :")), 0, 1, anchorLeft = 1)
  873.     overall.setField (Label ("%12d" % total), 1, 1, anchorLeft = 1)
  874.     overall.setField (Label ("%10dM" % (totalSize / (1024 * 1024))),
  875.                           2, 1, anchorLeft = 1)
  876.     self.timeTotalW = Label("")
  877.     overall.setField(self.timeTotalW, 3, 1, anchorLeft = 1)
  878.  
  879.     overall.setField (Label (_("Completed:   ")), 0, 2, anchorLeft = 1)
  880.     self.numComplete = 0
  881.     self.numCompleteW = Label("%12d" % self.numComplete)
  882.     overall.setField(self.numCompleteW, 1, 2, anchorLeft = 1)
  883.     self.sizeComplete = 0
  884.         self.sizeCompleteW = Label("%10dM" % (self.sizeComplete / (1024 * 1024)))
  885.     overall.setField(self.sizeCompleteW, 2, 2, anchorLeft = 1)
  886.     self.timeCompleteW = Label("")
  887.     overall.setField(self.timeCompleteW, 3, 2, anchorLeft = 1)
  888.  
  889.     overall.setField (Label (_("Remaining:  ")), 0, 3, anchorLeft = 1)
  890.     self.numRemainingW = Label("%12d" % total)
  891.         self.sizeRemainingW = Label("%10dM" % (totalSize / (1024 * 1024)))
  892.     overall.setField(self.numRemainingW, 1, 3, anchorLeft = 1)
  893.     overall.setField(self.sizeRemainingW, 2, 3, anchorLeft = 1)
  894.     self.timeRemainingW = Label("")
  895.     overall.setField(self.timeRemainingW, 3, 3, anchorLeft = 1)
  896.  
  897.     toplevel.add(overall, 0, 3)
  898.  
  899.     self.numTotal = total
  900.     self.sizeTotal = totalSize
  901.     self.total = Scale (width, totalSize)
  902.     toplevel.add(self.total, 0, 4, (0, 1, 0, 0))
  903.  
  904.     self.timeStarted = time.time()    
  905.     
  906.     toplevel.draw()
  907.     self.g = toplevel
  908.     screen.refresh()
  909.  
  910.     def __del__ (self):
  911.         self.screen.popWindow ()
  912.  
  913. class WaitWindow:
  914.  
  915.     def pop(self):
  916.     self.screen.popWindow()
  917.     self.screen.refresh()
  918.  
  919.     def __init__(self, screen, title, text):
  920.     self.screen = screen
  921.     width = 40
  922.     if (len(text) < width): width = len(text)
  923.  
  924.     t = TextboxReflowed(width, _(text))
  925.  
  926.     g = GridForm(self.screen, _(title), 1, 1)
  927.     g.add(t, 0, 0)
  928.     g.draw()
  929.     self.screen.refresh()
  930.  
  931. class Flag:
  932.     """a quick mutable boolean class"""
  933.     def __init__(self, value = 0):
  934.         self.flag = value
  935.  
  936.     def set(self, value):
  937.         self.flag = value;
  938.  
  939.     def get(self):
  940.         return self.flag
  941.  
  942.  
  943. class ProgressWindow:
  944.     def pop(self):
  945.     self.screen.popWindow()
  946.     self.screen.refresh()
  947.  
  948.     def set (self, amount):
  949.         self.scale.set (amount)
  950.     self.screen.refresh()
  951.  
  952.     def __init__(self, screen, title, text, total):
  953.     self.screen = screen
  954.     width = 55
  955.     if (len(text) > width): width = len(text)
  956.  
  957.     t = TextboxReflowed(width, text)
  958.  
  959.     g = GridForm(self.screen, title, 1, 2)
  960.     g.add(t, 0, 0, (0, 0, 0, 1))
  961.  
  962.         self.scale = Scale (width, total)
  963.         g.add(self.scale, 0, 1)
  964.                 
  965.     g.draw()
  966.     self.screen.refresh()
  967.  
  968. class InstallInterface:
  969.     def progressWindow(self, title, text, total):
  970.         return ProgressWindow (self.screen, _(title), _(text), total)
  971.  
  972.     def messageWindow(self, title, text):
  973.     ButtonChoiceWindow(self.screen, _(title), _(text),
  974.                            buttons = [ _("OK") ])
  975.     
  976.     def exceptionWindow(self, title, text):
  977.     rc = ButtonChoiceWindow(self.screen, title, text,
  978.                            buttons = [ _("OK"), _("Debug") ])
  979.         if rc == string.lower (_("Debug")):
  980.             return 1
  981.         return None
  982.  
  983.     def waitWindow(self, title, text):
  984.     return WaitWindow(self.screen, title, text)
  985.  
  986.     def packageProgressWindow(self, total, totalSize):
  987.     return InstallProgressWindow(self.screen, total, totalSize)
  988.  
  989.     def __init__(self):
  990.         self.screen = SnackScreen()
  991.         self.welcomeText = _("Red Hat Linux (C) 2000 Red Hat, Inc.")
  992.         self.screen.drawRootText (0, 0, self.welcomeText)
  993.         self.screen.pushHelpLine (_("  <Tab>/<Alt-Tab> between elements   |  <Space> selects   |  <F12> next screen"))
  994. # uncomment this line to make the installer quit on <Ctrl+Z>
  995. # handy for quick debugging.
  996.     #self.screen.suspendCallback(killSelf, self.screen)
  997. # uncomment this line to drop into the python debugger on <Ctrl+Z>
  998. # --VERY handy--
  999.     #self.screen.suspendCallback(debugSelf, self.screen)
  1000.         self.individual = Flag(0)
  1001.         self.step = 0
  1002.         self.dir = 1
  1003.     signal.signal(signal.SIGINT, signal.SIG_IGN)
  1004.     signal.signal(signal.SIGTSTP, signal.SIG_IGN)
  1005.  
  1006.     def __del__(self):
  1007.         self.screen.finish()
  1008.  
  1009.     def run(self, todo, test = 0):
  1010.     if todo.serial:
  1011.         self.screen.suspendCallback(spawnShell, self.screen)
  1012.  
  1013.         if todo.reconfigOnly:
  1014.             self.commonSteps = [
  1015.                 [_("Welcome"), ReconfigWelcomeWindow, 
  1016.                  (self.screen,), "reconfig" ],
  1017.                 [_("Language Selection"), LanguageWindow, 
  1018.                  (self.screen, todo), "language" ],
  1019.                 [_("Keyboard Selection"), KeyboardWindow, 
  1020.                  (self.screen, todo), "keyboard" ],
  1021.                 [_("Hostname Setup"), HostnameWindow, (self.screen, todo), 
  1022.                  "network"],
  1023.                 [_("Network Setup"), NetworkWindow, (self.screen, todo), 
  1024.                  "network"],
  1025. #                [_("Mouse Configuration"), MouseWindow, (self.screen, todo),
  1026. #                 "mouse" ],
  1027. #                [_("Mouse Configuration"), MouseDeviceWindow, (self.screen, todo),
  1028. #                 "mouse" ],
  1029.                 [_("Time Zone Setup"), TimezoneWindow, 
  1030.                  (self.screen, todo, test), "timezone" ],
  1031.                 [_("Root Password"), RootPasswordWindow, 
  1032.                  (self.screen, todo), "accounts" ],
  1033.                 [_("User Account Setup"), UsersWindow, 
  1034.                  (self.screen, todo), "accounts" ],
  1035.                 [_("Authentication"), AuthConfigWindow, (self.screen, todo),
  1036.                  "authentication" ],
  1037. #                [_("X Configuration"), XConfigWindow, (self.screen, todo),
  1038. #                 "xconfig" ],
  1039. #                [_("X Configuration"), XconfiguratorWindow, (self.screen, todo), 
  1040. #            "xconfig"],
  1041.                 [_("Configuration Complete"), ReconfigFinishedWindow, (self.screen,todo),
  1042.                  "complete" ],
  1043.                 ]
  1044.         else:
  1045.             self.commonSteps = [
  1046.                 [_("Language Selection"), LanguageWindow, 
  1047.                  (self.screen, todo), "language" ],
  1048.                 [_("Keyboard Selection"), KeyboardWindow, 
  1049.                  (self.screen, todo), "keyboard" ],
  1050.                 [_("Welcome"), WelcomeWindow, (self.screen,), "welcome" ],
  1051.                 [_("Installation Type"), InstallPathWindow, 
  1052.                  (self.screen, todo, self) ],
  1053.                 ]
  1054.  
  1055.     if iutil.getArch() == 'sparc':
  1056.         BootloaderAppendWindow = SiloAppendWindow
  1057.         BootloaderWindow = SiloWindow
  1058.         BootloaderImagesWindow = SiloImagesWindow
  1059.         BootloaderConfiguration = _("SILO Configuration")
  1060.             BootloaderSkipName = "silo"
  1061.     else:
  1062.         BootloaderAppendWindow = LiloAppendWindow
  1063.         BootloaderWindow = LiloWindow
  1064.         BootloaderImagesWindow = LiloImagesWindow
  1065.         BootloaderConfiguration = _("LILO Configuration")
  1066.             BootloaderSkipName = "lilo"            
  1067.  
  1068.         self.installSteps = [
  1069.             [_("Partition"), PartitionMethod,
  1070.             (self.screen, todo), "partition" ],
  1071.             [_("Manually Partition"), ManualPartitionWindow, 
  1072.             (self.screen, todo), "partition" ],
  1073.             [_("Automatic Partition"), AutoPartitionWindow, 
  1074.             (self.screen, todo), "partition" ],
  1075.             [_("Partition"), PartitionWindow, (self.screen, todo),
  1076.             "partition" ],
  1077.             [_("Root Filesystem Size"), LoopSizeWindow, (self.screen, todo),
  1078.             "partition" ],
  1079.             [_("Swap"), TurnOnSwapWindow, (self.screen, todo),
  1080.             "partition" ],
  1081.             [_("Filesystem Formatting"), FormatWindow, (self.screen, todo),
  1082.             "format" ],
  1083.             [BootloaderConfiguration, BootloaderAppendWindow, 
  1084.             (self.screen, todo), BootloaderSkipName ],
  1085.             [BootloaderConfiguration, BootloaderWindow, 
  1086.             (self.screen, todo), BootloaderSkipName ],
  1087.         [BootloaderConfiguration, BootloaderImagesWindow, 
  1088.             (self.screen, todo), BootloaderSkipName ],
  1089.             [_("Hostname Setup"), HostnameWindow, (self.screen, todo), 
  1090.             "network"],
  1091.             [_("Network Setup"), NetworkWindow, (self.screen, todo), 
  1092.             "network"],
  1093.             [_("Mouse Configuration"), MouseWindow, (self.screen, todo),
  1094.             "mouse" ],
  1095.             [_("Mouse Configuration"), MouseDeviceWindow, (self.screen, todo),
  1096.             "mouse" ],
  1097.             [_("Time Zone Setup"), TimezoneWindow, 
  1098.             (self.screen, todo, test), "timezone" ],
  1099.             [_("Root Password"), RootPasswordWindow, 
  1100.             (self.screen, todo), "accounts" ],
  1101.             [_("User Account Setup"), UsersWindow, 
  1102.             (self.screen, todo), "accounts" ],
  1103.             [_("Authentication"), AuthConfigWindow, (self.screen, todo),
  1104.             "authentication" ],
  1105.             [_("Package Groups"), PackageGroupWindow, 
  1106.         (self.screen, todo, self.individual), "package-selection" ],
  1107.             [_("Individual Packages"), IndividualPackageWindow, 
  1108.         (self.screen, todo, self.individual), "package-selection" ],
  1109.             [_("Package Dependencies"), PackageDepWindow, (self.screen, todo),
  1110.         "package-selection" ],
  1111.             [_("X Configuration"), XConfigWindow, (self.screen, todo),
  1112.                 "xconfig" ],
  1113.             [_("Installation Begins"), BeginInstallWindow, 
  1114.         (self.screen, todo), "confirm-install" ],
  1115.             [_("Install System"), InstallWindow, (self.screen, todo) ],
  1116.             [_("Boot Disk"), BootDiskWindow, (self.screen, todo),
  1117.         "bootdisk" ],
  1118.             [_("Boot Disk"), BootdiskWindow, (self.screen, todo), "bootdisk"],
  1119.             [_("X Configuration"), XconfiguratorWindow, (self.screen, todo), 
  1120.             "xconfig"],
  1121.             [_("Installation Complete"), FinishedWindow, (self.screen, todo),
  1122.         "complete" ]
  1123.             ]
  1124.  
  1125.     self.upgradeSteps = [
  1126.         [_("Examine System"), UpgradeExamineWindow, (self.screen, todo)],
  1127.             [BootloaderConfiguration, BootloaderAppendWindow, 
  1128.             (self.screen, todo), "lilo"],
  1129.             [BootloaderConfiguration, BootloaderWindow, 
  1130.             (self.screen, todo), "lilo"],
  1131.         [BootloaderConfiguration, BootloaderImagesWindow, 
  1132.             (self.screen, todo), "lilo"],
  1133.         [_("Customize Upgrade"), CustomizeUpgradeWindow, 
  1134.             (self.screen, todo, self.individual), "custom-upgrade" ],
  1135.             [_("Individual Packages"), IndividualPackageWindow, (self.screen, todo, self.individual)],
  1136.             [_("Upgrade System"), InstallWindow, (self.screen, todo)],
  1137.             [_("Boot Disk"), BootDiskWindow, (self.screen, todo),
  1138.         "bootdisk" ],
  1139.             [_("Boot Disk"), BootdiskWindow, (self.screen, todo), "bootdisk"],
  1140.             [_("Upgrade Complete"), FinishedWindow, (self.screen, todo)]
  1141.             ]
  1142.  
  1143.     dir = 1
  1144.         self.steps = self.commonSteps
  1145.  
  1146.         while self.step >= 0 and self.step < len(self.steps) and self.steps[self.step]:
  1147.         step = self.steps[self.step]
  1148.  
  1149.         rc = INSTALL_OK
  1150.         if (len(step) == 4):
  1151.         if (todo.instClass.skipStep(step[3])):
  1152.             rc = INSTALL_NOOP
  1153.  
  1154.         if (rc != INSTALL_NOOP):
  1155.         # clear out the old root text by writing spaces in the blank
  1156.         # area on the right side of the screen
  1157.         self.screen.drawRootText (len(self.welcomeText), 0,
  1158.                  (self.screen.width - len(self.welcomeText)) * " ")
  1159.         self.screen.drawRootText (0 - len(step[0]),
  1160.                      0, step[0])
  1161.         # This is *disgusting* (ewt)
  1162.         if step[1] == UpgradeExamineWindow:
  1163.             rc = apply (step[1](), (dir,) + step[2])
  1164.         else:
  1165.             rc = apply (step[1](), step[2])
  1166.  
  1167.         if rc == INSTALL_BACK:
  1168.         dir = -1
  1169.         elif rc == INSTALL_OK:
  1170.         dir = 1
  1171.  
  1172.         self.step = self.step + dir
  1173.             if self.step < 0:
  1174.                 ButtonChoiceWindow(self.screen, _("Cancelled"),
  1175.                                    _("I can't go to the previous step"
  1176.                                      " from here. You will have to try again."),
  1177.                                    buttons = [ _("OK") ])
  1178.                                    
  1179.                 self.step = 0
  1180.                 dir = 1
  1181.         self.screen.finish ()
  1182.  
  1183. def killSelf(screen):
  1184.     screen.finish()
  1185.     os._exit(0)
  1186.  
  1187. def debugSelf(screen):
  1188.     screen.suspend ()
  1189.     import pdb
  1190.     pdb.set_trace()
  1191.     screen.resume ()
  1192.  
  1193. def spawnShell(screen):
  1194.     screen.suspend ()
  1195.     print "\n\nType <exit> to return to the install program.\n"
  1196.     iutil.execWithRedirect ("/bin/sh", ["-/bin/sh"])
  1197.     time.sleep(5)
  1198.     screen.resume ()
  1199.