getch 0.1.9 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +132 -0
- data/LICENSE +10 -0
- data/README.md +35 -29
- data/bin/getch +8 -6
- data/getch.gemspec +31 -0
- data/lib/clean.rb +149 -0
- data/lib/cryptsetup.rb +132 -0
- data/lib/devs.rb +199 -0
- data/lib/dracut/encrypt.rb +36 -0
- data/lib/dracut/hybrid.rb +15 -0
- data/lib/dracut/lvm.rb +14 -0
- data/lib/dracut/minimal.rb +11 -0
- data/lib/dracut/root.rb +45 -0
- data/lib/dracut/zfs.rb +35 -0
- data/lib/dracut.rb +11 -0
- data/lib/fstab/encrypt.rb +44 -0
- data/lib/fstab/hybrid.rb +34 -0
- data/lib/fstab/lvm.rb +25 -0
- data/lib/fstab/minimal.rb +6 -0
- data/lib/fstab/root.rb +93 -0
- data/lib/fstab/zfs.rb +23 -0
- data/lib/fstab.rb +11 -0
- data/lib/getch/assembly.rb +150 -0
- data/lib/getch/command.rb +88 -128
- data/lib/getch/config/account.rb +39 -0
- data/lib/getch/config/dhcp.rb +104 -0
- data/lib/getch/config/grub.rb +42 -0
- data/lib/getch/config/iwd.rb +60 -0
- data/lib/getch/config/keymap.rb +78 -0
- data/lib/getch/config/locale.rb +96 -0
- data/lib/getch/config/portage.rb +90 -0
- data/lib/getch/config/pre_network.rb +37 -0
- data/lib/getch/config/timezone.rb +52 -0
- data/lib/getch/config/void.rb +0 -36
- data/lib/getch/config.rb +16 -37
- data/lib/getch/device.rb +67 -0
- data/lib/getch/filesystem/ext4/encrypt/config.rb +9 -71
- data/lib/getch/filesystem/ext4/encrypt/deps.rb +15 -25
- data/lib/getch/filesystem/ext4/encrypt/device.rb +11 -5
- data/lib/getch/filesystem/ext4/encrypt/format.rb +6 -15
- data/lib/getch/filesystem/ext4/encrypt/mount.rb +7 -11
- data/lib/getch/filesystem/ext4/encrypt/partition.rb +10 -76
- data/lib/getch/filesystem/ext4/encrypt/void.rb +0 -38
- data/lib/getch/filesystem/ext4/encrypt.rb +2 -1
- data/lib/getch/filesystem/ext4/hybrid/config.rb +27 -0
- data/lib/getch/filesystem/ext4/hybrid/deps.rb +55 -0
- data/lib/getch/filesystem/ext4/hybrid/device.rb +24 -0
- data/lib/getch/filesystem/ext4/hybrid/format.rb +23 -0
- data/lib/getch/filesystem/ext4/hybrid/mount.rb +21 -0
- data/lib/getch/filesystem/ext4/hybrid/partition.rb +27 -0
- data/lib/getch/filesystem/{lvm/encrypt → ext4/hybrid}/void.rb +0 -39
- data/lib/getch/filesystem/ext4/hybrid.rb +19 -0
- data/lib/getch/filesystem/ext4/lvm/config.rb +25 -0
- data/lib/getch/filesystem/ext4/lvm/deps.rb +56 -0
- data/lib/getch/filesystem/ext4/lvm/device.rb +28 -0
- data/lib/getch/filesystem/ext4/lvm/format.rb +21 -0
- data/lib/getch/filesystem/ext4/lvm/mount.rb +21 -0
- data/lib/getch/filesystem/ext4/lvm/partition.rb +28 -0
- data/lib/getch/filesystem/{lvm.rb → ext4/lvm.rb} +6 -4
- data/lib/getch/filesystem/ext4/minimal/config.rb +25 -0
- data/lib/getch/filesystem/ext4/{device.rb → minimal/deps.rb} +3 -1
- data/lib/getch/filesystem/ext4/minimal/device.rb +22 -0
- data/lib/getch/filesystem/ext4/minimal/format.rb +23 -0
- data/lib/getch/filesystem/ext4/minimal/mount.rb +21 -0
- data/lib/getch/filesystem/ext4/minimal/partition.rb +28 -0
- data/lib/getch/filesystem/ext4/minimal.rb +19 -0
- data/lib/getch/filesystem/ext4.rb +7 -7
- data/lib/getch/filesystem/zfs/encrypt/config.rb +10 -39
- data/lib/getch/filesystem/zfs/encrypt/deps.rb +4 -55
- data/lib/getch/filesystem/zfs/encrypt/device.rb +7 -51
- data/lib/getch/filesystem/zfs/encrypt/format.rb +6 -90
- data/lib/getch/filesystem/zfs/encrypt/mount.rb +16 -35
- data/lib/getch/filesystem/zfs/encrypt/partition.rb +6 -54
- data/lib/getch/filesystem/zfs/encrypt.rb +2 -1
- data/lib/getch/filesystem/zfs/minimal/config.rb +37 -0
- data/lib/getch/filesystem/zfs/minimal/deps.rb +126 -0
- data/lib/getch/filesystem/zfs/minimal/device.rb +24 -0
- data/lib/getch/filesystem/zfs/minimal/format.rb +23 -0
- data/lib/getch/filesystem/zfs/minimal/mount.rb +23 -0
- data/lib/getch/filesystem/zfs/minimal/partition.rb +23 -0
- data/lib/getch/filesystem/zfs/minimal.rb +19 -0
- data/lib/getch/filesystem/zfs.rb +1 -7
- data/lib/getch/filesystem.rb +0 -6
- data/lib/getch/gentoo/bootloader.rb +23 -44
- data/lib/getch/gentoo/finalize.rb +25 -0
- data/lib/getch/gentoo/post_config.rb +75 -0
- data/lib/getch/gentoo/pre_config.rb +37 -0
- data/lib/getch/gentoo/services.rb +18 -0
- data/lib/getch/gentoo/sources.rb +39 -33
- data/lib/getch/gentoo/tarball.rb +91 -0
- data/lib/getch/gentoo/terraform.rb +34 -0
- data/lib/getch/gentoo/update.rb +54 -0
- data/lib/getch/gentoo/use.rb +9 -6
- data/lib/getch/gentoo/use_flag.rb +17 -20
- data/lib/getch/gentoo.rb +9 -75
- data/lib/getch/guard.rb +3 -3
- data/lib/getch/helpers.rb +63 -115
- data/lib/getch/log.rb +87 -25
- data/lib/getch/options.rb +41 -11
- data/lib/getch/states.rb +28 -8
- data/lib/getch/tree.rb +56 -0
- data/lib/getch/version.rb +1 -1
- data/lib/getch/void/bootloader.rb +18 -0
- data/lib/getch/void/finalize.rb +31 -0
- data/lib/getch/void/post_config.rb +19 -0
- data/lib/getch/void/pre_config.rb +18 -0
- data/lib/getch/void/services.rb +18 -0
- data/lib/getch/void/{stage.rb → tarball.rb} +34 -14
- data/lib/getch/void/terraform.rb +28 -0
- data/lib/getch/void/update.rb +33 -0
- data/lib/getch/void.rb +9 -59
- data/lib/getch.rb +58 -90
- data/lib/luks.rb +239 -0
- data/lib/lvm2.rb +112 -0
- data/lib/mkfs/zfs.rb +167 -0
- data/lib/mkfs.rb +144 -0
- data/lib/mountfs.rb +154 -0
- data/lib/nito.rb +131 -0
- data/lib/sgdisk.rb +160 -0
- data.tar.gz.sig +0 -0
- metadata +113 -74
- metadata.gz.sig +0 -0
- data/lib/getch/config/gentoo.rb +0 -58
- data/lib/getch/filesystem/clean.rb +0 -58
- data/lib/getch/filesystem/device.rb +0 -63
- data/lib/getch/filesystem/ext4/config.rb +0 -62
- data/lib/getch/filesystem/ext4/deps.rb +0 -24
- data/lib/getch/filesystem/ext4/format.rb +0 -31
- data/lib/getch/filesystem/ext4/mount.rb +0 -26
- data/lib/getch/filesystem/ext4/partition.rb +0 -55
- data/lib/getch/filesystem/ext4/void.rb +0 -44
- data/lib/getch/filesystem/lvm/config.rb +0 -44
- data/lib/getch/filesystem/lvm/deps.rb +0 -44
- data/lib/getch/filesystem/lvm/device.rb +0 -45
- data/lib/getch/filesystem/lvm/encrypt/config.rb +0 -74
- data/lib/getch/filesystem/lvm/encrypt/deps.rb +0 -49
- data/lib/getch/filesystem/lvm/encrypt/device.rb +0 -48
- data/lib/getch/filesystem/lvm/encrypt/format.rb +0 -35
- data/lib/getch/filesystem/lvm/encrypt/mount.rb +0 -27
- data/lib/getch/filesystem/lvm/encrypt/partition.rb +0 -84
- data/lib/getch/filesystem/lvm/encrypt.rb +0 -18
- data/lib/getch/filesystem/lvm/format.rb +0 -32
- data/lib/getch/filesystem/lvm/mount.rb +0 -26
- data/lib/getch/filesystem/lvm/partition.rb +0 -72
- data/lib/getch/filesystem/lvm/void.rb +0 -46
- data/lib/getch/filesystem/mount.rb +0 -63
- data/lib/getch/filesystem/partition.rb +0 -85
- data/lib/getch/filesystem/zfs/config.rb +0 -43
- data/lib/getch/filesystem/zfs/deps.rb +0 -67
- data/lib/getch/filesystem/zfs/device.rb +0 -66
- data/lib/getch/filesystem/zfs/encrypt/void.rb +0 -97
- data/lib/getch/filesystem/zfs/format.rb +0 -117
- data/lib/getch/filesystem/zfs/mount.rb +0 -47
- data/lib/getch/filesystem/zfs/partition.rb +0 -69
- data/lib/getch/filesystem/zfs/void.rb +0 -81
- data/lib/getch/gentoo/boot.rb +0 -64
- data/lib/getch/gentoo/chroot.rb +0 -75
- data/lib/getch/gentoo/config.rb +0 -167
- data/lib/getch/gentoo/stage.rb +0 -73
- data/lib/getch/void/boot.rb +0 -84
- data/lib/getch/void/chroot.rb +0 -56
- data/lib/getch/void/config.rb +0 -90
data/lib/getch/gentoo/sources.rb
CHANGED
@@ -1,86 +1,93 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'cmdline'
|
4
|
+
require 'nito'
|
4
5
|
|
5
6
|
module Getch
|
6
7
|
module Gentoo
|
7
8
|
class Sources
|
9
|
+
include NiTo
|
10
|
+
|
8
11
|
def initialize
|
12
|
+
@log = Log.new
|
9
13
|
@lsmod = `lsmod`.chomp
|
10
|
-
|
11
|
-
|
14
|
+
x
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
def x
|
20
|
+
bask
|
21
|
+
gen_cmdline
|
22
|
+
grub_mkconfig
|
23
|
+
use_flags
|
24
|
+
make
|
12
25
|
end
|
13
26
|
|
14
27
|
def bask
|
15
|
-
|
28
|
+
@log.info "Kernel hardening...\n"
|
16
29
|
#Getch::Bask.new('10_kspp.config').cp
|
17
30
|
Getch::Bask.new('11-kspp-gcc.config').cp
|
18
31
|
Getch::Bask.new('12-kspp-x86_64.config').cp
|
19
32
|
#Getch::Bask.new('20-clipos.config').cp
|
20
|
-
|
33
|
+
Getch::Bask.new('30-grsecurity.config').cp
|
21
34
|
#Getch::Bask.new('40-kconfig-hardened.config').cp
|
22
35
|
Getch::Bask.new('50-blacklist.config').cp
|
23
36
|
Getch::Bask.new('51-blacklist-madaidans.config').cp
|
24
37
|
end
|
25
38
|
|
26
|
-
def configs
|
27
|
-
gen_cmdline
|
28
|
-
grub_mkconfig unless Helpers.efi?
|
29
|
-
end
|
30
|
-
|
31
39
|
def gen_cmdline
|
32
40
|
cmdline = CmdLine::Kernel.new(workdir: "#{MOUNTPOINT}/etc/kernel")
|
33
41
|
cmdline.main
|
34
42
|
end
|
35
43
|
|
36
44
|
def grub_mkconfig
|
37
|
-
|
45
|
+
return if Helpers.systemd? and Helpers.efi?
|
46
|
+
|
47
|
+
file = "#{OPTIONS[:mountpoint]}/etc/kernel/postinst.d/90-mkconfig.install"
|
38
48
|
content = <<~SHELL
|
39
49
|
#!/usr/bin/env sh
|
40
50
|
set -o errexit
|
51
|
+
|
52
|
+
if ! hash grub-mkconfig ; then
|
53
|
+
exit 0
|
54
|
+
fi
|
41
55
|
grub-mkconfig -o /boot/grub/grub.cfg
|
42
|
-
exit 0
|
43
56
|
SHELL
|
57
|
+
mkdir "#{OPTIONS[:mountpoint]}/etc/kernel/postinst.d"
|
44
58
|
File.write file, content
|
45
59
|
File.chmod 0755, file
|
46
60
|
end
|
47
61
|
|
62
|
+
def use_flags
|
63
|
+
use = Getch::Gentoo::Use.new('sys-kernel/gentoo-kernel')
|
64
|
+
use.add('hardened')
|
65
|
+
end
|
66
|
+
|
67
|
+
# https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Kernel#Alternative:_Using_distribution_kernels
|
48
68
|
def make
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
69
|
+
Helpers.systemd? ?
|
70
|
+
Install.new('sys-kernel/installkernel-systemd-boot') :
|
71
|
+
Install.new('sys-kernel/installkernel-gentoo')
|
72
|
+
|
73
|
+
#Install.new 'sys-kernel/gentoo-kernel'
|
74
|
+
Install.new 'sys-kernel/gentoo-kernel-bin'
|
56
75
|
end
|
57
76
|
|
58
77
|
def load_modules
|
59
|
-
|
78
|
+
wifi
|
60
79
|
flash_mod
|
61
80
|
end
|
62
81
|
|
63
82
|
private
|
64
83
|
|
65
|
-
def make_kernel
|
66
|
-
puts 'Compiling kernel sources'
|
67
|
-
Getch::Emerge.new('sys-kernel/gentoo-kernel').pkg!
|
68
|
-
is_kernel = Dir.glob("#{MOUNTPOINT}/boot/vmlinuz-*")
|
69
|
-
raise 'No kernel installed, compiling source fail...' if is_kernel == []
|
70
|
-
end
|
71
|
-
|
72
84
|
def ismatch?(arg)
|
73
85
|
@lsmod.match?(/#{arg}/)
|
74
86
|
end
|
75
87
|
|
76
|
-
def
|
88
|
+
def wifi
|
77
89
|
return unless ismatch?('cfg80211')
|
78
90
|
|
79
|
-
wifi_drivers
|
80
|
-
Getch::Emerge.new('net-wireless/iwd').pkg!
|
81
|
-
end
|
82
|
-
|
83
|
-
def wifi_drivers
|
84
91
|
conf = "#{MOUNTPOINT}/etc/modules-load.d/wifi.conf"
|
85
92
|
File.delete(conf) if File.exist? conf
|
86
93
|
|
@@ -101,7 +108,6 @@ SHELL
|
|
101
108
|
end
|
102
109
|
|
103
110
|
def module_load(name, file)
|
104
|
-
return unless name
|
105
111
|
return unless ismatch?(name)
|
106
112
|
|
107
113
|
File.write(file, "#{name}\n", mode: 'a')
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'open-uri'
|
4
|
+
require 'open3'
|
5
|
+
|
6
|
+
module Getch
|
7
|
+
module Gentoo
|
8
|
+
class Tarball
|
9
|
+
def initialize
|
10
|
+
@log = Log.new
|
11
|
+
@mirror = 'https://mirror.rackspace.com/gentoo'
|
12
|
+
@release = release
|
13
|
+
@stage_file = OPTIONS[:musl] ?
|
14
|
+
"stage3-amd64-musl-#{@release}.tar.xz" :
|
15
|
+
"stage3-amd64-systemd-#{@release}.tar.xz"
|
16
|
+
end
|
17
|
+
|
18
|
+
def x
|
19
|
+
get_stage3
|
20
|
+
control_files
|
21
|
+
checksum
|
22
|
+
install
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
def stage3
|
28
|
+
OPTIONS[:musl] ?
|
29
|
+
@mirror + '/releases/amd64/autobuilds/latest-stage3-amd64-musl.txt' :
|
30
|
+
@mirror + '/releases/amd64/autobuilds/latest-stage3-amd64-systemd.txt'
|
31
|
+
end
|
32
|
+
|
33
|
+
def release
|
34
|
+
URI.open(stage3) do |file|
|
35
|
+
file.read.match(/^[[:alnum:]]+/)
|
36
|
+
end
|
37
|
+
rescue Net::OpenTimeout => e
|
38
|
+
@log.fatal "Problem with DNS? #{e}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def file
|
42
|
+
"#{@release}/#{@stage_file}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_stage3
|
46
|
+
Dir.chdir OPTIONS[:mountpoint]
|
47
|
+
return if File.exist? @stage_file
|
48
|
+
|
49
|
+
@log.info "wget #{@stage_file}, please wait...\n"
|
50
|
+
Helpers.get_file_online(@mirror + '/releases/amd64/autobuilds/' + file, @stage_file)
|
51
|
+
end
|
52
|
+
|
53
|
+
def control_files
|
54
|
+
@log.info "Download other files..."
|
55
|
+
['DIGESTS', 'asc', 'CONTENTS.gz'].each do |f|
|
56
|
+
Helpers.get_file_online("#{@mirror}/releases/amd64/autobuilds/#{file}.#{f}", "#{@stage_file}.#{f}")
|
57
|
+
end
|
58
|
+
@log.result_ok
|
59
|
+
end
|
60
|
+
|
61
|
+
def checksum
|
62
|
+
@log.info 'Checking SHA512 checksum...'
|
63
|
+
command = "awk '/SHA512 HASH/{getline;print}' #{@stage_file}.DIGESTS | sha512sum --check"
|
64
|
+
_, stderr, status = Open3.capture3(command)
|
65
|
+
if status.success? then
|
66
|
+
@log.result_ok
|
67
|
+
else
|
68
|
+
cleaning
|
69
|
+
@log.fatal "Problem with the checksum, stderr\n#{stderr}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def install
|
74
|
+
decompress
|
75
|
+
cleaning
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
# https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Stage
|
81
|
+
def decompress
|
82
|
+
cmd = "tar xpf #{@stage_file} --xattrs-include=\'*.*\' --numeric-owner"
|
83
|
+
Getch::Command.new(cmd)
|
84
|
+
end
|
85
|
+
|
86
|
+
def cleaning
|
87
|
+
Dir.glob('stage3-amd64-*').each { |f| File.delete(f) }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Getch
|
2
|
+
module Gentoo
|
3
|
+
class Terraform
|
4
|
+
def initialize
|
5
|
+
x
|
6
|
+
end
|
7
|
+
|
8
|
+
protected
|
9
|
+
|
10
|
+
def x
|
11
|
+
Gentoo::Sources.new
|
12
|
+
install_pkgs
|
13
|
+
emerge_deep
|
14
|
+
end
|
15
|
+
|
16
|
+
def install_pkgs
|
17
|
+
@pkgs = 'app-portage/gentoolkit'
|
18
|
+
@pkgs << ' app-admin/sudo'
|
19
|
+
@pkgs << ' app-editors/vim'
|
20
|
+
@pkgs << ' net-firewall/iptables'
|
21
|
+
@pkgs << ' net-wireless/iwd'
|
22
|
+
@pkgs << ' net-misc/dhcpcd' unless Helpers.systemd?
|
23
|
+
@pkgs << ' sys-kernel/linux-firmware'
|
24
|
+
@pkgs << ' sys-firmware/intel-microcode'
|
25
|
+
@pkgs << ' sys-fs/dosfstools' if Helpers.efi?
|
26
|
+
Install.new(@pkgs)
|
27
|
+
end
|
28
|
+
|
29
|
+
def emerge_deep
|
30
|
+
ChrootOutput.new('emerge --deep --newuse @world')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'nito'
|
4
|
+
|
5
|
+
module Getch
|
6
|
+
module Gentoo
|
7
|
+
class Update
|
8
|
+
include NiTo
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@log = Log.new
|
12
|
+
x
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
def x
|
18
|
+
sync
|
19
|
+
add_musl_repo if OPTIONS[:musl]
|
20
|
+
update
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def sync
|
26
|
+
gentoo_conf = "#{OPTIONS[:mountpoint]}/etc/portage/repos.conf/gentoo.conf"
|
27
|
+
@log.info "Synchronize index, please waiting...\n"
|
28
|
+
ChrootOutput.new('emaint sync --auto')
|
29
|
+
sed gentoo_conf, /^sync-type/, 'sync-type = rsync'
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_musl_repo
|
33
|
+
Install.new('dev-vcs/git')
|
34
|
+
|
35
|
+
file = "#{OPTIONS[:mountpoint]}/etc/portage/repos.conf/musl.conf"
|
36
|
+
content = <<~CONF
|
37
|
+
[musl]
|
38
|
+
location = /var/db/repos/musl
|
39
|
+
sync-type = git
|
40
|
+
sync-uri = https://github.com/gentoo/musl.git
|
41
|
+
auto-sync = Yes
|
42
|
+
CONF
|
43
|
+
File.write file, "#{content}\n"
|
44
|
+
|
45
|
+
ChrootOutput.new('emaint sync -r musl')
|
46
|
+
end
|
47
|
+
|
48
|
+
def update
|
49
|
+
cmd = 'emerge --update --deep --newuse @world'
|
50
|
+
ChrootOutput.new(cmd)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/getch/gentoo/use.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'nito'
|
4
|
+
|
3
5
|
module Getch
|
4
6
|
module Gentoo
|
5
7
|
class Use
|
8
|
+
include NiTo
|
9
|
+
|
6
10
|
def initialize(pkg = nil)
|
7
|
-
@use_dir = "#{
|
11
|
+
@use_dir = "#{OPTIONS[:mountpoint]}/etc/portage/package.use"
|
8
12
|
@pkg = pkg
|
9
13
|
@file = @pkg ? @pkg.match(/[\w]+$/) : nil
|
10
|
-
@make = "#{
|
14
|
+
@make = "#{OPTIONS[:mountpoint]}/etc/portage/make.conf"
|
11
15
|
end
|
12
16
|
|
13
17
|
def add(*flags)
|
@@ -24,15 +28,14 @@ module Getch
|
|
24
28
|
|
25
29
|
def write
|
26
30
|
content = "#{@pkg} #{@flags}\n"
|
27
|
-
|
31
|
+
echo "#{@use_dir}/#{@file}", content
|
28
32
|
end
|
29
33
|
|
30
34
|
def write_global
|
31
35
|
list = []
|
32
|
-
@flags.each { |f| list << f unless
|
36
|
+
@flags.each { |f| list << f unless grep?(@make, f) }
|
33
37
|
use = list.join(' ')
|
34
|
-
|
35
|
-
File.write(@make, line, mode: 'a')
|
38
|
+
echo_a @make, "USE=\"${USE} #{use}\""
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
@@ -4,13 +4,15 @@ module Getch
|
|
4
4
|
module Gentoo
|
5
5
|
class UseFlag
|
6
6
|
def initialize
|
7
|
-
|
7
|
+
x
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
protected
|
11
|
+
|
12
|
+
def x
|
13
|
+
dist_kernel
|
11
14
|
systemd
|
12
15
|
pam
|
13
|
-
kernel
|
14
16
|
kmod
|
15
17
|
grub
|
16
18
|
zfs
|
@@ -20,41 +22,40 @@ module Getch
|
|
20
22
|
|
21
23
|
private
|
22
24
|
|
25
|
+
# https://wiki.gentoo.org/wiki/Project:Distribution_Kernel#Trying_it_out
|
26
|
+
def dist_kernel
|
27
|
+
use = Getch::Gentoo::Use.new
|
28
|
+
use.add_global('dist-kernel')
|
29
|
+
end
|
30
|
+
|
23
31
|
def systemd
|
32
|
+
return unless Helpers.systemd?
|
33
|
+
|
24
34
|
flags = []
|
25
35
|
use = Getch::Gentoo::Use.new('sys-apps/systemd')
|
26
36
|
flags << 'dns-over-tls'
|
27
|
-
flags << 'gnuefi' if
|
37
|
+
flags << 'gnuefi' if Helpers.efi?
|
28
38
|
use.add(flags)
|
29
39
|
end
|
30
40
|
|
31
41
|
def pam
|
32
42
|
flags = []
|
33
43
|
use = Getch::Gentoo::Use.new('sys-auth/pambase')
|
34
|
-
flags << '-passwdqc'
|
35
|
-
flags << 'pwquality'
|
36
44
|
flags << 'sha512'
|
37
45
|
use.add(flags)
|
38
46
|
end
|
39
47
|
|
40
|
-
def kernel
|
41
|
-
use = Getch::Gentoo::Use.new('sys-kernel/gentoo-kernel')
|
42
|
-
use.add('hardened')
|
43
|
-
end
|
44
|
-
|
45
48
|
def kmod
|
46
49
|
use = Getch::Gentoo::Use.new('sys-apps/kmod')
|
47
50
|
use.add('zstd', 'lzma')
|
48
51
|
end
|
49
52
|
|
50
53
|
def grub
|
51
|
-
return if @efi
|
52
|
-
|
53
54
|
flags = []
|
54
55
|
use = Getch::Gentoo::Use.new('sys-boot/grub')
|
55
|
-
flags << '-grub_platforms_efi-64'
|
56
|
-
flags << 'libzfs' if
|
57
|
-
flags << 'device-mapper' if
|
56
|
+
flags << '-grub_platforms_efi-64' unless Helpers.efi?
|
57
|
+
flags << 'libzfs' if OPTIONS[:fs] == 'zfs'
|
58
|
+
flags << 'device-mapper' if OPTIONS[:fs] == 'lvm' or OPTIONS[:encrypt]
|
58
59
|
use.add(flags)
|
59
60
|
end
|
60
61
|
|
@@ -65,10 +66,6 @@ module Getch
|
|
65
66
|
use.add('rootfs')
|
66
67
|
use = Getch::Gentoo::Use.new('sys-fs/zfs')
|
67
68
|
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
69
|
end
|
73
70
|
|
74
71
|
def lvm
|
data/lib/getch/gentoo.rb
CHANGED
@@ -1,85 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'gentoo/stage'
|
4
|
-
require_relative 'gentoo/config'
|
5
|
-
require_relative 'gentoo/chroot'
|
6
|
-
require_relative 'gentoo/bootloader'
|
7
3
|
require_relative 'gentoo/sources'
|
8
|
-
require_relative 'gentoo/boot'
|
9
4
|
require_relative 'gentoo/use'
|
10
5
|
require_relative 'gentoo/use_flag'
|
11
6
|
|
12
7
|
module Getch
|
13
8
|
module Gentoo
|
14
|
-
class Main
|
15
|
-
def initialize
|
16
|
-
@state = Getch::States.new
|
17
|
-
end
|
18
|
-
|
19
|
-
def stage3
|
20
|
-
return if STATES[:gentoo_base]
|
21
|
-
|
22
|
-
stage = Getch::Gentoo::Stage.new
|
23
|
-
stage.get_stage3
|
24
|
-
stage.control_files
|
25
|
-
stage.checksum
|
26
|
-
@state.stage3
|
27
|
-
end
|
28
|
-
|
29
|
-
def config
|
30
|
-
return if STATES[:gentoo_config]
|
31
|
-
|
32
|
-
config = Getch::Gentoo::Config.new
|
33
|
-
config.portage
|
34
|
-
config.portage_fs
|
35
|
-
config.portage_bashrc
|
36
|
-
config.repo
|
37
|
-
config.network
|
38
|
-
config.systemd
|
39
|
-
config.hostname
|
40
|
-
@state.config
|
41
|
-
end
|
42
|
-
|
43
|
-
def chroot
|
44
|
-
return if STATES[:gentoo_update]
|
45
|
-
|
46
|
-
chroot = Getch::Gentoo::Chroot.new
|
47
|
-
chroot.update
|
48
|
-
chroot.cpuflags
|
49
|
-
chroot.systemd
|
50
|
-
|
51
|
-
flags = Getch::Gentoo::UseFlag.new
|
52
|
-
flags.apply
|
53
|
-
|
54
|
-
chroot.world
|
55
|
-
chroot.kernel_license
|
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
|
66
|
-
end
|
67
|
-
|
68
|
-
def kernel
|
69
|
-
return if STATES[:gentoo_kernel]
|
70
|
-
|
71
|
-
source = Getch::Gentoo::Sources.new
|
72
|
-
source.bask
|
73
|
-
source.configs
|
74
|
-
source.make
|
75
|
-
source.load_modules
|
76
|
-
@state.kernel
|
77
|
-
end
|
78
|
-
|
79
|
-
def boot
|
80
|
-
boot = Getch::Gentoo::Boot.new
|
81
|
-
boot.start
|
82
|
-
end
|
83
|
-
end
|
84
9
|
end
|
85
10
|
end
|
11
|
+
|
12
|
+
require_relative 'gentoo/tarball'
|
13
|
+
require_relative 'gentoo/pre_config'
|
14
|
+
require_relative 'gentoo/update'
|
15
|
+
require_relative 'gentoo/post_config'
|
16
|
+
require_relative 'gentoo/terraform'
|
17
|
+
require_relative 'gentoo/services'
|
18
|
+
require_relative 'gentoo/bootloader'
|
19
|
+
require_relative 'gentoo/finalize'
|
data/lib/getch/guard.rb
CHANGED
@@ -16,7 +16,7 @@ module Getch
|
|
16
16
|
module Guard
|
17
17
|
def self.disk(name)
|
18
18
|
raise InvalidDisk, 'No disk.' unless name
|
19
|
-
raise InvalidDisk, "Bad device name #{name}." unless name.match(
|
19
|
+
raise InvalidDisk, "Bad device name #{name}." unless name.match(/^?d[a-z]{1}$/)
|
20
20
|
raise InvalidDisk, "Disk /dev/#{name} no found." unless File.exist? "/dev/#{name}"
|
21
21
|
|
22
22
|
name
|
@@ -27,8 +27,8 @@ module Getch
|
|
27
27
|
|
28
28
|
def self.format(name)
|
29
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|
|
30
|
+
raise InvalidFormat, "Format #{name} not yet available." if name.match(/btrfs|xfs/)
|
31
|
+
raise InvalidFormat, "Format #{name} not supported." unless name.match(/zfs|ext4/)
|
32
32
|
|
33
33
|
name
|
34
34
|
rescue InvalidFormat => e
|