home *** CD-ROM | disk | FTP | other *** search
-
- /**
- * Module: inst_sw_select.ycp
- *
- * Authors: Mathias Kettner <kettner@suse.de>
- * Klaus Kaempf <kkaempf@suse.de> (initial)
- * Stefan Hundhammer <sh@suse.de>
- * Stefan Schubert <schubi@suse.de>
- *
- * Purpose:
- * Displays software selection screen. Show checkboxes for software
- * categories. Let the user select his software.
- *
- * user_settings read: "softwaresel"
- * "language"
- * "install_info"
- *
- *
- * user_settings write: "softwaresel"
- * "install_info"
- *
- *
- *
- *
- *
- * $Id: inst_sw_select.ycp,v 1.38 2000/03/09 10:47:44 kkaempf Exp $
- */
-
- {
- // ------------------------------------------------------------------------
- // collect mountpoint:device as map to get a sorted list
-
- boolean going_backwards = Args(2);
-
- map targetMap = lookup(user_settings, "targets", $[]);
- if ( lookup(user_settings, "test_mode", false) == true )
- {
- // TEST VALUES !!!
- targetMap = $[
- "/dev/sda":$[
- "bus":"SCSI",
- "name":"1. SCSI, 8.54 GB, /dev/sda, IBM-DNES-309170W",
- "cyl_count":1114,
- "cyl_size":8224768,
- "vendor":"IBM DNES-309170W",
- "partitions":[
- $["fsid":131, // YES: mount
- "mount":"/boot",
- "fstype":"Linux native",
- "nr":1,
- "region":[1, 254],
- "type":`primary],
- $["delete":true, // NO: no mount
- "fsid":130,
- "fstype":"Linux swap",
- "nr":2,
- "region":[255, 299],
- "type":`primary],
- $["create":false, // NO: create false
- "fsid":131,
- "mount":"/var",
- "fstype":"Linux native",
- "nr":3,
- "region":[300, 499],
- "type":`primary],
- $["create":true, // YES: create true + mount
- "fsid":131,
- "mount":"/",
- "nr":4,
- "format":true,
- "region":[500, 844],
- "type":`primary
- ]
- ]
- ],
- "/dev/sdb":$[
- "bus":"SCSI",
- "name":"1. SCSI, 8.54 GB, /dev/sda, IBM-DNES-309170W",
- "cyl_count":11141,
- "cyl_size":8224768,
- "vendor":"IBM DNES-309170-XEW",
- "partitions":[
- $["fsid":131, // NO: nothing
- "fstype":"Linux native",
- "nr":1,
- "region":[1, 254],
- "type":`primary],
- $["create":true, // NO: no mount
- "fsid":130,
- "fstype":"Linux swap",
- "nr":2,
- "region":[255, 299],
- "type":`primary],
- $["delete":true, // NO: delete false
- "fsid":131,
- "mount":"/var",
- "fstype":"Linux native",
- "nr":3,
- "region":[300, 499],
- "type":`primary],
- $[ "delete":false, // YES: delete true
- "fsid":130,
- "mount":"/usr",
- "fstype":"Linux swap", // user-visible string
- "nr":4, // partition number, as seen by linux (!)
- "region": [500,10871], // start end of region in cyl.s
- "use":true, // mark as 'used' in inst_target_partition
- "type":`primary
- ]
- ] ] ];
-
- // End TEST VALUES
- }
-
- if (!going_backwards) {
-
- // debug
- SCR(`Write (.dumpto.tmp.targets, targetMap));
-
- map mountPoints = $[];
- list swapPoints = [];
-
- foreach (`targetdevice,`target, targetMap, ``{
- any partitions = lookup ( target, "partitions" );
- foreach (`partition, partitions, ``{
- string partitionName = targetdevice + lookup (partition, "nr", 0 );
- string mountPoint = lookup (partition, "mount", "" );
- integer fsid = lookup (partition, "fsid", 0);
- if (mountPoint != "") {
- if (mountPoint == "swap")
- swapPoints = add (swapPoints, [partitionName, fsid, targetdevice]);
- else
- mountPoints = add (mountPoints, mountPoint, [partitionName, fsid, targetdevice]);
- }
- });
- });
-
- if (size (swapPoints) > 0)
- mountPoints = add (mountPoints, "swap", swapPoints);
-
- SCR(`Write (.dumpto.tmp.mounts, mountPoints));
- user_settings = add(user_settings, "mountpoints", mountPoints);
- }
-
- // ------------------------------------------------------------------------
-
- list current_sel = lookup(user_settings, "softwaresel", [.default]);
- // setting user_settings:softwaresel, if it has not been set
- user_settings = add(user_settings, "softwaresel", current_sel);
- string language = lookup(user_settings, "language", default_language);
- boolean retval = false;
-
- _debug("Current softwaresel:", current_sel);
-
- map lang2yast1 = $[
- "en_GB" : "english",
- "en_US" : "english",
- "en" : "english",
- "de_DE" : "german",
- "de_CH" : "german",
- "de" : "german",
- "br_FR" : "french",
- "fr_FR" : "french",
- "fr_CH" : "french",
- "fr" : "french",
- "it_IT" : "italian",
- "es_ES" : "spanish",
- "nl_NL" : "dutch",
- "pt_PT" : "portuguese",
- "pt_BR" : "brazilian",
- "hu_HU" : "hungarian",
- "pl_PL" : "polish",
- "el_GR" : "greek",
- "ru_RU.KOI8-R" : "russian",
- "cs_CZ" : "czech",
- "sk_SK" : "slovak"
- ];
-
-
- string long_language = lookup(lang2yast1, language, "english");
-
- //
- // Initialize PKGINFO server
- //
-
-
- string infopath = "/var/adm/mount/suse/setup/descr";
- string dudir = "/var/adm/mount/suse/setup/du/du.dir";
-
- if ( lookup(user_settings, "test_mode", false) )
- {
- // TEST VALUES !!!
-
- dudir = "/dist/6.3-i386/suse/setup/du/du.dir";
-
- infopath = "/dist/6.3-i386/suse/setup/descr";
-
- }
-
- UI(`OpenDialog(`opt(`decorated ),`Label(_("One moment please..."))));
-
- // Get information about available partitions
- list partition = get_partition_info( targetMap, true );
-
- retval = PKGINFO (`setEnvironment(
- $["packageinfopath":infopath, "common.pkd":"common.pkd", "language":long_language,
- "dudir":dudir, "partition":partition]
- ));
-
- PKGINFO( `setDebugLevel(0) );
-
- UI(`CloseDialog());
-
- _debug( "Return setEnvironment:", retval );
-
- // screen title for software selection
- locale title = _("Software Selection");
-
- list pacsels = [];
-
- if ( lookup(user_settings, "test_mode", false) )
- {
- pacsels = filter(`sel,
- Read("/lib/YaST2/pacsel/index.ycp"),
- ``(select(sel, 1) != .paylist));
- }
- else
- {
- pacsels = filter(`sel,
- Read("/var/adm/mount/suse/setup/descr/pacsel/index.ycp"),
- ``(select(sel, 1) != .paylist));
- }
-
- // Construct Box with Checkbox for each software category
-
- // Title of frame around "basic software"
- term baseconfs = `VBox();
-
- foreach(`sel, pacsels, ``{
- path selid = select(sel, 0);
- path group = select(sel, 1);
- map langmap = select(sel, 2);
-
- string seldesc = translate(langmap, language );
-
- if ( group == .baseconf )
- {
- baseconfs = add(baseconfs, `Left(`RadioButton(`id(selid),`opt(`notify),
- seldesc,
- contains (current_sel, selid))));
- }
- });
-
- string wrn_msg = "";
- boolean added = false;
-
- // Checking: already selected addons or single selection?
- if ( size(current_sel) > 1 || PKGINFO ( `isSingleSelected() ) )
- {
- // Display warning message
- wrn_msg = UI(_("\
- You have already chosen something from \"Detailed selection\"\n\
- You will lose that selection if you change the basic selection."));
- added = true;
- }
-
- // Build and show dialog
-
- term contents = `HVSquash(
- `VBox(`VBox(
- `HSquash(`Frame( "", `RadioButtonGroup(`id(`baseconf),`opt(`notify), baseconfs) )),
- `Label( " " ), // just to add some spacing
- // Push button that will pop up the detailed
- // software selection (e.g. Multimedia, Games,
- // KDE, Gnome, ... - not the individual packages!)
- `PushButton( `id(`details), _("&Detailed selection...") )
- ),
- `Label( " " ),
- `Label( `id(`wrn_label), wrn_msg )
- )
- );
-
-
- // explain choosable system configurations
- // but beware: some of the text in <b>'s, e.g. Default comes from the index file,
- // translations must be consistent with po/index/index.??.po
- // help part 1 of 3
- string helptext = UI(_("<p>
- The SuSE Linux <b>Default</b> system is a good software
- base for most systems. You will not need to insert all of the CDs that
- come with SuSE Linux for this selection. Further software from the
- other CDs can always be added later.
- </p>"));
- // help part 2 of 3
- helptext = helptext + UI(_("<p>
- The <b>Minimal</b> system includes just the bare essentials necessary
- to safely run SuSE Linux. Please notice that this selection <b><i>does not include
- graphical desktop environments</i></b>, i.e. no X11, no KDE, no Gnome etc.
- Select this option as a base for your own custom selection, for
- dedicated server systems that don't need a graphical desktop or for
- systems that are short on disk space and/or memory.
- </p>"));
- // help part 3 of 3
- helptext = helptext + UI(_("<p>
- <b>Almost everything</b> includes every software package that comes
- with SuSE Linux except the sources. Please make sure you have a lot of
- disk space available when you select this option.
- </p>
-
- <p>
- For more control about what software to install select
- <b>Detailed selection</b>.
- </p>
- <br>"));
-
-
-
- UI(`SetWizardContents(title, contents, helptext, Args(0),Args(1)));
-
-
- // get all packages to install
- list package_list = CallFunction( `inst_pkg_toinstall( user_settings ) );
-
- _debug ( "Required packages:", package_list );
-
- // Initialize server with the packages which have to be installed, but without resetting
- // single-selected packages.
- PKGINFO ( `setInstallSelection ( package_list, true ) );
- PKGINFO ( `setSourceInstallation(lookup(user_settings, "install_sources", false)) );
-
- any ret = nil;
- boolean error_found = false;
- while (true)
- {
-
- list(map) required_partition = PKGINFO ( `getDiskSpace ( partition ) ) ;
-
- _debug("Required partitions :",required_partition );
-
- // Construct a popup like:
- // +-----------------------------------------------+
- // | Partition / needs 200 KB more disk space. |
- // | Partition etc needs 40 MB more disk space. |
- // | |
- // | Please deselect some packages. |
- // +-----------------------------------------------+
- string message = "";
-
- foreach( `par, required_partition,
- ``{
- if ( lookup( par, "free", 0 ) < 0 )
- {
- message = message + sformat ( UI(_("Partition \"%1\" needs %2 more disk space.")),
- lookup ( par, "name" ),
- UI( `size_text(lookup ( par, "free" ) * -1 *1024) ) ) + "\n";
- }
- } );
- if ( size ( message ) > 0 )
- {
- message = message + "\n" + UI(_("Please deselect some packages."));
- _debug("Warning:", message );
- UI(`DisplayMessage(message));
- error_found = true;
- }
- else
- {
- error_found = false;
- }
-
- list save_sel = [];
- save_sel = add(save_sel, UI(`QueryWidget(`id(`baseconf), `CurrentButton)));
-
- ret = UI(`UserInput());
-
- // Add the selection of the basic group
- current_sel = [];
- current_sel = add(current_sel, UI(`QueryWidget(`id(`baseconf),`CurrentButton)));
-
- if ( save_sel != current_sel )
- {
- // boolean single = PKGINFO ( `isSingleSelected());
- // _debug ( "isSingleSelected:", single );
- // single is replaced by added -> see above
-
- if ( !added
- || UI(`YesOrNo(_("Do you really want\nto reset your detailed selection?"), _("&Yes"), _("&No") ) ) )
- {
- user_settings = add(user_settings, "softwaresel", current_sel);
- _debug( "Add current_sel to user_settings: ", current_sel );
- // Reset source-selected
- user_settings = add(user_settings, "install_sources", false);
-
- list package_list = CallFunction( `inst_pkg_toinstall( user_settings ) );
-
- _debug ( "Required packages:", package_list );
-
- // Initialize pkginfo-server and reset ALL single-selected packages
- PKGINFO ( `setInstallSelection ( package_list ) );
- PKGINFO ( `setSourceInstallation(lookup(user_settings, "install_sources", false)) );
-
- if ( added )
- {
- // rebuild
- ret = `again;
- break;
- }
- else
- {
- // goto size-calculation
- continue;
- }
-
- }
- else
- {
- // rebuild the former selected RadioButton
- ret = `again;
- break;
- }
- }
-
- if (ret == `cancel || ret == `back ) break;
-
- if ( ret == `details )
- {
- any details_ret = `again;
- while ( details_ret == `again )
- {
- details_ret = CallFunction( `inst_sw_details( true, true ) );
- }
-
- if ( details_ret == `back )
- {
- ret = `again;
- }
- else if ( details_ret == `next )
- ret = `next;
- else if ( details_ret == `cancel )
- ret = `cancel;
- break;
- }
-
- if ( ret == `next && !error_found ) break;
-
- }
-
- if ( ret == `next )
- {
- // setting user_setting.install_info for packages which have to be installed
- list install_info = PKGINFO ( `getInstallSet() );
- _debug ( "Writing install_info: ", install_info );
- user_settings = add ( user_settings , "install_info", install_info );
-
- // get totally used space for package selection
- list(map) req_part = PKGINFO( `getDiskSpace( partition ) );
- integer used = 0;
-
- foreach( `part, req_part,
- ``{
- used = used + lookup( part, "used" );
- } );
- _debug( "Totally used space: ", used*1024 );
-
- user_settings = add ( user_settings, "neededspace", used*1024 );
-
- // adding manual packages
- CallFunction( `inst_add_pkg_toinstall( user_settings ) );
- }
- _debug ( "inst_sw_select return :", ret );
- return ret;
- }
-