home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd2.bin / suse / inst-sys / lib / YaST2 / clients / inst_lilo_expert.ycp < prev    next >
Encoding:
Text File  |  2000-03-30  |  6.7 KB  |  221 lines

  1. /**
  2.  *
  3.  * $Id: inst_lilo_expert.ycp,v 1.13.4.1 2000/03/27 15:28:27 kkaempf Exp $
  4.  *
  5.  * Module:    inst_lilo_expert.ycp
  6.  *
  7.  * Author:    Klaus KΣmpf
  8.  *        Stefan Hundhammer <sh@suse.de>
  9.  *
  10.  * Purpose.     This module asks the LILO bootmode and save this
  11.  *              infomation in the user_settings
  12.  *
  13.  * user_settings:
  14.  * ro: "has_floppy"
  15.  * rw: "lilo"
  16.  * rw: "lilo_device"
  17.  * rw: "lilo_boot_params"
  18.  * rw: "lilo_linear"
  19.  *
  20.  * "rw" read/write
  21.  * "ro" readonly 
  22.  
  23.  */
  24. {
  25.     string architecture = lookup (user_settings, "architecture", default_architecture);
  26.  
  27.     if (architecture == "ppc")
  28.     return `next;
  29.  
  30.     string lilo = lookup (user_settings, "lilo", "");
  31.     string lilo_device = lookup (user_settings, "lilo_device", "");
  32. y2log (.milestone, "inst_lilo_expert", 1, "lilo: "+lilo+" at "+lilo_device);
  33.     boolean has_floppy = lookup (user_settings, "has_floppy", false);
  34.  
  35.     string lilo_boot_params = lookup (user_settings, "lilo_boot_params", "");
  36.     boolean lilo_linear = lookup (user_settings, "lilo_linear", false);
  37.  
  38.     term buttons = `VBox(
  39.              `VStretch(),
  40.              `Left(
  41.                    `RadioButton( `id( "mbr" ),
  42.                          // Radio button for LILO installation on /dev/hda or /dev/sda MBR
  43.                          _("Install LILO in the boot disk ('MBR')"),
  44.                          lilo == "mbr")
  45.                    )
  46.              );
  47.     
  48.     if (has_floppy)
  49.     buttons = add ( buttons,
  50.             `Left(
  51.                   `RadioButton( `id( "floppy" ),
  52.                         // Radio button for LILO installation on floppy only
  53.                         _("Create a boot floppy"),
  54.                         lilo == "floppy")
  55.                   )
  56.             );
  57.  
  58.     buttons = add ( buttons,
  59.             `Left(
  60.               `RadioButton( `id("boot"),
  61.                     // Radio button for LILO installation: Have other boot manager,
  62.                     // install in partition /boot only
  63.                     _("Install LILO on partition /boot (have other boot manager)"),
  64.                     lilo == "boot")
  65.               )
  66.             );
  67.  
  68.     string default_text = "";
  69.     if ((lilo == "custom")
  70.     && (substring (lilo_device, 0, 5) == "/dev/"))
  71.     default_text = lilo_device;
  72.  
  73.     buttons = add ( buttons,
  74.             `HBox(
  75.               `Left(
  76.                 `RadioButton( `id("custom"),
  77.                           // Radio button for LILO installation:
  78.                           // Other partition (enter name in text input field)
  79.                           _("Install LILO on other partition:"),
  80.                           (lilo == "custom")
  81.                           )
  82.                 ),
  83.               `TextEntry( `id(`custom_partition), "", default_text)
  84.               )
  85.             );
  86.  
  87.     
  88.     // Input field for boot parameters
  89.     
  90.     buttons = add ( buttons, `VStretch() );
  91.     buttons = add ( buttons,
  92.             `VCenter(
  93.                  `VBox(
  94.                    `Left(`TextEntry(
  95.                             `id( `boot_params ),
  96.                             // Text input field to enter additional boot parameters
  97.                             _( "Kernel boot parameters:" ),
  98.                             lilo_boot_params
  99.                             )
  100.                      ),
  101.                    `Left(`CheckBox(
  102.                            `id( `linear ),
  103.                            // check box: use the 'linear' option?
  104.                            _( "Use the 'linear' option" ),
  105.                            lilo_linear
  106.                            )
  107.                      )
  108.                    )
  109.                  )
  110.             );
  111.     
  112.     buttons = add ( buttons, `VStretch() );
  113.  
  114.     // determine destination location of lilo boot loader
  115.     term contents = `VCenter(`HSquash(`RadioButtonGroup(`id(`options), buttons) ) );
  116.  
  117.     // helptext for the customized LILO installation    
  118.     // part 1 of 7
  119.     string helptext = UI(_("<p>
  120. LILO (the LInux LOader) can be installed in different places:</p>"));
  121.     // part 2 of 7
  122.     helptext = helptext + UI(_("<p>
  123. - In the <b>MBR</b> (the Master Boot Record).  This is recommended whenever SuSE Linux
  124. is the only operating system on the hard drive, or if you <em>definitely</em>
  125. know that you can boot all the other operating systems with LILO. The old MBR
  126. should be saved to disk, as a precaution.
  127. </p>"));
  128.     // part 3 of 7
  129.     helptext = helptext + UI(_("<p>
  130. - On a <b>floppy</b> disk (if your system has a floppy disk drive),
  131. if you want to avoid the risk of interfering with an already existing
  132. boot mechanism. You may need to enable booting from floppy disk in
  133. your system's BIOS when you select this option.
  134. </p>"));
  135.     // part 4 of 7
  136.     helptext = helptext + UI(_("<p>
  137. - In the <b>/boot</b> partition.  This option can always be used
  138. if you have a number of operating systems on the hard drive, and if you want to
  139. boot with your own boot manager, or <tt>loadlin</tt>, for example. The
  140. advantage of this method is that the MBR is left alone.
  141. </p>"));
  142.     // part 5 of 7
  143.     helptext = helptext + UI(_("<p>
  144. Notice: If you use this method, you will also need to configure
  145. this other boot manager (e.g. <tt>loadlin</tt>) accordingly.
  146. </p>"));
  147.     // part 6 of 7
  148.     helptext = helptext + UI(_("<p>
  149. - In some <b>other</b> partition. You need to know your system's
  150. restrictions when you select this option. Most PCs for example have a
  151. BIOS limit that restricts booting to hard disk cylinders below
  152.  1024. Depending on what boot manager to use, you may or you may not
  153.  be able to boot with LILO in a logical partition.
  154. </p>"));
  155.     // part 7 of 7
  156.     helptext = helptext + UI(_("<p>
  157. Enter the partition's device name (e.g. <tt>/dev/hda3</tt>,
  158. <tt>/dev/sdb</tt>) in the input field.
  159. </p>
  160. <br>"));
  161.  
  162.     any dlg = UI(`SetWizardContents(_("Custom LILO installation"),
  163.                     contents, helptext, Args(0), Args(1)));
  164.  
  165.     // Event handling
  166.  
  167.     any ret = nil;
  168.  
  169.     while (true) {
  170.     ret = UI(`UserInput());
  171.     if (ret == `next || ret == `back) {
  172.         any option = UI(`QueryWidget(`id(`options), `CurrentButton));
  173.         if (option == nil) {
  174.         if ( ret == `next ) {
  175.             // User MUST choose one of the options
  176.             UI(`DisplayMessage(_("You have to choose one of the\noptions in order to continue.")));
  177.                       continue;
  178.         }
  179.         }
  180.         else if (is(option,string)) {
  181.         user_settings = add (user_settings, "lilo", option);
  182.         if (option == "mbr") {
  183.             user_settings = add (user_settings, "lilo_device", lookup (user_settings, "mbr_disk"));
  184.         }
  185.         else if (option == "floppy") {
  186.             user_settings = add (user_settings, "lilo_device", lookup (user_settings, "floppy_device", "/dev/fd0"));
  187.         }
  188.         else if (option == "boot") {
  189.             user_settings = add (user_settings, "lilo_device", lookup (user_settings, "boot_device"));
  190.         }
  191.         else if (option == "custom") {
  192.             option = UI(`QueryWidget(`id(`custom_partition), `Value));
  193.             if ((ret == `next)
  194.             && ((!is(option, string))
  195.                 || (option == "")
  196.                 || (substring (option, 0, 5) != "/dev/"))) {
  197.             UI(`DisplayMessage(_("You did not enter a partition")));
  198.             continue;
  199.             }
  200.             if (is(option,string)) {
  201.             user_settings = add (user_settings, "lilo_device", option);
  202.             }
  203.         }
  204.         }
  205.  
  206.         option = UI(`QueryWidget(`id(`boot_params), `Value));
  207.         if (is (option, string))
  208.         user_settings = add (user_settings, "lilo_boot_params", option);
  209.         option = UI(`QueryWidget(`id(`linear), `Value));
  210.         if (is (option, boolean))
  211.         user_settings = add (user_settings, "lilo_linear", option);
  212.  
  213.     } // ret == next|back
  214.  
  215.     break;
  216.  
  217.     } // while (true);
  218.  
  219.     return ret;
  220. }
  221.