ACC SHELL
/**
* File:
* include/installation/misc.ycp
*
* Module:
* System installation
*
* Summary:
* Miscelaneous functions
*
* Authors:
* Jiri Srain <jsrain@suse.cz>
*
* $Id: misc.ycp 56223 2009-03-18 16:39:42Z mkudlvasr $
*
*/
{
textdomain "installation";
import "Installation";
import "Mode";
import "ProductControl";
import "ProductFeatures";
import "Label";
import "FileUtils";
import "Linuxrc";
import "InstData";
import "HTML";
import "Storage";
/**
* Function appends blacklisted modules to the /etc/modprobe.d/50-blacklist.conf
* file.
*
* More information in bugzilla #221815 and #485980
*/
void AdjustModprobeBlacklist () {
// check whether we need to run it
string brokenmodules = Linuxrc::InstallInf("BrokenModules");
if (brokenmodules == "" || brokenmodules == nil) {
y2milestone ("No BrokenModules in install.inf, skipping...");
return;
}
// comma-separated list of modules
list <string> blacklisted_modules = splitstring (brokenmodules, ", ");
// run before SCR switch
string blacklist_file = Installation::destdir + "/etc/modprobe.d/50-blacklist.conf";
// read the content
string content = "";
if (FileUtils::Exists (blacklist_file)) {
content = (string) SCR::Read (.target.string, blacklist_file);
if (content == nil) {
y2error ("Cannot read %1 file", blacklist_file);
content = "";
}
} else {
y2warning ("File %1 does not exist, installation will create new one", blacklist_file);
}
// creating new entries with comment
string blacklist_file_added = "# Note: Entries added during installation/update (Bug 221815)\n";
foreach (string blacklisted_module, blacklisted_modules, {
blacklist_file_added = blacklist_file_added +
sformat ("blacklist %1\n", blacklisted_module);
});
// newline if the file is not empty
content = content + (content != "" ? "\n\n" : "") + blacklist_file_added;
y2milestone ("Blacklisting modules: %1 in %2", blacklisted_modules, blacklist_file);
if (! SCR::Write (.target.string, blacklist_file, content)) {
y2error ("Cannot write into %1 file", blacklist_file);
} else {
y2milestone ("Changes into file %1 were written successfully", blacklist_file);
}
}
void InjectFile (string filename) {
y2milestone("InjectFile: <%1>", filename );
WFM::Execute (.local.bash, "/bin/cp " + filename + " " + Installation::destdir + filename);
return;
// this just needs too much memory
//byteblock copy_buffer = WFM::Read (.local.byte, filename);
//return SCR::Write (.target.byte, filename, copy_buffer);
}
void InjectRenamedFile( string dir, string src_name, string target_name ) {
y2milestone("InjectRenamedFile: <%1/%2> -> <%3/%4/%5>",
dir, src_name,
Installation::destdir, dir, target_name );
WFM::Execute (.local.bash,
sformat( "/bin/cp %1/%2 %3/%4/%5",
dir, src_name,
Installation::destdir, dir, target_name ) );
return;
}
void UpdateWizardSteps () {
string wizard_mode = Mode::mode();
y2milestone ("Switching Steps to %1 ", wizard_mode);
list<map> stage_mode = [
$["stage": "initial" , "mode": wizard_mode ],
$["stage": "continue", "mode": wizard_mode ]
];
y2milestone ("Updating wizard steps: %1", stage_mode);
ProductControl::UpdateWizardSteps (stage_mode);
}
// moved from clients/inst_doit.ycp
// to fix bug #219097
/**
* Confirm installation or update.
* Returns 'true' if the user confirms, 'false' otherwise.
**/
boolean confirmInstallation()
{
string heading = "";
string body = "";
string confirm_button_label = "";
if (!Mode::update())
{
// Heading for confirmation popup before the installation really starts
heading = HTML::Heading(_("Confirm Installation"));
// Text for confirmation popup before the installation really starts 1/3
body = _("<p>All information required for the base installation is now complete.</p>");
boolean some_destructive = find(map info, Storage::GetCommitInfos(), {
return info[`destructive]:false;
}) != nil;
if (some_destructive)
{
// Text for confirmation popup before the installation really starts 2/3
body = body + _("<p>If you continue now, <b>existing
partitions</b> on your hard disk will be <b>deleted</b> or <b>formatted</b>
(<b>erasing any existing data</b> in those partitions) according to the
installation settings in the previous dialogs.</p>");
}
else
{
// Text for confirmation popup before the installation really starts 2/3
body = body + _("<p>If you continue now, partitions on your
hard disk will be modified according to the installation settings in the
previous dialogs.</p>");
}
// Text for confirmation popup before the installation really starts 3/3
body = body + _("<p>Go back and check the settings if you are unsure.</p>");
confirm_button_label = Label::InstallButton ();
}
else
{
// Heading for confirmation popup before the update really starts
heading = "<h3>" + _("Confirm Update") + "</h3>";
body =
// Text for confirmation popup before the update really starts 1/3
_("<p>All information required to perform an update is now complete.</p>")
// Text for confirmation popup before the update really starts 2/3
+ _("
<p>If you continue now, data on your hard disk will be overwritten
according to the settings in the previous dialogs.</p>")
// Text for confirmation popup before the update really starts 3/3
+ _("<p>Go back and check the settings if you are unsure.</p>")
;
// Label for the button that confirms startint the installation
confirm_button_label = _("Start &Update");
}
string heading_bg_color = "#A9CEDD";
map display_info = UI::GetDisplayInfo();
string text = display_info[ "RichTextSupportsTable" ]:false ?
sformat( "<table bgcolor=\"%1\"><tr><td>%2</td></tr></table>%3",
heading_bg_color, heading, body )
: ( heading + body );
integer size_x = tointeger(display_info["Width"]:800);
integer size_y = tointeger(display_info["Height"]:600);
// 576x384 support for for ps3
// bugzilla #273147
if (size_x >= 800 && size_y >= 600) {
size_x = 70;
size_y = 18;
} else {
size_x = 54;
size_y = 15;
}
UI::OpenDialog(
`VBox(
`VSpacing( 0.4 ),
`HSpacing( size_x ), // force width
`HBox(
`HSpacing( 0.7 ),
`VSpacing( size_y ), // force height
`RichText( text ),
`HSpacing( 0.7 )
),
`ButtonBox (
`PushButton (`id (`cancel), `opt(`cancelButton, `key_F10, `default), Label::BackButton()),
`PushButton (`id (`ok), `opt (`okButton, `key_F9), confirm_button_label)
)
)
);
symbol button = (symbol) UI::UserInput();
UI::CloseDialog();
return button == `ok;
}
list <string> modules_to_enable_with_AC_on = nil;
// Some client calls have to be called even if using AC
void EnableRequiredModules () {
// Lazy init
if (modules_to_enable_with_AC_on == nil) {
any feature = ProductFeatures::GetFeature ("globals", "autoconfiguration_enabled_modules");
if (feature == "" || feature == nil || feature == []) {
modules_to_enable_with_AC_on = [];
} else {
modules_to_enable_with_AC_on = (list <string>) feature;
}
y2milestone ("Steps to enable with AC in use: %1", modules_to_enable_with_AC_on);
}
if (modules_to_enable_with_AC_on != nil) {
foreach (string one_module, modules_to_enable_with_AC_on, {
ProductControl::EnableModule (one_module);
});
}
}
void AdjustAutomaticConfiguration () {
// AC is supported in Mode::installation only
if (Mode::installation() && ProductControl::GetUseAutomaticConfiguration()) {
y2milestone ("Using AC...");
ProductControl::DisableAllModulesAndProposals ("installation", "continue");
ProductControl::EnableModule ("automatic_configuration");
// Enable Modules that are required to run even if using AC, bnc #428190
EnableRequiredModules();
// Otherwise it is always disabled
} else {
y2milestone ("Not using AC...");
ProductControl::UnDisableAllModulesAndProposals ("installation", "continue");
ProductControl::DisableModule ("automatic_configuration");
}
}
void AdjustStepsAccordingToInstallationSettings () {
AdjustAutomaticConfiguration();
if (Installation::add_on_selected == true) {
ProductControl::EnableModule ("add-on");
} else {
ProductControl::DisableModule ("add-on");
}
if (Installation::productsources_selected == true) {
ProductControl::EnableModule ("productsources");
} else {
ProductControl::DisableModule ("productsources");
}
y2milestone ("Disabled Modules: %1, Proposals: %2",
ProductControl::GetDisabledModules(), ProductControl::GetDisabledProposals());
UpdateWizardSteps();
}
void SetXENExceptions () {
// not in text-mode
if (! UI::TextMode()) {
// bnc #376945
// problems with keyboard in xen
if (SCR::Read (.probe.xen) == true) {
y2milestone ("XEN in X detected: running xset");
WFM::Execute (.local.bash, "xset r off; xset m 1");
// bnc #433338
// enabling key-repeating
} else {
y2milestone ("Enabling key-repeating");
WFM::Execute (.local.bash, "xset r on");
}
}
}
/**
* Writes to /etc/install.inf whether running the second stage is required
* This is written to inst-sys and not copied to the installed system
* (which is already umounted in that time).
*
* @see BNC #439572
*/
void WriteSecondStageRequired (boolean scst_required) {
// writes 'SecondStageRequired' '1' or '0'
// if such tag exists, it is removed before
WFM::Execute (.local.bash, sformat (
"sed --in-place '/^%1: .*/D' %3; echo '%1: %2' >> %3",
"SecondStageRequired",
(scst_required == false ? "0":"1"),
"/etc/install.inf"
));
Linuxrc::ResetInstallInf();
}
} //end of include
ACC SHELL 2018