ACC SHELL

Path : /usr/share/YaST2/clients/
File Upload :
Current File : //usr/share/YaST2/clients/inst_update.ycp

/**
 * Module: 		inst_update.ycp
 *
 * Authors:		Stefan Schubert <schubi@suse.de>
 *			Arvin Schnell <arvin@suse.de>
 *
 * Purpose:
 * Displays software selection screen of previous installed software-groups.
 * Show checkboxes for software categories. Let the user select his software.
 * if he want to UPGRADE his system.
 *
 * $Id: inst_update.ycp 47330 2008-05-06 16:49:50Z locilka $
 */

{
    textdomain "update";

    import "Wizard";
    import "Popup";
    import "RootPart";
    import "Update";
    import "Packages";
    import "Installation";

    // screen title for update options
    string title = _("Update Options");

    // create box with base selections, check if current selection really is available
    term baseconfsbox = `VBox ();

    // loop through available base selections, create radio button entry for every base selection
    // preselect current selection

    list<string> base_configurations = [];

    if (Packages::using_patterns)
    {
	baseconfsbox = `PushButton (`id (`details), _("Select Patterns"));
    }
    else
    {
	// get available base selection sorted by reverse order (highest ordered base selection first)
	list<string> available_base_selections = Update::GetBaseSelections ();
	y2milestone ("available_base_selections %1, current_selection %2", available_base_selections, Update::selected_selection);
	foreach (string selection, available_base_selections, {
	    map selection_data = Pkg::SelectionData (selection);
	    string selection_summary = selection_data["summary"]:"";
	    boolean preselect = (selection == Update::selected_selection);
	    baseconfsbox = add (baseconfsbox, `Left(`RadioButton(`id(selection),
								 `opt(`notify, `autoShortcut),
								 selection_summary,
								 preselect)));
	});
	baseconfsbox = `RadioButtonGroup(`id(`baseconf), baseconfsbox);
	base_configurations = available_base_selections;
    }

    // Checking: already selected addons or single selection?

    string wrn_msg = "";

    if (Pkg::RestoreState (true))		// check if state changed
    {
	// Display warning message
	wrn_msg = _("\
You have already chosen software from \"Detailed selection\".\n\
You will lose that selection if you change the basic selection.");
    }

    // Build and show dialog

    string from_version = Installation::installedVersion["show"]:_("Unknown");
    string to_version   = Installation::updateVersion["show"]:_("Unknown");

    string update_label = "";
    if (from_version == to_version) {
	// label showing to which version we are updating
	update_label = sformat (_("Update to %1"), to_version);
    } else {
	// label showing from which version to which version we are updating
	update_label = sformat (_("Update from %1 to %2"), from_version, to_version);
    }

    term contents = `HVSquash(
	`VBox(
	      `Left (`Label (update_label)),
	      `VSpacing (1),
	      // frame title for update selection
	      `Frame( _("Update Mode"),
		      `VBox(
			    `VSpacing(1),
			    `RadioButtonGroup( `id(`bgoup), `opt(`notify),
					       `VBox(
						     `Left(`RadioButton(`id(`upgrade),`opt(`notify),
									// radio button label for update including new packages
									_("&Update with Installation of New Software and Features
Based on the Selection:
"), false)),
						     `VSpacing(0.5),
						     `HBox(
							   `HSpacing(4),
							   baseconfsbox
							),
						     `VSpacing(1.5),
						     `Left(`RadioButton(`id(`notupgrade),`opt(`notify),
									// radio button label for update of already installed packages only
									_("Only U&pdate Installed Packages"), true)),
						     `VSpacing(1.0)
						     )
					       )
			    )
		      ),
//	      `VSpacing (1),
//	      `Left(`CheckBox(`id(`delete),
//			      // check box label
//			      // translator: add a & shortcut
//			      _("&Delete Unmaintained Packages"), true)),
	      `VSpacing(1),
	      `Label( `id(`wrn_label), wrn_msg )
	      )
	);


    // help text for dialog "update options" 1/4
    string helptext = _("<p>The update option differs between two modes. In
either case, it is recommended to make a backup of your personal data.</p>
");

    // help text for dialog "update options" 2/4, %1 is a product name
    helptext = helptext + sformat(_("<p><b>With New Software:</b> This default setting
updates the existing software and installs all new features and benefits of
the new <tt>%1</tt> version. The selection is based on the former predefined
software selection.</p>
"), Installation::updateVersion["show"]:"");

    // help text for dialog "update options" 3/4
    helptext = helptext + _("<p><b>Only Installed Packages:</b> This selection
only updates the packages already installed on your system. <i>Note:</i>
New software in the predefined software selection, such as new YaST modules, is
not available after the update. You might miss advertised features.</p>
");

    // help text for dialog "update options" 4/4
    helptext = helptext + _("<p>After the update, some software might not
function anymore. Activate <b>Delete Unmaintained Packages</b> to delete those
packages during the update.</p>
");


    Wizard::OpenOKDialog ();

    Wizard::SetContents (title, contents, helptext, (boolean) WFM::Args(0), (boolean) WFM::Args(1));
    Wizard::SetTitleIcon ("yast-software");

    // preset update/upgrade radio buttons properly

    UI::ChangeWidget(`id(`upgrade), `Value, !Update::onlyUpdateInstalled);
    UI::ChangeWidget(`id(`notupgrade), `Value, Update::onlyUpdateInstalled);

    // grey out radio buttons if only already installed packages should be updated

    foreach (string sel, base_configurations, {
	UI::ChangeWidget(`id(sel), `Enabled, !Update::onlyUpdateInstalled);
    });

//    UI::ChangeWidget(`id(`delete), `Value, Update::deleteOldPackages);

    any ret = nil;
    boolean details_pressed = false;

    while (true)
    {
	ret = Wizard::UserInput ();

	if (ret == `abort && Popup::ConfirmAbort (`painless))
	    break;

	if (ret == `upgrade || ret == `notupgrade)
	{
	    boolean tmp = (boolean) UI::QueryWidget (`id(`upgrade), `Value);
	    foreach (string sel, base_configurations, {
		UI::ChangeWidget(`id(sel), `Enabled, tmp);
	    });

	    continue;
	}

	if (ret == `details)
	{

            symbol result = `again;
            while ( result == `again )
            {
                result = (symbol) WFM::CallFunction ("inst_sw_select", [true, true]);
            }
	    if (ret == `next)
		details_pressed = true;
	    continue;
	}

	if ((ret == `next || ret == `ok) && Pkg::RestoreState (true))
	{
	    boolean something_changed = false;

	    if (UI::QueryWidget (`id(`notupgrade), `Value) != Update::onlyUpdateInstalled)
		something_changed = true;

            if (Packages::using_patterns)
	    {
		y2milestone ("Using patterns");
	    }
	    else
	    {
		if ((boolean) UI::QueryWidget (`id(`upgrade), `Value) &&
		    Update::selected_selection != UI::QueryWidget(`id(`baseconf), `CurrentButton))
		    something_changed = true;
	    }

//	    if (UI::QueryWidget (`id(`delete), `Value ) != Update::deleteOldPackages)
//		something_changed = true;

	    if (something_changed && Packages::base_selection_modified)
	    {
		// yes/no question
		if (!Popup::YesNo (_("Do you really want\nto reset your detailed selection?")))
		    continue;
	    }
	}

	if (ret == `back || ret == `next || ret == `ok)
	    break;
    }

    if (ret == `next || ret == `ok)
    {
	Update::did_init1 = false;

	boolean b1 = Update::onlyUpdateInstalled;
	Update::onlyUpdateInstalled = (boolean) UI::QueryWidget (`id(`notupgrade), `Value);
//	Update::deleteOldPackages = (boolean) UI::QueryWidget (`id(`delete), `Value);

	if (Packages::using_patterns)
	{
	    if (b1 != Update::onlyUpdateInstalled || details_pressed)
	    {
		Update::manual_interaction = true;
	    }
	}
	else
	{
	    string s1 = Update::selected_selection;
	    Update::selected_selection = (string) UI::QueryWidget(`id(`baseconf), `CurrentButton);

	    if (b1 != Update::onlyUpdateInstalled || s1 != Update::selected_selection)
	    {
		Update::manual_interaction = true;
	    }
	}
    }

    Wizard::CloseDialog ();

    return ret;
}

ACC SHELL 2018