ACC SHELL
/**
* File:
* modules/BootZIPL.ycp
*
* Module:
* Bootloader installation and configuration
*
* Summary:
* Module containing specific functions for ZIPL configuration
* and installation
*
* Authors:
* Joachim Plack <jplack@suse.de>
* Jiri Srain <jsrain@suse.cz>
* Philipp Thomas <pth@suse.de>
*
* $Id: BootZIPL.ycp 56771 2009-04-14 11:41:36Z jreidinger $
*
*/
{
module "BootZIPL";
textdomain "bootloader";
import "BootArch";
import "BootCommon";
import "Installation";
import "Kernel";
import "Mode";
import "Stage";
include "bootloader/zipl/helps.ycp";
include "bootloader/routines/popups.ycp";
// local data
map<string,map<string,any> > hw_descr = $[
"ctc" : $[
"skeleton": "hwcfg-ctc",
"target" : "ctc-bus-ccw-%1",
"options" : $[
"CCW_CHAN_IDS" : "%1 %2",
"CCW_CHAN_MODE" : "%3",
],
],
"qeth" : $[
"skeleton" : "hwcfg-qeth",
"target" : "qeth-bus-ccw-%1",
"options" : $[
"CCW_CHAN_IDS" : "%1 %2 %3",
"CCW_CHAN_MODE" : "%4",
],
],
"iucv" : $[
"skeleton" : "hwcfg-iucv",
"target" : "iucv-id-%1",
],
];
// misc. functions
/**
* Update /etc/sysconfig/hardware configuration
* Use data from install.inf file
* @return boolean true on success
*/
global define boolean updateHardwareConfig () {
if (! Stage::initial () || Mode::update ())
return true;
boolean failed = false;
string cfg = (string)SCR::Read (.etc.install_inf.Hardware);
y2milestone ("Read hardware configuration from install.inf: %1", cfg);
list<string> l = splitstring (cfg, ";");
foreach (string s, l, ``{
list<string> args = splitstring (s, ",");
args = maplist (string a, args, ``{
while (a != "" && substring (a, 0, 1) == " ")
a = substring (a, 1);
while (a != "" && substring (a, size (a) - 1, 1) == " ")
a = substring (a, 0, size (a) - 1);
return a;
});
string key = args[0]:"";
string a1 = args[1]:"";
string a2 = args[2]:"";
string a3 = args[3]:"";
string a4 = args[4]:"";
if (key != "")
{
map<string,any> descr = hw_descr[key]:$[];
string src = (string)(descr["skeleton"]:"");
string dst = sformat ((string)(descr["target"]:""),
a1, a2, a3, a4);
y2milestone ("Template: %1, Target: %2", src, dst);
string command = sformat (
"/bin/cp /etc/sysconfig/hardware/skel/%1 /etc/sysconfig/hardware/hwcfg-%2",
src, dst);
if (0 != SCR::Execute (.target.bash, command))
{
Report::Error (
// error report
_("Copying hardware configuration template failed."));
failed = true;
}
path p = add (.sysconfig.hardware.value, dst);
foreach (string k, string v,
(map<string,string>)(descr["options"]:$[]),
``{
path op = add (p, k);
v = sformat (v, a1, a2, a3, a4);
if (! SCR::Write (op, v))
failed = true;
});
}
});
if (! SCR::Write (.sysconfig.hardware, nil))
failed = true;;
return failed;
}
// general functions
/**
* Read settings from disk
* @param reread boolean true to force reread settings from system
* @param avoid_reading_device_map do not read new device map from file, use
* internal data
* @return boolean true on success
*/
global boolean Read (boolean reread, boolean avoid_reading_device_map) {
BootCommon::InitializeLibrary (reread, "zipl");
if (reread) {
BootCommon::ReadFiles (avoid_reading_device_map);
}
BootCommon::DetectDisks ();
boolean ret = BootCommon::Read (false, avoid_reading_device_map);
return ret;
}
// wrapper function to adjust to special zipl needs
map<string,any> CreateLinuxSection(string title) {
map<string,any>section = BootCommon::CreateLinuxSection(title);
section["target"] = "/boot/zipl";
return section;
}
/**
* Propose bootloader settings
*/
global define void Propose () {
BootCommon::DetectDisks ();
string parameters = BootArch::DefaultKernelParams ("");
BootCommon::globals = $[
"default":"menu",
];
BootCommon::sections = [
$[
"name":"menu",
"default":"1",
"prompt":"true",
"target":"/boot/zipl",
"timeout":"10",
"list": BootCommon::translateSectionTitle ("ipl") + ","
+ BootCommon::translateSectionTitle ("failsafe"),
"type":"menu",
],
CreateLinuxSection("ipl"),
CreateLinuxSection("failsafe"),
];
}
/**
* Save all bootloader configuration files to the cache of the PlugLib
* PlugLib must be initialized properly !!!
* @param clean boolean true if settings should be cleaned up (checking their
* correctness, supposing all files are on the disk
* @param init boolean true to init the library
* @param flush boolean true to flush settings to the disk
* @return boolean true if success
*/
global boolean Save (boolean clean, boolean init, boolean flush) {
boolean ret = BootCommon::Save (clean, init, flush);
if (Mode::normal ())
return ret;
updateHardwareConfig ();
return ret;
}
/**
* Display bootloader summary
* @return a list of summary lines
*/
global define list<string> Summary () {
// summary
return [_("Install S390 Boot Loader")];
}
/**
* Update read settings to new version of configuration files
*/
global define void Update () {
y2milestone ("No update functionality implemented");
}
/**
* Write bootloader settings to disk
* @return boolean true on success
*/
global define boolean Write () {
boolean ret = BootCommon::UpdateBootloader ();
ret = ret && BootCommon::InitializeBootloader ();
if (ret == nil)
ret = false;
return ret;
}
global map<string,symbol()> Dialogs () {
return $[];
}
/**
* Set section to boot on next reboot.
* @param section string section to boot
* @return boolean true on success
*/
global define boolean FlagOnetimeBoot (string section)
{
/* For now a dummy */
return true;
}
list <string> zipl_section_types()
{
return ["image", "menu", "dump"];
}
map<string,map<string,any> > ziplWidgets(){
return $[];
}
/**
* Return map of provided functions
* @return a map of functions (eg. $["write"::Write])
*/
global map<string, any> GetFunctions () {
return $[
//"export" : Export,
//"import" : Import,
"read" : Read,
//"reset" : Reset,
"propose" : Propose,
"save" : Save,
"summary" : Summary,
"update" : Update,
"write" : Write,
"widgets" : ziplWidgets,
"dialogs" : Dialogs,
"section_types" : zipl_section_types,
"flagonetimeboot" : FlagOnetimeBoot,
];
}
/**
* Initializer of S390 bootloader
*/
global define void Initializer () {
y2milestone ("Called ZIPL initializer");
BootCommon::current_bootloader_attribs = $[
"section_title" : "label",
"propose" : true,
"read" : true,
"scratch" : true,
];
BootCommon::InitializeLibrary (false, "zipl");
}
/**
* Constructor
*/
global void BootZIPL () {
BootCommon::bootloader_attribs["zipl"] = $[
"loader_name" : "zipl",
"required_packages" : [], // FIXME
"initializer" : BootZIPL::Initializer,
];
}
} // EOF
/*
* Local variables:
* mode: ycp
* mode: font-lock
* mode: auto-fill
* indent-level: 4
* fill-column: 78
* End:
*/
ACC SHELL 2018