home *** CD-ROM | disk | FTP | other *** search
- /**
- * Module: inst_target_selection.ycp
- *
- * Authors: Klaus Kaempf (kkaempf@suse.de)
- *
- * Purpose: This module selects the harddisk(s) for installation.
- * -Harddisk recognition
- * -Selecting the harddisk for the installation by
- * the user ( if possible harddisks > 1 ).
- * -Write selected harddisk(s) into "target_is" of user_settings
- *
- * user_settings: "target_is":<devicename> (key to "targets" map)
- * if custom, set "target_is":"CUSTOM"
- *
- * $Id: inst_target_selection.ycp,v 1.66 2000/03/09 10:54:33 kkaempf Exp $
- */
- {
- boolean test_mode = lookup ( user_settings, "test_mode", false );
-
- // if we get here in update mode it's a BUG
-
- if (lookup ( user_settings, "instmode", `install) == `update) {
- return `cancel;
- }
-
- // reset old target selections and partitionings
-
- define reset_target (map target_info) ``{
- list partitions = lookup (target_info, "partitions", []);
-
- // filter out all "create" paritions, they will be re-created at exit
- // (this ensures a 'clean' partition list if this dialogue is re-entered
-
- partitions = filter (`pentry, partitions, ``(!lookup (pentry, "create", false)));
-
- // reset all "delete" paritions, they will be re-created at exit
- // (this ensures a 'clean' partition list if this dialogue is re-entered
-
- partitions = maplist (`pentry, partitions, ``(add (pentry, "delete", false)));
-
- return add (target_info, "partitions", partitions);
- };
-
- define check_for_reset (string old_target, string new_target, map targets) ``{
- if (old_target == "")
- return $[];
- if (old_target == new_target)
- return $[];
-
- if (old_target == "CUSTOM") {
- // clear all old targets
- map new_targets = $[];
- foreach (`tname, `tinfo, targets, ``{
- new_targets = add (new_targets, tname, reset_target (tinfo));
- });
- targets = new_targets;
- }
- else {
- // just clear the old target
- // (the new target will be cleared in the following module
- targets = add (targets, old_target, reset_target (lookup (targets, old_target, $[])));
- }
-
- return targets;
- };
-
- map targetMap = lookup ( user_settings, "targets", $[]);
- string target_is = lookup ( user_settings, "target_is", "");
-
- if ( test_mode && (targetMap == nil) || (size(targetMap) == 0) ) {
- y2log(.warning, "inst_target_part", 1, "***** Test mode active - using fake values *****");
-
- targetMap =
- $[
- "/dev/hda":
- $[
- "bus" : "IDE", "cyl_count" : 53040, "cyl_size" : 516096,
- "device" : "/dev/hda", "name" : "1. IDE, 25.49 GB, /dev/hda, (empty)",
- "partitions" : [ ],
- "vendor" : "WDC"
- ],
- "/dev/hdb":
- $[
- "bus" : "IDE", "cyl_count" : 53040, "cyl_size" : 516096,
- "device" : "/dev/hdb", "name" : "2. IDE, 25.49 GB, /dev/hdb, (windows)",
- "partitions" : [
- $["fsid" : 1, "fstype" : "FAT12",
- "nr" : 1, "region" : [ 0, 513 ], "type" : `primary
- ]
- ],
- "vendor" : "WDC"
- ],
- "/dev/hdc":
- $[
- "bus" : "IDE", "cyl_count" : 53040, "cyl_size" : 516096,
- "device" : "/dev/hdc", "name" : "3. IDE, 25.49 GB, /dev/hdb, (full)",
- "partitions" : [
- $["fsid" : 4, "fstype" : "FAT16",
- "nr" : 1, "region" : [ 0, 513 ], "type" : `primary
- ],
- $["fsid" : 4, "fstype" : "FAT16",
- "nr" : 2, "region" : [ 513, 513 ], "type" : `primary
- ],
- $["fsid" : 4, "fstype" : "FAT16",
- "nr" : 3, "region" : [ 1026, 513 ], "type" : `primary
- ],
- $["fsid" : 4, "fstype" : "FAT16",
- "nr" : 4, "region" : [ 1539, 51500 ], "type" : `primary
- ]
- ],
- "vendor" : "WDC"
- ],
- "/dev/sda" :
- $[
- "bus" : "SCSI", "cyl_count" : 8748, "cyl_size" : 1048576,
- "device" : "/dev/sda", "name" : "1. SCSI, 8.54 GB, /dev/sda, (linux)",
- "partitions" : [
- $["fsid" : 130, "fstype" : "Linux swap",
- "nr" : 1, "region" : [ 0, 513 ], "type" : `primary
- ],
- $["fsid" : 131,"fstype" : "Linux native",
- "nr" : 2, "region" : [ 513, 8235 ], "type" : `primary
- ]
- ],
- "vendor" : "IBM"
- ],
- "/dev/sdb" :
- $[
- "bus" : "SCSI", "cyl_count" : 8748, "cyl_size" : 1048576,
- "device" : "/dev/sdb", "name" : "2. SCSI, 8.54 GB, /dev/sda, (apple)",
- "partitions" : [
- $["fsid" : 130, "fstype" : "Linux swap",
- "nr" : 1, "region" : [ 0, 513 ], "type" : `pdisk
- ],
- $["fsid" : 131,"fstype" : "Linux native",
- "nr" : 2, "region" : [ 513, 8235 ], "type" : `pdisk
- ]
- ],
- "vendor" : "IBM"
- ]
- ];
-
- user_settings = add( user_settings, "targets", targetMap );
- }
-
- term contents = `Dummy();
-
- if (size(targetMap) != 0) {
-
- if (test_mode) y2log (.milestone, "inst_target_selection", 1, "found targetMap, target_is "+target_is);
-
- // loop over targetMap and build radio buttons for selection
- // dont use foreach here since we need a counter (as a shortcut)
- // anyway
-
- term buttonbox = `VBox();
-
- integer i = 0;
- foreach (`tname, `tdata, targetMap, ``{
- string tline = "&" + (i+1) + ": " + lookup (tdata, "name", "?");
- buttonbox = add(buttonbox, `Left(`RadioButton(`id(tname), tline, (target_is == tname))));
- i = i + 1;
- });
-
- buttonbox = add(buttonbox, `Label( " " ) );
- buttonbox = add(buttonbox, `Left(`RadioButton(`id("CUSTOM"),
- // Check box for expert partitioning mode rather than
- // just selecting one of the hard disks and use
- // a standard partitioning scheme
- _( "&Custom partitioning - for experts" ),
- (target_is == "CUSTOM")
- )
- )
- );
-
- // This dialog selects the target disk for the installation.
- // Below this label, all targets are listed that can be used as installation target
-
- contents = `Frame ( _("Choose a hard disk"),
- `RadioButtonGroup(`id(`options), `HSquash(buttonbox) )
- );
- }
- else {
- if (test_mode) y2log (.milestone, "inst_target_selection", 1, "NO targetMap");
- // normally the target is located on hard disks. Here no hard disks can be found.
- // YaST2 cannot install - now the fallback YaST must be used
- contents = `Label (_("No disks found, please use the update CD for installation."));
- }
-
-
- // There are several hard disks found. Linux is completely installed on
- // one hard disk - this selection is done here
- // "Preparing Hard Disk - Step 1" is the description of the dialog what to do
- // while the following locale is the help description
- // help part 1 of 3
- string helptext = UI(_("<p>
- All hard disks that have been automatically detected on your system
- are shown here. Please select the hard disk to install SuSE Linux on.
- </p>"));
- // help part 2 of 3
- helptext = helptext + UI(_("
- <p>
- Under certain conditions not all of your hard disks might be
- auto-detected properly. If you wish to install SuSE Linux on such a
- hard disk, you might want to use <b>YaST1</b> as described in the manual.
- </p>"));
- // help part 3 of 3
- helptext = helptext + UI(_("
- <p>
- For experts, there is the <b>custom partitioning</b> option for full
- control about how to partition your hard disk(s) and assigning
- partitions to your SuSE Linux installation.
- </p>
- <br>"));
-
- // first step of hd prepare, select a single disk or "expert" partitioning
- any dlg = UI(`SetWizardContents( _("Preparing Hard Disk - Step 1" ),
- contents, helptext, Args(0), Args(1)));
- any ret = nil;
-
- // Event handling
-
- any option = nil;
-
- while (option == nil) {
- ret = UI(`UserInput());
- if (ret == `next || ret == `back) {
- option = UI(`QueryWidget(`id(`options), `CurrentButton));
- if (option == nil) {
- if ( ret != `back ) {
- // there is a selection from that one option has to be chosen - at the moment
- // no option is chosen
- UI(`DisplayMessage(_("You have to choose one of the\noptions in order to continue.")));
- continue;
- }
- }
- else if (option == "CUSTOM") {
- map new_targets = check_for_reset (target_is, option, targetMap);
- if (new_targets != $[])
- user_settings = add (user_settings, "targets", new_targets);
- user_settings = add (user_settings, "target_is", option);
- }
- else {
- map new_targets = check_for_reset (target_is, option, targetMap);
- if (new_targets != $[])
- user_settings = add (user_settings, "targets", new_targets);
- user_settings = add (user_settings, "target_is", option);
- } // if (option)
-
- } // if (ret == back|next)
-
- break;
-
- } // while (option == nil)
-
- return ret;
- }
-