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

  1. /**
  2.  * Module:         inst_writelilo.ycp
  3.  *
  4.  * Authors:         Klaus Kaempf (kkaempf@suse.de)
  5.  *
  6.  * Purpose:         This module writes lilo by calling
  7.  *            do<boot_mode> via shell.
  8.  *
  9.  * user_settings:
  10.  * ro:    boot_mode
  11.  * ro:    lilo
  12.  * ro:    lilo_device
  13.  * ro:    other_lilo
  14.  * ro: "lilo_boot_params"
  15.  * ro: "lilo_linear"
  16.  *
  17.  * $Id: inst_writelilo.ycp,v 1.27 2000/03/13 16:10:25 kkaempf Exp $
  18.  */
  19. {
  20.     // Boot setup start
  21.  
  22.     string lilo = lookup (user_settings, "lilo", "boot");
  23.     string lilo_device = lookup (user_settings, "lilo_device", "lilo");
  24.  
  25.     string boot_mode = lookup (user_settings, "boot_mode", "lilo");
  26.     string boot_device = lookup (user_settings, "boot_device", "");
  27.     string root_device = lookup (user_settings, "root_device", "");
  28.  
  29.     string other_lilo = lookup (user_settings, "other_lilo", "");
  30.     string lilo_boot_params = lookup (user_settings, "lilo_boot_params", "");
  31.     boolean lilo_linear = lookup (user_settings, "lilo_linear", false);
  32.  
  33.     integer doresult = 0;
  34.     string docmd = "chroot /mnt do"+boot_mode+" /";
  35.     if (lilo == "mbr")
  36.     docmd = docmd + " -m "+lilo_device;
  37.     else if (lilo == "floppy")
  38.     docmd = docmd + " -m "+lilo_device;
  39.     else if (lilo == "custom") {
  40.     string last_dev_char = substring (lilo_device, size(lilo_device)-1, 1);
  41.     // if lilo_device does not end in a digit, it is a disk device for mbr
  42.     if (!(filterchars (last_dev_char, "0123456789") == last_dev_char))
  43.         docmd = docmd + " -m "+lilo_device;
  44.     }
  45.     if (other_lilo != "") docmd = docmd + " " + other_lilo;
  46.  
  47.     string lilo_append = lookup (user_settings, "lilo_boot_params", "");
  48.     string lilo_opt_linear = "";
  49.     if (lookup (user_settings, "lilo_linear", false))
  50.     lilo_opt_linear = "yes";
  51.  
  52.   y2log(.milestone, "inst_writelilo", 5, "lilo: "+lilo+" cmd: "+docmd);
  53.  
  54.     if (lilo == "floppy") {
  55.  
  56.     Shell("umount /floppy"); // Just for safety
  57.     UI(`DisplayMessage(_("The LILO boot sector will be written on a floppy disk.\nPlease insert a formatted floppy and confirm with 'OK'.")));
  58.  
  59.     while (true) {
  60.         doresult = Shell (docmd, $[ "bootdev" : boot_device,
  61.                     "rootdev" : root_device,
  62.                     "append" : lilo_append,
  63.                     "linear" : lilo_opt_linear ]);
  64.         Shell ("/bin/sync");
  65.  
  66.         if (doresult == 0) {
  67.         // data saved to floppy disk
  68.         UI(`DisplayMessage(_("The LILO boot sector has been written to floppy disk.")));
  69.  
  70.         break;
  71.         }
  72.         else {
  73.         // boot write to floppy failed
  74.         if (!UI(`YesOrNo(_("\
  75. Couldn't write LILO boot sector to the floppy.\n\
  76. Please check that the floppy disk is formatted\n\
  77. and that the write protection is removed.\n\
  78. Do you want to try again?"), _("&Yes"), _("&No"))))
  79.             break;        // no choosen
  80.         }
  81.     } // while (true)
  82.  
  83.     } // lilo == "floppy"
  84.     else {
  85.  
  86.     // lilo not on floppy
  87.     doresult = Shell (docmd, $[ "bootdev" : boot_device,
  88.                     "rootdev" : root_device,
  89.                     "append" : lilo_append,
  90.                     "linear" : lilo_linear ]);
  91.  
  92.     if ((lilo == "mbr") || (lilo == "custom")) {
  93.        UI(`DisplayMessage(sformat(UI(_("\
  94. The LILO boot sector has been written to disk. You can restore\n\
  95. the old boot sector in the installed system with \"lilo -u %1\"")),
  96.        lilo_device)));
  97.     }
  98.  
  99.     } // lilo != "floppy"
  100.  
  101.     // LILO setup end
  102.  
  103.     return `auto;
  104. }
  105.