home *** CD-ROM | disk | FTP | other *** search
- /**
- * File:
- * include/installation/misc.ycp
- *
- * Module:
- * System installation
- *
- * Summary:
- * Miscelaneous functions
- *
- * Authors:
- * Jiri Srain <jsrain@suse.cz>
- *
- * $Id: misc.ycp 34485 2006-11-20 14:27:26Z locilka $
- *
- */
-
-
-
- {
-
- textdomain "installation";
-
- import "Installation";
- import "Mode";
- import "ProductControl";
- import "Label";
- import "FileUtils";
- import "Linuxrc";
-
- /**
- * Function appends blacklisted modules to the /etc/modprobe.d/blacklist
- * file.
- *
- * More information in bugzilla #221815
- */
- 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/blacklist";
-
- // 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::test () ? "installation" : 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()
- {
- // Heading for confirmation popup before the installation really starts
- string heading = "<h3>" + _("Confirm Installation") + "</h3>";
-
- string body =
- // Text for confirmation popup before the installation really starts 1/3
- _("<p>All information required for the base installation is now complete.</p>")
- // Text for confirmation popup before the installation really starts 2/3
- + _("
- <p>If you continue now, partitions on your hard disk will be <b>formatted</b>
- (erasing any existing data in those partitions)
- according to the installation settings in the previous dialogs.</p>")
- // Text for confirmation popup before the installation really starts 3/3
- + _("<p>Go back and check the settings if you are unsure.</p>")
- ;
-
- string confirm_button_label = Label::InstallButton ();
-
- if ( Mode::update () )
- {
- // 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 );
-
-
-
- UI::OpenDialog(
- `VBox(
- `VSpacing( 0.4 ),
- `HSpacing( 70 ), // force width
- `HBox(
- `HSpacing( 0.7 ),
- `VSpacing( 18 ), // force height
- `RichText( text ),
- `HSpacing( 0.7 )
- ),
- `HBox(
- `HStretch(),
- `PushButton(`id(`back), `opt(`default), Label::BackButton() ),
- `HStretch(),
- `PushButton(`id(`confirm), confirm_button_label ),
- `HStretch()
- )
- )
- );
-
- symbol button = (symbol) UI::UserInput();
- UI::CloseDialog();
-
- return ( button == `confirm );
- }
-
- } //end of include
-