ACC SHELL
/**
* File: modules/AutoinstGeneral.ycp
* Package: Autoyast
* Summary: Configuration of general settings for autoyast
* Authors: Anas Nashif (nashif@suse.de)
*
* $Id: AutoinstGeneral.ycp 62055 2010-05-21 13:07:18Z ug $
*/
{
module "AutoinstGeneral";
textdomain "autoinst";
import "Stage";
import "AutoInstall";
import "AutoinstConfig";
import "Summary";
import "Keyboard";
import "Mouse";
import "Language";
import "Keyboard";
import "Timezone";
import "Misc";
import "Profile";
import "Pkg";
import "ProductFeatures";
import "Storage";
import "SignatureCheckCallbacks";
// All shared data are in yast2.rpm to break cyclic dependencies
import "AutoinstData";
//
// Show proposal and ask user for confirmation to go on with auto-installation
// Similar to interactive mode, without letting use change settings
// Interactive mode implies confirmation as well..
//
global boolean Confirm = true;
//
// Mode Settings
//
global map mode = $[];
global map signature_handling = $[];
global list askList = [];
// global list<string> proposals = ["bootloader_proposal", "software_proposal", "country_simple_proposal", "timezone_proposal", "users_proposal", "runlevel_proposal", "hwinfo_proposal", "mouse_proposal", "deploying_proposal"];
global list<string> proposals = [];
global map storage = $[];
/* default value of settings modified */
global boolean modified = false;
/**
* Function sets internal variable, which indicates, that any
* settings were modified, to "true"
*/
global define void SetModified () {
modified = true;
}
/**
* Functions which returns if the settings were modified
* @return boolean settings were modified
*/
global define boolean GetModified () {
return modified;
}
/**
* Summary of configuration
* @return string Formatted summary
*/
global define string Summary()
{
//string language_name = "";
//string keyboard_name = "";
string mouse_name = "";
if ( AutoinstData::mouse["id"]:"" != "" && AutoinstData::mouse["id"]:"" != "probe")
{
Mouse::Set(AutoinstData::mouse["id"]:"");
mouse_name = Mouse::MakeProposal(false, false);
}
else
{
mouse_name = _("probe");
}
string summary = "";
summary = Summary::AddHeader(summary, _("Mouse"));
summary = Summary::AddLine(summary, (mouse_name != "") ?
mouse_name : Summary::NotConfigured());
summary = Summary::AddHeader(summary, _("Confirm installation?"));
summary = Summary::AddLine(summary, (mode["confirm"]:true) ?
_("Yes") : _("No"));
summary = Summary::AddHeader(summary, _("Second Stage of AutoYaST"));
summary = Summary::AddLine(summary, (mode["second_stage"]:true) ?
_("Yes") : _("No"));
summary = Summary::AddHeader(summary, _("Halting the machine after stage one"));
summary = Summary::AddLine(summary, (mode["halt"]:false) ?
_("Yes") : _("No"));
if( mode["final_halt"]:false == true ) {
summary = Summary::AddHeader(summary, _("Halting the machine after stage two"));
summary = Summary::AddLine(summary, _("Yes"));
}
if( mode["final_reboot"]:false == true ) {
summary = Summary::AddHeader(summary, _("Reboot the machine after stage two"));
summary = Summary::AddLine(summary, _("Yes"));
}
summary = Summary::AddHeader(summary, _("Signature Handling"));
summary = Summary::AddLine(summary, (AutoinstGeneral::signature_handling["accept_unsigned_file"]:false) ?
_("Accepting unsigned files") : _("Not accepting unsigned files"));
summary = Summary::AddLine(summary, (AutoinstGeneral::signature_handling["accept_file_without_checksum"]:false) ?
_("Accepting files without a checksum") : _("Not accepting files without a checksum"));
summary = Summary::AddLine(summary, (AutoinstGeneral::signature_handling["accept_verification_failed"]:false) ?
_("Accepting failed verifications") : _("Not accepting failed verifications"));
summary = Summary::AddLine(summary, (AutoinstGeneral::signature_handling["accept_unknown_gpg_key"]:false) ?
_("Accepting unknown GPG keys") : _("Not accepting unknown GPG Keys"));
summary = Summary::AddLine(summary, (AutoinstGeneral::signature_handling["import_gpg_key"]:false) ?
_("Importing new GPG keys") : _("Not importing new GPG Keys"));
// summary = Summary::AddHeader(summary, _("Proposals"));
// foreach(string p, proposals, ``{
// summary = Summary::AddLine(summary, p);
// });
return summary;
}
/**
* Import Configuration
* @param map settings
* @return booelan
*/
global define boolean Import (map settings)
{
SetModified ();
y2milestone("General import: %1",settings);
AutoinstData::mouse = settings["mouse"]:$[];
mode = settings["mode"]:$[];
signature_handling = settings["signature-handling"]:$[];
askList = settings["ask-list"]:[];
proposals = settings["proposals"]:[];
storage = settings["storage"]:$[];
return true;
}
/**
* Export Configuration
* @return map
*/
global define map Export ()
{
map general = $[];
general["mouse"] = AutoinstData::mouse;
general["mode"] = mode;
general["signature-handling"] = signature_handling;
general["ask-list"] = askList;
general["proposals"] = proposals;
general["storage"] = storage;
return general;
}
/**
* set the sigature handling
* @return void
*/
global define void SetSignatureHandling() {
// this will break compatibility a bit. A XML file without signature handling can
// block the installation now because we have the popups back
Pkg::CallbackAcceptUnsignedFile (SignatureCheckCallbacks::AcceptUnsignedFile);
Pkg::CallbackAcceptFileWithoutChecksum (SignatureCheckCallbacks::AcceptFileWithoutChecksum);
Pkg::CallbackAcceptVerificationFailed (SignatureCheckCallbacks::AcceptVerificationFailed);
Pkg::CallbackTrustedKeyAdded (SignatureCheckCallbacks::TrustedKeyAdded);
Pkg::CallbackAcceptUnknownGpgKey (SignatureCheckCallbacks::AcceptUnknownGpgKey);
Pkg::CallbackImportGpgKey (SignatureCheckCallbacks::ImportGpgKey);
Pkg::CallbackAcceptNonTrustedGpgKey (SignatureCheckCallbacks::TrustGpgKey);
Pkg::CallbackAcceptWrongDigest (SignatureCheckCallbacks::AcceptWrongDigest);
Pkg::CallbackAcceptUnknownDigest (SignatureCheckCallbacks::AcceptUnknownDigest);
Pkg::CallbackTrustedKeyRemoved (SignatureCheckCallbacks::TrustedKeyRemoved);
if( haskey(signature_handling, "accept_unsigned_file" ) )
Pkg::CallbackAcceptUnsignedFile(
signature_handling["accept_unsigned_file"]:false ? AutoInstall::callbackTrue_boolean_string_integer : AutoInstall::callbackFalse_boolean_string_integer
);
if( haskey(signature_handling, "accept_file_without_checksum" ) )
Pkg::CallbackAcceptFileWithoutChecksum(
signature_handling["accept_file_without_checksum"]:false ? AutoInstall::callbackTrue_boolean_string : AutoInstall::callbackFalse_boolean_string
);
if( haskey(signature_handling, "accept_verification_failed") )
Pkg::CallbackAcceptVerificationFailed(
signature_handling["accept_verification_failed"]:false ? AutoInstall::callbackTrue_boolean_string_map_integer : AutoInstall::callbackFalse_boolean_string_map_integer
);
if( haskey(signature_handling, "trusted_key_added") )
Pkg::CallbackTrustedKeyAdded(
AutoInstall::callback_void_map
);
if( haskey(signature_handling, "trusted_key_removed") )
Pkg::CallbackTrustedKeyRemoved(
AutoInstall::callback_void_map
);
if( haskey(signature_handling, "accept_unknown_gpg_key") )
Pkg::CallbackAcceptUnknownGpgKey(
signature_handling["accept_unknown_gpg_key"]:false ? AutoInstall::callbackTrue_boolean_string_string_integer : AutoInstall::callbackFalse_boolean_string_string_integer
);
if( haskey(signature_handling, "import_gpg_key") )
Pkg::CallbackImportGpgKey(
signature_handling["import_gpg_key"]:false ? AutoInstall::callbackTrue_boolean_map_integer : AutoInstall::callbackFalse_boolean_map_integer
);
if( haskey(signature_handling, "accept_non_trusted_gpg_key") )
Pkg::CallbackAcceptNonTrustedGpgKey(
signature_handling["accept_non_trusted_gpg_key"]:false ? AutoInstall::callbackTrue_boolean_map : AutoInstall::callbackFalse_boolean_map
);
if( haskey(signature_handling, "accept_wrong_digest") )
Pkg::CallbackAcceptWrongDigest(
signature_handling["accept_wrong_digest"]:false ? AutoInstall::callbackTrue_boolean_string_string_string : AutoInstall::callbackFalse_boolean_string_string_string
);
if( haskey(signature_handling, "accept_unknown_digest") )
Pkg::CallbackAcceptWrongDigest(
signature_handling["accept_unknown_digest"]:false ? AutoInstall::callbackTrue_boolean_string_string_string : AutoInstall::callbackFalse_boolean_string_string_string
);
}
/**
* Write General Configuration
* @return boolean true on success
*/
global define boolean Write()
{
AutoinstConfig::Confirm = mode["confirm"]:true;
if( haskey( mode, "forceboot" ) )
ProductFeatures::SetBooleanFeature( "globals", "kexec_reboot", !mode["forceboot"]:false );
AutoinstConfig::Halt = mode["halt"]:false;
AutoinstConfig::RebootMsg = mode["rebootmsg"]:false;
AutoinstConfig::setProposalList( proposals );
// see bug #597723. Some machines can't boot with the new alignment that parted uses
// `align_cylinder == old behavior
// `align_optimal == new behavior
if( haskey( storage, "partition_alignment" ) ) {
Storage::SetPartitionAlignment( storage["partition_alignment"]:`align_optimal );
y2milestone("alignment set to %1", storage["partition_alignment"]:`align_optimal);
}
//
// mouse
//
if ( AutoinstData::mouse["id"]:"" != "probe" && AutoinstData::mouse["id"]:"" != "")
{
Mouse::Set(AutoinstData::mouse["id"]:"");
}
else if (haskey(AutoinstData::mouse,"device"))
{
//
// Otherwise, try to find the mouse id from the DB using data supplied by user,
// at least the device is needed.
//
string device = AutoinstData::mouse["device"]:"none";
integer wheels = AutoinstData::mouse["wheels"]:0;
map<string, list> mice = (map<string, list>)Misc::ReadAlternateFile ("mouse_db.ycp", "mouse_raw.ycp");
foreach(string f,list g, mice, ``{
map data = g[1]:$[];
if ( data["wheels"]:0 == wheels && data["device"]:"" == device)
{
AutoinstData::mouse["id"] = f;
}
});
Mouse::Set(AutoinstData::mouse["id"]:"");
}
SetSignatureHandling();
}
/**
* Constructor
*/
global define void AutoinstGeneral ()
{
if( Stage::cont () ) {
// FIXME: wrong position for this
if (Profile::current["general"]:$[] != $[])
Import(Profile::current["general"]:$[]);
SetSignatureHandling();
// FIXME: seriously FIXME! We need a real Read() function
Storage::InitLibstorage(false);
storage["partition_alignment"] = Storage::GetPartitionAlignment();
}
return;
}
}
ACC SHELL 2018