lib/getch/gentoo/bootloader.rb in getch-0.1.9 vs lib/getch/gentoo/bootloader.rb in getch-0.3.0

- old
+ new

@@ -1,68 +1,47 @@ -# frozen_strin_literal: true +# frozen_string_literal: true module Getch module Gentoo class Bootloader def initialize - @pkgs = [] - @class_fs = Getch.select_fs - @config = @class_fs::Config.new - @disk = Getch::OPTIONS[:boot_disk] ? - Getch::OPTIONS[:boot_disk] : - Getch::OPTIONS[:disk] @esp = '/efi' + @boot = DEVS[:boot] ||= nil + @encrypt = OPTIONS[:encrypt] ||= false end - def start - @config.fstab - config_useflag - dependencies - install - @config.cmdline - end - - def config_useflag - end - # Dracut is used by sys-kernel/gentoo-kernel def dependencies - @pkgs << 'app-shells/dash' - @pkgs << 'sys-kernel/dracut' - if Helpers.efi? - @pkgs << 'efivar' - @pkgs << 'sys-kernel/installkernel-systemd-boot' + Install.new('app-shells/dash') + if Helpers.systemd? and Helpers.efi? + Log.new.info "Systemd-boot alrealy installed...\n" else - @pkgs << 'sys-boot/grub:2' - @pkgs << 'sys-kernel/installkernel-gentoo' # for Grub + ChrootOutput.new('emerge --update --newuse sys-boot/grub') end end def install - all_pkgs = @pkgs.join(' ') - Getch::Emerge.new(all_pkgs).pkg! - end + Helpers.grub? ? + Config::Grub.new : + bootctl - def setup - if Helpers.efi? - Getch::Chroot.new("bootctl --path #{@esp} install").run! - else - Getch::Chroot.new("grub-install /dev/#{@disk}").run! - end + #ChrootOutput.new('emerge --config sys-kernel/gentoo-kernel') + ChrootOutput.new('emerge --config sys-kernel/gentoo-kernel-bin') end - def update - Getch::Emerge.new('--config sys-kernel/gentoo-kernel').pkg! - if Helpers.efi? - puts ' => Updating systemd-boot...' - Getch::Chroot.new("bootctl --path #{@esp} update").run! - else - puts ' => Updating grub...' - Getch::Chroot.new('grub-mkconfig -o /boot/grub/grub.cfg').run! - end + def bootctl + @boot ? + with_boot : + Chroot.new("bootctl --path #{@esp} install") end - def config + # We need to umount the encrypted /boot first + # https://github.com/systemd/systemd/issues/16151 + def with_boot + boot = @encrypt ? '/dev/mapper/boot-luks' : "/dev/#{DEVS[:boot]}" + NiTo.umount "#{OPTIONS[:mountpoint]}/boot" + Chroot.new("bootctl --path #{@esp} install") + NiTo.mount boot, "#{OPTIONS[:mountpoint]}/boot" end end end end