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

  1. /**
  2.  *
  3.  * Author:    Klaus KΣmpf
  4.  *         Mathias Kettner
  5.  *
  6.  * Purpose:     This module ask about do the installation or not,
  7.  *         It additonally displays the current settings
  8.  *               - login
  9.  *               - partitions which will be erased
  10.  *          - partitions which will be created
  11.  *         - boot configuration
  12.  *         - needed disk space
  13.  *
  14.  * user_setting:
  15.  *
  16.  * ro: "loginname"
  17.  * ro: "neededspace"    contains, the diskspace needed for installation in byte 
  18.  * ro: "lilo"        contains, how lilo will be installed
  19.  * ro: "lilo_device"    contains, where lilo will be installed
  20.  *
  21.  * "ro" readonly
  22.  *
  23.  * $Id: inst_doit.ycp,v 1.91 2000/03/09 01:28:12 kkaempf Exp $
  24.  */
  25. {
  26.     term vbox = `VBox ();
  27.  
  28.     // show future user login
  29.  
  30.     string username = lookup (user_settings, "loginname", "");
  31.     // show the user the final username used for login
  32.     vbox = add(vbox, `Left(`Label (sformat(UI(_("Your user name will be '%1'.")), username ))));
  33.  
  34.     // inform user about the harddisk he selected
  35.  
  36.     string target_is        = lookup (user_settings, "target_is", "unknown");
  37.     map targetMap        = lookup (user_settings, "targets", $[]);
  38.     map target            = lookup (targetMap, target_is, $[]);
  39.  
  40.     string targetname        = "";
  41.     list partitions        = [];
  42.     if (target_is == "CUSTOM") {
  43.     map mountPoints    = lookup ( user_settings, "mountpoints", $[]);
  44.     target_is    = select (lookup (mountPoints, "/", []), 2);        // root disk (raw disk)
  45.     target        = lookup (targetMap, target_is, $[]);
  46.     }
  47.  
  48.     targetname = lookup (target, "name", "Unknown Device");
  49.     partitions = lookup (target, "partitions", []);
  50.  
  51.     vbox = add(vbox, `Left(`Label(sformat(UI(_("Linux will be installed on harddisk\n%1")), targetname))));
  52.  
  53.     integer pnum = 0;
  54.  
  55.     // maximum number of targetpartitions to show
  56.     // there simply isn't more space on a 640x480 screen
  57.     // if more partitions are defined, only inform about
  58.     // created partitions
  59.  
  60.     string text_to_show = "";
  61.     integer max2show = 8;
  62.  
  63.     if (size (partitions) < max2show) {
  64.       foreach(`part, partitions,
  65.       ``{ pnum = pnum + 1;
  66.       if (lookup (part, "delete") == true &&
  67.         // Ignore the extended partition, it is never shown before
  68.         lookup (part, "type") != `extended) {
  69.         text_to_show = text_to_show +
  70.         // inform about which partitions will be erased (i.e. re-used) for linux
  71.           sformat(UI(_("  Erasing partition %1 (%2), was '%3'\n")),
  72.         pnum,
  73.         target_is + lookup (part, "nr"),
  74.         lookup (part, "fstype"));
  75.       }
  76.          });
  77.     }
  78.  
  79.     // now show created partitions
  80.  
  81.     pnum = 0;
  82.     foreach(`part, partitions,
  83.     ``{ if ((lookup (part, "delete") != true)
  84.         && (lookup (part, "type") != `extended))
  85.       pnum = pnum + 1;
  86.     if ((lookup (part, "create") == true)
  87.         && (lookup (part, "type") != `extended)
  88.         && (lookup (part, "mount","") != "")) {
  89.       string used_fs = "ext2fs";
  90.       if (lookup (part, "mount") == "swap") {
  91.          used_fs = "swap";
  92.       }
  93.       else if (lookup (part, "used_fs") == `reiser) {
  94.          used_fs = "reiserfs";
  95.       }
  96.       text_to_show = text_to_show +
  97.       // inform about which partitions will be created for linux
  98.         sformat(UI(_("  Creating partition %1 (%2), as %3 (%4)\n")),
  99.         pnum,
  100.         target_is + lookup (part, "nr"),
  101.         lookup (part, "mount"),
  102.         used_fs);
  103.     }
  104.        });
  105.     vbox = add(vbox, `Left(`Label(text_to_show)));
  106.  
  107.     // Installed software
  108.  
  109.     vbox = add(vbox, `Left(`Label(sformat(UI(_("%1 MB software will be installed")), 
  110.                       lookup(user_settings, "neededspace") / (1024 * 1024)))));
  111.  
  112.     // show boot configuration
  113.  
  114.     string sline = "";
  115.     string lilo = lookup (user_settings, "lilo");
  116.     string lilo_device = lookup (user_settings, "lilo_device");
  117.     if (lilo == "mbr") {
  118.     // show where lilo will be installed, this means MBR
  119.     sline = UI(_("The Linux boot manager will be written on your hard disk."));
  120.     }
  121.     else if (lilo == "floppy") {
  122.     // show where lilo will be installed, this means just on floppy
  123.     sline = UI(_("The Linux boot manager will be written on a floppy disk."));
  124.     }
  125.     else if (lilo == "boot") {
  126.     // show where lilo will be installed, this means just on the boot record of the partition
  127.     sline = UI(_("The Linux boot manager will only be written on the linux partition."));
  128.     }
  129.     else {
  130.     // show where lilo will be installed, this means the user-selected partition
  131.     sline = sformat (UI(_("The Linux boot manager will only be written to %1")), lilo_device);
  132.     }
  133.  
  134.     vbox = add(vbox, `Left(`Label (sline)));
  135.     vbox = add(vbox, `Left(`Label(_("Pressing \"Next\" will start the installation."))));
  136.  
  137.     term contents = `VBox(
  138.               `HVCenter( `HSquash( vbox ) ), 
  139.               `HBox(
  140.                 `HWeight( 5, `HStretch() ),
  141.                 
  142.                 // Push button: Do not install Linux at all (this will reboot)
  143.                 // `Abort' will abort the whole config and perform a clean shutdown.
  144.                 `HWeight( 35, `PushButton(`id(`abort), `opt(`hstretch),  _("&Abort installation") ) ),
  145.                 
  146.                 `HWeight( 2, `HStretch() ),
  147.                 
  148.                 // Push button: Save the settings (i.e. everything entered
  149.                 // during installation) to a floppy disk.
  150.                 `HWeight( 35, `PushButton(`id(`save), `opt(`hstretch), _("&Save settings to floppy disk") ) ),
  151.                 
  152.                 `HWeight( 5, `HStretch() )
  153.                 ),
  154.               `Label ( " " )
  155.               
  156.               );
  157.   // helptext (html-format)
  158.   // part 1 of 6
  159.   string helptext = UI(_("<p>
  160. YaST2 now has all the required information.
  161. <b><i>Please read all the data carefully</i></b> before you continue.
  162. </p>"));
  163.  
  164.   // part 2 of 6
  165.   helptext = helptext + UI(_("<p>
  166. You will need your <b>user name</b>, your <b>user password</b> and -
  167. most importantly - the <b>root password</b> to work with the installed
  168. system. Do not forget those values! (But do not write them to a sticky
  169. note on your screen, either - this is a common security hole).
  170. </p>"));
  171.  
  172.   // part 3 of 6
  173.   helptext = helptext + UI(_("<p>
  174. If you are satisfied with the settings, select <b>next</b> in this dialog
  175. to <b><i>start the installation</i></b>. This is when things actually
  176. will happen: Your hard disk will be prepared according to your
  177. selections, and the software will be installed.
  178. </p>"));
  179.  
  180.   // part 4 of 6
  181.   helptext = helptext + UI(_("<p>
  182. If you wish to change any of the settings, use <b>back</b> to move back
  183. to the respective dialog(s), change them accordingly and then use
  184. <b>next</b> to move to this screen again.
  185. </p>"));
  186.  
  187.   // part 5 of 6
  188.   helptext = helptext + UI(_("<p>
  189. <b>Save settings to floppy disk</b> if you want to re-use these
  190. settings later.  Please use a fresh floppy disk - <em>not</em> the
  191. supplied SuSE \"Boot disk\" or the SuSE \"Modules\" disk. You might
  192. need those some day.
  193. </p>"));
  194.  
  195.   // part 6 of 6
  196.   helptext = helptext + UI(_("<p>
  197. If you wish to abort the installaion entirely, select <b>Abort
  198. installation</b>.  You will lose all settings chosen so far,
  199. but your hard disk will remain untouched.
  200. </p>
  201. <br>"));
  202.  
  203.   // screen title
  204.  
  205.   any dlg = UI(`SetWizardContents(_("Confirm installation"), contents,
  206.         helptext, Args(0), true));
  207.  
  208.   // Event handling
  209.   
  210.   any option = nil;
  211.   any ret = nil;
  212.   while (true) {
  213.       ret = UI(`UserInput());
  214.       if (ret == `cancel || ret == `back) break;
  215.       else if (ret == `next) {
  216.       if (!UI(``{
  217.           OpenDialog(`opt(`decorated, `warncolor),
  218.                 // configuration was confirmed, pop-up text if we *really* should go on.
  219.                 // `Yes' will prepare the disk and install the sotware.
  220.                 // `No' will go back; further config steps are possible.
  221.                 // "Now we mean business. There is no going back after this point!"
  222.                                 // Warning MsgBox.  line length < 48 chars.
  223.              `VBox(`Heading(_("\
  224. Warning:\n\n\
  225. YaST2 has all information to install SuSE Linux.\n\
  226. The installation will be done according to your\n\
  227. settings done by the previous dialogs.\n\
  228. To commit the installation, and all choices made\n\
  229. so far, choose \"yes\".  Choose \"no\" to go back\n\
  230. to the previous dialog.\n\n\
  231. Start installation?
  232. ")), 
  233.                    `HBox(
  234.                     // no, don't go on, i just changed my mind
  235.                     `PushButton(`opt(`default), _("&No")),
  236.                     `HStretch(),
  237.                     // all right, start installation *now*
  238.                     `PushButton(`id(`yes),  _("&Yes - install"))
  239.                     )));
  240.           
  241.           boolean ok = (UserInput() == `yes);
  242.           CloseDialog();
  243.           return ok;
  244.       })) continue;
  245.       else break;
  246.       }
  247.       else if (ret == `abort) {
  248.       // go here if user selected 'no' to 'start installation ?'
  249.       if (UI(``{
  250.           OpenDialog(`opt(`decorated, `warncolor),
  251.                 // configuration was aborted, pop-up text to
  252.                 // inform user about possibilities
  253.                 // `yes' will reboot the system
  254.                 // `no' will go back; further config steps are possible.
  255.              `VBox(`Heading(_("All right, the installation will be aborted.")), 
  256.                    `HBox(
  257.                      // user wont abort installation, pushbutton "no continue"
  258.                      // Not longer than 30-35 chars
  259.                      `PushButton(`opt(`default), _("&No, continue the installation")),
  260.                      `HStretch(),
  261.                      // user really want to abort the installation, pushbutton "yes"
  262.                      // Not longer than 30-35 chars
  263.                      `PushButton(`id(`yes), _("&Yes, abort the installation"))
  264.                      )));
  265.           boolean abort = (UserInput() == `yes);
  266.           CloseDialog();
  267.           return abort;
  268.       })) return `cancel;
  269.       }
  270.       else if (ret == `save) {
  271.       Shell("umount /floppy"); // Just for safety
  272.           // Yes/No MsgBox; default: Yes 
  273.       while (UI(`YesOrNo(_("\
  274. The selected configuration and settings will be saved\n\
  275. on a floppy disk.  Please insert a formatted floppy.\n\n\
  276. Write data to floppy disk now?\
  277. "), _("&Yes"), _("&No")))) {
  278.           if (0 == Shell("mount /dev/fd0 /floppy -t msdos"))
  279.           {
  280.           boolean success = Write("/floppy/settings.ycp",
  281.                       // Remove biggggg install_info
  282.                       add (user_settings, "install_info", nil));
  283.           Shell("umount /floppy");
  284.           if (success) {
  285.               // msgbox
  286.               // data saved to floppy disk
  287.               UI(`DisplayMessage(_("Your settings have been written to floppy disk.")));
  288.               break;
  289.           }
  290.           else
  291.               UI(`DisplayMessage(_("\
  292. Couldn't write your settings to the floppy.\n\
  293. Is it formatted and is the write protection removed?")));
  294.           
  295.           }
  296.           else {
  297.           UI(`DisplayMessage(_("\
  298. Couldn't find a valid floppy disk.\n\
  299. Are you sure, you've entered a floppy disk?\n\
  300. Is the disk formatted and verified?")));
  301.           }
  302.       }
  303.       }
  304.   }
  305.  
  306.   return ret;
  307. }
  308.