YaST2 Developers Documentation: Misc

Misc

Misc.ycp Purpose: miscellaneous definitions for installation
  • Klaus Kaempf

This module has an unstable interface.

Imports

  • Mode

Structures

Global Functions

global ReadAlternateFile (string first, string second) -> any

Parameters:
first string name of first file to try
second string name of second file to try
Return value:
content of file try to read first file, if it doesn't exist, read second files must reside below /usr/lib/YaST2 files must have ycp syntax
global hardware_name (map hardware_entry) -> string

Parameters:
hardware_entry map map of .probe entry
Return value:
vendor and device name common function to extract 'name' of hardware
global translate (map lmap, string lang) -> string

Parameters:
lmap map map of language codes and translations e.g. $[ "default" : "Defaultstring", "de" : "German....", ...]
lang string language as ISO code, either 2 chars (de) or 5 chars (de_DE)
Return value:
translation Define a macro that looks up a localized string in a language map of the form $[ "default" : "Defaultstring", "de" : "German....", ...]
global SysconfigWrite (path level, list<list> values) -> boolean

SysconfigWrite()

Parameters:
level
values
Return value:
false if SCR::Write reported error write list of sysyconfig entries via rcconfig agent
global SplitOptions (string options, map optmap) -> map

MergeOptions Merges "opt1=val1 opt2=val2 ..." and $["opta":"vala", ..."] to $["opt1":"val1", "opt2":"val2", "opta":"vala", ...] as needed by modules.conf agent

Parameters:
options string module options, e.g. "opt1=val1 opt2=val2 ..."
optmap map possible old options $["opta":"vala", ...]
Return value:
$["opt1":"val1", "opt2":"val2", ...]
global SysconfigRead (path sysconfig_path, string defaultv) -> string

SysconfigRead()

Try an SCR::Read(...) and return the result if successful. On failure return the the second parameter (default value)

Parameters:
sysconfig_path Sysconfig SCR path.
defaultv Default value
Return value:
Success --> Result of SCR::Read
Failure --> Default value
global CustomSysconfigRead (string key, string defval, string location) -> string

Try to read value from sysconfig file and return the result if successful. Function reads from arbitrary sysconfig file, for which the agent doesn't exist: e.g. from different partition like /mnt/etc/sysconfig/file.

Parameters:
key Key of the value we want to read from sysconfig file.
defval
location Full path to target sysconfig file.
Return value:
Success --> Result of SCR::Read
Failure --> Default value
Example
 Misc::CustomSysconfigRead ("INSTALLED_LANGUAGES", "", Installation::destdir + "/etc/sysconfig/language");
global RunCommandWithTimeout (string run_command, string log_command, integer script_time_out) -> map

Runs a bash command with timeout.

Structure Returns map $[

     "exit" : int_return_code,
     "stdout"  : [ "script", "stdout", "lines" ],
     "stderr"  : [ "script", "stderr", "lines" ],
 ]
Parameters:
run_command what to run
log_command what to log (passwords masked)
script_time_out in sec.
Return value:
with out, err and ret_code
global RunDumbTimeout (string command, string log_command, integer seconds) -> map

Run - with a timeout - on dumb terminal to disable colors etc - using 'exit $?' because of buggy behavior '.background vs. ZMD' (FIXME still needed???)

Parameters:
command a command
log_command a command to log
seconds timeout
Return value:
with out, err and ret_code