home *** CD-ROM | disk | FTP | other *** search
-
- /**
- * Module: inst_startup.ycp
- *
- * Authors: Mathias Kettner (kettner@suse.de)
- * Klaus Kaempf (kkaempf@suse.de) (initial)
- *
- * Purpose:
- * This module does the startup:
- * - Set hostname and domainname
- * - Determine architecture and boot mode
- * - Detect the mouse and mouse device (create /dev/mouse)
- * - Detect floppy drives
- * - Find IDE controllers and status enabled/disabled
- * - Find SCSI controllers and status enabled/disabled
- * - Find RAID controllers and status enabled/disabled
- * - Probe all controllers for disks
- * - Probe all disks for partition data
- *
- *
- * user_settings read: ---
- *
- *
- * user_settings write: "targets"
- * "architecture"
- * "boot_mode"
- * "has_floppy"
- * "mouse"
- * "mouse_id"
- *
- *
- * SCR: Read(.probe.architecture)
- * Read(.probe.boot_arch)
- * Read(.probe.byclass.mouse)
- * Read(.probe.byclass.storage_device.floppy)
- * Read(.probe.byclass.storage)
- * Read(.probe.again)
- *
- *
- * $Id: inst_startup.ycp,v 1.75 2000/03/09 14:14:34 kkaempf Exp $
- */
-
- {
- // --------------------------------------------------------------
- // determine architecture and start SCR()
-
- string architecture = SCR(`Read(.probe.architecture));
- user_settings = add (user_settings, "architecture", architecture);
-
- // get test_mode flag from user_settings
- boolean test_mode = lookup(user_settings, "test_mode", false);
-
- Shell("echo "+ "'YaST2 Version " + SCR(`Read(.probe.version)) + "' > /dev/tty2");
-
- // --------------------------------------------------------------
- // set up dialogue
-
- term contents =
- `VBox(
- // startup text, same as in installation.ycp
- `Left(`Heading ( _("YaST2\nInitializing ..."))),
- // label to progress bar for startup initialization
- `HVCenter(`ProgressBar(`id(`bar), _("Checking system")))
- );
- any dlg = UI(`SetWizardContents("", contents, "", false, false));
-
- // --------------------------------------------------------------
- // Progress: 5 % Startup
-
- integer pvalue = 10;
- UI(`ChangeWidget(`id(`bar), `Value, pvalue));
-
- integer usb_type = SCR(`Read(.probe.usb_type));
- user_settings = add (user_settings, "usb_type", usb_type);
-
- y2log (.milestone, "startup", 1, "usb_type "+usb_type);
- // --------------------------------------------------------------
- // Progress: 10 % USB
-
- pvalue = 10;
- UI(`ChangeWidget(`id(`bar), `Value, pvalue));
-
- // --------------------------------------------------------------
- // Set hostname and domainname to something reasonable.
- // Some programs depend on it (rpm install scripts, Xlib)
-
- if (!test_mode) {
- Shell("hostname linux");
- Shell("domainname local");
-
- // fallback for br_FR
- Symlink ("/usr/share/locale/fr", "/usr/share/locale/br");
- }
-
- string boot_mode = SCR(`Read(.probe.boot_arch));
- user_settings = add (user_settings, "boot_mode", boot_mode);
-
- y2log (.milestone, "inst_startup", 1, "arch "+architecture+", boot "+boot_mode);
-
- // --------------------------------------------------------------
- // mouse detection
- // linuxrc only does a dummy mouse setup for x11
- // the real mouse detection and activation is done here
-
- // hw-probe for mouse, result is a map since no subclass given
- map|void mouseprobe = SCR(`Read(.probe.byclass.mouse));
-
- map mouse_map = $[]; // filled in later
- string mouse_id = "";
-
- if ((mouseprobe != nil) && (mouseprobe != $[])) {
-
- // evaluate probed mice in the order PS/2, USB, serial, Busmouse
-
- list bus = lookup (mouseprobe, "ps2", []);
- if (bus == []) bus = lookup (mouseprobe, "usb", []);
- if (bus == []) bus = lookup (mouseprobe, "serial", []);
- if (bus == []) bus = lookup (mouseprobe, "bus", []);
-
- if (bus != []) {
-
- // get value from bus, select first mouse
- map firstmouse = select (bus, 0);
-
- map mprotocol = lookup (firstmouse, "mouse", $[]);
- string mdevice = lookup (firstmouse, "dev_name", "");
-
- if ((size (mprotocol) > 0) && (mdevice != "")) {
-
- string mgpm = lookup (mprotocol, "gpm", "");
- string mxf86 = lookup (mprotocol, "xf86", "");
- boolean emul3 = lookup (mprotocol, "emul3", true);
-
- if ((mgpm != "") || (mxf86 != "")) {
- // fake device here, set /dev/mouse
- mouse_map = $["gpm" : mgpm,
- "xf86" : mxf86,
- "device": "/dev/mouse",
- "emul3" : emul3 ];
-
- mouse_id = mgpm;
- if (mdevice == "/dev/ttyS0") mouse_id = mouse_id + "0";
-
- if (!test_mode) {
- Symlink (mdevice, "/dev/mouse");
- SetXMouse (mouse_map);
- }
-
- // re-enter real device for inst_finish
- mouse_map = add (mouse_map, "device", mdevice);
-
- } // mouse data found in protocol
-
- } // mprotocol found
-
- } // known subclass (bus) found
-
- } // mouseprobe
-
- user_settings = add (user_settings, "mouse_id", mouse_id);
- user_settings = add (user_settings, "mouse", mouse_map);
-
- y2log (.milestone, "startup", 1, "mouse_id "+mouse_id);
-
- // --------------------------------------------------------------
- // Progress: 20 % Mouse probed
-
- pvalue = 20;
- UI(`ChangeWidget(`id(`bar), `Value, pvalue));
-
- // --------------------------------------------------------------
- // do we have a floppy drive attached ?
-
- boolean has_floppy = false;
- list|void floppy_drives = SCR(`Read(.probe.byclass.storage_device.floppy));
- if (floppy_drives != nil) {
- string floppy_device = lookup (select (floppy_drives, 0), "dev_name", "");
- if (floppy_device != "") {
- has_floppy = true;
- user_settings = add (user_settings, "floppy_device", floppy_device);
- }
- }
- user_settings = add (user_settings, "has_floppy", has_floppy);
-
- y2log (.milestone, "startup", 1, "floppy probed");
-
- // --------------------------------------------------------------
- // Progress: 30 % Floppy probed
-
- pvalue = 30;
- UI(`ChangeWidget(`id(`bar), `Value, pvalue));
-
-
- // --------------------------------------------------------------
- // find 'storage' controllers
-
- // probe complete 'storage' tree, result is a map
-
- map|void controllers = SCR(`Read(.probe.byclass.storage));
-
- if (controllers == nil) {
-
- y2log (.milestone, "inst_startup", 4, "no controllers");
-
- // Oops, no storage controllers ?
- return `cancel;
- }
-
-
- // --------------------------------------------------------------
- // Progress: 40 % Controllers probed
-
- pvalue = 40;
- UI(`ChangeWidget(`id(`bar), `Value, pvalue));
-
-
- // --------------------------------------------------------------
- // now check for modules to load
-
- // function to initialize controllers
- // I: list of maps from Read(.probe.byclass.storage.[ide|scsi|raid] ...
- // O: list of loaded modules
-
- define init_controllers (map all_modules, list controller_list, boolean manual_mode) ``{
-
- map controller = $[];
- integer cindex = 0;
- list ioresources = [];
-
- y2log(.milestone, "inst_startup", 4, sformat("controller_list: %1", controller_list));
-
- while (cindex < size (controller_list)) { // use while(), continue not allowed in foreach()
-
- controller = select (controller_list, cindex);
-
- cindex = cindex + 1;
-
- // for every IDE controller it is checked whether
- // the controller is disabled in BIOS
-
- ioresources = lookup (lookup (controller, "resource", $[]), "io", []);
- y2log (.debug, "inst_startup", 5, sformat("ioresources: %1", ioresources));
- if (size (ioresources) == 0)
- continue;
-
- // continue if disabled in BIOS
- if (lookup (select (ioresources, 0), "active", true) == false)
- continue;
-
- // check module information
- // skip controller if no module info available
- map module = lookup (controller, "module", $[]);
- y2log (.milestone, "inst_startup", 6, sformat("module: %1", module));
- if (module == $[])
- continue;
-
- // skip controller if module already active
- if (lookup (module, "active", true) == true)
- continue;
-
- // get module loading information
-
- string module_name = lookup (module, "name", "");
- if (module_name == "")
- continue;
-
- // possible modules.conf entry
- string module_conf = lookup (module, "conf", "");
-
- all_modules = add (all_modules, module_name, module_conf);
-
- string mod_args = lookup (module, "args", "");
- if (mod_args != "")
- mod_args = " " + mod_args;
-
- if (lookup (module, "modprobe", false) == true) {
- if (!test_mode) Shell("/sbin/modprobe "+module_name+mod_args);
- y2log (.milestone, "startup", 1, "/sbin/modprobe "+module_name+mod_args);
- }
- else {
- if (!test_mode) Shell("/sbin/insmod "+module_name+mod_args);
- y2log (.milestone, "startup", 1, "/sbin/insmod "+module_name+mod_args);
- }
-
- } // while (controller)
-
- return all_modules;
-
- }; // init_controllers ()
-
- // --------------------------------------------------------------
- // now probe & initialize controllers
-
- map install_inf = SCR(`Read(.etc.install_inf));
- boolean manual_mode = false;
- if (lookup (install_inf, "manual", "") == "1") {
- manual_mode = true;
- }
-
- map moduleMap = $[];
-
- y2log (.debug, "inst_startup", 7, "Checking for ide controllers...");
- moduleMap = init_controllers (moduleMap, lookup (controllers, "ide", []), manual_mode);
- y2log (.debug, "inst_startup", 8, "Checking for scsi controllers...");
- moduleMap = init_controllers (moduleMap, lookup (controllers, "scsi", []), manual_mode);
- y2log (.debug, "inst_startup", 9, "Checking for raid controllers...");
- moduleMap = init_controllers (moduleMap, lookup (controllers, "raid", []), manual_mode);
-
- user_settings = add (user_settings, "modules", moduleMap);
-
- // --------------------------------------------------------------
- // Progress: 50 % All modules loaded
-
- pvalue = 50;
- UI(`ChangeWidget(`id(`bar), `Value, pvalue));
-
- y2log (.milestone, "startup", 1, "all controllers initialized");
-
- // --------------------------------------------------------------
- // now check for disks 'behind' controllers
-
- map targets = $[];
- list|void all_disks = SCR(`Read(.probe.disk));
-
- y2log (.milestone, "startup", 1, "disks probed");
-
- if ((all_disks == nil) || (all_disks == [])) {
- // somehow, we couldn't find any harddisks for installation. This is a fatal error,
- // we can't do anything about it
- UI(`DisplayMessage(_("No disks found for installation\nPlease check your hardware")));
- return `cancel;
- }
-
- integer progress_per_disk = (100-pvalue) / size (all_disks);
-
- // loop over all_disks, constructing targets map
-
- integer ide_count = 0;
- integer scsi_count = 0;
- integer raid_count = 0;
-
- foreach (`disk, all_disks, ``{
-
- map target = $[];
-
- string bus = lookup (disk, "bus", "?");
- string dname = "";
- integer i = 0;
-
- // ------------------------------------------------------
- // check bus, count disks per bus
-
- if (bus == "IDE") { ide_count = ide_count + 1; i = ide_count;
- } else if (bus == "SCSI") { scsi_count = scsi_count + 1; i = scsi_count;
- } else if (bus == "RAID") { raid_count = raid_count + 1; i = raid_count;
- } else { i = 1; // Oops, which bus ?
- }
-
- target = add (target, "bus", bus);
-
- // ------------------------------------------------------
- // construct disk name for user
-
- dname = ""+i+". "+bus+", ";
-
- // needed also later as key
- string ddevice = lookup (disk, "dev_name", "?");
-
- // strip /dev/ from ddevice, convert to path for fdisk
-
- path diskpath = topath ("." + substring (ddevice, 5));
- path fullpath = .disk + diskpath;
-
- y2log (.milestone, "startup", 1, "disk_size ? "+ddevice);
-
- // call fdisk agent to get size information
-
- integer cyl_count = SCR(`Read(fullpath+.disk_size));
- integer cyl_size = SCR(`Read(fullpath+.bytes_per_unit));
-
- target = add (target, "cyl_count", cyl_count);
- target = add (target, "cyl_size", cyl_size);
-
- // ------------------------------------------------------
- // construct full target name
-
- dname = dname + UI(`size_text(cyl_count * cyl_size)) + ", " + ddevice + ", ";
-
- string dinfo = lookup (disk, "vendor", "");
- target = add (target, "vendor", dinfo);
-
- if (dinfo != "") dname = dname + dinfo + "-";
- dinfo = lookup (disk, "device", "");
- target = add (target, "model", dinfo);
-
- if (dinfo != "") dname = dname + dinfo;
-
- target = add (target, "name", dname);
-
- // ------------------------------------------------------
- // check partitions
-
- y2log (.milestone, "startup", 1, "partitions ?"+dname);
-
- list partitions = check4partitions (diskpath, architecture);
-
- target = add (target, "partitions", partitions);
-
- // add constructed target map to list of all targets
-
- if (target != $[]) targets = add (targets, ddevice, target);
-
- pvalue = pvalue + progress_per_disk;
- UI(`ChangeWidget(`id(`bar), `Value, pvalue));
-
- }); // foreach (`disk)
-
- if (test_mode) SCR(`Write(.dumpto.tmp.targets, targets));
-
- user_settings = add (user_settings, "targets", targets);
-
- // --------------------------------------------------------------
- // keep dialogue open in test_mode
-
- // if (test_mode) UI(`UserInput());
-
- return `next;
- }
-