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

  1.  
  2. /**
  3.  * Module:         inst_sw_details.ycp
  4.  *
  5.  * Authors:        Mathias Kettner (kettner@suse.de)
  6.  *            Klaus Kaempf (kkaempf@suse.de) (initial)
  7.  *            Stefan Hundhammer (sh@suse.de)
  8.  *            Stefan Schubert (schubi@suse.de)
  9.  *
  10.  * Purpose:
  11.  * Display detailed software selection screen.
  12.  * Show checkboxes for software categories.
  13.  * Let the user select his software.
  14.  *
  15.  * user_settings read:    "softwaresel"
  16.  *            "language"
  17.  *            "install_sources"
  18.  *            "install_info"
  19.  *
  20.  * user_settings write: "softwaresel"
  21.  *            "have_x11"
  22.  *            "install_sources"
  23.  *            "install_info"
  24.  *
  25.  * 
  26.  *
  27.  *
  28.  * $Id: inst_sw_details.ycp,v 1.28 2000/03/10 14:52:09 kkaempf Exp $
  29.  */
  30.  
  31. {
  32.     list current_sel     = lookup(user_settings, "softwaresel", [.default]);
  33.     string language      = lookup(user_settings, "language", default_language);
  34.     list(map) required_partition = [];
  35.     
  36.     
  37.     map targetMap = lookup( user_settings, "targets", $[] );
  38.  
  39.     define GetFreeSpace( list partion_list ) ``{
  40.  
  41.     integer free_space = 0;
  42.     
  43.     foreach( `part, partion_list, ``{
  44.         free_space = free_space + lookup( part, "free" );
  45.     } );
  46.  
  47.     return ( UI( `size_text( free_space*1024) ) );
  48.     };
  49.     
  50.     if ( lookup(user_settings, "test_mode", false) == true )
  51.     {
  52.        // TEST VALUES !!!
  53.     targetMap = $[
  54.               "/dev/sda":$[
  55.                        "bus":"SCSI",
  56.                        "name":"1. SCSI, 8.54 GB, /dev/sda, IBM-DNES-309170W",
  57.                        "cyl_count":1114,                               
  58.                        "cyl_size":8224768,                            
  59.                        "vendor":"IBM DNES-309170W",                      
  60.                        "partitions":[
  61.                              $["fsid":131,    // YES: mount
  62.                               "mount":"/boot",        
  63.                               "fstype":"Linux native",
  64.                               "nr":1,
  65.                               "region":[1, 254],
  66.                               "type":`primary],
  67.                              $["delete":true,    // NO: no mount
  68.                                "fsid":130,
  69.                               "fstype":"Linux swap",
  70.                               "nr":2,
  71.                               "region":[255, 299],
  72.                               "type":`primary],
  73.                              $["create":false,    // NO: create false
  74.                                "fsid":131,
  75.                               "mount":"/var",
  76.                               "fstype":"Linux native",
  77.                               "nr":3,
  78.                               "region":[300, 499],
  79.                               "type":`primary],
  80.                              $["create":true,      // YES: create true + mount  
  81.                                "fsid":131,
  82.                                "mount":"/",
  83.                                "nr":4,
  84.                                "format":true,
  85.                                "region":[500, 844],
  86.                                "type":`primary
  87.                              ]
  88.                        ]
  89.               ],
  90.               "/dev/sdb":$[
  91.                        "bus":"SCSI",
  92.                        "name":"1. SCSI, 8.54 GB, /dev/sda, IBM-DNES-309170W",
  93.                        "cyl_count":11141,                               
  94.                        "cyl_size":8224768,                            
  95.                        "vendor":"IBM DNES-309170-XEW",                      
  96.                        "partitions":[
  97.                              $["fsid":131,        // NO: nothing
  98.                               "fstype":"Linux native",
  99.                               "nr":1,
  100.                               "region":[1, 254],
  101.                               "type":`primary],
  102.                              $["create":true,        // NO: no mount
  103.                                "fsid":130,
  104.                               "fstype":"Linux swap",
  105.                               "nr":2,
  106.                               "region":[255, 299],
  107.                               "type":`primary],
  108.                              $["delete":true,        // NO: delete false
  109.                                "fsid":131,
  110.                               "mount":"/var",
  111.                               "fstype":"Linux native",
  112.                               "nr":3,
  113.                               "region":[300, 499],
  114.                               "type":`primary],
  115.                              $[ "delete":false,          // YES: delete true
  116.                                "fsid":130,
  117.                               "mount":"/usr",
  118.                               "fstype":"Linux swap", // user-visible string
  119.                               "nr":4,    // partition number, as seen by linux (!)
  120.                               "region": [500,10871], // start end of region in cyl.s
  121.                               "use":true,  // mark as 'used' in inst_target_partition
  122.                               "type":`primary    
  123.                              ]
  124.                        ] ] ];
  125.   
  126.        // End TEST VALUES 
  127.     }
  128.  
  129.     // Get information about available partitions
  130.     list partition = get_partition_info( targetMap, true );
  131.     _debug("partition:", partition);
  132.  
  133.     // screen title for detailed software selection
  134.     locale title = _("Detailed Software Selection");
  135.  
  136.     list pacsels = [];
  137.     if ( lookup(user_settings, "test_mode", false) )
  138.     {
  139.     pacsels = filter(`sel,
  140.               Read("/lib/YaST2/pacsel/index.ycp"),
  141.               ``(select(sel, 1) != .paylist));
  142.     }
  143.     else
  144.     {
  145.     pacsels = filter(`sel,
  146.           Read("/var/adm/mount/suse/setup/descr/pacsel/index.ycp"),
  147.               ``(select(sel, 1) != .paylist));
  148.     }
  149.  
  150.     // Construct Box with Checkbox for each software category
  151.  
  152.     // Title of frame around "basic software"
  153.     term categories    = `VBox();
  154.     list baseconf  = [];
  155.  
  156.     foreach(`sel, pacsels, ``{
  157.     path   selid   = select(sel, 0);
  158.     path   group   = select(sel, 1);
  159.     map    langmap = select(sel, 2);
  160.  
  161.     string seldesc = translate(langmap, language );
  162.  
  163.     if ( group == .addon )
  164.     {
  165.        categories = add(categories, `Left(`CheckBox(`id(selid), `opt(`notify),
  166.             seldesc, contains(current_sel, selid))));
  167.     }
  168.     if ( group == .baseconf )
  169.     {
  170.        baseconf = add ( baseconf, selid );   
  171.     }
  172.     });
  173.     
  174.     // recognize the current selected baseconf ( .default, .Minimal, .All )
  175.     path software_group_path = .;
  176.     list software_group = [];
  177.     foreach(`sel, current_sel, ``{
  178.     if ( contains ( baseconf, sel ) )
  179.     {
  180.         software_group_path = sel;
  181.     }
  182.     });    
  183.     if ( size ( software_group_path ) > 0 )
  184.     {
  185.         software_group = add ( software_group, software_group_path );
  186.     }
  187.     _debug ( "Software_group = ", software_group );
  188.  
  189.  
  190.     categories = add(categories, `Label( " " ) );    // spacing
  191.     categories = add(categories, `Left(`CheckBox(`id(`sources),`opt(`notify),
  192.                          // Check box for installing all source code packages
  193.                          _("&Install available sources"),    // false ) ) );
  194.                              lookup(user_settings, "install_sources", false) ) ) );
  195.  
  196.     // get information about free disk space
  197.     required_partition = PKGINFO ( `getDiskSpace ( partition ) );
  198.  
  199.     
  200.     // Build and show dialog
  201.     term contents = `VBox(
  202.               `VWeight( 80, `VCenter( `HSquash( `Frame( _( "Categories" ), categories ) ) ) ),
  203.               `Label( `id(`free_space), sformat( UI(_("%1 remaining free space on hard disk")), GetFreeSpace( required_partition ) ) ),
  204.               `VWeight( 10, `HBox(
  205.                           `HWeight( 10, `HStretch() ),
  206.                           `HWeight( 35, `PushButton( `id(`sw_pay    ), `opt(`hstretch), _( "&Commercial software..."    ) ) ),
  207.                           `HWeight( 2, `HStretch() ),
  208.                           `HWeight( 35, `PushButton( `id(`sw_single ), `opt(`hstretch), _( "&Select single packages..." ) ) ),
  209.                           `HWeight( 10, `HStretch() )
  210.                           )
  211.                     ),
  212.               `VWeight( 10, `VStretch() )
  213.               );
  214.  
  215.     
  216.     // Explain additional software categories
  217.     // (E.g. Multimedia, Games, Development, ...).
  218.     // help part 1 of 3
  219.     string helptext = UI(_("<p>
  220. Select categories of software to install.
  221. </p>
  222.  
  223. <p>
  224. The basic system will always be installed. The software categories
  225. automatically include other system components as required,
  226. i.e. if you select a desktop like <i>KDE</i> or <i>GNOME</i>, the X
  227. Window System will automatically be installed.
  228. </p>"));
  229.     // help part 2 of 3
  230.     helptext = helptext + UI(_("<p>
  231. Software categories may overlap, i.e. there may be software packages
  232. that belong to <i>Multimedia</i> as well as to <i>KDE</i>.
  233. That's why the required disk space is not displayed along with the
  234. categories - the total disk space required depends on the combination
  235. of selected categories.
  236. </p>"));
  237.      // help part 3 of 3
  238.      helptext = helptext + UI(_("<p>
  239. SuSE Linux comes with all free sources, so you have the option to
  240. <b>install available sources</b> for selected components.  Please
  241. note: Sources are not available for commercial software.
  242. </p>
  243. <br>"));
  244.  
  245.     UI(`SetWizardContents(title, contents, helptext, Args(0),Args(1)));
  246.     
  247.     any ret = nil;
  248.     while (true)
  249.     {
  250.       ret = UI(`UserInput());
  251.  
  252.       if ( ret == `back || ret == `cancel )
  253.       {
  254.        break;  
  255.       }                  
  256.    
  257.  
  258.       current_sel = software_group;
  259.  
  260.       // Query the addon checkboxes
  261.  
  262.       foreach(`sel, filter(`ps, pacsels, ``(select(ps, 1) == .addon)), ``{
  263.       path id = select(sel, 0);
  264.       if (UI(`QueryWidget(`id(id), `Value)))
  265.           current_sel = add(current_sel, id);
  266.       });
  267.  
  268.       user_settings = add(user_settings, "softwaresel", current_sel);
  269.  
  270.       // .Minimal has no X11
  271.       if (contains(current_sel, .Minimal)
  272.       && (!(contains(current_sel, .Kde) || contains (current_sel, .Gnome))))
  273.       user_settings = add(user_settings, "have_x11", false);
  274.       else
  275.       user_settings = add(user_settings, "have_x11", true);
  276.  
  277.       user_settings = add(user_settings, "install_sources",
  278.                UI(`QueryWidget(`id(`sources), `Value)));
  279.  
  280.       // Get package-install-list for the preselected package-groups     
  281.       list package_list = CallFunction( `inst_pkg_toinstall( user_settings ) );    
  282.  
  283.       _debug ("Packages to install:", package_list );
  284.  
  285.  
  286.       // setting all packages to server pkginfo. If there was a single selected package 
  287.       // ( made in frame inst_single_select), this selection will not be reset.
  288.       // ( second parameter of setInstallSelection )
  289.       PKGINFO ( `setInstallSelection ( package_list, true ) );
  290.  
  291.       PKGINFO ( `setSourceInstallation(lookup(user_settings, "install_sources", false)) );
  292.  
  293.       if ( lookup(user_settings, "test_mode", false) )
  294.       { 
  295.          // TEST MODE !!!
  296.          // Check, if there is a unresolved dependency
  297.          map    pac_depends = $[];
  298.          list(map) or_depends = [];
  299.          list(map) xor_depends = [];
  300.          pac_depends = PKGINFO(`getDependencies());
  301.      _debug ( "TESTMODE: check-dependencies BEFORE solving" );  
  302.          or_depends = lookup( pac_depends, "OR" );
  303.          _debug( "OR Dependencies:", or_depends );
  304.          xor_depends = lookup( pac_depends, "XOR" );
  305.          _debug( "XOR Dependencies:", xor_depends );
  306.     list install_info =  PKGINFO ( `getInstallSet() );
  307.     _debug( "getInstallSet =",install_info );
  308.       }
  309.  
  310.       if ( ret == `sw_pay )
  311.       {
  312.        ret = CallFunction( `inst_sw_single( `pay, `not_only_checked ) );
  313.  
  314.        if ( ret == `ok || ret == `cancel )
  315.            ret = `again;
  316.            break;
  317.       }
  318.       else if ( ret == `sw_single )
  319.       {
  320.        ret = CallFunction( `inst_sw_single( `single, `not_only_checked ) );
  321.        
  322.        if ( ret == `ok || ret == `cancel )
  323.            ret = `again;
  324.            break;
  325.       }
  326.       
  327.       // Check, if there is a unresolved dependency
  328.       map    pac_depends = $[];
  329.       list(map) or_depends = [];
  330.       list(map) xor_depends = [];
  331.       pac_depends = PKGINFO(`getDependencies());
  332.        
  333.       or_depends = lookup( pac_depends, "OR" );
  334.       _debug( "OR Dependencies:", or_depends );
  335.       xor_depends = lookup( pac_depends, "XOR" );
  336.       _debug( "XOR Dependencies:", xor_depends );
  337.  
  338.       if ( or_depends != [] || xor_depends != [] )
  339.       {
  340.        // There is an unresolved dependency -> call single-package-selection
  341.       // to solve it ( only if user did any single selection before )
  342.       if ( PKGINFO( `isSingleSelected() ) )
  343.       {
  344.           CallFunction( `inst_sw_single( `single, `only_check ) );
  345.       }
  346.       else
  347.       {
  348.           y2log(.warning, "inst_sw_details", 1, sformat("Unresolved: OR: %1, XOR: %2", or_depends, xor_depends));
  349.       }
  350.       }
  351.  
  352.       if ( lookup(user_settings, "test_mode", false) )
  353.       {
  354.           // TEST MODE !!!
  355.          // Check, if there is a unresolved dependency
  356.          map    pac_depends = $[];
  357.          list(map) or_depends = [];
  358.          list(map) xor_depends = [];
  359.          pac_depends = PKGINFO(`getDependencies());
  360.      _debug ( "TESTMODE: check-dependencies AFTER solving" );  
  361.          or_depends = lookup( pac_depends, "OR" );
  362.          _debug( "OR Dependencies:", or_depends );
  363.          xor_depends = lookup( pac_depends, "XOR" );
  364.          _debug( "XOR Dependencies:", xor_depends );
  365.      list install_info =  PKGINFO ( `getInstallSet() );
  366.     _debug( "getInstallSet =",install_info );
  367.       }
  368.  
  369.  
  370.       // calculating size
  371.  
  372.       required_partition = PKGINFO ( `getDiskSpace ( partition ) );
  373.         
  374.       _debug("Required partitions :",required_partition );
  375.  
  376.       UI( `ChangeWidget( `id(`free_space), `Value, sformat( UI(_("%1 remaining free space on hard disk")), GetFreeSpace( required_partition ) ) ) );
  377.              
  378.       string message = "";
  379.  
  380.       // Construct a popup like:
  381.       // +-----------------------------------------------+
  382.       // | Partition / needs 200 KB more disk space.     |
  383.       // | Partition etc needs 40 MB more disk space.    |
  384.       // |                                               |
  385.       // | Please deselect some packages.                |
  386.       // +-----------------------------------------------+
  387.       foreach( `par, required_partition,
  388.            ``{ 
  389.         if ( lookup( par, "free", 0 ) < 0 )
  390.         {
  391.             message = message + sformat ( UI(_("Partition \"%1\" needs %2 more disk space.")),
  392.                                         lookup ( par, "name" ), UI( `size_text(lookup ( par, "free" ) * -1 *1024) ) ) + "\n";
  393.         }
  394.           } );            
  395.  
  396.       if ( size ( message ) > 0 )
  397.       {
  398.      message = message + "\n" +  UI(_("Please deselect some packages."));
  399.          _debug("Warning:", message );
  400.          UI(`DisplayMessage(message));
  401.       }
  402.       else
  403.       {
  404.          if ( ret == `next || ret == `again )
  405.      {
  406.              break;
  407.      }
  408.       }
  409.     }
  410.  
  411.     _debug ( "inst_sw_details return :", ret );
  412.  
  413.     return ret;
  414. }
  415.