Class: Getch::Gentoo::Bootloader

Inherits:
Object
  • Object
show all
Defined in:
lib/getch/gentoo/bootloader.rb

Overview

install grub or bootctl

Instance Method Summary collapse

Constructor Details

#initializeBootloader

Returns a new instance of Bootloader.



7
8
9
10
11
# File 'lib/getch/gentoo/bootloader.rb', line 7

def initialize
  @esp = '/efi'
  @boot = DEVS[:boot] ||= nil
  @encrypt = OPTIONS[:encrypt] ||= false
end

Instance Method Details

#bootctlObject



37
38
39
40
41
42
43
# File 'lib/getch/gentoo/bootloader.rb', line 37

def bootctl
  if @boot
    with_boot
  else
    Chroot.new("bootctl --esp-path=#{@esp} install")
  end
end

#dependenciesObject

Dracut is used by sys-kernel/gentoo-kernel



14
15
16
17
18
19
20
# File 'lib/getch/gentoo/bootloader.rb', line 14

def dependencies
  if Helpers.systemd_minimal?
    Log.new.info "Systemd-boot alrealy installed...\n"
  else
    ChrootOutput.new('emerge --update --newuse sys-boot/grub')
  end
end

#installObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/getch/gentoo/bootloader.rb', line 22

def install
  if Helpers.grub?
    Config::Grub.new
  else
    bootctl
  end

  # should also reload grub-mkconfig
  if OPTIONS[:binary]
    ChrootOutput.new('emerge --config sys-kernel/gentoo-kernel-bin')
  else
    ChrootOutput.new('emerge --config sys-kernel/gentoo-kernel')
  end
end

#with_bootObject

We need to umount the encrypted /boot first github.com/systemd/systemd/issues/16151



47
48
49
50
51
52
# File 'lib/getch/gentoo/bootloader.rb', line 47

def with_boot
  boot = @encrypt ? '/dev/mapper/boot-luks' : "/dev/#{DEVS[:boot]}"
  NiTo.umount "#{OPTIONS[:mountpoint]}/boot"
  Chroot.new("bootctl --esp-path=#{@esp} install")
  NiTo.mount boot, "#{OPTIONS[:mountpoint]}/boot"
end