Sha256: 9a3de5d8659af918c4c8c3f3eb81251eec17d0f401a4ae58f22238fdccc0592c

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

require_relative '../helpers'

module Getch
  module Void
    class Chroot
      include Helpers::Void

      def initialize
        @state = Getch::States.new()
        @pkgs = []
        mount
      end

      # https://docs.voidlinux.org/installation/guides/chroot.html#install-base-system-rootfs-method-only
      def update
        return if STATES[:gentoo_update]
        command_output "/usr/bin/xbps-install -Suy xbps" # y to force (--yes)
        command_output "/usr/bin/xbps-install -uy"
        command_output "/usr/bin/xbps-install -y base-system"
        #command_output "/usr/bin/xbps-remove base-voidstrap"
        @state.update
      end

      def extras
        @pkgs << "vim"
        @pkgs << "iptables"
        @pkgs << "iwd"
      end

      def fs
        @pkgs << "lvm2" if OPTIONS[:fs] == 'lvm'
        @pkgs << "zfs" if OPTIONS[:fs] == 'zfs'
        @pkgs << "cryptsetup" if OPTIONS[:encrypt]
      end

      def install_pkgs
        all_pkgs = @pkgs.join(" ")
        command_output "/usr/bin/xbps-install -y #{all_pkgs}"
      end

      private

      def mount
        puts "Populate /proc, /sys and /dev."
        Helpers::exec_or_die("mount --types proc /proc \"#{MOUNTPOINT}/proc\"")
        Helpers::exec_or_die("mount --rbind /sys \"#{MOUNTPOINT}/sys\"")
        Helpers::exec_or_die("mount --make-rslave \"#{MOUNTPOINT}/sys\"")
        Helpers::exec_or_die("mount --rbind /dev \"#{MOUNTPOINT}/dev\"")
        Helpers::exec_or_die("mount --make-rslave \"#{MOUNTPOINT}/dev\"")
        # Maybe add /dev/shm like describe here:
        # https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Base
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
getch-0.1.6 lib/getch/void/chroot.rb