class Getch::Gentoo::Boot
Public Class Methods
new()
click to toggle source
# File lib/getch/gentoo/boot.rb, line 6 def initialize @disk = Getch::OPTIONS[:boot_disk] ? Getch::OPTIONS[:boot_disk] : Getch::OPTIONS[:disk] @user = Getch::OPTIONS[:username] @class_fs = Getch::select_fs @config = @class_fs::Config.new end
Public Instance Methods
bootctl()
click to toggle source
bootctl is alrealy installed with the stage3-amd64-systemd
# File lib/getch/gentoo/boot.rb, line 35 def bootctl bootctl_dep puts "Configuring systemd-boot." # ref: https://forums.gentoo.org/viewtopic-p-8118822.html esp = '/efi' Getch::Chroot.new("bootctl --path #{esp} install").run! datas_loader = [ 'default gentoo', 'timeout 3', 'editor 0' ] @config.systemd_boot File.write("#{MOUNTPOINT}/#{esp}/loader/loader.conf", datas_loader.join("\n")) FileUtils.cp("#{MOUNTPOINT}/usr/src/linux/arch/x86/boot/bzImage", "#{MOUNTPOINT}/#{esp}/vmlinuz", preserve: true) initramfs = Dir.glob("#{MOUNTPOINT}/boot/initramfs-*.img") FileUtils.cp("#{initramfs[0]}", "#{MOUNTPOINT}/#{esp}/initramfs", preserve: true) if initramfs != [] Getch::Chroot.new("bootctl --path #{esp} update").run! end
bootctl_dep()
click to toggle source
# File lib/getch/gentoo/boot.rb, line 57 def bootctl_dep puts 'Installing systemd-boot...' Getch::Emerge.new("efivar").pkg! end
bootloader()
click to toggle source
# File lib/getch/gentoo/boot.rb, line 23 def bootloader # Ensure than systemd is build with all our flags Getch::Emerge.new("@world").pkg! if Helpers::efi? bootctl else grub end end
grub()
click to toggle source
# File lib/getch/gentoo/boot.rb, line 62 def grub puts 'Installing GRUB...' Getch::Emerge.new("sys-boot/grub:2").pkg! @config.grub Getch::Chroot.new("grub-install /dev/#{@disk}").run! Getch::Chroot.new("grub-mkconfig -o /boot/grub/grub.cfg").run! end
password()
click to toggle source
# File lib/getch/gentoo/boot.rb, line 70 def password puts 'Password for root' cmd = "chroot #{MOUNTPOINT} /bin/bash -c \"source /etc/profile && passwd\"" system(cmd) if @user puts "Creating user #{@user}" Getch::Chroot.new("useradd -m -G users,wheel,audio,video #{@user}").run! puts "Password for your user #{@user}" cmd = "chroot #{MOUNTPOINT} /bin/bash -c \"source /etc/profile && passwd #{@user}\"" system(cmd) end end
start()
click to toggle source
# File lib/getch/gentoo/boot.rb, line 15 def start @config.fstab bootloader password permission the_end end
Private Instance Methods
exec_chroot(cmd)
click to toggle source
# File lib/getch/gentoo/boot.rb, line 106 def exec_chroot(cmd) script = "chroot #{MOUNTPOINT} /bin/bash -c \" source /etc/profile #{cmd} \"" Getch::Command.new(script).run! end
permission()
click to toggle source
# File lib/getch/gentoo/boot.rb, line 85 def permission FileUtils.chmod_R 0755, "#{MOUNTPOINT}/etc/portage" if @user Getch::Chroot.new("chown -R #{@user}:#{@user} /home/#{@user}").run! end end
the_end()
click to toggle source
# File lib/getch/gentoo/boot.rb, line 92 def the_end #Helpers::exec_or_die("umount -l /mnt/gentoo/dev{/shm,/pts,}") #Helpers::exec_or_die("umount -R #{MOUNTPOINT}") puts puts "getch has finish, before reboot, you can:" puts " + Chroot on your system with: chroot #{MOUNTPOINT} /bin/bash" puts " + Install more packages like networkmanager or emacs" puts puts " + Add more modules for your kernel (graphic, wifi card) and recompile it with:" puts " genkernel --kernel-config=/usr/src/linux/.config all " puts puts "Reboot the system when you have done !" end