ACC SHELL
/**
* File: clients/inst_system_analysis.ycp
* Package: Installation
* Summary: Installation mode selection, system analysis
* Authors: Jiri Srain <jsrain@suse.cz>
* Lukas Ocilka <locilka@suse.cz>
*
* $Id: inst_mode.ycp 60026 2009-12-09 14:17:18Z kmachalkova $
*
*/
{
textdomain "installation";
import "AddOnProduct";
import "GetInstArgs";
import "Installation";
import "InstData";
import "Kernel";
import "Linuxrc";
import "Mode";
import "PackageCallbacks";
import "Packages";
import "Popup";
import "ProductControl";
import "Report";
import "Stage";
import "Storage";
import "Wizard";
import "ProductFeatures";
import "Directory";
import "PackagesProposal";
import "InstError";
include "packager/storage_include.ycp";
include "installation/misc.ycp";
InstData::start_mode = Mode::mode();
// always check whether user wants to continue
AddOnProduct::skip_add_ons = false;
map display_info = UI::GetDisplayInfo();
boolean in_textmode = display_info["TextMode"]:false;
string GenerateIconID (any icon_whatever) {
return sformat ("icon_%1", tostring (icon_whatever));
}
/**
* Function creates term containing radio button and icon
* based on current display (graphical/textual)
*
* @param string radio button label
* @param symbol radio button id
* @param string path to an image
* @boolean whether selected (more than one buttons selected don't make sense!)
*/
term CreateRadioButtonTerm (string button_label, symbol button_id, string icon_file, boolean selected) {
return `HBox (
(in_textmode ?
`Empty()
:
`HWeight (
1,
(icon_file == "" ?
`Empty()
:
`Image (`id (GenerateIconID (button_id)), icon_file, "")
)
)
),
`HWeight(
5,
`Left (`RadioButton (
`id (button_id),
`opt(`notify),
button_label,
selected
))
)
);
}
Wizard::SetTitleIcon ("yast-inst-mode");
// In case of going back from Update/New Installation
if (GetInstArgs::going_back()) {
Pkg::TargetFinish();
}
boolean other_options_enabled = (InstData::have_linux && InstData::offer_update);
// bugzilla #208222
// Release disk used as the installation source
ReleaseHDDUsedAsInstallationSource();
if (Mode::autoinst ()) {
y2milestone ("Autoinst -> returning `auto");
return `auto;
}
boolean show_online_repositories = ProductFeatures::GetBooleanFeature ("globals", "show_online_repositories");
// if not visible, internally disabled as well
if (show_online_repositories != true) {
Installation::productsources_selected = false;
}
// see bugzilla #156529
term InstModeDialogContent (symbol pre_selected) {
return `HBox (
`HStretch(),
`VBox (
`Frame (
// frame
_("Select Mode"),
`VBox (
// Basis RadioButtonGroup
`RadioButtonGroup (
`id (`inst_mode),
`MarginBox (
2, 1.3,
`VBox (
// radio button
CreateRadioButtonTerm (
_("New &Installation"),
`install,
Directory::themedir + "/current/icons/48x48/apps/yast-dirinstall.png",
!Mode::update ()
),
`VSpacing( 0.3 ),
// radio button
CreateRadioButtonTerm (
_("&Update"),
`update,
Directory::themedir + "/current/icons/48x48/apps/yast-update.png",
Mode::update ()
)
)
)
)
)
),
`VSpacing (2),
(show_online_repositories == true ?
`Left (`CheckBox (
`id (`productsources), `opt(`notify),
// check box
_("&Add Online Repositories Before Installation"),
Installation::productsources_selected
))
:
`Empty()
),
`Left (`CheckBox (
`id (`add_on), `opt(`notify),
// check box
_("In&clude Add-On Products from Separate Media"),
Installation::add_on_selected
)),
(InstData::enable_autoconfiguration == true ?
`Left (`CheckBox (
`id (`use_automatic_configuration), `opt(`notify),
// check box
_("&Use Automatic Configuration"),
ProductControl::GetUseAutomaticConfiguration()
))
:
`Empty()
)
),
`HStretch()
);
}
string InstModeDialogHelp () {
// help text for installation method
return _("<p><big><b>Installation Mode</b></big><br>
Select what to do:</p>") +
// help text for installation method
_("<p>
Select <b>New Installation</b> if there is no existing Linux system on your
machine or if you want to replace an existing Linux system completely,
abandoning all its configuration data.
</p>") +
// help text for installation method
_("<p>
Select <b>Update an Existing System</b> to update a Linux system already
installed on your machine. This option preserves configuration settings
from your existing system whenever possible.
</p>") +
// help text for installation option
(show_online_repositories == true ? _("<p>
To use suggested remote repositories during installation or update, select
<b>Add Online Repositories Before Installation</b>.</p>"):"") +
// help text for installation method
_("<p>
To install an add-on product from separate media together with &product;, select
<b>Include Add-On Products from Separate Media</b>.</p>") +
// help text for installation method
_("<p>
Select <b>Use Automatic Configuration</b> to let the installation program
configure your network and hardware automatically. Otherwise you will
be offered a configuration proposal with the possibility to tune all the
settings manually. Inexperienced users are advised to use automatic
configuration.</p>
") +
// help text for installation method
_("<p>Update mode does not support automatic configuration.</p>") +
// help text for installation method
_("<p>The feature <b>Update</b> is only
available if an existing Linux system has been detected.
</p>
");
}
Wizard::SetContents (
// dialog caption
_("Installation Mode"), InstModeDialogContent(`install), InstModeDialogHelp(), true, true
);
Wizard::SetTitleIcon ("yast-software");
symbol ret = nil;
symbol new_mode = Mode::update () ? `update : `install;
string umount_result = Linuxrc::InstallInf ("umount_result");
string media = Linuxrc::InstallInf ("InstMode");
y2milestone ("Umount result: %1, inst mode: %2", umount_result, media);
// only installation (and addon products) enabled
if (other_options_enabled != true) {
UI::ChangeWidget (`id (`update), `Enabled, false);
// disable also icons related to options if supported by UI
if (! in_textmode) {
foreach (symbol image_id, [`update], {
string icon_id = GenerateIconID (image_id);
if (UI::WidgetExists (`id(icon_id))) {
UI::ChangeWidget (`id (icon_id), `Enabled, false);
}
});
}
}
y2milestone ("Initial Mode: %1, AC: %2", Mode::mode(), ProductControl::GetUseAutomaticConfiguration());
AdjustStepsAccordingToInstallationSettings();
repeat {
ret = (symbol) UI::UserInput();
y2milestone("ret: %1", ret);
// Use-Add-On-Product status changed
if (ret == `add_on) {
if (UI::WidgetExists (`id (`add_on))) {
Installation::add_on_selected = (boolean) UI::QueryWidget (`id (`add_on), `Value);
y2milestone ("add_on_selected: %1", Installation::add_on_selected);
AdjustStepsAccordingToInstallationSettings();
}
ret = nil;
continue;
}
// FIXME: this mode needs more RAM because it starts another YaST process.
// Warn user and/or disable the option if a machine has not enough memory.
// Use-Automatic-Configuration status changed
else if (ret == `use_automatic_configuration) {
if (UI::WidgetExists (`id (`use_automatic_configuration))) {
ProductControl::SetUseAutomaticConfiguration ((boolean) UI::QueryWidget (`id (`use_automatic_configuration), `Value));
y2milestone ("GetUseAutomaticConfiguration: %1", ProductControl::GetUseAutomaticConfiguration());
AdjustStepsAccordingToInstallationSettings();
}
ret = nil;
continue;
}
// Use-Community-Repositories status changed
else if (ret == `productsources) {
if (UI::WidgetExists (`id (`productsources))) {
Installation::productsources_selected = (boolean) UI::QueryWidget (`id (`productsources), `Value);
y2milestone ("productsources_selected: %1", Installation::productsources_selected);
AdjustStepsAccordingToInstallationSettings();
}
ret = nil;
continue;
}
// Adjusting current UI - Hide Other Options
// in case of `install, `update, or `repair clicked
else if (contains([`install, `update], ret)) {
symbol selected_mode = (symbol) UI::QueryWidget (`id (`inst_mode), `CurrentButton);
// [(any) `check_box_id, (boolean) selected, (boolean) enabled]
foreach (list one_item, [
[`add_on, Installation::add_on_selected, (ret != `repair)],
[`productsources, Installation::productsources_selected, (show_online_repositories && ret != `repair)],
// automatic installation works only for new installation
[`use_automatic_configuration, (ProductControl::GetUseAutomaticConfiguration() && ret == `install),
(ret == `install)],
], {
if (UI::WidgetExists (`id (one_item[0]:`_inotdef_))) {
UI::ChangeWidget (`id (one_item[0]:`_inotdef_), `Enabled, one_item[2]:false);
UI::ChangeWidget (`id (one_item[0]:`_inotdef_), `Value, one_item[1]:false);
}
});
// Switch the mode and steps ASAP
if (selected_mode == `install) {
Mode::SetMode ("installation");
} else if (selected_mode == `update) {
Mode::SetMode ("update");
}
y2milestone ("New mode has been selected: %1", Mode::mode());
AdjustStepsAccordingToInstallationSettings();
continue;
// Next button
} else if (ret == `next) {
new_mode = (symbol) UI::QueryWidget (`id (`inst_mode), `CurrentButton);
if (new_mode == nil)
{
// this is a label of a message box
Popup::Message(_("Choose one of the\noptions to continue."));
ret = nil;
continue;
}
continue;
// Abort button
} else if (ret == `abort) {
if (Popup::ConfirmAbort (Stage::initial () ? `painless : `incomplete))
return `abort;
ret = nil;
continue;
}
} until (ret == `back || ret == `next);
// <-- Handling User Input in Installation Mode
y2milestone("Selected mode: %1, Return: %2", new_mode, ret);
if (ret == `next) {
y2milestone ("Disabled modules: %1", ProductControl::GetDisabledModules());
} else if (ret == `back || ret == `finish) {
y2milestone("Returning: %1", ret);
return ret;
}
// bugzilla #293808
// Check (and setup) the network only when needed
if (new_mode != `repair && (Installation::add_on_selected || Installation::productsources_selected)) {
// Check and setup network
symbol inc_ret = (symbol) WFM::CallFunction ("inst_network_check", []);
y2milestone ("inst_network_check ret: %1", inc_ret);
if (contains ([`back, `abort], inc_ret)) {
return inc_ret;
}
}
// bug #302384
Wizard::SetContents (
_("Initializing"),
// TRANSLATORS: progress message
`Label (_("Initializing...")),
"",
false, false
);
Wizard::SetTitleIcon ("yast-software");
// BNC #469730: Installation requires some packages
void SetRequiredPackages () {
if (new_mode == `install) {
y2milestone ("Adding packages required for installation to succeed...");
PackagesProposal::AddResolvables ("YaST-Installation", `package, ["yast2-installation"]);
} else if (new_mode == `update) {
y2milestone ("Adding packages required for update to succeed...");
PackagesProposal::AddResolvables ("YaST-Update", `package, ["yast2-update"]);
}
}
if (Mode::mode () != InstData::start_mode) {
y2milestone ("Switching Steps from %1 to %2 ", InstData::start_mode, Mode::mode ());
UpdateWizardSteps ();
y2milestone ("Resetting disk target to read values");
Storage::ResetOndiskTarget ();
y2debug ("Original target map (from disk): %1", Storage::GetTargetMap ());
y2milestone ("Resetting package manager");
Kernel::ProbeKernel();
Pkg::TargetFinish ();
Pkg::PkgReset ();
// Resets all resolvables required by installation/update parts
// Particular modules will add them again when needed
PackagesProposal::ResetAll();
Packages::Init( true );
SetRequiredPackages ();
ret = ProductControl::RunFrom (ProductControl::CurrentStep () + 1, false);
if (ret == `next)
ret = `finish;
} else {
UpdateWizardSteps ();
SetRequiredPackages ();
ret = ProductControl::RunFrom (ProductControl::CurrentStep () + 1, false);
if (ret == `next)
ret = `finish;
}
return ret;
/* EOF */
}
ACC SHELL 2018