getch 0.1.9 → 0.3.0
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 +35 -29
- data/bin/getch +8 -6
- 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 +2 -2
- 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 +140 -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 +83 -47
- 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/log.rb
CHANGED
|
@@ -4,54 +4,116 @@ require 'logger'
|
|
|
4
4
|
|
|
5
5
|
module Getch
|
|
6
6
|
class Log
|
|
7
|
+
|
|
8
|
+
WHITE = "\033[37m"
|
|
9
|
+
CYAN = "\033[36m"
|
|
10
|
+
MAGENTA = "\033[35m"
|
|
11
|
+
BLUE = "\033[34m"
|
|
12
|
+
YELLOW = "\033[33m"
|
|
13
|
+
GREEN = "\033[32m"
|
|
14
|
+
RED = "\033[31m"
|
|
15
|
+
BLACK = "\033[30m"
|
|
16
|
+
BOLD = "\033[1m"
|
|
17
|
+
CLEAR = "\033[0m"
|
|
18
|
+
|
|
7
19
|
def initialize(verbose = false)
|
|
8
20
|
@log_file = '/tmp/log_install.txt'
|
|
9
21
|
@verbose = verbose
|
|
10
|
-
|
|
11
|
-
init_log
|
|
12
|
-
init_log_text
|
|
22
|
+
init
|
|
13
23
|
end
|
|
14
24
|
|
|
25
|
+
# TODO remove length
|
|
15
26
|
def info(msg)
|
|
16
|
-
|
|
17
|
-
|
|
27
|
+
tab = msg.match("\n") ? '' : add_tab(msg)
|
|
28
|
+
l = msg.length
|
|
29
|
+
@info.info "#{GREEN}#{BOLD} >>> #{CLEAR}#{l} #{WHITE}#{msg}#{CLEAR}" + tab
|
|
30
|
+
@save.info(msg)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def result_ok
|
|
34
|
+
@result.info "#{GREEN}[ #{WHITE}ok#{GREEN} ]#{CLEAR}\n"
|
|
18
35
|
end
|
|
19
36
|
|
|
20
37
|
def error(msg)
|
|
21
|
-
@
|
|
22
|
-
@
|
|
38
|
+
@error.error "#{BOLD} > #{CLEAR}#{WHITE}#{msg}#{CLEAR}"
|
|
39
|
+
@save.error(msg)
|
|
23
40
|
end
|
|
24
41
|
|
|
25
42
|
def debug(msg)
|
|
26
|
-
@
|
|
27
|
-
@
|
|
43
|
+
@debug.debug "#{BOLD} > #{CLEAR}#{WHITE}#{msg}#{CLEAR}"
|
|
44
|
+
@save.debug(msg)
|
|
28
45
|
end
|
|
29
46
|
|
|
30
47
|
def fatal(msg)
|
|
31
|
-
@
|
|
32
|
-
@
|
|
48
|
+
@fatal.fatal "#{BOLD} > #{CLEAR}#{WHITE}#{msg}#{CLEAR}\n"
|
|
49
|
+
@save.fatal(msg)
|
|
50
|
+
exit 1
|
|
33
51
|
end
|
|
34
52
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def check_file
|
|
38
|
-
puts "Creating log at #{@log_file}" unless File.exist? @log_file
|
|
39
|
-
end
|
|
53
|
+
protected
|
|
40
54
|
|
|
41
55
|
def init_log
|
|
42
|
-
@
|
|
43
|
-
@
|
|
44
|
-
@
|
|
45
|
-
"#{severity}
|
|
56
|
+
@info = Logger.new $stdout
|
|
57
|
+
@info.level = @verbose ? Logger::DEBUG : Logger::INFO
|
|
58
|
+
@info.formatter = proc { |severity, _, _, msg|
|
|
59
|
+
"#{BOLD}#{severity[0]}#{CLEAR}#{msg}"
|
|
46
60
|
}
|
|
47
61
|
end
|
|
48
62
|
|
|
49
|
-
def
|
|
50
|
-
@
|
|
51
|
-
@
|
|
52
|
-
|
|
53
|
-
|
|
63
|
+
def init_res
|
|
64
|
+
@result = Logger.new $stdout, level: 'INFO'
|
|
65
|
+
@result.formatter = proc do | _, _, _, msg | msg end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def init_debug
|
|
69
|
+
@debug = Logger.new $stdout
|
|
70
|
+
@debug.formatter = proc do | severity, _, _, msg |
|
|
71
|
+
"\n#{BLUE}#{BOLD}#{severity[0]}#{CLEAR} [#{Process.pid}]#{CLEAR}#{msg}"
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def init_error
|
|
76
|
+
@error = Logger.new $stdout
|
|
77
|
+
@error.formatter = proc do | severity, _, _, msg |
|
|
78
|
+
"#{RED}#{BOLD}#{severity[0]}#{CLEAR}#{msg}\t"
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def init_fatal
|
|
83
|
+
@fatal = Logger.new $stdout
|
|
84
|
+
@fatal.formatter = proc do | severity, _, _, msg |
|
|
85
|
+
"\n#{YELLOW}#{BOLD}#{severity[0]}#{CLEAR}#{msg}"
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def init_save
|
|
90
|
+
File.exist? @log_file || puts("Creating log at #{@log_file}")
|
|
91
|
+
@save = Logger.new(@log_file, 1)
|
|
92
|
+
@save.level = Logger::DEBUG
|
|
93
|
+
@save.formatter = proc { |severity, datetime, _, msg|
|
|
94
|
+
"#{severity}, #{datetime}, #{msg}\n"
|
|
54
95
|
}
|
|
55
96
|
end
|
|
97
|
+
|
|
98
|
+
private
|
|
99
|
+
|
|
100
|
+
def init
|
|
101
|
+
init_log
|
|
102
|
+
init_res
|
|
103
|
+
init_error
|
|
104
|
+
init_debug
|
|
105
|
+
init_fatal
|
|
106
|
+
init_save
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def add_tab(text)
|
|
110
|
+
case text.length
|
|
111
|
+
when 39..47 then "\t\t"
|
|
112
|
+
when 31..38 then "\t\t\t"
|
|
113
|
+
when 23..30 then "\t\t\t\t"
|
|
114
|
+
when 16..22 then "\t\t\t\t\t"
|
|
115
|
+
else "\t"
|
|
116
|
+
end
|
|
117
|
+
end
|
|
56
118
|
end
|
|
57
119
|
end
|
data/lib/getch/options.rb
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'optparse'
|
|
4
|
+
require 'nito'
|
|
4
5
|
|
|
5
6
|
module Getch
|
|
6
7
|
class Options
|
|
8
|
+
include NiTo
|
|
9
|
+
|
|
7
10
|
def initialize(argv)
|
|
8
11
|
parse(argv)
|
|
9
12
|
end
|
|
@@ -12,52 +15,71 @@ module Getch
|
|
|
12
15
|
|
|
13
16
|
def parse(argv)
|
|
14
17
|
OptionParser.new do |opts|
|
|
15
|
-
opts.
|
|
18
|
+
opts.banner = 'Usage: getch [OPTION...] <action>'
|
|
19
|
+
|
|
20
|
+
opts.separator "\noptions:"
|
|
16
21
|
|
|
17
22
|
opts.on('-l', '--language LANG', 'Default is en_US') do |lang|
|
|
18
23
|
OPTIONS[:language] = lang
|
|
19
24
|
end
|
|
20
25
|
|
|
21
|
-
opts.on('-
|
|
22
|
-
OPTIONS[:
|
|
26
|
+
opts.on('-t', '--timezone ZONE', 'Default is UTC') do |zone|
|
|
27
|
+
OPTIONS[:timezone] = Getch::Guard.zone(zone)
|
|
23
28
|
end
|
|
24
29
|
|
|
25
30
|
opts.on('-k', '--keymap KEY', 'Default is us') do |key|
|
|
26
31
|
OPTIONS[:keymap] = Getch::Guard.keymap(key)
|
|
27
32
|
end
|
|
28
33
|
|
|
29
|
-
opts.on('-d', '--disk DISK',
|
|
34
|
+
opts.on('-d', '--disk DISK',
|
|
35
|
+
'Root Disk where install the system (sda,sdb)') do |disk|
|
|
30
36
|
OPTIONS[:disk] = Getch::Guard.disk(disk)
|
|
31
37
|
end
|
|
32
38
|
|
|
33
|
-
opts.on('-f', '--format FS',
|
|
39
|
+
opts.on('-f', '--format FS',
|
|
40
|
+
'Can be ext4, zfs. Default use ext4') do |fs|
|
|
34
41
|
OPTIONS[:fs] = Getch::Guard.format(fs)
|
|
35
42
|
end
|
|
36
43
|
|
|
37
|
-
opts.on('-u', '--username USERNAME',
|
|
44
|
+
opts.on('-u', '--username USERNAME',
|
|
45
|
+
'Create a new user /home/USERNAME with password.') do |user|
|
|
38
46
|
OPTIONS[:username] = user
|
|
39
47
|
end
|
|
40
48
|
|
|
41
|
-
opts.on('-o', '--os NAME', /gentoo|void/,
|
|
49
|
+
opts.on('-o', '--os NAME', /gentoo|void/,
|
|
50
|
+
'Install distro NAME, can be gentoo or void.') do |name|
|
|
42
51
|
OPTIONS[:os] = name
|
|
43
52
|
end
|
|
44
53
|
|
|
45
|
-
opts.on('--separate-boot DISK',
|
|
54
|
+
opts.on('--separate-boot DISK',
|
|
55
|
+
'Use a different DISK for the /boot or /efi partition.') do |boot|
|
|
46
56
|
OPTIONS[:boot_disk] = Getch::Guard.disk(boot)
|
|
47
57
|
end
|
|
48
58
|
|
|
49
|
-
opts.on('--separate-cache DISK',
|
|
59
|
+
opts.on('--separate-cache DISK',
|
|
60
|
+
'Use a different DISK for the swap partition, add ZIL/L2ARC for ZFS when set.') do |swap|
|
|
50
61
|
OPTIONS[:cache_disk] = Getch::Guard.disk(swap)
|
|
51
62
|
end
|
|
52
63
|
|
|
53
|
-
opts.on('--separate-home DISK',
|
|
64
|
+
opts.on('--separate-home DISK',
|
|
65
|
+
'Use a different DISK for the /home partition.') do |home|
|
|
54
66
|
OPTIONS[:home_disk] = Getch::Guard.disk(home)
|
|
55
67
|
end
|
|
56
68
|
|
|
57
|
-
opts.on('--
|
|
69
|
+
opts.on('--lvm',
|
|
70
|
+
'System will use LVM, do not work with ZFS.') do
|
|
71
|
+
OPTIONS[:lvm] = true
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
opts.on('--encrypt',
|
|
75
|
+
'Encrypt your system, use LUKS or native encryption for ZFS.') do
|
|
58
76
|
OPTIONS[:encrypt] = true
|
|
59
77
|
end
|
|
60
78
|
|
|
79
|
+
opts.on('--musl', 'Prefer to install Musl over Glibc.') do
|
|
80
|
+
OPTIONS[:musl] = true
|
|
81
|
+
end
|
|
82
|
+
|
|
61
83
|
opts.on('--verbose', 'Write more messages to the standard output.') do
|
|
62
84
|
OPTIONS[:verbose] = true
|
|
63
85
|
end
|
|
@@ -67,6 +89,14 @@ module Getch
|
|
|
67
89
|
exit
|
|
68
90
|
end
|
|
69
91
|
|
|
92
|
+
opts.separator "\n<action> is one of:"
|
|
93
|
+
|
|
94
|
+
opts.on('--restart', 'Restart the whole installation') do
|
|
95
|
+
rm '/tmp/install_gentoo.yaml'
|
|
96
|
+
rm '/tmp/log_install.txt'
|
|
97
|
+
rm '/tmp/getch_devs.yaml'
|
|
98
|
+
end
|
|
99
|
+
|
|
70
100
|
begin
|
|
71
101
|
opts.parse!(argv)
|
|
72
102
|
rescue OptionParser::ParseError => e
|
data/lib/getch/states.rb
CHANGED
|
@@ -24,28 +24,48 @@ module Getch
|
|
|
24
24
|
save
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
def
|
|
28
|
-
STATES[:
|
|
27
|
+
def tarball
|
|
28
|
+
STATES[:tarball] = true
|
|
29
29
|
save
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
def
|
|
33
|
-
STATES[:
|
|
32
|
+
def pre_config
|
|
33
|
+
STATES[:pre_config] = true
|
|
34
34
|
save
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def update
|
|
38
|
-
STATES[:
|
|
38
|
+
STATES[:update] = true
|
|
39
|
+
save
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def post_config
|
|
43
|
+
STATES[:post_config] = true
|
|
44
|
+
save
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def terraform
|
|
48
|
+
STATES[:terraform] = true
|
|
49
|
+
save
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def services
|
|
53
|
+
STATES[:services] = true
|
|
54
|
+
save
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def luks_keys
|
|
58
|
+
STATES[:luks_keys] = true
|
|
39
59
|
save
|
|
40
60
|
end
|
|
41
61
|
|
|
42
62
|
def bootloader
|
|
43
|
-
STATES[:
|
|
63
|
+
STATES[:bootloader] = true
|
|
44
64
|
save
|
|
45
65
|
end
|
|
46
66
|
|
|
47
|
-
def
|
|
48
|
-
STATES[:
|
|
67
|
+
def finalize
|
|
68
|
+
STATES[:finalize] = true
|
|
49
69
|
save
|
|
50
70
|
end
|
|
51
71
|
|
data/lib/getch/tree.rb
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Getch
|
|
4
|
+
module Tree
|
|
5
|
+
class Os
|
|
6
|
+
|
|
7
|
+
OS_TREE = {
|
|
8
|
+
gentoo: Gentoo,
|
|
9
|
+
void: Void
|
|
10
|
+
}.freeze
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
@os = OPTIONS[:os]
|
|
14
|
+
@log = Log.new
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def select
|
|
18
|
+
OS_TREE[@os.to_sym] || @log.fatal('OS no found')
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
class FS
|
|
22
|
+
|
|
23
|
+
FS_TREE = {
|
|
24
|
+
true => { # + encrypt
|
|
25
|
+
true => { # + lvm
|
|
26
|
+
ext4: FileSystem::Ext4::Hybrid,
|
|
27
|
+
},
|
|
28
|
+
false => { # - lvm
|
|
29
|
+
ext4: FileSystem::Ext4::Encrypt,
|
|
30
|
+
zfs: FileSystem::Zfs::Encrypt
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
false => { # - encrypt
|
|
34
|
+
true => { # + lvm
|
|
35
|
+
ext4: FileSystem::Ext4::Lvm,
|
|
36
|
+
},
|
|
37
|
+
false => { # - lvm
|
|
38
|
+
ext4: FileSystem::Ext4::Minimal,
|
|
39
|
+
zfs: FileSystem::Zfs::Minimal,
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
}.freeze
|
|
43
|
+
|
|
44
|
+
def initialize
|
|
45
|
+
@encrypt = OPTIONS[:encrypt]
|
|
46
|
+
@lvm = OPTIONS[:lvm]
|
|
47
|
+
@fs = OPTIONS[:fs]
|
|
48
|
+
@log = Log.new
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def select
|
|
52
|
+
FS_TREE[@encrypt][@lvm][@fs.to_sym] || @log.fatal('Error in FS_TREE or no comptatible options')
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
data/lib/getch/version.rb
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Getch
|
|
4
|
+
module Void
|
|
5
|
+
class Bootloader
|
|
6
|
+
def dependencies
|
|
7
|
+
Helpers.efi? ?
|
|
8
|
+
Install.new('grub-x86_64-efi') :
|
|
9
|
+
Install.new('grub')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def install
|
|
13
|
+
Config::Grub.new
|
|
14
|
+
ChrootOutput.new('xbps-reconfigure -fa') # this command also start grub-mkconfig
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Getch
|
|
4
|
+
module Void
|
|
5
|
+
class Finalize
|
|
6
|
+
def initialize
|
|
7
|
+
x
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
protected
|
|
11
|
+
|
|
12
|
+
def x
|
|
13
|
+
shell
|
|
14
|
+
accounts
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
# Make the default shell /bin/bash instead of /bin/sh
|
|
20
|
+
def shell
|
|
21
|
+
Chroot.new('chsh -s /bin/bash')
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def accounts
|
|
25
|
+
account = Config::Account.new
|
|
26
|
+
account.root
|
|
27
|
+
account.new_user
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Getch
|
|
4
|
+
module Void
|
|
5
|
+
class PostConfig
|
|
6
|
+
def initialize
|
|
7
|
+
x
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
protected
|
|
11
|
+
|
|
12
|
+
def x
|
|
13
|
+
Getch::Config::Locale.new
|
|
14
|
+
Getch::Config::Keymap.new
|
|
15
|
+
Getch::Config::TimeZone.new
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -5,59 +5,79 @@ require 'open3'
|
|
|
5
5
|
|
|
6
6
|
module Getch
|
|
7
7
|
module Void
|
|
8
|
-
class
|
|
8
|
+
class Tarball
|
|
9
9
|
def initialize
|
|
10
|
+
@log = Log.new
|
|
10
11
|
@url = 'https://alpha.de.repo.voidlinux.org/live/current'
|
|
11
12
|
@file = 'sha256sum.txt'
|
|
12
13
|
@xbps = false
|
|
13
|
-
Dir.chdir
|
|
14
|
+
Dir.chdir OPTIONS[:mountpoint]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def x
|
|
18
|
+
search_archive
|
|
19
|
+
download
|
|
20
|
+
checksum
|
|
21
|
+
install
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
protected
|
|
25
|
+
|
|
26
|
+
def tarball
|
|
27
|
+
OPTIONS[:musl] ?
|
|
28
|
+
/void-x86_64-musl-ROOTFS-[\d._]+.tar.xz/ :
|
|
29
|
+
/void-x86_64-ROOTFS-[\d._]+.tar.xz/
|
|
14
30
|
end
|
|
15
31
|
|
|
16
32
|
# Search only the glibc x86_64 for now
|
|
17
33
|
def search_archive
|
|
18
34
|
yurl = "#{@url}/#{@file}"
|
|
19
|
-
|
|
35
|
+
@log.info "Opening #{yurl}...\n"
|
|
20
36
|
Helpers.get_file_online(yurl, @file)
|
|
21
37
|
File.open(@file).each do |l|
|
|
22
|
-
@xbps = l.tr('()', '').split(' ') if l.match(
|
|
38
|
+
@xbps = l.tr('()', '').split(' ') if l.match(tarball)
|
|
23
39
|
end
|
|
24
40
|
end
|
|
25
41
|
|
|
26
42
|
def download
|
|
27
|
-
|
|
43
|
+
@log.fatal 'No file found, retry later.' unless @xbps
|
|
28
44
|
return if File.exist? @xbps[1]
|
|
29
45
|
|
|
30
|
-
|
|
46
|
+
@log.info "Downloading #{@xbps[1]}..."
|
|
31
47
|
Helpers.get_file_online("#{@url}/#{@xbps[1]}", @xbps[1])
|
|
48
|
+
@log.result_ok
|
|
32
49
|
end
|
|
33
50
|
|
|
34
51
|
def checksum
|
|
35
|
-
|
|
52
|
+
@log.info 'Checking SHA256 checksum...'
|
|
36
53
|
# Should contain 2 spaces...
|
|
37
54
|
command = "echo #{@xbps[3]} #{@xbps[1]} | sha256sum --check"
|
|
38
55
|
_, stderr, status = Open3.capture3(command)
|
|
39
56
|
if status.success? then
|
|
40
|
-
|
|
41
|
-
decompress
|
|
42
|
-
cleaning
|
|
57
|
+
@log.result_ok
|
|
43
58
|
return
|
|
44
59
|
end
|
|
45
60
|
cleaning
|
|
46
|
-
|
|
61
|
+
@log.fatal "Problem with the checksum, stderr\n#{stderr}"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def install
|
|
65
|
+
decompress
|
|
66
|
+
cleaning
|
|
47
67
|
end
|
|
48
68
|
|
|
49
69
|
private
|
|
50
70
|
|
|
51
71
|
def decompress
|
|
52
|
-
|
|
72
|
+
@log.info "Decompressing #{@xbps[1]}..."
|
|
53
73
|
cmd = "tar xpf #{@xbps[1]} --xattrs-include=\'*.*\' --numeric-owner"
|
|
54
74
|
_, stderr, status = Open3.capture3(cmd)
|
|
55
75
|
if status.success? then
|
|
56
|
-
|
|
76
|
+
@log.result_ok
|
|
57
77
|
return
|
|
58
78
|
end
|
|
59
79
|
cleaning
|
|
60
|
-
|
|
80
|
+
@log.fatal "Fail to decompressing #{@xbps[1]} - #{stderr}."
|
|
61
81
|
end
|
|
62
82
|
|
|
63
83
|
def cleaning
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Getch
|
|
2
|
+
module Void
|
|
3
|
+
class Terraform
|
|
4
|
+
def initialize
|
|
5
|
+
x
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
protected
|
|
9
|
+
|
|
10
|
+
def x
|
|
11
|
+
install_pkgs
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def install_pkgs
|
|
15
|
+
@pkgs = 'sudo'
|
|
16
|
+
@pkgs << ' vim'
|
|
17
|
+
@pkgs << ' iptables'
|
|
18
|
+
@pkgs << ' runit-iptables'
|
|
19
|
+
@pkgs << ' iwd'
|
|
20
|
+
@pkgs << ' dhcpcd'
|
|
21
|
+
@pkgs << ' lvm2' if OPTIONS[:fs] == 'lvm'
|
|
22
|
+
@pkgs << ' zfs' if OPTIONS[:fs] == 'zfs'
|
|
23
|
+
@pkgs << ' cryptsetup' if OPTIONS[:encrypt]
|
|
24
|
+
Install.new(@pkgs)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Getch
|
|
4
|
+
module Void
|
|
5
|
+
class Update
|
|
6
|
+
def initialize
|
|
7
|
+
@log = Log.new
|
|
8
|
+
x
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
protected
|
|
12
|
+
|
|
13
|
+
# https://docs.voidlinux.org/installation/guides/chroot.html#install-base-system-rootfs-method-only
|
|
14
|
+
def x
|
|
15
|
+
sync
|
|
16
|
+
update
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def sync
|
|
22
|
+
@log.info "Synchronize index...\n"
|
|
23
|
+
ChrootOutput.new '/usr/bin/xbps-install', '-Suy', 'xbps'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def update
|
|
27
|
+
ChrootOutput.new '/usr/bin/xbps-install -uy'
|
|
28
|
+
ChrootOutput.new '/usr/bin/xbps-install -y base-system'
|
|
29
|
+
ChrootOutput.new '/usr/bin/xbps-remove -y base-voidstrap'
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|