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

  1. /**
  2.  * Module:         inst_sw_single.ycp
  3.  *
  4.  * Authors:        Gabriele Strattner <gs@suse.de>
  5.  *
  6.  * Purpose: 
  7.  * Called with `single:
  8.  * Provides a list of package sets on the left and the corresponding
  9.  * packages to a selected set on the right.
  10.  * A Table Widget is filled with the packages and the user can select
  11.  * the wanted ones. The selected packages are marked with "X". If needed 
  12.  * packages are shown in the list they are marked with an "a".
  13.  * The needed disk space is checked with every user input and is
  14.  * displayed.
  15.  * Called with `pay:
  16.  * Provides one set (pay) on left and all pay packages on right.
  17.  *            
  18.  *            
  19.  *
  20.  * user_settings read:    see module inst_pkg_toinstall
  21.  *            lookup( user_settings, "targets" )
  22.  *
  23.  * user_settings write:    see module inst_pkg_toinstall/inst_sw_detail
  24.  *
  25.  *
  26.  * $Id: inst_sw_single.ycp,v 1.43 2000/03/08 17:03:26 kkaempf Exp $
  27.  */ 
  28.  
  29.  
  30. {
  31.   any     ret = nil;
  32.   boolean retval = false;
  33.  
  34.   string  actual_set = "";    // actual selected set
  35.   string  actual_pac = "";    // actual selected package
  36.   map       set_pacs = $[];    // all packages belonging to selected set
  37.   map     all_sets = $[];    // all available package sets
  38.  
  39.   integer initial_used = 0;    // used disk space at begin of installation in bytes
  40.  
  41.   string descr_all = "zall";    // short description for all packages
  42.   string default_set = "a";    // first package list when entering dialog  
  43.   string pay_set = "pay";    // set commercial packages
  44.       
  45. map set_descr =
  46. $[
  47.   // We need a short (about 25 characters) description for all following sets
  48.   // ( Linux Base System to List of all Packages ).
  49.   //
  50.  // Linux Base System (You need it!)
  51.  "a":     UI(_("Linux Base System")), 
  52.  // Programs that don't need X
  53.  "ap":    UI(_("Programs without X")), 
  54.  // ApplixWare Office
  55.  "aplx": UI(_("ApplixWare Office")),
  56.  // Extreme Linux (Beowulf) 
  57.  "beo": UI(_("Extreme Linux (Beowulf)")),
  58.  // Development (C, C++, Lisp, etc.) 
  59.  "d":     UI(_("Development (C, C++, Lisp)")), 
  60.  // Documentation
  61.  "doc":  UI(_("Documentation")),
  62.  //  Emacs
  63.  "e":  UI(_("Emacs")), 
  64.  // Emulators
  65.  "emu": UI(_("Emulators")),
  66.  // Games and more
  67.  "fun": UI(_("Games and more")),
  68.  // GNOME - GNU Network Object Model Environment
  69.  "gnm": UI(_("GNOME")),          
  70.  // All about graphics
  71.  "gra": UI(_("All about graphics")),
  72.  //  Amateur Radio (AX.25, CW, Logs, etc.)
  73.  "ham": UI(_("Amateur Radio (AX.25, CW)")),
  74.  // K Desktop Environment
  75.  "kde": UI(_("K Desktop Environment")),
  76.  // KDE alpha applications
  77.  "kpa": UI(_("KDE alpha applications")),
  78.  // Network-Support (TCP/IP, UUCP, Mail, News)
  79.  "n":     UI(_("Network (TCP/IP, UUCP)")),
  80.  // Commercial Software
  81.  "pay": UI(_("Commercial Software")),
  82.  // Security related software
  83.  "sec": UI(_("Security")),
  84.  // Components for a SGML system
  85.  "sgm":  UI(_("Components for SGML")),
  86.  // Sound related stuff
  87.  "snd": UI(_("Sound related stuff")),
  88.  // Spell checking utilities and databases
  89.  "spl":  UI(_("Dictionaries")),
  90.  // SuSE internal Software
  91.  "suse":  UI(_("SuSE internal Software")),
  92.  // Tcl/Tk/TclX, Tcl-Language and Tk-Toolkit for X
  93.  "tcl":  UI(_("Tcl/Tk/TclX")),
  94.  // TeX/LaTeX and applications
  95.  "tex":  UI(_("TeX/LaTeX and appl.")),
  96.  // Base X Window System - XFree86\tm 3.3
  97.  "x":     UI(_("Base X Window System")),
  98.  // 3D stuff for X11 and console
  99.  "x3d": UI(_("3D stuff for X11")),
  100.  // X Applications
  101.  "xap": UI(_("X Applications")),
  102.  // Development under X11
  103.  "xdev": UI(_("Development under X11")),
  104.  //Several X Servers (XFree86\tm 3.3 and other)
  105.  "xsrv": UI(_("X Servers (XFree86[tm]")), 
  106.  // XView (OpenLook, Applications)
  107.  "xv":    UI(_("XView (OpenLook)")),
  108.  // Window Manager and Desktop
  109.  "xwm":  UI(_("Window Manager")),
  110.  //Additional packets for SuSE Linux IMAP Server
  111.  "zima":  UI(_("SuSE IMAP Server")),
  112.  // Source packages
  113.  "zq":     UI(_("Source packages")),
  114.  // All packages
  115.  "zall": UI(_("List of all Packages"))
  116. ];
  117.  
  118.   //
  119.   // Get packages belonging to selected "set" and create input for Table Widget
  120.   //
  121.   // map set_pacs:
  122.   // $["aaa_base":["SuSE Linux Basispaket", "X"], "aaa_dir":["SuSE Linux Verzeichnisstruktur", "a"], ...
  123.   //         key : value    0                1      
  124.   // Create table input, e.g.
  125.   // [ `item( `id("aaa_base"), "X", "aaa_base", "SuSE Linux base package", "45.34 MB" ), ... ]
  126.  
  127.   define CreatePacTable( string set ) ``{
  128.  
  129.       list table_input = [];
  130.       set_pacs = $[];
  131.       
  132.       // Get list of packages belonging to selected set
  133.       if ( set != descr_all )
  134.       {
  135.       set_pacs = PKGINFO( `getHierarchyInformation( set ) );
  136.       }
  137.       else
  138.       {
  139.           set_pacs = PKGINFO( `getPackageList( ) );
  140.       }
  141.  
  142.       table_input = maplist( `key, `value,
  143.                  set_pacs,
  144.                  ``(`item(`id(key), select(value,1), key, select(value,0), my_size_text(select(value,2)*1024) )) );
  145.                  
  146.       return ( table_input );
  147.   };
  148.  
  149.   //
  150.   // Update single lines in table  
  151.   //
  152.   
  153.   define UpdateTable( string set ) ``{
  154.       map upd_pacs = $[];
  155.  
  156.       // Get list of packages belonging to selected set with new status information
  157.       if ( set != descr_all )
  158.       {
  159.       upd_pacs = PKGINFO( `getHierarchyInformation( set ) );
  160.       }
  161.       else
  162.       {
  163.       upd_pacs = PKGINFO( `getPackageList( ) );
  164.       }
  165.       
  166.       // map set_pacs:
  167.       // $["aaa_base":["SuSE Linux Basispaket", "X"], "aaa_dir":["SuSE Linux Verz.", "a"], ...
  168.       //         key : value    0                1                
  169.  
  170.       list old_value = [];
  171.       
  172.       maplist( `key, `value, upd_pacs, ``({
  173.  
  174.       old_value = lookup( set_pacs, key );
  175.       
  176.       if ( select( old_value, 1 ) != select(value, 1) )
  177.       {
  178.           _debug( "Update line: ", old_value );
  179.           UI( `ChangeWidget(`id(`pac_table), `Item( key, 0 ), select(value, 1) ) );
  180.           
  181.       } } ) );
  182.  
  183.       set_pacs = upd_pacs;    // save new status info 
  184.   };
  185.   
  186.   //
  187.   // Create input for table partition info  
  188.   //
  189.  
  190.   define CreatePartTable( list part_info ) ``{
  191.   
  192.       list part_input = [];
  193.  
  194.       foreach( `part, part_info,
  195.             ``{
  196.              string part_name = lookup( part, "name" ); 
  197.          integer free_space   = lookup( part, "free" );      
  198.  
  199.          term a = `item(`id(part_name), part_name, UI( `size_text( free_space*1024)) );      
  200.  
  201.          part_input = add( part_input, a );
  202.       } );  
  203.  
  204.       return( part_input );
  205.   };
  206.  
  207.   //
  208.   // Select a package
  209.   //
  210.  
  211.   define SelectPac( string package ) ``{
  212.       string msg = "";
  213.       
  214.       any r = PKGINFO( `selectInstall( package ));
  215.       _debug( "PKGINFO selectInstall: ", package );
  216.  
  217.       msg = PKGINFO( `getNotifyDesc( package ) );
  218.       if ( msg != "" )
  219.       {
  220.       string nty_title = "                " + UI(_("Notify")) + "                ";
  221.       term msg_text = `RichText( "<p>" + package + "</p>" + "<p>" + msg + "</p>" );
  222.        UI( `DisplayHelpMsg( nty_title, msg_text, false) ); 
  223.       }
  224.   };
  225.  
  226.   //
  227.   // Deselect a package
  228.   //
  229.  
  230.   define DeselectPac( string package ) ``{
  231.       string msg = "";
  232.       
  233.       any r = PKGINFO( `deselectInstall( package ));
  234.       _debug( "PKGINFO deselectInstall: ", package );
  235.  
  236.       msg = PKGINFO( `getDelDesc( package ) );
  237.       if ( msg != "" )
  238.       {
  239.       string wrn_title = "                " + UI(_("Warning")) + "                ";
  240.       term msg_text = `RichText( "<p>" + package + "</p>" + "<p>" + msg + "</p>" );
  241.        UI( `DisplayHelpMsg( wrn_title, msg_text, true) ); 
  242.       }
  243.   };
  244.   
  245.   //
  246.   // Calculate required disk space
  247.   //
  248.   
  249.   define GetRequSpace(  list part_info, boolean initialize ) ``{
  250.  
  251.       integer used = 0;
  252.       foreach( `part, part_info,
  253.             ``{
  254.          used = used + lookup( part, "used" );
  255.       } );  
  256.       
  257.       if ( initialize )
  258.       {
  259.       initial_used = used;    // store initial value for used space
  260.       return ( UI( `size_text( used*1024 )) );
  261.       }
  262.       else
  263.       {
  264.       return ( UI( `size_text( (used-initial_used)*1024 )) );
  265.       }
  266.   };
  267.  
  268.   //
  269.   // Returns nice size string
  270.   //
  271.   define my_size_text (integer bytes) ``{
  272.  
  273.       if ( bytes == nil )
  274.       return "";
  275.       
  276.       float whole = tofloat (bytes) / 1024.0 / 1024.0;
  277.       string unit = UI(_("MB"));
  278.  
  279.       // nnn.nn  999.99 MB
  280.       
  281.       string size_str = tostring (whole, 2);
  282.       integer num = size(size_str);
  283.       integer anz = 6 - num;
  284.  
  285.       if ( anz <= 0 )
  286.       {
  287.       return ( size_str + " " + unit );
  288.       }  
  289.       else if ( anz == 1 )
  290.       {
  291.       return ( " " + size_str + " " + unit );
  292.       }
  293.       else
  294.       {
  295.       return ( "  " + size_str + " " + unit );
  296.       }  
  297.   };
  298.       
  299.   //
  300.   // Popup displays helptext
  301.   //
  302.  
  303.   UI( ``{
  304.       define DisplayHelpMsg( string headline, term helptext, boolean color ) ``{
  305.  
  306.       if ( color )
  307.       {
  308.           OpenDialog( `opt ( `decorated, `warncolor ),
  309.               `VBox (`Heading( headline ),
  310.                  helptext,    // e.g. `Richtext()
  311.                  `PushButton( `opt(`default), _("OK") )
  312.                  )
  313.               );
  314.       }
  315.       else
  316.       {
  317.           OpenDialog(`opt ( `decorated ),
  318.              `VBox (`Heading( headline ),
  319.                 helptext,    // e.g. `Richtext()
  320.                 `PushButton( `opt(`default), _("OK") )
  321.                 )
  322.              ); 
  323.       }
  324.       
  325.       any r = UserInput();
  326.       CloseDialog();
  327.       return (r);
  328.       };
  329.   });
  330.   
  331.   //
  332.   // Get dependencies from pkginfo + display popup OR / XOR dependencies.
  333.   // 
  334.   // $["AND": , "OR":[$["name":"example1", "packages":["aaa", "bbb", "ccc"]],
  335.   //                  $["name":"example2", "packages":["aaa", "abc", "ddd"]]], "XOR":[]]
  336.   //
  337.   // We do not show all OR/XOR Popups in one loop but only the first dependency, because
  338.   // after a new check with getDependencies some dependencies could be resolved.
  339.   //
  340.   
  341.   define CheckDependencies( ) ``{ 
  342.       repeat {
  343.       map    pac_depends = $[];
  344.       list(map) or_depends = [];
  345.  
  346.       pac_depends = PKGINFO(`getDependencies());
  347.       _debug( "Dependencies:", pac_depends );
  348.         
  349.       or_depends = lookup( pac_depends, "OR" );
  350.  
  351.       if ( or_depends != [] )
  352.       {
  353.           map first_dep = select( or_depends, 0 );    // get first dependency
  354.  
  355.           list pac_list = lookup( first_dep, "packages" );
  356.           string pac_name = lookup( first_dep, "name" );
  357.           // _debug( "first package list: ", pac_list );
  358.  
  359.           list or_table = [];
  360.         
  361.           foreach( `pac, pac_list, ``{
  362.           or_table = add( or_table, `item(`id(pac), pac, PKGINFO(`getShortDesc(pac))) );
  363.           }
  364.                );
  365.           // The user have to choose an additional package from a package list
  366.           any ret = UI(`DisplayOrList( _("Additional package required"),
  367.                        sformat( UI(_("Package \"%1\" requires an additional package.\nPlease select one from list below.")),
  368.                             pac_name ), or_table ) );
  369.  
  370.           if ( ret == nil ) break;
  371.  
  372.           if ( ret != 0 )
  373.           {
  374.           // DisplayOrList returns selected package
  375.           SelectPac( ret );
  376.           
  377.           //any r = PKGINFO( `selectInstall( ret ));
  378.           //_debug( "PKGINFO selectInstall: ", ret );
  379.           }
  380.           else if ( ret == 0 )
  381.           {
  382.           // User decides to cancel that OR dependency
  383.           any r =  PKGINFO( `deleteOrDependencies( pac_name, pac_list ) );
  384.           _debug( "PKGINFO deleteOrDependencies: ", pac_name, pac_list );
  385.           }
  386.       }
  387.       } until ( or_depends == [] );
  388.  
  389.       repeat {
  390.         
  391.       map    pac_depends = $[];
  392.       list(map) xor_depends = [];
  393.         
  394.       pac_depends = PKGINFO(`getDependencies());
  395.       _debug("Dependencies: ", pac_depends );
  396.       
  397.       xor_depends = lookup( pac_depends, "XOR" );
  398.       _debug( "XOR Dependencies:", xor_depends );
  399.  
  400.       if ( xor_depends != [] )
  401.       {
  402.           map first_dep = $[];
  403.  
  404.           // If actual_pac is in XOR-list display that dependency first 
  405.           foreach ( `pac, xor_depends, ``{
  406.           if ( lookup( pac, "name") == actual_pac ) 
  407.               first_dep = pac;
  408.           } );
  409.           // Dependencies are not direct related to actual_pac
  410.           if ( first_dep == $[] )
  411.           {
  412.           first_dep = select( xor_depends, 0 ); // get first
  413.           }
  414.           
  415.           string pac_name = lookup( first_dep, "name" );
  416.           list pac_list = lookup( first_dep, "packages" );
  417.           _debug( "first package list: ", pac_list );
  418.  
  419.           // This popup is shown if packages cannot installed together
  420.           string msg_str = sformat( UI(_("Package \"%1\" interferes with:\n")), pac_name );
  421.         
  422.           foreach ( `pac, pac_list, ``{
  423.           msg_str = msg_str + sformat("\"%1\"\n", pac );
  424.           } );
  425.           // question to user: install package anyway or not?
  426.           msg_str = msg_str + sformat(UI(_( "Do you want to install package \"%1\"")), pac_name );
  427.  
  428.           // Headline of the popup Package ... interferes with ...
  429.           any ret = UI(`DisplayXorList( _("Package conflict"), msg_str ) );
  430.  
  431.           if ( ret == `yes_install ) // install package anyway and forget dependencies
  432.           {
  433.           foreach( `pac, pac_list, ``{
  434.               any r =  PKGINFO( `deleteXorDependencies( pac_name, pac ));
  435.               _debug( "PKGINFO deleteXorDependencies: ", pac_name, pac );
  436.               r =  PKGINFO( `deleteXorDependencies( pac, pac_name ));
  437.               _debug( "PKGINFO deleteXorDependencies: ", pac, pac_name );
  438.           } );
  439.  
  440.           if ( pac_name != actual_pac )
  441.           {
  442.               SelectPac( pac_name );
  443.               
  444.               //any r = PKGINFO( `selectInstall( pac_name ));
  445.               //_debug( "PKGINFO selectInstall: ", pac_name );
  446.           }
  447.           }
  448.           else if ( ret == `no_let_it )  // do not install package
  449.           {
  450.           if ( !contains( lookup( pac_depends, "AND" ), pac_name ) )
  451.           {
  452.               // package is NOT automatically selected -> deselect it
  453.               DeselectPac( pac_name );
  454.               
  455.               //any r = PKGINFO( `deselectInstall( pac_name ));
  456.               //_debug( "PKGINFO deselectInstall: ",  pac_name );
  457.  
  458.           }
  459.           else
  460.           {
  461.               // package will be selected again - delete it or install it?
  462.               string yesorno = sformat(UI(_("\
  463. \"%1\" is an automatically selected package,\n\
  464. that means another package depends on it.\n\
  465. Shall YaST2 remove it from installation list?\n\
  466. YES will deselect the package\n\
  467. NO  will install it")), pac_name );
  468.  
  469.               any r = UI( `YesOrNo( yesorno, _("&Yes"), _("&No") ) );
  470.               if ( r == true )
  471.               {
  472.               PKGINFO( `deleteAndDependencies( pac_name ));
  473.               _debug( "PKGINFO deleteAndDependencies: ", pac_name );
  474.  
  475.               DeselectPac( pac_name );
  476.               
  477.               //any r = PKGINFO(`deselectInstall(pac_name));
  478.               //_debug( "PKGINFO deselectInstall: ", pac_name );
  479.               
  480.               }
  481.               else
  482.               {
  483.               foreach( `pac, pac_list, ``{
  484.                   any r =  PKGINFO( `deleteXorDependencies( pac_name, pac ));
  485.                   _debug( "PKGINFO deleteXorDependencies: ", pac_name, pac );
  486.                   r =  PKGINFO( `deleteXorDependencies( pac, pac_name ));
  487.                   _debug( "PKGINFO deleteXorDependencies: ", pac, pac_name );
  488.               } );
  489.               }
  490.           }
  491.           }
  492.       }
  493.       } until ( xor_depends == [] );
  494.   };
  495.  
  496.   
  497.   //
  498.   // Popup displays the OR dependencies
  499.   //
  500.  
  501.   UI( ``{
  502.       define DisplayOrList(string popup_label, string list_label, list table_contents) ``{
  503.           OpenDialog(`opt( `decorated),
  504.                      `VBox( `Heading( popup_label ),
  505.                 `Label( list_label ),
  506.                 `VBox( `Table( `id(`table_or),
  507.                        // This is a popup with a list of several packages.
  508.                        // The list has 2 colums, the name and the package description.
  509.                        // The user should  choose a package.
  510.                        `header( _("Name"), _("Description") ),
  511.                        table_contents ),
  512.                    // user cancels dialog und must decide later
  513.                    `HBox( `PushButton( `id(`cancel), _("Cancel") ),
  514.                       // the user doesnt want a package from list
  515.                       `PushButton( `id(`none), _("None") ),
  516.                                           `PushButton( `id(`ready), `opt(`default), _("OK") )
  517.                                           )
  518.                                    )
  519.                             )
  520.                      );
  521.  
  522.           any r = UserInput();
  523.  
  524.               if ( r == `cancel )
  525.               {
  526.                   CloseDialog();
  527.                   return nil;
  528.               }
  529.               else if ( r == `ready )
  530.               {
  531.                   any ret = QueryWidget( `id(`table_or), `CurrentItem );
  532.                   CloseDialog();
  533.                   return( ret );
  534.               }
  535.               else if ( r == `none )
  536.               {
  537.                   CloseDialog();
  538.                   return ( 0 );
  539.               }
  540.           else
  541.           {
  542.           CloseDialog();
  543.           return ( r );
  544.           }
  545.       };
  546.   });
  547.  
  548.   //
  549.   // Popup display XOR dependencies
  550.   //
  551.  
  552.   UI( ``{
  553.      define DisplayXorList(string popup_label, string popup_contents ) ``{
  554.      OpenDialog(`opt(`decorated), 
  555.              `VBox( `Heading( popup_label ),
  556.                 `VBox( `Label( popup_contents ),
  557.                    // This is a popup with message "package1 interferes with package2".
  558.                    // The question is: do not install package 1 or install it anyway!
  559.                    `HBox( `PushButton( `id(`no_let_it), `opt(`default), _("No installation") ),
  560.                       `PushButton( `id(`yes_install),  _("Install it anyway") )
  561.                       )
  562.                    )
  563.                 )
  564.              );
  565.           any r = UserInput();
  566.           CloseDialog();
  567.           return (r);
  568.       };
  569.   });
  570.  
  571.   //
  572.   // Initialize PKGINFO server -> all initialisation is done in former modules
  573.   //
  574.  
  575.   //
  576.   // Get info about targets and partitions
  577.   //
  578.   
  579.   map targetMap = lookup( user_settings, "targets", $[] );
  580.  
  581.    if ( lookup(user_settings, "test_mode", false) == true )
  582.    {
  583.        // TEST VALUES !!!
  584.     targetMap = $[
  585.               "/dev/sda":$[
  586.                        "bus":"SCSI",
  587.                        "name":"1. SCSI, 8.54 GB, /dev/sda, IBM-DNES-309170W",
  588.                        "cyl_count":1114,                               
  589.                        "cyl_size":8224768,                            
  590.                        "vendor":"IBM DNES-309170W",                      
  591.                        "partitions":[
  592.                              $["fsid":131,    // YES: mount
  593.                               "mount":"/boot",        
  594.                               "fstype":"Linux native",
  595.                               "nr":1,
  596.                               "region":[1, 254],
  597.                               "type":`primary],
  598.                              $["delete":true,    // NO: no mount
  599.                                "fsid":130,
  600.                               "fstype":"Linux swap",
  601.                               "nr":2,
  602.                               "region":[255, 299],
  603.                               "type":`primary],
  604.                              $["create":false,    // NO: create false
  605.                                "fsid":131,
  606.                               "mount":"/var",
  607.                               "fstype":"Linux native",
  608.                               "nr":3,
  609.                               "region":[300, 499],
  610.                               "type":`primary],
  611.                              $["create":true,      // YES: create true + mount  
  612.                                "fsid":131,
  613.                                "mount":"/",
  614.                                "nr":4,
  615.                                "format":true,
  616.                                "region":[500, 844],
  617.                                "type":`primary
  618.                              ]
  619.                        ]
  620.               ],
  621.               "/dev/sdb":$[
  622.                        "bus":"SCSI",
  623.                        "name":"1. SCSI, 8.54 GB, /dev/sda, IBM-DNES-309170W",
  624.                        "cyl_count":11141,                               
  625.                        "cyl_size":8224768,                            
  626.                        "vendor":"IBM DNES-309170-XEW",                      
  627.                        "partitions":[
  628.                              $["fsid":131,        // NO: nothing
  629.                               "fstype":"Linux native",
  630.                               "nr":1,
  631.                               "region":[1, 254],
  632.                               "type":`primary],
  633.                              $["create":true,        // NO: no mount
  634.                                "fsid":130,
  635.                               "fstype":"Linux swap",
  636.                               "nr":2,
  637.                               "region":[255, 299],
  638.                               "type":`primary],
  639.                              $["delete":true,        // NO: delete false
  640.                                "fsid":131,
  641.                               "mount":"/var",
  642.                               "fstype":"Linux native",
  643.                               "nr":3,
  644.                               "region":[300, 499],
  645.                               "type":`primary],
  646.                              $[ "delete":false,          // YES: delete true
  647.                                "fsid":130,
  648.                               "mount":"/usr",
  649.                               "fstype":"Linux swap", // user-visible string
  650.                               "nr":4,    // partition number, as seen by linux (!)
  651.                               "region": [500,10871], // start end of region in cyl.s
  652.                               "use":true,  // mark as 'used' in inst_target_partition
  653.                               "type":`primary    
  654.                              ]
  655.                        ] ] ];
  656.   
  657.        // End TEST VALUES 
  658.   }
  659.  
  660.   // Get information about available partitions
  661.   list partition = get_partition_info( targetMap, true );
  662.  
  663.   _debug( "PartitionInfo: ", partition);
  664.       
  665.   // initialize used space at begin of installation
  666.   GetRequSpace( partition, true );    
  667.   
  668.   // initialisation of pkginfo is done by inst_sw_select
  669.  
  670.   //
  671.   // OpenDialog with set "a" for Single or set "pay" for Pay Selection  
  672.   //
  673.  
  674.   list set_input = [];
  675.  
  676.   if (  Args(0) == `single )
  677.   {
  678.       actual_set = default_set;
  679.  
  680.       all_sets  = PKGINFO(`getHierarchyInformation( ));
  681.       all_sets = add( all_sets, descr_all, [] );    // add "zall"
  682.       foreach( `set, `value, all_sets,
  683.            ``{
  684.                 term a = `item(`id(set), set, lookup( set_descr, set ) );      
  685.             set_input = add( set_input, a );
  686.       } );
  687.   }
  688.   else
  689.   {
  690.       actual_set = pay_set;
  691.  
  692.       term a = `item(`id(actual_set), actual_set, lookup( set_descr, actual_set ) );
  693.       set_input = add( set_input, a );
  694.       
  695.   }
  696.  
  697.   list(map) partition_info = PKGINFO ( `getDiskSpace ( partition ) );
  698.  
  699.   list part_input = CreatePartTable( partition_info );
  700.  
  701.   string headline = "";
  702.   
  703.   if ( Args(0) == `single )
  704.   {
  705.       // title dialog Software Single Selection
  706.       headline = UI(_("Software Single Selection"));
  707.   }
  708.   else
  709.   {
  710.       // title dialog Commercial Package Selection
  711.       headline = UI(_("Commercial Package Selection"));
  712.   }
  713.  
  714.   UI( `OpenDialog(`opt(`defaultsize),
  715.           `VBox( `ReplacePoint( `id(`image) ,`Image(`suseheader, "SuSE") ),
  716.              `Heading(headline),
  717.              `HBox(
  718.                    // headline selection box package sets
  719.                    // (the box isn't wide, please keep it short (up to 20 characters)
  720.                    `HWeight( 30, `HCenter( `Label( _("Please select a set") ) ) ),
  721.                    // headline selection box packages belonging to selected set
  722.                    `HWeight( 70, `HCenter( `Label( _("Please select or deselect a package with double click") ) ) )
  723.                    ),
  724.              `HBox(
  725.                    `HWeight( 30, `VBox(
  726.                            `VWeight( 70, `Table( `id(`set_table), `opt(`notify, `immediate, `vshrinkable),
  727.                                      // The short description of the package set e.g. "dev", "x".
  728.                                      // Please keep it short, it's a column header ( up to 6 chars )
  729.                                      `header( _("Set"), _("Description") ),
  730.                                      set_input        ) ),
  731.                            `VWeight( 22, `Table( `id(`part_table), `opt(`vshrinkable), 
  732.                                      `header( _("Partition"), _("Free space")),
  733.                                      part_input ) ),
  734.                            `VWeight( 10,  `VBox(
  735.                                        `Left ( `Label(`id(`req_space), sformat(UI(_("Required: %1")),
  736.                                                            GetRequSpace(partition_info, false))
  737.                                               )
  738.                                            ),
  739.                                        `VStretch()
  740.                                        )
  741.                                  )
  742.                            )
  743.                      ),
  744.                    `HWeight( 70, `VBox( `Table( `id(`pac_table), `opt(`notify ),
  745.                                 `header( "  ", _("Package"), _("Description"), `Right(_("Size") )),
  746.                                 CreatePacTable( actual_set ) ),
  747.                             `HBox(
  748.                               `Left(`HWeight( 10, ( `PushButton(`id(`descr), `opt(`default), _("&Description"))) )),
  749.                               `Right(`HWeight( 10, ( `PushButton(`id(`single_help), _("&Help") ) )))
  750.                               )
  751.                             )    
  752.                      )
  753.                    ),
  754.  
  755.              `HBox( `HWeight( 10, `Left( `PushButton(`id(`cancel), _("&Cancel"))) ),
  756.                 `HWeight( 10, `Right(`PushButton(`id(`ok), _("&OK") ))  )
  757.                 )
  758.              )
  759.           )
  760.      );
  761.  
  762.   SetWizardStage( 3, true );
  763.  
  764.   //
  765.   // save state solver and dependencies in case of `cancel
  766.   //
  767.   retval = PKGINFO( `saveState() );
  768.   _debug( "return saveState: ", retval );
  769.  
  770.   //
  771.   // Check dependencies ( maybe there are some unresolved dependencies )
  772.   // 
  773.   if ( PKGINFO( `isSingleSelected() ) )
  774.   {
  775.       CheckDependencies();
  776.   }
  777.       
  778.   if ( Args(1) == `only_check )
  779.   {
  780.       UI( `CloseDialog() );
  781.  
  782.       // Delete saved information in pkginfo
  783.       retval = PKGINFO( `deleteOldState() );
  784.       return `ok;
  785.   }
  786.   
  787.   while (true)
  788.   {
  789.      ret = UI(`UserInput());
  790.  
  791.      if ( ret == `set_table ) 
  792.      {
  793.     term     set_line = `item();
  794.      
  795.         // Get selected set
  796.         actual_set = UI(`QueryWidget(`id(`set_table), `CurrentItem));
  797.  
  798.     list new_input = CreatePacTable( actual_set );
  799.  
  800.     UI( `ChangeWidget(`id(`pac_table), `Items, new_input) );
  801.      }
  802.      else if ( ret == `pac_table )
  803.      {
  804.         // Get information about selected line (package)
  805.     any id = UI( `QueryWidget(`id(`pac_table), `CurrentItem) );
  806.  
  807.     // notify vom TableWidget kommt anscheinend nach Neuaufbau (ChangeWigdet) nochmal
  808.     // QueryWidget liefert dann nil
  809.     if ( id != nil )
  810.     {
  811.     term  table_line = UI( `QueryWidget(`id(`pac_table), `Item(id)) );
  812.  
  813.     actual_pac = select( table_line, 2 );
  814.     _debug( "Actual selected package: ", actual_pac );
  815.     
  816.     if ( ( select(table_line, 1) == "X" ) )
  817.     {
  818.         DeselectPac( actual_pac );
  819.         
  820.         //retval = PKGINFO(`deselectInstall( actual_pac ));
  821.         //_debug( "PKGINFO deselectInstall: ", actual_pac );
  822.  
  823.     }
  824.     else if ( ( select(table_line, 1) == "a") )
  825.     {
  826.         any r = UI(`YesOrNo(_("\
  827. This is an automatically selected package,\n\
  828. that means another package depends on it.\n\
  829. Do you really want to deselect it?"), _("&Yes"), _("&No") ) );
  830.         _debug( "YesOrNo ", r );
  831.         if ( r == true )
  832.         {
  833.         PKGINFO( `deleteAndDependencies( actual_pac ));
  834.         _debug( "PKGINFO deleteAndDependencies", actual_pac );
  835.  
  836.         DeselectPac( actual_pac );
  837.         
  838.         //PKGINFO( `deselectInstall( actual_pac ));
  839.         //_debug( "PKGINFO deselectInstall", actual_pac );
  840.         
  841.         }
  842.     }
  843.     else    // package is not selected 
  844.     {
  845.         SelectPac( actual_pac );
  846.         
  847.         //any r = PKGINFO( `selectInstall( actual_pac ));
  848.         //_debug( "PKGINFO selectInstall", actual_pac );
  849.     }
  850.     
  851.     //
  852.     // Get dependencies from pkginfo + display popup OR / XOR dependencies.
  853.     // 
  854.     if ( PKGINFO( `isSingleSelected() ) )
  855.     {
  856.         CheckDependencies();
  857.     }
  858.     
  859.     // Update disk space information
  860.     list(map) partition_info = PKGINFO ( `getDiskSpace ( partition ) );
  861.  
  862.     list new_part_input = CreatePartTable( partition_info );
  863.     UI( `ChangeWidget(`id(`part_table), `Items, new_part_input) );    
  864.  
  865.     UI( `ChangeWidget(`id(`req_space), `Value, sformat(UI(_("Required: %1")), GetRequSpace( partition_info, false ))) );
  866.  
  867.     _debug( "RequSpace: ", GetRequSpace( partition_info, false ) );
  868.     
  869.     // Warning message if free space < 0 
  870.     string message = "";
  871.     foreach( `par, partition_info,
  872.             ``{
  873.                 if ( lookup( par, "free", 0 ) < 0 )
  874.                 {
  875.             integer needed = lookup (par, "free") * -1;
  876.             message = message + sformat ( UI(_("Partition \"%1\" needs %2 more disk space.")),
  877.                                         lookup ( par, "name" ), UI( `size_text(needed*1024) ) ) + "\n";
  878.                 }
  879.               } );
  880.   
  881.     if ( size ( message ) > 0 )
  882.     {
  883.         UI(`DisplayMessage(message));
  884.     }
  885.     
  886.     // Update single lines in table widgets ( new status )     
  887.     UpdateTable( actual_set );
  888.  
  889.     }    
  890.      }
  891.      else if (ret == `single_help)
  892.      {
  893.      term help = `id();
  894.      string help_part = "";
  895.  
  896.      if ( Args(0) == `single )
  897.      {
  898.          // helptext1 for dialog software single selection
  899.          // help1 part 1 of 6
  900.          help_part = UI(_("\
  901. <p>
  902. This dialog is devided into two sections: \n
  903. on the left a list with all available <b>package
  904. sets</b> and information about disk space, on the
  905. right a list with <b>every package</b>
  906. belonging to selected set. 
  907. </p>") );
  908.          // help1 part 2 of 6
  909.          help_part = help_part + UI(_("\
  910. <p>
  911. With your basic selection <i>Minimal</i>,<i>Default</i>
  912. or <i>Almost everything</i> and your choice from
  913. categories <i>Multimedia</i>, <i>Games</i> and so on, a number
  914. of packages is preselected.
  915. Now you have the possibility to make your
  916. own decision about installing a certain
  917. package or not.
  918. YaST2 will show you the totally <b>required space</b>
  919. for all selected packages and
  920. <b>free</b> space on every partitions with
  921. every change. 
  922. </p>") );
  923.           // help1 part 3 of 6
  924.          help_part = help_part + UI(_("\
  925. <p>
  926. How to do:
  927. </p>
  928. <p>
  929. <tt>1.</tt> Select a package set in list on
  930. left and YaST2 will show the corresponding
  931. packages with status information:
  932. </p>
  933. <p>
  934. <b>X</b> : package is selected for installation
  935. </p>
  936. <p>
  937. <b>_</b> : package is not selected
  938. </p>
  939. <p>
  940. <b>a</b> : YaST2 has automatically selected this
  941.            package because another selected package
  942.            depends on it
  943. </p>" ) );
  944.           // help1 part 4 of 6
  945.          help_part = help_part + UI(_("\
  946. <p>
  947. <tt>2.</tt> To select an additional package for
  948. installation double click on corresponding line in package
  949. list. You can also remove a selected package from
  950. installation list.
  951. YaST2 will always check the dependencies, that means
  952. all needed packages will automatically marked with
  953. an <b>a</b> and all unneeded will be deselected.
  954. </p>" ) );
  955.          // help1 part 5 of 6
  956.          help_part = help_part + UI(_("\
  957. <p>
  958. <tt>3.</tt> For some packages you need at least one of
  959. several other packages. In that case you can choose
  960. from a list in popup <em>Additional package required</em>.
  961. Please note: The package shown in popup is possibly
  962. not the selected one, but an automatically needed one.\n
  963. Other packages cannot be installed together. They 
  964. are shown in <em>Package conflict</em> popup and you
  965. can decide whether to install the package or not.
  966. </p>" ));
  967.          // help1 part 6 of 6
  968.          help_part = help_part + UI(_("<p>
  969. For getting a detailed description for each package
  970. press button <b>Description</b>.
  971. With button <b>Cancel</b> you will return to
  972. <b>Detailed Software Selection</b> without saving
  973. any of your choices, <b>OK</b> will save your selection.
  974. </p>
  975. <br>" ));
  976.  
  977.          help = `RichText( help_part );
  978.          // title for popup with helptext
  979.          string help_title = "                    " + UI(_("Help Software Single Selection")) + "                      ";
  980.          
  981.          UI( `DisplayHelpMsg( help_title, help, false ) );
  982.      }
  983.      else
  984.      {
  985.              // helptext2 for dialog pay selection
  986.              // help2 part 1 of 2
  987.          help_part = help_part + UI(_("<p>
  988. Here you can choose which commercial packages should
  989.  be installed.
  990. </p>
  991. <p>
  992. Beware. Not all packages are full-featured versions, some require a
  993. registration, some are time-limited.
  994. </p>
  995. <p>
  996. You can select an package by clicking on corresponding line or
  997. deselect a marked one.
  998. </p>
  999. <p> The packages are shown with status information:
  1000. </p>
  1001. <p>
  1002. <b>X</b> : package is selected for installation
  1003. </p>
  1004. <p>
  1005. <b>_</b> : package is not selected
  1006. </p>
  1007. <p>
  1008. <b>a</b> : YaST2 has automatically selected this
  1009.            package because another selected package
  1010.            depends on it
  1011. </p>" ) );
  1012.          // help2 part 2 of 2
  1013.          help_part = help_part +  UI(_("\
  1014. <p>
  1015. For getting a detailed description for each package
  1016. press Button <b>Description</b>.
  1017. With button <b>Cancel</b> you will return to
  1018. <b>Detailed Software Selection</b> without saving
  1019. any of your choices, <b>OK</b> will save your selection.
  1020. </p>
  1021. <br>") );
  1022.          help = `RichText( help_part );
  1023.          // title for popup with help text
  1024.          string help_title = "                   " + UI(_("Help Commercial Package Selection")) + "                   ";
  1025.          UI( `DisplayHelpMsg( help_title, help, false ) );
  1026.         
  1027.      }
  1028.      
  1029.      }
  1030.      else if (ret == `descr )
  1031.      {
  1032.      any sel_pac = UI(`QueryWidget(`id(`pac_table), `CurrentItem));
  1033.  
  1034.      if (sel_pac != nil)
  1035.      {
  1036.          term long_desc = `RichText( sformat( "<p> %1 </p>",
  1037.                           PKGINFO(`getLongDesc( sel_pac )) ) );
  1038.          UI( `DisplayHelpMsg( sformat( "                       %1                       ", sel_pac ), long_desc, false ) );
  1039.      }
  1040.      }
  1041.      else if (ret == `cancel)
  1042.      {
  1043.      // Restore old selection and former dependencies
  1044.      retval = PKGINFO( `restoreState() );
  1045.      _debug( "Return restoreState:", retval );
  1046.      
  1047.      break;
  1048.      }
  1049.      else if ( ret == `ok )
  1050.      {
  1051.      // Add selected packages to user_settings -> inst_sw_detail
  1052.      _debug( "Return inst_sw_single: ", ret );
  1053.      // Check again dependencies
  1054.      if ( PKGINFO( `isSingleSelected() ) )
  1055.      {
  1056.          CheckDependencies();
  1057.      }
  1058.      break;
  1059.      }
  1060.  
  1061.   }
  1062.   
  1063.   UI( `CloseDialog() );
  1064.  
  1065.   // Delete saved information in pkginfo
  1066.   retval = PKGINFO( `deleteOldState() );
  1067.    
  1068.   return ret;
  1069.  
  1070. }
  1071.  
  1072.  
  1073.