ACC SHELL

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

/**
 * 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_system_analysis.ycp 56656 2009-04-07 11:03:22Z ug $
 *
 */

{

textdomain "installation";

import "Arch";
import "GetInstArgs";
import "Hotplug";
import "InstData";
import "Kernel";
import "Packages";
import "Popup";
import "Product";
import "Progress";
import "Report";
import "Storage";
import "StorageControllers";
import "StorageDevices";
import "Wizard";
import "PackageCallbacks";

include "installation/misc.ycp";
include "packager/storage_include.ycp";

    if( Mode::autoinst() ) {
        Report::Import( $[  "messages":$[ "timeout":10 ], 
                            "errors":$[ "timeout":10 ], 
                            "warnings":$[ "timeout":10 ]]);
    }

    // This dialog in not interactive
    // always return `back when came from the previous dialog
    if (GetInstArgs::going_back()) {
	return `back;
    }

    // Function definitions -->

    // --------------------------------------------------------------
    //				      USB
    // --------------------------------------------------------------
    boolean ActionUSB () {
	Hotplug::StartUSB ();

	return true;
    }
    
    // --------------------------------------------------------------
    //				FireWire (ieee1394)
    // --------------------------------------------------------------
    boolean ActionFireWire () {
	Hotplug::StartFireWire ();

	return true;
    }
    
    // --------------------------------------------------------------
    //				    Floppy
    // --------------------------------------------------------------
    boolean ActionFloppyDisks () {
	StorageDevices::FloppyReady ();

	return true;
    }

    boolean found_controllers = true;
    
    // --------------------------------------------------------------
    //			     Hard disk controllers
    // 1. Probe
    // 2. Initialize (module loading)
    // --------------------------------------------------------------
    // In live_eval mode, all modules have been loaded by linuxrc. But
    // they are loaded by StorageControllers::Initialize(). Well, there
    // also was another reason for skipping StorageControllers::Probe ()
    // but nobody seems to remember more.
    // --------------------------------------------------------------
    boolean ActionHHDControllers () {
	found_controllers = (StorageControllers::Probe () > 0);

	return true;
    }
    
    // --------------------------------------------------------------
    // Don't abort or even warn if no storage controllers can be
    // found.  Disks might be detected even without proper knowledge
    // about the controller.  There's a warning below if no disks were
    // found.
    // --------------------------------------------------------------
    boolean ActionLoadModules () {
	StorageControllers::Initialize ();
	
	return true;
    }
    
    // --------------------------------------------------------------
    //				  Hard disks
    // --------------------------------------------------------------
    boolean ActionHDDProbe () {
	map targetMap = StorageDevices::Probe (true);

	if (size (targetMap) == 0) {
	    if (found_controllers) {
                if( !Mode::autoinst() ) {
                        // pop-up error report
                        Report::Error(_("No hard disks were found for the installation.
Please check your hardware!
"));
                } else {
                        Report::Warning(_("No hard disks were found for the installation.
During an automatic installation, they might be detected later.
(especially on s390 or iSCSI systems)
"));
                }
	    } else {
		// pop-up error report
		Report::Error(_("No hard disks and no hard disk controllers were
found for the installation.
Check your hardware.
"));
	    }

	    return false;
	}
	
	return true;
    }

    boolean EvaluateUpdatePossibilities () {
	y2milestone ("Product flags: %1", Product::flags);
	if (Product::flags == nil || size (Product::flags) == 0) {
	    y2warning ("No product flags defined!");
	    InstData::offer_update = true;
	} else if (contains (Product::flags, "update") || Kernel::GetSuSEUpdate ()) {
	    InstData::offer_update = true;
	} else {
	    InstData::offer_update = false;
	}

	return true;
    }

    boolean SearchForLinuxPartitions () {
	if (Storage::HaveLinuxPartitions ()) {
	    InstData::have_linux = true;
	} else {
	    InstData::have_linux = false;
	}
	
	return true;
    }

    boolean packager_initialized = false;

    boolean InitInstallationRepositoriesReal () {
	// disable callbacks
	PackageCallbacks::RegisterEmptyProgressCallbacks();

	boolean ret = true;

	Packages::InitializeCatalogs ();

	if (Packages::InitFailed ()) {
	    // popup message
	    Popup::Message (_("Failed to initialize the software repositories.
Aborting the installation."));
	    ret = false;
	} else {
	    packager_initialized = true;
	    Packages::InitializeAddOnProducts ();
	}

	// reregister callbacks
	PackageCallbacks::RestorePreviousProgressCallbacks();

	return ret;
    }

    boolean InitInstallationRepositories () {
	//boolean progress_orig = Progress::set (false);
	//y2milestone ("Pregress was: %1", progress_orig);

	boolean ret = InitInstallationRepositoriesReal();

	//y2milestone ("Adjusting progress: %1", progress_orig);
	//Progress::set (progress_orig);

	return ret;
    }

    boolean FilesFromOldedSystems () {
	// FATE #300421: Import ssh keys from previous installations
	// FATE #120103: Import Users From Existing Partition
	// FATE #302980: Simplified user config during installation
	//	All needs to be known before configuring users
	y2milestone ("PreInstallFunctions -- start --");
	WFM::CallFunction ("inst_pre_install", []);
	y2milestone ("PreInstallFunctions -- end --");

	return true;
    }

    // <-- Function definitions

Wizard::SetContents (_("Analyzing the Computer"), `Empty (), "", false, false);
Wizard::SetTitleIcon ("yast-controller");

// Do hardware probing
//
// This must happen before submodule descriptions are initialized; module
// constructors might depend on it.
// In autoinst mode, this has been called already.

list <string> actions_todo      = [];
list <string> actions_doing     = [];
list          actions_functions = [];
list <string> visible_icons     = [];

y2milestone ("Probing done: %1", Installation::probing_done);
if (! Installation::probing_done)
{
	if (!(Arch::s390 () || Arch::board_iseries ())) {
	    // TRANSLATORS: progress step
	    actions_todo = add (actions_todo, _("Probe USB devices"));
	    // TRANSLATORS: progress step
	    actions_doing = add (actions_doing, _("Probing USB devices..."));
	    actions_functions = add (actions_functions, ActionUSB);
	    visible_icons = add (visible_icons, "32x32/apps/yast-usb.png");

	    // TRANSLATORS: progress step
	    actions_todo = add (actions_todo, _("Probe FireWire devices"));
	    // TRANSLATORS: progress step
	    actions_doing = add (actions_doing, _("Probing FireWire devices..."));
	    actions_functions = add (actions_functions, ActionFireWire);
	    visible_icons = add (visible_icons, "32x32/apps/yast-firewire.png");

	    // TRANSLATORS: progress step
	    actions_todo = add (actions_todo, _("Probe floppy disks devices"));
	    // TRANSLATORS: progress step
	    actions_doing = add (actions_doing, _("Probing floppy disks devices..."));
	    actions_functions = add (actions_functions, ActionFloppyDisks);
	    visible_icons = add (visible_icons, "32x32/apps/yast-floppy.png");
        }

        // TRANSLATORS: progress step
        actions_todo = add (actions_todo, _("Probe hard disk controllers"));
        // TRANSLATORS: progress step
        actions_doing = add (actions_doing, _("Probing hard disk controllers..."));
        actions_functions = add (actions_functions, ActionHHDControllers);
	visible_icons = add (visible_icons, "32x32/apps/yast-hdd-controller.png");

        // TRANSLATORS: progress step
        actions_todo = add (actions_todo, _("Load kernel modules for hard disk controllers"));
        // TRANSLATORS: progress step
        actions_doing = add (actions_doing, _("Loading kernel modules for hard disk controllers..."));
        actions_functions = add (actions_functions, ActionLoadModules);
	visible_icons = add (visible_icons, "32x32/apps/yast-hdd-controller-kernel-module.png");

        // TRANSLATORS: progress step
        actions_todo = add (actions_todo, _("Probe hard disks"));
        // TRANSLATORS: progress step
        actions_doing = add (actions_doing, _("Probing hard disks..."));
	actions_functions = add (actions_functions, ActionHDDProbe);
	visible_icons = add (visible_icons, "32x32/apps/yast-hdd.png");

	WFM::CallFunction("inst_features", []);
}

// TRANSLATORS: progress step
actions_todo = add (actions_todo, _("Search for Linux partitions"));
// TRANSLATORS: progress step
actions_doing = add (actions_doing, _("Searching for Linux partitions..."));
actions_functions = add (actions_functions, SearchForLinuxPartitions);
visible_icons = add (visible_icons, "32x32/apps/yast-search-linux-partition.png");

// TRANSLATORS: progress step
actions_todo = add (actions_todo, _("Search for system files"));
// TRANSLATORS: progress step
actions_doing = add (actions_doing, _("Searching for system files..."));
// FATE #302980: Simplified user config during installation
actions_functions = add (actions_functions, FilesFromOldedSystems);
visible_icons = add (visible_icons, "32x32/apps/yast-system-files.png");

// TRANSLATORS: progress step
actions_todo = add (actions_todo, _("Evaluate update possibility"));
// TRANSLATORS: progress step
actions_doing = add (actions_doing, _("Evaluating update possibility..."));
actions_functions = add (actions_functions, EvaluateUpdatePossibilities);
visible_icons = add (visible_icons, "32x32/apps/yast-update-possibility.png");

// TRANSLATORS: progress step
actions_todo = add (actions_todo, _("Initialize package manager"));
// TRANSLATORS: progress step
actions_doing = add (actions_doing, _("Initializing package manager..."));
actions_functions = add (actions_functions, InitInstallationRepositories);
visible_icons = add (visible_icons, "32x32/apps/yast-package-manager.png");

Progress::NewProgressIcons (
    // TRANSLATORS: dialog caption
    _("System Probing"),
    " ",
    size (actions_todo),
    actions_todo,
    actions_doing,
    // TRANSLATORS: dialog help
    _("Please wait while computer hardware and installed systems are being probed..."),
    [visible_icons]
);

foreach (any run_function, actions_functions, {
    Progress::NextStage();

    // Bugzilla #298049
    // Allow to abort the probing
    any ui_ret = UI::PollInput();

    if (ui_ret == `abort) {
	y2milestone ("Abort pressed");

	if (Popup::ConfirmAbort (`painless)) {
	    y2warning ("User decided to abort the installation");
	    return `abort;
	}
    }

    y2milestone ("Running function: %1", run_function);

    boolean () run_this = (boolean()) (run_function);
    boolean ret = run_this();

    y2milestone ("Function %1 returned %2", run_function, ret);
});
Installation::probing_done = true;

Progress::Finish();
sleep (500);

if (! packager_initialized) {
    return `abort;
}

y2milestone ("Have Linux: %1, Offer Update: %2", InstData::have_linux, InstData::offer_update);

return `next;

/* EOF */
}

ACC SHELL 2018