Bootloader installation and configuration
|
include/bootloader/routines/misc-common.ycp
|
Miscelaneous functions for bootloader configuration and installation
|
|
|
WARNING:
To be included to BootCommon.ycp only, requires function
getLoaderType to avoid include-import cycle
Use import "BootCommon" instead.
Imports
- Kernel
- Misc
- Mode
- Report
- Storage
- StorageDevices
Includes
- bootloader/routines/routines.ycp
Global Variables
Global Functions
- AddMbrToDescription (string descr, string device)
- GetAdditionalFailsafeParams ()
- GetBootloaderDevice ()
- IsMbr (string device)
- UpdateInstallationKernelParameters ()
- addValueToBootloaderSection (symbol s_section, string key, any value)
- confirmAbort ()
- convertSection (string otype, string ntype, list<map> orig)
- createSectionItemsList (list prependlist, list forbidden_keys, boolean alpha_order)
- dev2majmin (string device)
- dev2majminIfNonStandard (string device)
- difflist (list a, list b)
- filterOrder (list order, map widgets, integer index)
- getAliasesKeys ()
- getAnyTypeAttrib (string attrib, any default)
- getBooleanAttrib (string attrib)
- getBootloaderPackages (string bootloader)
- getDefaultFirstIndex ()
- getDefaultKey ()
- getDefaultSection ()
- getDefaultType ()
- getDeviceOfRaid (string device)
- getFileChangeDate (string filename)
- getFloppyDevices ()
- getFreeSectionLabel ()
- getKernelKey ()
- getKernelParamFromLine (string line, string key)
- getKernelParamKeys ()
- getLargestSwapPartition ()
- getLoaderName (string bootloader)
- getPartitionList (symbol type)
- getPartitionToActivate ()
- getSectionIndex (string name)
- getSectionTitle ()
- getSectionType (list section)
- getSwapPartitions ()
- getTimeoutMultiplier ()
- installingToFloppy ()
- isBlank (string s)
- isSpecial (string opt)
- list2path (list<string> strs)
- loadCfgFileFromAgent ()
- markGeneralOptionChanged (string optname)
- mergePath (list<string> devpth)
- mod2ui (any val)
- opttypes ()
- removeBlanks (string original)
- replaceAll (string src, string from, string to)
- restoreMBR (string device)
- saveCfgFileToAgent ()
- saveMBR (string device)
- sectOptions2Map (string bl, string type, string section)
- setKernelParamToLine (string line, string key, string value)
- splitPath (string fullpth)
- strip (string str)
- swapItems (list input, integer index1, integer index2)
- tobool (any v)
- translateSectionTitle (string orig)
- ui2mod (any val)
- updateGfxMenu ()
- updateKernelParams (string orig)
- updateMBR ()
- updateTimeoutPopupForFloppy (string bootloader)
|
|
|
global getSectionTitle () -> string
|
|
Get the name of key containing section name of currently used bootloader
- Return value:
global getKernelKey () -> string
|
|
Get the name of key containing kernel in currently used bootloader
- Return value:
global getBootloaderPackages (string bootloader) -> list<string>
|
|
Get packages needed by specified bootloader
maybe should be moved to bootloader specific modules
- Parameters:
bootloader |
string name of bootloader |
- Return value:
|
a list of required packages names |
global getLoaderName (string bootloader) -> string
|
|
return printable name of bootloader
- Parameters:
bootloader |
string bootloader type internal string |
- Return value:
|
printable bootloader name |
global getDefaultKey () -> string
|
|
Get the name of key containing default section identification
in currently used bootloader
- Return value:
|
default section option key |
global getDefaultType () -> symbol
|
|
Get type of value containing default section identification
in currently used bootloader
- Return value:
|
`label or `index (type of contents) |
global getDefaultFirstIndex () -> integer
|
|
Get index of first section when index identificatipno is used
- Return value:
global getTimeoutMultiplier () -> integer
|
|
Get the value which multiplies timeout (in seconds) before writing
to bootloader configuration file (eg. 10 for lilo)
- Return value:
global getAliasesKeys () -> list<string>
|
|
Get list of keys which mean section alias
- Return value:
global getBooleanAttrib (string attrib) -> boolean
|
|
Get value of specified boolean bootloader attribute
- Parameters:
attrib |
string attribute name |
- Return value:
global getAnyTypeAttrib (string attrib, any default) -> any
|
|
Get value of specified bootloader attribute
- Parameters:
attrib |
string attribute name |
default |
any default value of the attribute (if not found) |
- Return value:
global getSectionIndex (string name) -> integer
|
|
Get index of a section specified by name
- Parameters:
- Return value:
|
index of the section or nil if not found |
global convertSection (string otype, string ntype, list<map> orig) -> list<map>
|
|
Convert section orig from type otype to ntype
Some information gets lost. ntype must be different from otype
- Parameters:
otype |
string original section type, "image" or "other" |
ntype |
string new section type, "image" or "other" |
orig |
list original section |
- Return value:
global getKernelParamKeys () -> map
|
|
Get map where to store kernel parameters
- Return value:
|
describing where to store which kernel parameter |
global getSectionType (list section) -> any
|
|
Get type of specified section
Type depends on currently used bootloader
- Parameters:
section |
map of the section |
- Return value:
global addValueToBootloaderSection (symbol s_section, string key, any value) -> void
|
|
Add value to key in bootloader section
- Parameters:
s_section |
symbol representing section, values are
`globals, `current_globals, `current_section |
key |
string key of requested parameter |
value |
any value to be set, nil for remiving key |
global getFreeSectionLabel () -> string
|
|
Generates unused section label for new section
- Return value:
global getFloppyDevices () -> list<string>
|
|
Get the list of installed floppy drives
- Return value:
global updateTimeoutPopupForFloppy (string bootloader) -> void
|
|
Update the text of countdown widget
- Parameters:
bootloader |
string printable name of used bootloader |
global bootloaders -> list<string>
|
|
List of all supported bootloaders
global list2path (list<string> strs) -> path
|
|
converts array of string to path
- Parameters:
- Return value:
|
whose components are taken from strs |
global getPartitionList (symbol type) -> list<string>
|
|
returns list of partitions. looks at '/proc/partitions' and creates list
of partition for combobox or menu
- Parameters:
type |
symbol
`boot - for botloader installation
`root - for kernel root
`boot_other - for bootable partitions of other systems
`all - all partitions
`parts_old - all partitions, except those what will be created
during isntallation
`deleted - all partitions deleted in current proposal |
- Return value:
global isBlank (string s) -> boolean
|
|
returns true if char is blank (newline, tab or space)
- Parameters:
- Return value:
global strip (string str) -> string
|
|
removes trailing and leading blank chars from string.
eg: " as df " -> "as df"
- Parameters:
- Return value:
global replaceAll (string src, string from, string to) -> string
|
|
replaces all occurences of 'from' to 'to' in src
- Parameters:
src |
input string |
from |
string to be replaced |
to |
string to be replaced by |
- Return value:
global mod2ui (any val) -> any
|
|
convert string values from agent representation to module representation
1) if string is quoted, quotes are removed
2) if string contains escaped quotes, they're unescaped
- Parameters:
- Return value:
global opttypes () -> map<string,string>
|
|
returns map of options and their types
- Return value:
global isSpecial (string opt) -> boolean
|
|
return true if given option is special
- Parameters:
- Return value:
global sectOptions2Map (string bl, string type, string section) -> list<map>
|
|
reads specified section and returns values as map
[$[option1:value1], $[option2:value2],...]
- Parameters:
bl |
string bootloader to read |
type |
string "sections" / "" |
section |
string |
- Return value:
global difflist (list a, list b) -> list
|
|
returns list difference A \ B (items that are in A and are not in B)
- Parameters:
- Return value:
global ui2mod (any val) -> any
|
|
reverse of mod2ui
- Parameters:
- Return value:
global swapItems (list input, integer index1, integer index2) -> list
|
|
returns modified list where items index1 and index2 are swapped.
if indices are out of bounds, unmodified list is returned.
- Parameters:
input |
list |
index1 |
index of the first element |
index2 |
index og the second element |
- Return value:
global splitPath (string fullpth) -> list<string>
|
|
translate filename path (eg. /boot/kernel) to list of device
and relative path
- Parameters:
fullpth |
string fileststem path (eg. /boot/vmlinuz) |
- Return value:
|
containing device and relative path,
eg. ["/dev/hda1", "/vmlinuz"] |
global mergePath (list<string> devpth) -> string
|
|
translate list of device and relative path
to filename path (eg. /boot/kernel)
- Parameters:
devpth |
list of two strings, first for device name, second for
relative path (eg. ["/dev/hda1", "/vmlinuz"]) |
- Return value:
|
fileststem path (eg. /boot/vmlinuz) |
global getDeviceOfRaid (string device) -> string
|
|
If device is part of RAID (md), then return first of its members
otherwise return the same as argument
- Parameters:
device |
string device of the RAID |
- Return value:
global GetBootloaderDevice () -> string
|
|
Get bootloader device for specified location
- Return value:
global installingToFloppy () -> boolean
|
|
- Return value:
|
true if installing bootloader to floppy |
global getDefaultSection () -> string
|
|
Get the label of default section
- Return value:
|
label default section label |
global getKernelParamFromLine (string line, string key) -> string
|
|
get kernel parameter from kernel command line
- Parameters:
line |
string original line |
key |
string parameter key |
- Return value:
|
value, "false" if not present,
"true" if present key without value |
global setKernelParamToLine (string line, string key, string value) -> string
|
|
set kernel parameter to GRUB command line
- Parameters:
line |
string original line |
key |
string parameter key |
value |
string value, "false" to remove key,
"true" to add key without value |
- Return value:
global saveCfgFileToAgent () -> boolean
|
|
Save settings stored in memory of module to Lilo agent
- Return value:
global loadCfgFileFromAgent () -> boolean
|
|
Load settings from Lilo agent to module variables
- Return value:
global markGeneralOptionChanged (string optname) -> void
|
|
Mark general bootloader option as changed by user
- Parameters:
optname |
string option name |
global removeBlanks (string original) -> string
|
|
remove blanks from section name and replace them with _
when not using GRUB
- Parameters:
- Return value:
global filterOrder (list order, map widgets, integer index) -> map
|
|
Filter list to only entries which are present as keys in map
- Parameters:
order |
list (ordered) of settings |
widgets |
map of present widgets |
index |
of selected option |
- Return value:
|
containing new index of selected option and list of options
where options that aren't ordered precede ordered options |
global getPartitionToActivate () -> map
|
|
Get partition which should be activated if doing it during bl inst.
- Return value:
|
$[ "dev" : string, "mbr": string, "num": any]
containing device (eg. "/dev/hda4"), disk (eg. "/dev/hda") and
partition number (eg. 4) |
global getFileChangeDate (string filename) -> string
|
|
Get last change time of file
- Parameters:
filename |
string name of file |
- Return value:
|
last change date as YYYY-MM-DD-HH-MM-SS |
global saveMBR (string device) -> void
|
|
Save current MBR to /boot/backup_mbr
Also save to /var/lib/YaST2/backup_boot_sectors/%device, if some
existing, rename it
- Parameters:
device |
string name of device |
global updateMBR () -> boolean
|
|
Update contents of MBR (active partition and booting code)
- Return value:
global restoreMBR (string device) -> boolean
|
|
Rewrite current MBR with /var/lib/YaST2/backup_boot_sectors/%device
Warning!!! don't use for bootsectors, 446 bytes of sector are written
- Parameters:
device |
string device to rewrite MBR to |
- Return value:
global dev2majmin (string device) -> string
|
|
Translate device name to major/minor number
- Parameters:
- Return value:
|
major*256+minor hexadecimal without leading 0x, in case
of any fail return unchanged device node |
global dev2majminIfNonStandard (string device) -> string
|
|
Translate device name to major/minor number if the device is not
"usual"
- Parameters:
- Return value:
|
the original device parameter if it is "usual",
same as dev2majmin otherwise |
global tobool (any v) -> boolean
|
|
Convert any to boolean
- Parameters:
- Return value:
global updateKernelParams (string orig) -> string
|
|
Update kernel parameters if some were added in Kernel module
- Parameters:
orig |
original kernel parameters or kernel command line |
- Return value:
|
kernel command line or parameters with added new parameters |
global confirmAbort () -> boolean
|
|
Check whether settings were changed and if yes, ask for exit
without saving
- Return value:
global createSectionItemsList (list prependlist, list forbidden_keys, boolean alpha_order) -> list
|
|
Create list of items to be displayed in bootloader section
- Parameters:
prependlist |
list of items, that should be at the beginning |
forbidden_keys |
list of keys, that shouldn't be added to the list |
alpha_order |
boolean true if items should be alphabetically
ordered (except prependlist) |
- Return value:
global getSwapPartitions () -> map<string, integer>
|
|
Get map of swap partitions
- Return value:
|
where key is partition name and value its size |
global getLargestSwapPartition () -> string
|
|
Get the name of the largest available swap partition
- Return value:
|
name of the largest partition |
global translateSectionTitle (string orig) -> string
|
|
Create translated name of a section
- Parameters:
orig |
string original section name |
- Return value:
global IsMbr (string device) -> boolean
|
|
Check if device is MBR of a disk
- Parameters:
device |
string device to check |
- Return value:
global AddMbrToDescription (string descr, string device) -> string
|
|
Add '(MBR)' to the disk description if it is a MBR of some partition
- Parameters:
descr |
string disk description |
device |
string disk device |
- Return value:
global UpdateInstallationKernelParameters () -> void
|
|
Update the Kernel::vgaType value to the saved one if not defined
global GetAdditionalFailsafeParams () -> string
|
|
Get additional kernel parameters
- Return value:
|
additional kernel parameters |
global updateGfxMenu () -> boolean
|
|
Update graphical bootloader to contain help text of current language
And make the selected installation language default
|