Class: Bootloader::GrubInstall

Inherits:
Object
  • Object
show all
Defined in:
src/lib/bootloader/grub_install.rb

Overview

Wraps grub install script for easier usage.

Instance Method Summary (collapse)

Constructor Details

- (GrubInstall) initialize(efi: false)

Returns a new instance of GrubInstall



9
10
11
# File 'src/lib/bootloader/grub_install.rb', line 9

def initialize(efi: false)
  @efi = efi
end

Instance Method Details

- (Object) execute(devices: nil, secure_boot: false)



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'src/lib/bootloader/grub_install.rb', line 13

def execute(devices: nil, secure_boot: false)
  raise "cannot have secure boot without efi" if secure_boot && !@efi

  cmd = []
  if secure_boot
    cmd << "/usr/sbin/shim-install" << "--config-file=/boot/grub2/grub.cfg"
  else
    cmd << "/usr/sbin/grub2-install" << "--target=#{target}"
    # Do skip-fs-probe to avoid error when embedding stage1
    # to extended partition
    cmd << "--force" << "--skip-fs-probe"
  end

  if devices
    devices.each do |dev|
      Yast::Execute.on_target(cmd + [dev])
    end
  else
    Yast::Execute.on_target(cmd)
  end
end