ACC SHELL

Path : /usr/share/YaST2/include/bootloader/routines/
File Upload :
Current File : //usr/share/YaST2/include/bootloader/routines/switcher.ycp

/**
 * File:
 *      include/bootloader/routines/switcher.ycp
 *
 * Module:
 *      Bootloader installation and configuration
 *
 * Summary:
 *      Functions for choosing proper bootloader-specific functions
 *
 * Authors:
 *      Jiri Srain <jsrain@suse.cz>
 *      Olaf Dabrunz <od@suse.de>
 *
 * $Id: switcher.ycp 56797 2009-04-16 06:32:38Z jreidinger $
 *
 */

{

import "BootELILO";
import "BootGRUB";
import "BootLILO";
import "BootPOWERLILO";
import "BootZIPL";
import "BootCommon";

    /**
      * Get map of main functions for bootloader
      * @param bootloader string bootloader name
      * @return map of function
      */
    global define map getFunctions (string bootloader) ``{
	if (bootloader == nil || bootloader == "")
	    return $[];
	map bl_functions = $[
	    "lilo"  : BootLILO::GetFunctions,
	    "grub"  : BootGRUB::GetFunctions,
	    "elilo" : BootELILO::GetFunctions,
	    "zipl"  : BootZIPL::GetFunctions,
	    "ppc"   : BootPOWERLILO::GetFunctions
	];
	map<string,any> () gf = (map<string,any>())(bl_functions[bootloader]:nil);
	if (gf == nil)
	{
	    y2warning ("No bootloader-specific functions specified");
	    return $[];
	}
	return gf();
    }

    /**
      * Export bootloader-specific settings
      * @return map of settings
      */
    global define map blExport () ``{
        map functions = getFunctions (BootCommon::getLoaderType (false));
        map() toEval = functions["export"]:BootCommon::Export;
        return toEval ();
    }

    /**
      * Import settings to bootloader
      * @param settings map of settingss
      * @return boolean true on success
      */
    global define boolean blImport (map settings) ``{
	map functions = getFunctions (BootCommon::getLoaderType (false));
	boolean(map) toEval = functions["import"]:BootCommon::Import;
	return toEval (settings);
    }

/**
 * Read bootloader-specific settings
 * @param reread boolean true to force rereading the settings from the disk
 * @return boolean true on success
 */
global define boolean blRead (boolean reread, boolean avoid_reading_device_map) ``{
    map functions = getFunctions (BootCommon::getLoaderType (false));
    boolean(boolean, boolean) toEval = functions["read"]:BootCommon::Read;
    return toEval (reread, avoid_reading_device_map);
}

    /**
      * Reset bootloader-specific settings
      * @param init boolean true if basic initialization of system-dependent
      * settings should be done
      */
    global define void blReset (boolean init) ``{
        map functions = getFunctions (BootCommon::getLoaderType (false));
        void(boolean) toEval = functions["reset"]:BootCommon::Reset;
        toEval (init);
    }

    /**
      * Propose bootloader settings
      */
    global define void blPropose () ``{
        map functions = getFunctions (BootCommon::getLoaderType (false));
        void() toEval = functions["propose"]:BootCommon::Propose;
        toEval ();
    }

/**
 * Get sections types
 * @return list <string> section types
 */
global list <string> blsection_types ()
{
	map functions = getFunctions (BootCommon::getLoaderType (false));
        list<string> fallback(){
          return ["image"];
        }
	list<string>() toEval = functions["section_types"]:fallback;
	return toEval();
}

/**
 * Save bootloader cfg. files to the cache of the pluglib
 * @param clean boolean true to perform checks on the settings
 * @param init boolean true to reinitialize the library
 * @param flush boolean true to flush the settings to the disk
 * @return boolean true on success
 */
global boolean blSave (boolean clean, boolean init, boolean flush) {
    map functions = getFunctions (BootCommon::getLoaderType (false));
    boolean(boolean,boolean,boolean) toEval
	= functions["save"]:BootCommon::Save;
    return toEval (clean, init, flush);
}

    /**
      * Get cfg. summary
      * @return a list summary items
      */
    global define list<string> blSummary () ``{
        map functions = getFunctions (BootCommon::getLoaderType (false));
        list<string>() toEval = functions["summary"]:BootCommon::Summary;
        return toEval ();
    }

    /**
      * Update bootloader-specific settings
      */
    global define void blUpdate () ``{
        map functions = getFunctions (BootCommon::getLoaderType (false));
        void() toEval = functions["update"]:BootCommon::Update;
        toEval ();
    }

    /**
      * Do the bootloader installation
      * @return boolean true on success
      */
    global define boolean blWrite () ``{
        map functions = getFunctions (BootCommon::getLoaderType (false));
        boolean() toEval = functions["write"]:BootCommon::Write;
        return toEval ();
    }

/**
 * Get description maps of loader-specific widgets
 * @return a map containing description of all loader-specific widgets
 */
global map<string,map<string,any> > blWidgetMaps () {
    map functions = getFunctions (BootCommon::getLoaderType (false));
    map<string,map<string,any> >() toEval = (map<string,map<string,any> >())
	functions["widgets"]:nil;
    if (toEval != nil)
	return toEval ();
    else
	return $[];
}

/**
 * Get the loader-specific dialogs
 * @return a map of loader-specific dialogs
 */
global map<string,symbol()> blDialogs () {
    map functions = getFunctions (BootCommon::getLoaderType (false));
    map<string,symbol()> () toEval = (map<string,symbol()> ())
	functions["dialogs"]:nil;
    if (toEval != nil)
	return toEval ();
    else
	return $[];
}

/**
 * Set section to boot on next reboot for this type of bootloader
 * @param section string section to boot
 * @return boolean true on success
 */
global boolean blFlagOnetimeBoot (string section) {
    map functions = getFunctions (BootCommon::getLoaderType (false));
    boolean(string) toEval = (boolean(string)) functions["flagonetimeboot"]:nil;
    if (toEval != nil)
	return toEval (section);
    else
	return false;
}


} // EOF

ACC SHELL 2018