home *** CD-ROM | disk | FTP | other *** search
- /**
- * Module: inst_writelilo.ycp
- *
- * Authors: Klaus Kaempf (kkaempf@suse.de)
- *
- * Purpose: This module writes lilo by calling
- * do<boot_mode> via shell.
- *
- * user_settings:
- * ro: boot_mode
- * ro: lilo
- * ro: lilo_device
- * ro: other_lilo
- * ro: "lilo_boot_params"
- * ro: "lilo_linear"
- *
- * $Id: inst_writelilo.ycp,v 1.27 2000/03/13 16:10:25 kkaempf Exp $
- */
- {
- // Boot setup start
-
- string lilo = lookup (user_settings, "lilo", "boot");
- string lilo_device = lookup (user_settings, "lilo_device", "lilo");
-
- string boot_mode = lookup (user_settings, "boot_mode", "lilo");
- string boot_device = lookup (user_settings, "boot_device", "");
- string root_device = lookup (user_settings, "root_device", "");
-
- string other_lilo = lookup (user_settings, "other_lilo", "");
- string lilo_boot_params = lookup (user_settings, "lilo_boot_params", "");
- boolean lilo_linear = lookup (user_settings, "lilo_linear", false);
-
- integer doresult = 0;
- string docmd = "chroot /mnt do"+boot_mode+" /";
- if (lilo == "mbr")
- docmd = docmd + " -m "+lilo_device;
- else if (lilo == "floppy")
- docmd = docmd + " -m "+lilo_device;
- else if (lilo == "custom") {
- string last_dev_char = substring (lilo_device, size(lilo_device)-1, 1);
- // if lilo_device does not end in a digit, it is a disk device for mbr
- if (!(filterchars (last_dev_char, "0123456789") == last_dev_char))
- docmd = docmd + " -m "+lilo_device;
- }
- if (other_lilo != "") docmd = docmd + " " + other_lilo;
-
- string lilo_append = lookup (user_settings, "lilo_boot_params", "");
- string lilo_opt_linear = "";
- if (lookup (user_settings, "lilo_linear", false))
- lilo_opt_linear = "yes";
-
- y2log(.milestone, "inst_writelilo", 5, "lilo: "+lilo+" cmd: "+docmd);
-
- if (lilo == "floppy") {
-
- Shell("umount /floppy"); // Just for safety
- UI(`DisplayMessage(_("The LILO boot sector will be written on a floppy disk.\nPlease insert a formatted floppy and confirm with 'OK'.")));
-
- while (true) {
- doresult = Shell (docmd, $[ "bootdev" : boot_device,
- "rootdev" : root_device,
- "append" : lilo_append,
- "linear" : lilo_opt_linear ]);
- Shell ("/bin/sync");
-
- if (doresult == 0) {
- // data saved to floppy disk
- UI(`DisplayMessage(_("The LILO boot sector has been written to floppy disk.")));
-
- break;
- }
- else {
- // boot write to floppy failed
- if (!UI(`YesOrNo(_("\
- Couldn't write LILO boot sector to the floppy.\n\
- Please check that the floppy disk is formatted\n\
- and that the write protection is removed.\n\
- Do you want to try again?"), _("&Yes"), _("&No"))))
- break; // no choosen
- }
- } // while (true)
-
- } // lilo == "floppy"
- else {
-
- // lilo not on floppy
- doresult = Shell (docmd, $[ "bootdev" : boot_device,
- "rootdev" : root_device,
- "append" : lilo_append,
- "linear" : lilo_linear ]);
-
- if ((lilo == "mbr") || (lilo == "custom")) {
- UI(`DisplayMessage(sformat(UI(_("\
- The LILO boot sector has been written to disk. You can restore\n\
- the old boot sector in the installed system with \"lilo -u %1\"")),
- lilo_device)));
- }
-
- } // lilo != "floppy"
-
- // LILO setup end
-
- return `auto;
- }
-