Class: Yast::BootGRUB2Class
- Inherits:
-
GRUB2Base
- Object
- Module
- GRUB2Base
- Yast::BootGRUB2Class
- Defined in:
- src/modules/BootGRUB2.rb
Instance Attribute Summary
Attributes inherited from GRUB2Base
Instance Method Summary (collapse)
-
- (Object) BootGRUB2
Constructor.
- - (Object) Dialogs
-
- (Object) GetFunctions
Return map of provided functions.
- - (Object) main
- - (Object) Propose
-
- (Boolean) Read(reread, avoid_reading_device_map)
Read settings from disk internal data.
-
- (Object) Summary
Display bootloader summary.
-
- (Object) urlLocationSummary
FATE#303643 Enable one-click changes in bootloader proposal.
-
- (Boolean) Write
Write bootloader settings to disk.
Methods inherited from GRUB2Base
#Initializer, #Reset, #Save, #StandardGlobals, #Update, #pmbr_setup
Instance Method Details
- (Object) BootGRUB2
Constructor
304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'src/modules/BootGRUB2.rb', line 304 def BootGRUB2 Ops.set( BootCommon.bootloader_attribs, "grub2", # we need syslinux to have generic mbr bnc#885496 "required_packages" => ["grub2", "syslinux"], "loader_name" => "GRUB2", "initializer" => fun_ref(method(:Initializer), "void ()") ) nil end |
- (Object) Dialogs
270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'src/modules/BootGRUB2.rb', line 270 def Dialogs Builtins.y2milestone("Called GRUB2 Dialogs") { "installation" => fun_ref( ::Bootloader::DeviceMapDialog.method(:run), "symbol ()" ), "loader" => fun_ref( method(:Grub2LoaderDetailsDialog), "symbol ()" ) } end |
- (Object) GetFunctions
Return map of provided functions
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'src/modules/BootGRUB2.rb', line 286 def GetFunctions { "read" => fun_ref(method(:Read), "boolean (boolean, boolean)"), "reset" => fun_ref(method(:Reset), "void (boolean)"), "propose" => fun_ref(method(:Propose), "void ()"), "save" => fun_ref(method(:Save), "boolean (boolean, boolean, boolean)"), "summary" => fun_ref(method(:Summary), "list <string> ()"), "update" => fun_ref(method(:Update), "void ()"), "widgets" => fun_ref( method(:grub2Widgets), "map <string, map <string, any>> ()" ), "dialogs" => fun_ref(method(:Dialogs), "map <string, symbol ()> ()"), "write" => fun_ref(method(:Write), "boolean ()") } end |
- (Object) main
35 36 37 38 39 40 41 42 43 44 |
# File 'src/modules/BootGRUB2.rb', line 35 def main super textdomain "bootloader" # includes # for shared some routines with grub Yast.include self, "bootloader/grub2/misc.rb" BootGRUB2() end |
- (Object) Propose
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'src/modules/BootGRUB2.rb', line 138 def Propose super # do not repropose, only in autoinst mode to allow propose missing parts return if BootCommon.was_proposed && !Mode.autoinst && !Mode.autoupgrade case Arch.architecture # intel need some specific handler. TODO: unify it to use same rutine when "i386", "x86_64" grub_LocationProposal # pass vga if available (bnc#896300) if !Kernel.GetVgaType.empty? BootCommon.globals["vgamode"] = Kernel.GetVgaType end # less tricky architectures, so directly propose stage1 location when /ppc/, /s390/ grub_DetectDisks ::Bootloader::Stage1.new.propose else raise "unsuported architecture #{Arch.architecture}" end end |
- (Boolean) Read(reread, avoid_reading_device_map)
Read settings from disk internal data
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'src/modules/BootGRUB2.rb', line 53 def Read(reread, avoid_reading_device_map) BootCommon.InitializeLibrary(reread, "grub2") BootCommon.ReadFiles(avoid_reading_device_map) if reread # TODO: check if necessary for grub2 grub_DetectDisks ret = BootCommon.Read(false, avoid_reading_device_map) # TODO: check if necessary for grub2 # refresh device map if not read BootStorage.device_map.propose if BootStorage.device_map.empty? if Mode.normal redundant_disks = BootStorage.devices_for_redundant_boot pB_md_value = Ops.get(BootCommon.globals, "boot_md_mbr", "") if pB_md_value != "" disks = Builtins.splitstring(pB_md_value, ",") disks = Builtins.filter(disks) { |v| v != "" } if Builtins.size(disks) == 2 BootCommon.enable_md_array_redundancy = true redundant_disks = [] end Builtins.y2milestone( "disks from md array (perl Bootloader): %1", disks ) end if !redundant_disks.empty? BootCommon.enable_md_array_redundancy = false BootCommon.globals["boot_md_mbr"] = redundant_disks.join(",") Builtins.y2milestone( "Add md array to globals: %1", BootCommon.globals ) end end # always disable failsafe unless user manually enable it (fate#317016) BootCommon.globals["failsafe_disabled"] = "true" if BootCommon.globals["failsafe_disabled"].nil? @orig_globals ||= deep_copy(BootCommon.globals) ret end |
- (Object) Summary
Display bootloader summary
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'src/modules/BootGRUB2.rb', line 224 def Summary result = [ Builtins.sformat( _("Boot Loader Type: %1"), BootCommon.getLoaderName(BootCommon.getLoaderType(false), :summary) ) ] locations = [] if BootCommon.globals["boot_boot"] == "true" locations << BootStorage.BootPartitionDevice + " (\"/boot\")" end if BootCommon.globals["boot_extended"] == "true" # TRANSLATORS: extended is here for extended partition. Keep translation short. locations << BootStorage.ExtendedPartitionDevice + _(" (extended)") end if BootCommon.globals["boot_root"] == "true" locations << BootStorage.RootPartitionDevice + " (\"/\")" end if BootCommon.globals["boot_mbr"] == "true" # TRANSLATORS: MBR is acronym for Master Boot Record, if nothing locally specific # is used in your language, then keep it as it is. locations << BootCommon.mbrDisk + _(" (MBR)") end if BootCommon.globals["boot_custom"] && !BootCommon.globals["boot_custom"].empty? locations << BootCommon.globals["boot_custom"] end if !locations.empty? result << Builtins.sformat( _("Status Location: %1"), locations.join(", ") ) end # it is necessary different summary for autoyast and installation # other mode than autoyast on running system # both ppc and s390 have special devices for stage1 so it do not make sense # allow change of location to MBR or boot partition (bnc#879107) result << urlLocationSummary if !Arch.ppc && !Arch.s390 && !Mode.config order_sum = BootCommon.DiskOrderSummary result << order_sum if order_sum result end |
- (Object) urlLocationSummary
FATE#303643 Enable one-click changes in bootloader proposal
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'src/modules/BootGRUB2.rb', line 164 def urlLocationSummary Builtins.y2milestone("Prepare url summary for GRUB2") line = "<ul>\n<li>" if BootCommon.globals["boot_mbr"] == "true" line << _( "Install bootcode into MBR (<a href=\"disable_boot_mbr\">do not install</a>)" ) else line << _( "Do not install bootcode into MBR (<a href=\"enable_boot_mbr\">install</a>)" ) end line << "</li>\n" # do not allow to switch on boot from partition that do not support it if BootStorage.can_boot_from_partition line << "<li>" # check for separated boot partition, use root otherwise if BootStorage.BootPartitionDevice != BootStorage.RootPartitionDevice if BootCommon.globals["boot_boot"] == "true" line << _( "Install bootcode into /boot partition (<a href=\"disable_boot_boot\">do not install</a>)" ) else line << _( "Do not install bootcode into /boot partition (<a href=\"enable_boot_boot\">install</a>)" ) end else if BootCommon.globals["boot_root"] == "true" line << _( "Install bootcode into \"/\" partition (<a href=\"disable_boot_root\">do not install</a>)" ) else line << _( "Do not install bootcode into \"/\" partition (<a href=\"enable_boot_root\">install</a>)" ) end end line << "</li>" end if ["boot_root", "boot_boot", "boot_mbr", "boot_extended"].none? { |loc| BootCommon.globals[loc] == "true" } && (BootCommon.globals["boot_custom"].nil? || BootCommon.globals["boot_custom"].empty?) # no location chosen, so warn user that it is problem unless he is sure msg = _("Warning: No location for bootloader stage1 selected." \ "Unless you know what you are doing please select above location.") line << "<li>" << HTML.Colorize(msg, "red") << "</li>" end line << "</ul>" # TRANSLATORS: title for list of location proposals _("Change Location: %s") % line end |
- (Boolean) Write
Write bootloader settings to disk
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'src/modules/BootGRUB2.rb', line 98 def Write ret = BootCommon.UpdateBootloader if @orig_globals location = ["boot_mbr", "boot_boot", "boot_root", "boot_extended", "boot_custom", "boot_custom", "activate", "generic_mbr"] location.each do |i| BootCommon.location_changed = true if @orig_globals[i] != BootCommon.globals[i] end else # there is no original, so we do not read config, but propose it BootCommon.location_changed = true end if BootCommon.location_changed # bnc #461613 - Unable to boot after making changes to boot loader # bnc #357290 - module rewrites grub generic code when leaving with no changes, which may corrupt grub ::Bootloader::MBRUpdate.new.run grub_ret = BootCommon.InitializeBootloader grub_ret = false if grub_ret.nil? Builtins.y2milestone("GRUB return value: %1", grub_ret) ret &&= grub_ret ret &&= BootCommon.PostUpdateMBR end # something with PMBR needed if BootCommon.pmbr_action boot_devices = BootCommon.GetBootloaderDevices boot_discs = boot_devices.map { |d| Storage.GetDisk(Storage.GetTargetMap, d) } boot_discs.uniq! gpt_disks = boot_discs.select { |d| d["label"] == "gpt" } gpt_disks_devices = gpt_disks.map { |d| d["device"] } pmbr_setup(BootCommon.pmbr_action, *gpt_disks_devices) end ret end |