ACC SHELL

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

/**
 * File:    clients/inst_autosetup.ycp
 * Package: Auto-installation
 * Summary: Setup and prepare system for auto-installation
 * Authors: Anas Nashif <nashif@suse.de>
 *          Uwe Gansert <ug@suse.de>
 *
 * $Id: inst_autosetup.ycp 61115 2010-03-03 09:56:04Z ug $
 */

{
    textdomain "autoinst";

    import "AutoinstConfig";
    import "AutoInstall";
    import "Installation";
    import "Profile";
    import "Progress";
    import "Report";
    import "AutoinstStorage";
    import "AutoinstScripts";
    import "AutoinstGeneral";
    import "AutoinstSoftware";
    import "Bootloader";
    import "BootCommon";
    import "Popup";
    import "RunlevelEd";
    import "Arch";
    import "AutoinstLVM";
    import "AutoinstRAID";
    import "Storage";
    import "Timezone";
    import "Keyboard";
    import "Call";
    import "ProductControl";
    import "LanUdevAuto";
    import "Language";
    import "Console";

    include "bootloader/routines/autoinstall.ycp";
    include "autoinstall/ask.ycp";

    define symbol readModified() {
        if (SCR::Read(.target.size, AutoinstConfig::modified_profile) > 0 ) {
            if (! Profile::ReadXML( AutoinstConfig::modified_profile ) || Profile::current == $[] ) {
                Popup::Error(_("Error while parsing the control file.
Check the log files for more details or fix the
control file and try again.
"));
                return `abort;
            }
            string cpcmd = sformat("mv %1 %2","/tmp/profile/autoinst.xml", "/tmp/profile/pre-autoinst.xml");
            y2milestone("copy original profile: %1",cpcmd);
            SCR::Execute(.target.bash, cpcmd);

            cpcmd = sformat("mv %1 %2", AutoinstConfig::modified_profile, "/tmp/profile/autoinst.xml");
            y2milestone("moving modified profile: %1",cpcmd);
            SCR::Execute(.target.bash, cpcmd);
            return `found;
        }
        return `not_found;
    }

    string help_text = _("<P>Please wait while the system is prepared for autoinstallation.</P>");
    list<string> progress_stages =
        [
    _("Configure General Settings "),
    _("Execute pre-install user scripts"),
    _("Set up language"),
    _("Create partition plans"),
    _("Configure Software selections"),
    _("Configure Bootloader"),
    _("Configure runlevel")
        ];

    list<string> progress_descriptions =
        [
    _("Configuring general settings..."),
    _("Executing pre-install user scripts..."),
    _("Creating partition plans..."),
    _("Configuring Software selections..."),
    _("Configuring Bootloader..."),
    _("Configuring runlevel...")
        ];

    Progress::New(
            _("Preparing System for Automated Installation"),
            "",     // progress_title
            size( progress_stages ),	// progress bar length
            progress_stages,
            progress_descriptions,
            help_text );


    if(UI::PollInput() == `abort)
        if (Popup::ConfirmAbort (`painless))
            return `abort;
    Progress::NextStage();


    // configure general settings





    if(UI::PollInput() == `abort)
	if (Popup::ConfirmAbort (`painless))
	    return `abort;

    Progress::NextStage();

    // Pre-Scripts
    AutoinstScripts::Import(Profile::current["scripts"]:$[]);
    AutoinstScripts::Write("pre-scripts", false);

    // Reread Profile in case it was modified in pre-script
    // User has to create the new profile in a pre-defined
    // location for easy processing in pre-script.

    if( readModified() == `abort )
        return `abort;

    //
    // Partitioning and Storage
    ////////////////////////////////////////////////////////////////////////

    boolean modified = true;
    do {
        askDialog();
        // Pre-Scripts
        AutoinstScripts::Import(Profile::current["scripts"]:$[]);
        AutoinstScripts::Write("pre-scripts", false);
        symbol ret = readModified();
        if( ret == `abort )
            return `abort;
        if( ret == `not_found )
            modified = false;
    } while( modified == true );

    // reimport scripts, for the case <ask> has changed them
    AutoinstScripts::Import(Profile::current["scripts"]:$[]);
    //
    // Set Mouse and other workflow variables
    //
    AutoinstGeneral::Import(Profile::current["general"]:$[]);
    y2milestone("general: %1", Profile::current["general"]:$[] );
    AutoinstGeneral::Write();

    if( haskey( Profile::current, "add-on" ) ) {
        Call::Function("add-on_auto", ["Import", Profile::current["add-on"]:$[]] );
        Call::Function("add-on_auto", ["Write"]);
    }

    boolean use_utf8 = true;		// utf8 is default

    map displayinfo = UI::GetDisplayInfo();
    if ( ! displayinfo["HasFullUtf8Support"]:true )
    {
	use_utf8 = false;		// fallback to ascii
    }


    //
    // Set it in the Language module.
    //
    Progress::NextStep();
    Progress::Title(_("Configuring language..."));
    Language::Import( Profile::current["language"]:$[] );

    //
    // Set Console font
    //
    Installation::encoding = Console::SelectFont( Language::language );

    if (displayinfo["HasFullUtf8Support"]:true)
    {
        Installation::encoding = "UTF-8";
    }

    UI::SetLanguage (Language::language, Installation::encoding);
    WFM::SetLanguage (Language::language, "UTF-8");

    if( haskey( Profile::current, "timezone" ) )
        Timezone::Import(Profile::current["timezone"]:$[]);
    if( haskey( Profile::current, "keyboard" ) )
        Keyboard::Import(Profile::current["keyboard"]:$[]);


    // one can override the <confirm> option by the commandline parameter y2confirm
    string tmp = (string)SCR::Read (.target.string, "/proc/cmdline");
    if (tmp != nil && contains (splitstring (tmp, " \n"), "y2confirm")) {
        AutoinstConfig::Confirm = true;
        y2milestone("y2confirm found and confirm turned on");
    }


    if(UI::PollInput() == `abort)
	if (Popup::ConfirmAbort (`painless))
	    return `abort;

    // moved here from autoinit for fate #301193
    // needs testing
    if( Arch::s390 () && AutoinstConfig::remoteProfile == true ) {
       y2milestone("arch=s390 and remote_profile=true");
       if( haskey(Profile::current, "dasd") ) {
            y2milestone("dasd found");
            Call::Function("dasd_auto", ["Import", Profile::current["dasd"]:$[] ]);
        }
        if( haskey(Profile::current, "zfcp") ) {
            y2milestone("zfcp found");
            Call::Function("zfcp_auto", ["Import", Profile::current["zfcp"]:$[] ]);
        }
    }


    Progress::NextStage();
    // if one modifies the partition table in a pre script, we will
    // recognize this now
    Storage::ReReadTargetMap();

    // No partitioning in the profile means yast2-storage proposal (hmmmm.....)
    if( size(Profile::current["partitioning"]:[]) > 0 ) {
        AutoinstStorage::Import(Profile::current["partitioning"]:[]);
    } else if( size(Profile::current["partitioning_advanced"]:$[]) > 0 ) {
        AutoinstStorage::ImportAdvanced(Profile::current["partitioning_advanced"]:$[]);
    } else {
        Storage::SetTestsuite(true); // FIXME: *urgs*
        WFM::CallFunction("inst_disk_proposal", [true, true]); // FIXME: fragile?
        Storage::SetTestsuite(false); // *urgs* again
    }

    if ( (size(Profile::current["partitioning"]:[]) > 0 || size(Profile::current["partitioning_advanced"]:$[]) > 0) && 
         !AutoinstStorage::Write())
    {
	Report::Error(_("Error while configuring partitions.
Try again.
"));
	y2error("Aborting...");
	return `abort;
    }
    if (AutoinstRAID::Init())
    {
        AutoinstRAID::Write();
    }
    if (AutoinstLVM::Init())
    {
        AutoinstLVM::Write();
    }



    // Software

    if(UI::PollInput() == `abort)
	if (Popup::ConfirmAbort (`painless))
	    return `abort;

    Progress::NextStage();
    AutoinstSoftware::Import( Profile::current["software"]:$[] );

    if (!AutoinstSoftware::Write())
    {
	Report::Error(_("Error while configuring software selections.
Try again.
"));
	y2error("Aborting...");
	return `abort;
    }
    // fate #301321 - AutoYaST imaging support
    // no generic images, just the ones the manual installation would use too, to speed up
    // installation
    //
    // no check if section is available makes product default possible
    Call::Function("deploy_image_auto", ["Import", Profile::current["deploy_image"]:$[] ]);
    Call::Function("deploy_image_auto", ["Write" ]);


    // Bootloader

    if(UI::PollInput() == `abort)
	if (Popup::ConfirmAbort (`painless))
	    return `abort;
    Progress::NextStage();

    BootCommon::getLoaderType(true);
    Bootloader::Import(AI2Export (Profile::current["bootloader"]:$[]));
    BootCommon::DetectDisks ();
    y2debug ("autoyast: Proposing - fix");
    Bootloader::Propose ();
    y2debug ("autoyast: Proposing done");

    // SLES only
    if( haskey(Profile::current, "kdump") )
        Call::Function("kdump_auto", ["Import", Profile::current["kdump"]:$[] ]);

    LanUdevAuto::Import(Profile::current["networking"]:$[]);

    Progress::NextStage();
    string rl = Profile::current["runlevel", "default"]:"";
    y2milestone("autoyast - configured runlevel: %1", rl);
    if (rl!="")
    {
        RunlevelEd::default_runlevel = rl;
    }
    else
    {
        RunlevelEd::default_runlevel = (Installation::x11_setup_needed ()
                && Arch::x11_setup_needed ()
                && Pkg::IsSelected ("xorg-x11") )? "5": "3";
    }
    y2milestone("autoyast - setting runlevel to: %1", RunlevelEd::default_runlevel);

//    AutoInstall::PXELocalBoot();
    AutoInstall::TurnOff();
    Progress::Finish();

    symbol ret = ProductControl::RunFrom ( ProductControl::CurrentStep () + 1, true);
    if (ret == `next)
	return `finish;
    return ret;
}

ACC SHELL 2018