class Getch::Gentoo::Sources

Public Class Methods

new() click to toggle source
# File lib/getch/gentoo/sources.rb, line 4
def initialize
  @lsmod = `lsmod`.chomp
  @class_fs = Getch::select_fs
  @filesystem = @class_fs::Deps.new
end

Public Instance Methods

build_kspp() click to toggle source
# File lib/getch/gentoo/sources.rb, line 19
def build_kspp
  puts "Adding KSPP to the kernel source"
  bask("-b -a systemd")
end
build_others() click to toggle source
# File lib/getch/gentoo/sources.rb, line 10
def build_others
  cryptsetup
  virtualbox_guest
  qemu_guest
  install_wifi
  install_audio
  flash_mod
end
firewall() click to toggle source
# File lib/getch/gentoo/sources.rb, line 34
def firewall
  bask("-a iptables")
  Getch::Emerge.new("net-firewall/iptables").pkg!
end
make() click to toggle source
# File lib/getch/gentoo/sources.rb, line 24
def make
  if Getch::OPTIONS[:fs] == 'lvm' ||
      Getch::OPTIONS[:fs] == 'zfs' ||
      Getch::OPTIONS[:encrypt]
    @filesystem.make
  else
    make_kernel
  end
end

Private Instance Methods

bask(cmd) click to toggle source
# File lib/getch/gentoo/sources.rb, line 75
def bask(cmd)
  Getch::Bask.new(cmd).run!
end
cryptsetup() click to toggle source
# File lib/getch/gentoo/sources.rb, line 49
def cryptsetup
  return unless Getch::OPTIONS[:encrypt]
  make_conf = "#{MOUNTPOINT}/etc/portage/make.conf"

  puts "Adding support for cryptsetup."
  bask("-a cryptsetup")
  Getch::Chroot.new("euse -E cryptsetup").run! unless Helpers::grep?(make_conf, /cryptsetup/)
  Getch::Emerge.new("sys-fs/cryptsetup").pkg!
end
flash_mod() click to toggle source
# File lib/getch/gentoo/sources.rb, line 103
def flash_mod
  conf = "#{MOUNTPOINT}/etc/modules-load.d/usb.conf"
  File.delete(conf) if File.exists? conf

  module_load("ehci_pci", conf)
  module_load("rtsx_pci_sdmmc", conf)
  module_load("sdhci_pci", conf)
  module_load("uas", conf)
  module_load("uhci_hcd", conf)
  module_load("xhci_pci", conf)
end
install_audio() click to toggle source
# File lib/getch/gentoo/sources.rb, line 86
def install_audio
  return if ! ismatch?('snd_pcm')
  bask("-a sound")
end
install_wifi() click to toggle source
# File lib/getch/gentoo/sources.rb, line 79
def install_wifi
  return if ! ismatch?('cfg80211')
  bask("-a wifi")
  wifi_drivers
  Getch::Emerge.new("net-wireless/iw wpa_supplicant net-wireless/iwd").pkg!
end
ismatch?(arg) click to toggle source
# File lib/getch/gentoo/sources.rb, line 71
def ismatch?(arg)
  @lsmod.match?(/#{arg}/)
end
make_kernel() click to toggle source
# File lib/getch/gentoo/sources.rb, line 41
def make_kernel
  puts "Compiling kernel sources"
  cmd = "make -j$(nproc) && make modules_install && make install"
  Getch::Make.new(cmd).run!
  is_kernel = Dir.glob("#{MOUNTPOINT}/boot/vmlinuz-*")
  raise "No kernel installed, compiling source fail..." if is_kernel == []
end
module_load(name, file) click to toggle source
# File lib/getch/gentoo/sources.rb, line 115
def module_load(name, file)
  return unless name
  return unless ismatch?(name)
  File.write(file, "#{name}\n", mode: 'a')
end
qemu_guest() click to toggle source
# File lib/getch/gentoo/sources.rb, line 66
def qemu_guest
  bask("-a kvm-host") if ismatch?('kvm')
  bask("-a kvm-guest") if ismatch?('virtio')
end
virtualbox_guest() click to toggle source
# File lib/getch/gentoo/sources.rb, line 59
def virtualbox_guest
  systemd=`systemd-detect-virt`.chomp
  return if ! ismatch?('vmwgfx') || systemd.match(/none/)
  bask("-a virtualbox-guest")
  Getch::Emerge.new("app-emulation/virtualbox-guest-additions").pkg!
end
wifi_drivers() click to toggle source
# File lib/getch/gentoo/sources.rb, line 91
def wifi_drivers
  conf = "#{MOUNTPOINT}/etc/modules-load.d/wifi.conf"
  File.delete(conf) if File.exists? conf

  if ismatch?('ath9k')
    bask("-a ath9k-driver")
  end

  module_load("iwlmvm", conf)
  module_load("ath9k", conf)
end