getch 0.1.2 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.md +66 -32
- data/assets/network-stack.conf +63 -0
- data/assets/system.conf +38 -0
- data/bin/getch +12 -4
- data/lib/cmdline.rb +128 -0
- data/lib/getch/command.rb +32 -22
- data/lib/getch/config/gentoo.rb +58 -0
- data/lib/getch/config/void.rb +47 -0
- data/lib/getch/config.rb +45 -0
- data/lib/getch/filesystem/clean.rb +22 -15
- data/lib/getch/filesystem/device.rb +8 -6
- data/lib/getch/filesystem/ext4/config.rb +8 -4
- data/lib/getch/filesystem/ext4/deps.rb +3 -1
- data/lib/getch/filesystem/ext4/device.rb +2 -3
- data/lib/getch/filesystem/ext4/encrypt/config.rb +15 -11
- data/lib/getch/filesystem/ext4/encrypt/deps.rb +5 -10
- data/lib/getch/filesystem/ext4/encrypt/device.rb +5 -3
- data/lib/getch/filesystem/ext4/encrypt/format.rb +4 -2
- data/lib/getch/filesystem/ext4/encrypt/mount.rb +3 -3
- data/lib/getch/filesystem/ext4/encrypt/partition.rb +29 -35
- data/lib/getch/filesystem/ext4/encrypt/void.rb +101 -0
- data/lib/getch/filesystem/ext4/encrypt.rb +3 -0
- data/lib/getch/filesystem/ext4/format.rb +4 -1
- data/lib/getch/filesystem/ext4/mount.rb +3 -0
- data/lib/getch/filesystem/ext4/partition.rb +11 -8
- data/lib/getch/filesystem/ext4/void.rb +44 -0
- data/lib/getch/filesystem/ext4.rb +3 -0
- data/lib/getch/filesystem/lvm/config.rb +10 -29
- data/lib/getch/filesystem/lvm/deps.rb +7 -11
- data/lib/getch/filesystem/lvm/device.rb +5 -3
- data/lib/getch/filesystem/lvm/encrypt/config.rb +17 -17
- data/lib/getch/filesystem/lvm/encrypt/deps.rb +8 -12
- data/lib/getch/filesystem/lvm/encrypt/device.rb +7 -5
- data/lib/getch/filesystem/lvm/encrypt/format.rb +5 -2
- data/lib/getch/filesystem/lvm/encrypt/mount.rb +4 -2
- data/lib/getch/filesystem/lvm/encrypt/partition.rb +17 -13
- data/lib/getch/filesystem/lvm/encrypt/void.rb +101 -0
- data/lib/getch/filesystem/lvm/encrypt.rb +3 -0
- data/lib/getch/filesystem/lvm/format.rb +4 -1
- data/lib/getch/filesystem/lvm/mount.rb +3 -0
- data/lib/getch/filesystem/lvm/partition.rb +10 -7
- data/lib/getch/filesystem/lvm/void.rb +46 -0
- data/lib/getch/filesystem/lvm.rb +3 -0
- data/lib/getch/filesystem/mount.rb +19 -12
- data/lib/getch/filesystem/partition.rb +19 -11
- data/lib/getch/filesystem/zfs/config.rb +10 -24
- data/lib/getch/filesystem/zfs/deps.rb +28 -58
- data/lib/getch/filesystem/zfs/device.rb +9 -1
- data/lib/getch/filesystem/zfs/encrypt/config.rb +12 -28
- data/lib/getch/filesystem/zfs/encrypt/deps.rb +29 -60
- data/lib/getch/filesystem/zfs/encrypt/device.rb +9 -1
- data/lib/getch/filesystem/zfs/encrypt/format.rb +24 -22
- data/lib/getch/filesystem/zfs/encrypt/mount.rb +15 -14
- data/lib/getch/filesystem/zfs/encrypt/partition.rb +24 -18
- data/lib/getch/filesystem/zfs/encrypt/void.rb +97 -0
- data/lib/getch/filesystem/zfs/encrypt.rb +3 -0
- data/lib/getch/filesystem/zfs/format.rb +21 -18
- data/lib/getch/filesystem/zfs/mount.rb +12 -13
- data/lib/getch/filesystem/zfs/partition.rb +20 -15
- data/lib/getch/filesystem/zfs/void.rb +81 -0
- data/lib/getch/filesystem/zfs.rb +3 -0
- data/lib/getch/filesystem.rb +2 -0
- data/lib/getch/gentoo/boot.rb +29 -67
- data/lib/getch/gentoo/bootloader.rb +68 -0
- data/lib/getch/gentoo/chroot.rb +26 -29
- data/lib/getch/gentoo/config.rb +69 -31
- data/lib/getch/gentoo/sources.rb +73 -38
- data/lib/getch/gentoo/stage.rb +12 -13
- data/lib/getch/gentoo/use.rb +39 -0
- data/lib/getch/gentoo/use_flag.rb +89 -0
- data/lib/getch/gentoo.rb +39 -21
- data/lib/getch/guard.rb +71 -0
- data/lib/getch/helpers.rb +180 -48
- data/lib/getch/log.rb +10 -7
- data/lib/getch/options.rb +50 -41
- data/lib/getch/states.rb +10 -3
- data/lib/getch/version.rb +1 -1
- data/lib/getch/void/boot.rb +84 -0
- data/lib/getch/void/chroot.rb +56 -0
- data/lib/getch/void/config.rb +90 -0
- data/lib/getch/void/stage.rb +69 -0
- data/lib/getch/void.rb +65 -0
- data/lib/getch.rb +125 -74
- data.tar.gz.sig +0 -0
- metadata +28 -10
- metadata.gz.sig +0 -0
- data/.gitignore +0 -2
- data/CHANGELOG.md +0 -80
- data/Rakefile +0 -21
- data/bin/setup.sh +0 -90
- data/getch.gemspec +0 -25
data/lib/getch/gentoo/sources.rb
CHANGED
|
@@ -1,75 +1,110 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'cmdline'
|
|
4
|
+
|
|
1
5
|
module Getch
|
|
2
6
|
module Gentoo
|
|
3
7
|
class Sources
|
|
4
8
|
def initialize
|
|
5
9
|
@lsmod = `lsmod`.chomp
|
|
6
|
-
@
|
|
10
|
+
@class_fs = Getch::select_fs
|
|
11
|
+
@filesystem = @class_fs::Deps.new
|
|
7
12
|
end
|
|
8
13
|
|
|
9
|
-
def
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
def bask
|
|
15
|
+
puts ' ==> Hardening kernel...'
|
|
16
|
+
#Getch::Bask.new('10_kspp.config').cp
|
|
17
|
+
Getch::Bask.new('11-kspp-gcc.config').cp
|
|
18
|
+
Getch::Bask.new('12-kspp-x86_64.config').cp
|
|
19
|
+
#Getch::Bask.new('20-clipos.config').cp
|
|
20
|
+
#Getch::Bask.new('30-grsecurity.config').cp
|
|
21
|
+
#Getch::Bask.new('40-kconfig-hardened.config').cp
|
|
22
|
+
Getch::Bask.new('50-blacklist.config').cp
|
|
23
|
+
Getch::Bask.new('51-blacklist-madaidans.config').cp
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def configs
|
|
27
|
+
gen_cmdline
|
|
28
|
+
grub_mkconfig unless Helpers.efi?
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def gen_cmdline
|
|
32
|
+
cmdline = CmdLine::Kernel.new(workdir: "#{MOUNTPOINT}/etc/kernel")
|
|
33
|
+
cmdline.main
|
|
14
34
|
end
|
|
15
35
|
|
|
16
|
-
def
|
|
17
|
-
|
|
18
|
-
|
|
36
|
+
def grub_mkconfig
|
|
37
|
+
file = "#{MOUNTPOINT}/etc/kernel/install.d/90-mkconfig.install"
|
|
38
|
+
content = <<~SHELL
|
|
39
|
+
#!/usr/bin/env sh
|
|
40
|
+
set -o errexit
|
|
41
|
+
grub-mkconfig -o /boot/grub/grub.cfg
|
|
42
|
+
exit 0
|
|
43
|
+
SHELL
|
|
44
|
+
File.write file, content
|
|
45
|
+
File.chmod 0755, file
|
|
19
46
|
end
|
|
20
47
|
|
|
21
48
|
def make
|
|
22
|
-
if
|
|
49
|
+
if Getch::OPTIONS[:fs] == 'lvm' ||
|
|
50
|
+
Getch::OPTIONS[:fs] == 'zfs' ||
|
|
51
|
+
Getch::OPTIONS[:encrypt]
|
|
23
52
|
@filesystem.make
|
|
24
53
|
else
|
|
25
54
|
make_kernel
|
|
26
55
|
end
|
|
27
56
|
end
|
|
28
57
|
|
|
58
|
+
def load_modules
|
|
59
|
+
install_wifi
|
|
60
|
+
flash_mod
|
|
61
|
+
end
|
|
62
|
+
|
|
29
63
|
private
|
|
30
64
|
|
|
31
65
|
def make_kernel
|
|
32
|
-
puts
|
|
33
|
-
|
|
34
|
-
Getch::Make.new(cmd).run!
|
|
66
|
+
puts 'Compiling kernel sources'
|
|
67
|
+
Getch::Emerge.new('sys-kernel/gentoo-kernel').pkg!
|
|
35
68
|
is_kernel = Dir.glob("#{MOUNTPOINT}/boot/vmlinuz-*")
|
|
36
|
-
raise
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def virtualbox_guest
|
|
40
|
-
systemd=`systemd-detect-virt`.chomp
|
|
41
|
-
return if ! ismatch?('vmwgfx') || systemd.match(/none/)
|
|
42
|
-
bask("-a virtualbox-guest")
|
|
43
|
-
Getch::Emerge.new("app-emulation/virtualbox-guest-additions").pkg!
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def qemu_guest
|
|
47
|
-
bask("-a kvm-host") if ismatch?('kvm')
|
|
48
|
-
bask("-a kvm-guest") if ismatch?('virtio')
|
|
69
|
+
raise 'No kernel installed, compiling source fail...' if is_kernel == []
|
|
49
70
|
end
|
|
50
71
|
|
|
51
72
|
def ismatch?(arg)
|
|
52
73
|
@lsmod.match?(/#{arg}/)
|
|
53
74
|
end
|
|
54
75
|
|
|
55
|
-
def bask(cmd)
|
|
56
|
-
Getch::Bask.new(cmd).run!
|
|
57
|
-
end
|
|
58
|
-
|
|
59
76
|
def install_wifi
|
|
60
|
-
return
|
|
61
|
-
|
|
77
|
+
return unless ismatch?('cfg80211')
|
|
78
|
+
|
|
62
79
|
wifi_drivers
|
|
63
|
-
Getch::Emerge.new(
|
|
80
|
+
Getch::Emerge.new('net-wireless/iwd').pkg!
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def wifi_drivers
|
|
84
|
+
conf = "#{MOUNTPOINT}/etc/modules-load.d/wifi.conf"
|
|
85
|
+
File.delete(conf) if File.exist? conf
|
|
86
|
+
|
|
87
|
+
module_load('iwlmvm', conf)
|
|
88
|
+
module_load('ath9k', conf)
|
|
64
89
|
end
|
|
65
90
|
|
|
66
|
-
def
|
|
67
|
-
|
|
68
|
-
|
|
91
|
+
def flash_mod
|
|
92
|
+
conf = "#{MOUNTPOINT}/etc/modules-load.d/usb.conf"
|
|
93
|
+
File.delete(conf) if File.exist? conf
|
|
94
|
+
|
|
95
|
+
module_load('ehci_pci', conf)
|
|
96
|
+
module_load('rtsx_pci_sdmmc', conf)
|
|
97
|
+
module_load('sdhci_pci', conf)
|
|
98
|
+
module_load('uas', conf)
|
|
99
|
+
module_load('uhci_hcd', conf)
|
|
100
|
+
module_load('xhci_pci', conf)
|
|
69
101
|
end
|
|
70
102
|
|
|
71
|
-
def
|
|
72
|
-
|
|
103
|
+
def module_load(name, file)
|
|
104
|
+
return unless name
|
|
105
|
+
return unless ismatch?(name)
|
|
106
|
+
|
|
107
|
+
File.write(file, "#{name}\n", mode: 'a')
|
|
73
108
|
end
|
|
74
109
|
end
|
|
75
110
|
end
|
data/lib/getch/gentoo/stage.rb
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'open-uri'
|
|
2
4
|
require 'open3'
|
|
3
5
|
|
|
4
6
|
module Getch
|
|
5
7
|
module Gentoo
|
|
6
8
|
class Stage
|
|
7
|
-
|
|
8
9
|
def initialize
|
|
9
|
-
@mirror =
|
|
10
|
+
@mirror = 'https://mirrors.soeasyto.com/distfiles.gentoo.org'
|
|
10
11
|
@release = release
|
|
11
12
|
@stage_file="stage3-amd64-systemd-#{@release}.tar.xz"
|
|
12
13
|
end
|
|
@@ -29,16 +30,16 @@ module Getch
|
|
|
29
30
|
Dir.chdir(MOUNTPOINT)
|
|
30
31
|
return if File.exist?(@stage_file)
|
|
31
32
|
puts "Download the last #{@stage_file}, please wait..."
|
|
32
|
-
Helpers
|
|
33
|
+
Helpers.get_file_online(@mirror + '/releases/amd64/autobuilds/' + file, @stage_file)
|
|
33
34
|
end
|
|
34
35
|
|
|
35
36
|
def control_files
|
|
36
|
-
puts
|
|
37
|
-
Helpers
|
|
38
|
-
puts
|
|
39
|
-
Helpers
|
|
37
|
+
puts 'Download the DIGESTS'
|
|
38
|
+
Helpers.get_file_online(@mirror + '/releases/amd64/autobuilds/' + file + '.DIGESTS', "#{@stage_file}.DIGESTS")
|
|
39
|
+
puts 'Download the DIGESTS.asc'
|
|
40
|
+
Helpers.get_file_online(@mirror + '/releases/amd64/autobuilds/' + file + '.DIGESTS.asc', "#{@stage_file}.DIGESTS.asc")
|
|
40
41
|
puts "Download the CONTENTS.gz"
|
|
41
|
-
Helpers
|
|
42
|
+
Helpers.get_file_online(@mirror + '/releases/amd64/autobuilds/' + file + '.CONTENTS.gz', "#{@stage_file}.CONTENTS.gz")
|
|
42
43
|
end
|
|
43
44
|
|
|
44
45
|
def checksum
|
|
@@ -46,7 +47,7 @@ module Getch
|
|
|
46
47
|
command = "awk '/SHA512 HASH/{getline;print}' #{@stage_file}.DIGESTS.asc | sha512sum --check"
|
|
47
48
|
_, stderr, status = Open3.capture3(command)
|
|
48
49
|
if status.success? then
|
|
49
|
-
puts
|
|
50
|
+
puts 'Checksum is ok'
|
|
50
51
|
decompress
|
|
51
52
|
cleaning
|
|
52
53
|
else
|
|
@@ -55,7 +56,7 @@ module Getch
|
|
|
55
56
|
end
|
|
56
57
|
end
|
|
57
58
|
|
|
58
|
-
private
|
|
59
|
+
private
|
|
59
60
|
|
|
60
61
|
# https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Stage
|
|
61
62
|
def decompress
|
|
@@ -65,9 +66,7 @@ module Getch
|
|
|
65
66
|
end
|
|
66
67
|
|
|
67
68
|
def cleaning
|
|
68
|
-
Dir.glob(
|
|
69
|
-
File.delete(f)
|
|
70
|
-
end
|
|
69
|
+
Dir.glob('stage3-amd64-systemd*').each { |f| File.delete(f) }
|
|
71
70
|
end
|
|
72
71
|
end
|
|
73
72
|
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Getch
|
|
4
|
+
module Gentoo
|
|
5
|
+
class Use
|
|
6
|
+
def initialize(pkg = nil)
|
|
7
|
+
@use_dir = "#{MOUNTPOINT}/etc/portage/package.use"
|
|
8
|
+
@pkg = pkg
|
|
9
|
+
@file = @pkg ? @pkg.match(/[\w]+$/) : nil
|
|
10
|
+
@make = "#{MOUNTPOINT}/etc/portage/make.conf"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def add(*flags)
|
|
14
|
+
@flags = flags.join(' ')
|
|
15
|
+
write
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def add_global(*flags)
|
|
19
|
+
@flags = flags
|
|
20
|
+
write_global
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def write
|
|
26
|
+
content = "#{@pkg} #{@flags}\n"
|
|
27
|
+
File.write("#{@use_dir}/#{@file}", content, mode: 'w')
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def write_global
|
|
31
|
+
list = []
|
|
32
|
+
@flags.each { |f| list << f unless Helpers.grep?(@make, /#{f}/) }
|
|
33
|
+
use = list.join(' ')
|
|
34
|
+
line = "USE=\"${USE} #{use}\"\n"
|
|
35
|
+
File.write(@make, line, mode: 'a')
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Getch
|
|
4
|
+
module Gentoo
|
|
5
|
+
class UseFlag
|
|
6
|
+
def initialize
|
|
7
|
+
@efi = Helpers.efi?
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def apply
|
|
11
|
+
systemd
|
|
12
|
+
pam
|
|
13
|
+
kernel
|
|
14
|
+
kmod
|
|
15
|
+
grub
|
|
16
|
+
zfs
|
|
17
|
+
lvm
|
|
18
|
+
cryptsetup
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def systemd
|
|
24
|
+
flags = []
|
|
25
|
+
use = Getch::Gentoo::Use.new('sys-apps/systemd')
|
|
26
|
+
flags << 'dns-over-tls'
|
|
27
|
+
flags << 'gnuefi' if @efi
|
|
28
|
+
use.add(flags)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def pam
|
|
32
|
+
flags = []
|
|
33
|
+
use = Getch::Gentoo::Use.new('sys-auth/pambase')
|
|
34
|
+
flags << '-passwdqc'
|
|
35
|
+
flags << 'pwquality'
|
|
36
|
+
flags << 'sha512'
|
|
37
|
+
use.add(flags)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def kernel
|
|
41
|
+
use = Getch::Gentoo::Use.new('sys-kernel/gentoo-kernel')
|
|
42
|
+
use.add('hardened')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def kmod
|
|
46
|
+
use = Getch::Gentoo::Use.new('sys-apps/kmod')
|
|
47
|
+
use.add('zstd', 'lzma')
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def grub
|
|
51
|
+
return if @efi
|
|
52
|
+
|
|
53
|
+
flags = []
|
|
54
|
+
use = Getch::Gentoo::Use.new('sys-boot/grub')
|
|
55
|
+
flags << '-grub_platforms_efi-64'
|
|
56
|
+
flags << 'libzfs' if Getch::OPTIONS[:fs] == 'zfs'
|
|
57
|
+
flags << 'device-mapper' if Getch::OPTIONS[:fs] == 'lvm'
|
|
58
|
+
use.add(flags)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def zfs
|
|
62
|
+
return unless Getch::OPTIONS[:fs] == 'zfs'
|
|
63
|
+
|
|
64
|
+
use = Getch::Gentoo::Use.new('sys-fs/zfs-kmod')
|
|
65
|
+
use.add('rootfs')
|
|
66
|
+
use = Getch::Gentoo::Use.new('sys-fs/zfs')
|
|
67
|
+
use.add('rootfs')
|
|
68
|
+
|
|
69
|
+
# https://wiki.gentoo.org/wiki/Project:Distribution_Kernel
|
|
70
|
+
use = Getch::Gentoo::Use.new
|
|
71
|
+
use.add_global('dist-kernel')
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def lvm
|
|
75
|
+
return unless Getch::OPTIONS[:fs] == 'lvm'
|
|
76
|
+
|
|
77
|
+
use = Getch::Gentoo::Use.new
|
|
78
|
+
use.add_global('lvm', 'device-mapper')
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def cryptsetup
|
|
82
|
+
return unless Getch::OPTIONS[:encrypt]
|
|
83
|
+
|
|
84
|
+
use = Getch::Gentoo::Use.new
|
|
85
|
+
use.add_global('cryptsetup')
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
data/lib/getch/gentoo.rb
CHANGED
|
@@ -1,65 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
3
|
require_relative 'gentoo/stage'
|
|
4
4
|
require_relative 'gentoo/config'
|
|
5
5
|
require_relative 'gentoo/chroot'
|
|
6
|
+
require_relative 'gentoo/bootloader'
|
|
6
7
|
require_relative 'gentoo/sources'
|
|
7
8
|
require_relative 'gentoo/boot'
|
|
9
|
+
require_relative 'gentoo/use'
|
|
10
|
+
require_relative 'gentoo/use_flag'
|
|
8
11
|
|
|
9
12
|
module Getch
|
|
10
13
|
module Gentoo
|
|
11
|
-
class
|
|
12
|
-
def
|
|
13
|
-
@state = Getch::States.new
|
|
14
|
+
class Main
|
|
15
|
+
def initialize
|
|
16
|
+
@state = Getch::States.new
|
|
14
17
|
end
|
|
15
18
|
|
|
16
19
|
def stage3
|
|
17
20
|
return if STATES[:gentoo_base]
|
|
18
|
-
|
|
19
|
-
stage = Getch::Gentoo::Stage.new
|
|
21
|
+
|
|
22
|
+
stage = Getch::Gentoo::Stage.new
|
|
20
23
|
stage.get_stage3
|
|
21
24
|
stage.control_files
|
|
22
25
|
stage.checksum
|
|
23
26
|
@state.stage3
|
|
24
27
|
end
|
|
25
28
|
|
|
26
|
-
def config
|
|
29
|
+
def config
|
|
27
30
|
return if STATES[:gentoo_config]
|
|
28
|
-
|
|
29
|
-
config = Getch::Gentoo::Config.new
|
|
31
|
+
|
|
32
|
+
config = Getch::Gentoo::Config.new
|
|
30
33
|
config.portage
|
|
31
34
|
config.portage_fs
|
|
35
|
+
config.portage_bashrc
|
|
32
36
|
config.repo
|
|
33
37
|
config.network
|
|
34
|
-
config.systemd
|
|
38
|
+
config.systemd
|
|
35
39
|
config.hostname
|
|
36
40
|
@state.config
|
|
37
41
|
end
|
|
38
42
|
|
|
39
43
|
def chroot
|
|
40
|
-
|
|
44
|
+
return if STATES[:gentoo_update]
|
|
45
|
+
|
|
46
|
+
chroot = Getch::Gentoo::Chroot.new
|
|
41
47
|
chroot.update
|
|
42
48
|
chroot.cpuflags
|
|
43
49
|
chroot.systemd
|
|
50
|
+
|
|
51
|
+
flags = Getch::Gentoo::UseFlag.new
|
|
52
|
+
flags.apply
|
|
53
|
+
|
|
44
54
|
chroot.world
|
|
45
|
-
|
|
46
|
-
chroot.kernel
|
|
47
|
-
chroot.kernel_deps
|
|
55
|
+
chroot.kernel_license
|
|
48
56
|
chroot.install_pkgs
|
|
57
|
+
@state.update
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def bootloader
|
|
61
|
+
return if STATES[:gentoo_bootloader]
|
|
62
|
+
|
|
63
|
+
bootloader = Getch::Gentoo::Bootloader.new
|
|
64
|
+
bootloader.start
|
|
65
|
+
@state.bootloader
|
|
49
66
|
end
|
|
50
67
|
|
|
51
68
|
def kernel
|
|
52
69
|
return if STATES[:gentoo_kernel]
|
|
53
|
-
|
|
54
|
-
new
|
|
55
|
-
source.
|
|
56
|
-
source.
|
|
70
|
+
|
|
71
|
+
source = Getch::Gentoo::Sources.new
|
|
72
|
+
source.bask
|
|
73
|
+
source.configs
|
|
57
74
|
source.make
|
|
75
|
+
source.load_modules
|
|
58
76
|
@state.kernel
|
|
59
77
|
end
|
|
60
78
|
|
|
61
|
-
def boot
|
|
62
|
-
boot = Getch::Gentoo::Boot.new
|
|
79
|
+
def boot
|
|
80
|
+
boot = Getch::Gentoo::Boot.new
|
|
63
81
|
boot.start
|
|
64
82
|
end
|
|
65
83
|
end
|
data/lib/getch/guard.rb
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class InvalidDisk < StandardError
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
class InvalidFormat < StandardError
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class InvalidZone < StandardError
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class InvalidKeymap < StandardError
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
module Getch
|
|
16
|
+
module Guard
|
|
17
|
+
def self.disk(name)
|
|
18
|
+
raise InvalidDisk, 'No disk.' unless name
|
|
19
|
+
raise InvalidDisk, "Bad device name #{name}." unless name.match(/^sd[a-z]{1}$/)
|
|
20
|
+
raise InvalidDisk, "Disk /dev/#{name} no found." unless File.exist? "/dev/#{name}"
|
|
21
|
+
|
|
22
|
+
name
|
|
23
|
+
rescue InvalidDisk => e
|
|
24
|
+
puts "#{e.class} => #{e}"
|
|
25
|
+
exit 1
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.format(name)
|
|
29
|
+
raise InvalidFormat, 'No format specified.' unless name
|
|
30
|
+
raise InvalidFormat, "Format #{name} not yet available." if name.match(/btrfs/)
|
|
31
|
+
raise InvalidFormat, "Format #{name} not supported." unless name.match(/zfs|lvm|ext4/)
|
|
32
|
+
|
|
33
|
+
name
|
|
34
|
+
rescue InvalidFormat => e
|
|
35
|
+
puts "#{e.class} => #{e}"
|
|
36
|
+
exit 1
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.zone(name)
|
|
40
|
+
raise InvalidZone, 'No zoneinfo specified.' unless name
|
|
41
|
+
raise InvalidZone, 'Directory /usr/share/zoneinfo/ no found on this system...' unless Dir.exist? '/usr/share/zoneinfo/'
|
|
42
|
+
raise InvalidZone, "Zoneinfo #{name} is no found in /usr/share/zoneinfo/." unless File.exist? "/usr/share/zoneinfo/#{name}"
|
|
43
|
+
|
|
44
|
+
name
|
|
45
|
+
rescue InvalidZone => e
|
|
46
|
+
puts "#{e.class} => #{e}"
|
|
47
|
+
exit 1
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def self.keymap(name)
|
|
51
|
+
raise InvalidKeymap, 'No keymap specified.' unless name
|
|
52
|
+
|
|
53
|
+
key = []
|
|
54
|
+
|
|
55
|
+
if Dir.exist? '/usr/share/keymaps'
|
|
56
|
+
key = Dir.glob("/usr/share/keymaps/**/#{name}.map.gz")
|
|
57
|
+
elsif Dir.exist? '/usr/share/kbd/keymaps'
|
|
58
|
+
key = Dir.glob("/usr/share/kbd/keymaps/**/#{name}.map.gz")
|
|
59
|
+
else
|
|
60
|
+
raise InvalidKeymap, 'No directory found for keymap.'
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
raise InvalidKeymap, "Keymap #{name} no found." if key == []
|
|
64
|
+
|
|
65
|
+
name
|
|
66
|
+
rescue InvalidKeymap => e
|
|
67
|
+
puts "#{e.class} => #{e}"
|
|
68
|
+
exit 1
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|