Module: Yast::BootloaderRoutinesLibIfaceInclude
- Defined in:
- src/include/bootloader/routines/lib_iface.rb
Defined Under Namespace
Classes: TmpYAMLFile
Constant Summary
- STATE_FILE =
"/var/lib/YaST2/pbl-state"
Instance Method Summary (collapse)
-
- (Boolean) CommitSettings
Flush the internal cache of the library to the disk.
-
- (Boolean) DefineMultipath(multipath_map)
Set the mapping (real device multipath).
-
- (String) examineMBR(device)
Analyse content of MBR.
-
- (Object) GetDeviceMap
Get the device mapping (Linux Firmware).
-
- (Object) GetFilesContents
Get contents of files from the library cache.
-
- (Object) GetGlobal
Get global bootloader options.
-
- (Object) GetSections
Get boot loader sections.
- - (Object) initialize_bootloader_routines_lib_iface(include_target)
-
- (Boolean) InitializeBootloader
Initialize the boot loader (eg. modify firmware, depending on architecture).
-
- (Boolean) InitializeLibrary(force, loader)
Initialize the bootloader library.
-
- (Boolean) ReadFiles(avoid_reading_device_map)
Read the files from the system to internal cache of the library data.
- - (Object) run_pbl_yaml(*args)
-
- (Boolean) SetDeviceMap(device_map)
Set the device mapping (Linux Firmware).
-
- (Object) SetDiskInfo
Retrieve the data for perl-Bootloader library from Storage module and pass it along @return nothing FIXME: this should be done directly in perl-Bootloader through LibStorage.pm.
-
- (Boolean) SetFilesContents(files)
Set the contents of all files to library cache.
-
- (Boolean) SetGlobal(globals)
Set global bootloader options.
-
- (Boolean) SetSections(sections)
Set boot loader sections.
- - (Object) SetSecureBoot(enable)
-
- (Boolean) UpdateBootloader
Update the bootloader settings, make updated saved settings active.
-
- (String) UpdateSerialConsole(append, console)
Update append in from boot section, it means take value from “console” and add it to “append”.
Instance Method Details
- (Boolean) CommitSettings
Flush the internal cache of the library to the disk
292 293 294 295 296 297 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 292 def CommitSettings Builtins.y2milestone("Writing files to system") run_pbl_yaml "WriteSettings()" true end |
- (Boolean) DefineMultipath(multipath_map)
Set the mapping (real device <-> multipath)
237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 237 def DefineMultipath(multipath_map) Builtins.y2milestone("Storing multipath map: %1", multipath_map) if Builtins.size(multipath_map) == 0 Builtins.y2milestone("Multipath was not detected") return true end arg_data = TmpYAMLFile.new(multipath_map) run_pbl_yaml "DefineMultipath(#{arg_data.path})" true ensure arg_data.unlink if arg_data end |
- (String) examineMBR(device)
Analyse content of MBR
397 398 399 400 401 402 403 404 405 406 407 408 409 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 397 def examineMBR(device) device_data = TmpYAMLFile.new(device) ret_data = TmpYAMLFile.new run_pbl_yaml "#{ret_data.path}=ExamineMBR(#{device_data.path})" ret = ret_data.data Builtins.y2milestone("Device: %1 includes in MBR: %2", device, ret) ret ensure device_data.unlink ret_data.unlink end |
- (Object) GetDeviceMap
Get the device mapping (Linux <-> Firmware)
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 255 def GetDeviceMap Builtins.y2milestone("Reading device mapping") res_data = TmpYAMLFile.new run_pbl_yaml "#{res_data.path}=GetDeviceMapping()" devmap = res_data.data if !devmap Builtins.y2error("Reading device mapping failed") return {} end Builtins.y2milestone("Read device mapping: %1", devmap) devmap ensure res_data.unlink end |
- (Object) GetFilesContents
Get contents of files from the library cache
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 361 def GetFilesContents Builtins.y2milestone("Getting contents of files") ret_data = TmpYAMLFile.new run_pbl_yaml "#{ret_data.path}=GetFilesContents()" ret = ret_data.data if ret == nil Builtins.y2error("Getting contents of files failed") return {} end ret ensure ret_data.unlink end |
- (Object) GetGlobal
Get global bootloader options
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 203 def GetGlobal Builtins.y2milestone("Reading bootloader global settings") globals_data = TmpYAMLFile.new run_pbl_yaml "#{globals_data.path}=GetGlobalSettings()" glob = globals_data.data if glob == nil Builtins.y2error("Reading global settings failed") return {} end Builtins.y2milestone("Read global settings: %1", glob) glob ensure globals_data.unlink end |
- (Object) GetSections
Get boot loader sections
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 169 def GetSections sections_data = TmpYAMLFile.new Builtins.y2milestone("Reading bootloader sections") run_pbl_yaml "#{sections_data.path}=GetSections()" sects = sections_data.data if sects == nil Builtins.y2error("Reading sections failed") return [] end Builtins.y2milestone("Read sections: %1", sects) sects ensure sections_data.unlink end |
- (Object) initialize_bootloader_routines_lib_iface(include_target)
28 29 30 31 32 33 34 35 36 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 28 def initialize_bootloader_routines_lib_iface(include_target) textdomain "bootloader" Yast.import "Storage" Yast.import "Mode" # Loader the library has been initialized to use @library_initialized = nil end |
- (Boolean) InitializeBootloader
Initialize the boot loader (eg. modify firmware, depending on architecture)
348 349 350 351 352 353 354 355 356 357 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 348 def InitializeBootloader ret_data = TmpYAMLFile.new run_pbl_yaml "#{ret_data.path}=InitializeBootloader()" ret = ret_data.data Builtins.y2milestone("Initializing bootloader ret: #{ret.inspect}") # perl have slightly different evaluation of boolean, so lets convert it ret = ![false, nil, 0, ""].include?(ret) return ret end |
- (Boolean) InitializeLibrary(force, loader)
Initialize the bootloader library
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 118 def InitializeLibrary(force, loader) return false if !force && loader == @library_initialized SCR.Execute(Path.new(".target.remove"), STATE_FILE) #remove old state file to do clear initialization Builtins.y2milestone("Initializing lib for %1", loader) architecture = BootArch.StrArch loader_data = TmpYAMLFile.new([loader, architecture]) udev_data = TmpYAMLFile.new(::Bootloader::DeviceMapping.to_hash) run_pbl_yaml "SetLoaderType(@#{loader_data.path})", "DefineUdevMapping(#{udev_data.path})" Builtins.y2milestone("Putting partitioning into library") # pass all needed disk/partition information to library SetDiskInfo() Builtins.y2milestone("Library initialization finished") @library_initialized = loader true ensure loader_data.unlink if loader_data udev_data.unlink if udev_data end |
- (Boolean) ReadFiles(avoid_reading_device_map)
Read the files from the system to internal cache of the library data
279 280 281 282 283 284 285 286 287 288 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 279 def ReadFiles(avoid_reading_device_map) param_data = TmpYAMLFile.new(avoid_reading_device_map) Builtins.y2milestone("Reading Files") run_pbl_yaml "ReadSettings(#{param_data.path})" true ensure param_data.unlink end |
- (Object) run_pbl_yaml(*args)
71 72 73 74 75 76 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 71 def run_pbl_yaml(*args) cmd = "pbl-yaml --state=#{STATE_FILE} " cmd << args.map{|e| "'#{e}'"}.join(" ") SCR.Execute(path(".target.bash"), cmd) end |
- (Boolean) SetDeviceMap(device_map)
Set the device mapping (Linux <-> Firmware)
223 224 225 226 227 228 229 230 231 232 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 223 def SetDeviceMap(device_map) arg_data = TmpYAMLFile.new(device_map) Builtins.y2milestone("Storing device map") run_pbl_yaml "SetDeviceMapping(#{arg_data.path})" true ensure arg_data.unlink end |
- (Object) SetDiskInfo
Retrieve the data for perl-Bootloader library from Storage module and pass it along @return nothing FIXME: this should be done directly in perl-Bootloader through LibStorage.pm
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 82 def SetDiskInfo BootStorage.InitDiskInfo Builtins.y2milestone( "Information about partitioning: %1", BootStorage.partinfo ) Builtins.y2milestone( "Information about MD arrays: %1", BootStorage.md_info ) Builtins.y2milestone( "Mapping real disk to multipath: %1", BootStorage.multipath_mapping ) mp_data = TmpYAMLFile.new(BootStorage.mountpoints) part_data = TmpYAMLFile.new(BootStorage.partinfo) md_data = TmpYAMLFile.new(BootStorage.md_info) run_pbl_yaml "DefineMountPoints(#{mp_data.path})", "DefinePartitions(#{part_data.path})", "DefineMDArrays(#{md_data.path})" DefineMultipath(BootStorage.multipath_mapping) nil ensure mp_data.unlink if mp_data part_data.unlink if part_data md_data.unlink if md_data end |
- (Boolean) SetFilesContents(files)
Set the contents of all files to library cache
381 382 383 384 385 386 387 388 389 390 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 381 def SetFilesContents(files) files_data = TmpYAMLFile.new(files) Builtins.y2milestone("Storing contents of files") run_pbl_yaml "SetFilesContents(#{files_data.path})" true ensure files_data.unlink end |
- (Boolean) SetGlobal(globals)
Set global bootloader options
188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 188 def SetGlobal(globals) globals = deep_copy(globals) Builtins.y2milestone("Storing global settings %1", globals) Ops.set(globals, "__modified", "1") globals_data = TmpYAMLFile.new(globals) run_pbl_yaml "SetGlobalSettings(#{globals_data.path})" true ensure globals_data.unlink end |
- (Boolean) SetSections(sections)
Set boot loader sections
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 145 def SetSections(sections) sections = deep_copy(sections) sections = Builtins.maplist(sections) do |s| if Mode.normal if Ops.get_boolean(s, "__changed", false) || Ops.get_boolean(s, "__auto", false) Ops.set(s, "__modified", "1") end else Ops.set(s, "__modified", "1") end deep_copy(s) end Builtins.y2milestone("Storing bootloader sections %1", sections) sections_data = TmpYAMLFile.new(sections) run_pbl_yaml "SetSections(#{sections_data.path})" true ensure sections_data.unlink end |
- (Object) SetSecureBoot(enable)
311 312 313 314 315 316 317 318 319 320 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 311 def SetSecureBoot(enable) arg_data = TmpYAMLFile.new(enable) Builtins.y2milestone("Set SecureBoot") run_pbl_yaml "SetSecureBoot(#{arg_data.path})" true ensure arg_data.unlink end |
- (Boolean) UpdateBootloader
Update the bootloader settings, make updated saved settings active
301 302 303 304 305 306 307 308 309 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 301 def UpdateBootloader # true mean avoid init of bootloader arg_data = TmpYAMLFile.new(true) Builtins.y2milestone("Updating bootloader configuration") run_pbl_yaml "UpdateBootloader(#{arg_data.path})" ensure arg_data.unlink end |
- (String) UpdateSerialConsole(append, console)
Update append in from boot section, it means take value from “console” and add it to “append”
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
# File 'src/include/bootloader/routines/lib_iface.rb', line 329 def UpdateSerialConsole(append, console) Builtins.y2milestone( "Updating append: %1 with console: %2", append, console ) args_data = TmpYAMLFile.new([append, console]) append_data = TmpYAMLFile.new run_pbl_yaml "#{append_data.path}=UpdateSerialConsole(@#{args_data.path})" append_data.data ensure args_data.unlink append_data.unlink end |