getch 0.1.5 → 0.1.6
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.tar.gz.sig +0 -0
- data/README.md +64 -24
- data/assets/network-stack.conf +63 -0
- data/bin/getch +12 -4
- data/lib/getch.rb +113 -78
- data/lib/getch/command.rb +1 -1
- data/lib/getch/config.rb +33 -49
- data/lib/getch/config/gentoo.rb +59 -0
- data/lib/getch/config/void.rb +49 -0
- data/lib/getch/filesystem/.mount.rb.swp +0 -0
- data/lib/getch/filesystem/device.rb +5 -5
- data/lib/getch/filesystem/ext4.rb +1 -0
- data/lib/getch/filesystem/ext4/encrypt.rb +1 -0
- data/lib/getch/filesystem/ext4/encrypt/config.rb +2 -2
- data/lib/getch/filesystem/ext4/encrypt/format.rb +0 -1
- data/lib/getch/filesystem/ext4/encrypt/mount.rb +0 -1
- data/lib/getch/filesystem/ext4/encrypt/partition.rb +10 -16
- data/lib/getch/filesystem/ext4/encrypt/void.rb +100 -0
- data/lib/getch/filesystem/ext4/format.rb +1 -1
- data/lib/getch/filesystem/ext4/void.rb +43 -0
- data/lib/getch/filesystem/lvm.rb +1 -0
- data/lib/getch/filesystem/lvm/encrypt.rb +1 -0
- data/lib/getch/filesystem/lvm/encrypt/config.rb +2 -2
- data/lib/getch/filesystem/lvm/encrypt/format.rb +1 -2
- data/lib/getch/filesystem/lvm/encrypt/mount.rb +1 -2
- data/lib/getch/filesystem/lvm/encrypt/partition.rb +10 -7
- data/lib/getch/filesystem/lvm/encrypt/void.rb +100 -0
- data/lib/getch/filesystem/lvm/format.rb +1 -1
- data/lib/getch/filesystem/lvm/void.rb +45 -0
- data/lib/getch/filesystem/partition.rb +4 -4
- data/lib/getch/filesystem/zfs.rb +1 -0
- data/lib/getch/filesystem/zfs/config.rb +3 -3
- data/lib/getch/filesystem/zfs/deps.rb +11 -4
- data/lib/getch/filesystem/zfs/device.rb +6 -0
- data/lib/getch/filesystem/zfs/encrypt.rb +1 -0
- data/lib/getch/filesystem/zfs/encrypt/.mount.rb.swp +0 -0
- data/lib/getch/filesystem/zfs/encrypt/config.rb +5 -5
- data/lib/getch/filesystem/zfs/encrypt/deps.rb +11 -4
- data/lib/getch/filesystem/zfs/encrypt/device.rb +6 -0
- data/lib/getch/filesystem/zfs/encrypt/format.rb +9 -10
- data/lib/getch/filesystem/zfs/encrypt/mount.rb +5 -9
- data/lib/getch/filesystem/zfs/encrypt/partition.rb +3 -1
- data/lib/getch/filesystem/zfs/encrypt/void.rb +96 -0
- data/lib/getch/filesystem/zfs/format.rb +9 -9
- data/lib/getch/filesystem/zfs/mount.rb +5 -8
- data/lib/getch/filesystem/zfs/partition.rb +2 -1
- data/lib/getch/filesystem/zfs/void.rb +81 -0
- data/lib/getch/gentoo.rb +12 -15
- data/lib/getch/gentoo/boot.rb +7 -4
- data/lib/getch/gentoo/config.rb +8 -8
- data/lib/getch/gentoo/sources.rb +6 -3
- data/lib/getch/gentoo/stage.rb +0 -1
- data/lib/getch/gentoo/use_flag.rb +6 -7
- data/lib/getch/guard.rb +3 -1
- data/lib/getch/helpers.rb +107 -1
- data/lib/getch/log.rb +3 -2
- data/lib/getch/options.rb +41 -34
- data/lib/getch/version.rb +1 -1
- data/lib/getch/void.rb +59 -0
- data/lib/getch/void/boot.rb +80 -0
- data/lib/getch/void/chroot.rb +55 -0
- data/lib/getch/void/config.rb +87 -0
- data/lib/getch/void/stage.rb +70 -0
- metadata +22 -9
- metadata.gz.sig +0 -0
- data/.gitignore +0 -2
- data/CHANGELOG.md +0 -99
- data/Rakefile +0 -21
- data/bin/setup.sh +0 -90
- data/getch.gemspec +0 -25
data/lib/getch/gentoo.rb
CHANGED
@@ -8,42 +8,40 @@ require_relative 'gentoo/use_flag'
|
|
8
8
|
|
9
9
|
module Getch
|
10
10
|
module Gentoo
|
11
|
-
class
|
12
|
-
def
|
11
|
+
class Main
|
12
|
+
def initialize
|
13
13
|
@state = Getch::States.new()
|
14
14
|
end
|
15
15
|
|
16
16
|
def stage3
|
17
17
|
return if STATES[:gentoo_base]
|
18
|
-
new
|
19
|
-
stage = Getch::Gentoo::Stage.new()
|
18
|
+
stage = Getch::Gentoo::Stage.new
|
20
19
|
stage.get_stage3
|
21
20
|
stage.control_files
|
22
21
|
stage.checksum
|
23
22
|
@state.stage3
|
24
23
|
end
|
25
24
|
|
26
|
-
def config
|
25
|
+
def config
|
27
26
|
return if STATES[:gentoo_config]
|
28
|
-
new
|
29
|
-
config = Getch::Gentoo::Config.new()
|
27
|
+
config = Getch::Gentoo::Config.new
|
30
28
|
config.portage
|
31
29
|
config.portage_fs
|
32
30
|
config.portage_bashrc
|
33
31
|
config.repo
|
34
32
|
config.network
|
35
|
-
config.systemd
|
33
|
+
config.systemd
|
36
34
|
config.hostname
|
37
35
|
@state.config
|
38
36
|
end
|
39
37
|
|
40
|
-
def chroot
|
41
|
-
chroot = Getch::Gentoo::Chroot.new
|
38
|
+
def chroot
|
39
|
+
chroot = Getch::Gentoo::Chroot.new
|
42
40
|
chroot.update
|
43
41
|
chroot.cpuflags
|
44
42
|
chroot.systemd
|
45
43
|
|
46
|
-
flags = Getch::Gentoo::UseFlag.new
|
44
|
+
flags = Getch::Gentoo::UseFlag.new
|
47
45
|
flags.apply
|
48
46
|
|
49
47
|
chroot.world
|
@@ -56,8 +54,7 @@ module Getch
|
|
56
54
|
|
57
55
|
def kernel
|
58
56
|
return if STATES[:gentoo_kernel]
|
59
|
-
source = Getch::Gentoo::Sources.new
|
60
|
-
new
|
57
|
+
source = Getch::Gentoo::Sources.new
|
61
58
|
source.build_kspp
|
62
59
|
source.build_others
|
63
60
|
source.firewall
|
@@ -65,8 +62,8 @@ module Getch
|
|
65
62
|
@state.kernel
|
66
63
|
end
|
67
64
|
|
68
|
-
def boot
|
69
|
-
boot = Getch::Gentoo::Boot.new
|
65
|
+
def boot
|
66
|
+
boot = Getch::Gentoo::Boot.new
|
70
67
|
boot.start
|
71
68
|
end
|
72
69
|
end
|
data/lib/getch/gentoo/boot.rb
CHANGED
@@ -3,10 +3,13 @@ require 'fileutils'
|
|
3
3
|
module Getch
|
4
4
|
module Gentoo
|
5
5
|
class Boot
|
6
|
-
def initialize
|
7
|
-
@disk =
|
8
|
-
|
9
|
-
|
6
|
+
def initialize
|
7
|
+
@disk = Getch::OPTIONS[:boot_disk] ?
|
8
|
+
Getch::OPTIONS[:boot_disk] :
|
9
|
+
Getch::OPTIONS[:disk]
|
10
|
+
@user = Getch::OPTIONS[:username]
|
11
|
+
@class_fs = Getch::select_fs
|
12
|
+
@config = @class_fs::Config.new
|
10
13
|
end
|
11
14
|
|
12
15
|
def start
|
data/lib/getch/gentoo/config.rb
CHANGED
@@ -69,13 +69,13 @@ module Getch
|
|
69
69
|
FileUtils.copy_file(src, dest, preserve = true)
|
70
70
|
end
|
71
71
|
|
72
|
-
def systemd
|
73
|
-
control_options
|
72
|
+
def systemd
|
73
|
+
control_options
|
74
74
|
File.write("#{MOUNTPOINT}/etc/locale.gen", @utf8)
|
75
75
|
File.write("#{MOUNTPOINT}/etc/locale.conf", "LANG=#{@lang}\n")
|
76
76
|
File.write("#{MOUNTPOINT}/etc/locale.conf", 'LC_COLLATE=C', mode: 'a')
|
77
|
-
File.write("#{MOUNTPOINT}/etc/timezone", "#{
|
78
|
-
File.write("#{MOUNTPOINT}/etc/vconsole.conf", "KEYMAP=#{
|
77
|
+
File.write("#{MOUNTPOINT}/etc/timezone", "#{Getch::OPTIONS[:zoneinfo]}\n")
|
78
|
+
File.write("#{MOUNTPOINT}/etc/vconsole.conf", "KEYMAP=#{Getch::OPTIONS[:keymap]}\n")
|
79
79
|
end
|
80
80
|
|
81
81
|
def hostname
|
@@ -130,10 +130,10 @@ function pre_pkg_preinst() {
|
|
130
130
|
|
131
131
|
private
|
132
132
|
|
133
|
-
def control_options
|
134
|
-
search_zone(
|
135
|
-
search_utf8(
|
136
|
-
search_key(
|
133
|
+
def control_options
|
134
|
+
search_zone(Getch::OPTIONS[:zoneinfo])
|
135
|
+
search_utf8(Getch::OPTIONS[:language])
|
136
|
+
search_key(Getch::OPTIONS[:keymap])
|
137
137
|
end
|
138
138
|
|
139
139
|
def search_key(keys)
|
data/lib/getch/gentoo/sources.rb
CHANGED
@@ -3,7 +3,8 @@ module Getch
|
|
3
3
|
class Sources
|
4
4
|
def initialize
|
5
5
|
@lsmod = `lsmod`.chomp
|
6
|
-
@
|
6
|
+
@class_fs = Getch::select_fs
|
7
|
+
@filesystem = @class_fs::Deps.new
|
7
8
|
end
|
8
9
|
|
9
10
|
def build_others
|
@@ -21,7 +22,9 @@ module Getch
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def make
|
24
|
-
if
|
25
|
+
if Getch::OPTIONS[:fs] == 'lvm' ||
|
26
|
+
Getch::OPTIONS[:fs] == 'zfs' ||
|
27
|
+
Getch::OPTIONS[:encrypt]
|
25
28
|
@filesystem.make
|
26
29
|
else
|
27
30
|
make_kernel
|
@@ -44,7 +47,7 @@ module Getch
|
|
44
47
|
end
|
45
48
|
|
46
49
|
def cryptsetup
|
47
|
-
return unless
|
50
|
+
return unless Getch::OPTIONS[:encrypt]
|
48
51
|
make_conf = "#{MOUNTPOINT}/etc/portage/make.conf"
|
49
52
|
|
50
53
|
puts "Adding support for cryptsetup."
|
data/lib/getch/gentoo/stage.rb
CHANGED
@@ -2,9 +2,8 @@
|
|
2
2
|
|
3
3
|
module Getch::Gentoo
|
4
4
|
class UseFlag
|
5
|
-
def initialize
|
5
|
+
def initialize
|
6
6
|
@efi = Helpers::efi?
|
7
|
-
@o = options
|
8
7
|
end
|
9
8
|
|
10
9
|
def apply
|
@@ -36,13 +35,13 @@ module Getch::Gentoo
|
|
36
35
|
flags = []
|
37
36
|
use = Getch::Gentoo::Use.new('sys-boot/grub')
|
38
37
|
flags << '-grub_platforms_efi-64'
|
39
|
-
flags << 'libzfs' if
|
40
|
-
flags << 'device-mapper' if
|
38
|
+
flags << 'libzfs' if Getch::OPTIONS[:fs] == 'zfs'
|
39
|
+
flags << 'device-mapper' if Getch::OPTIONS[:fs] == 'lvm'
|
41
40
|
use.add(flags)
|
42
41
|
end
|
43
42
|
|
44
43
|
def zfs
|
45
|
-
return unless
|
44
|
+
return unless Getch::OPTIONS[:fs] == 'zfs'
|
46
45
|
use = Getch::Gentoo::Use.new('sys-fs/zfs-kmod')
|
47
46
|
use.add('rootfs')
|
48
47
|
use = Getch::Gentoo::Use.new('sys-fs/zfs')
|
@@ -50,13 +49,13 @@ module Getch::Gentoo
|
|
50
49
|
end
|
51
50
|
|
52
51
|
def lvm
|
53
|
-
return unless
|
52
|
+
return unless Getch::OPTIONS[:fs] == 'lvm'
|
54
53
|
use = Getch::Gentoo::Use.new
|
55
54
|
use.add_global('lvm', 'device-mapper')
|
56
55
|
end
|
57
56
|
|
58
57
|
def cryptsetup
|
59
|
-
return unless
|
58
|
+
return unless Getch::OPTIONS[:encrypt]
|
60
59
|
use = Getch::Gentoo::Use.new
|
61
60
|
use.add_global('cryptsetup')
|
62
61
|
end
|
data/lib/getch/guard.rb
CHANGED
@@ -24,7 +24,8 @@ module Getch::Guard
|
|
24
24
|
def self.format(name)
|
25
25
|
raise InvalidFormat, "No format specified." unless name
|
26
26
|
raise InvalidFormat, "Format #{name} not yet available." if name.match(/btrfs/)
|
27
|
-
raise InvalidFormat, "Format #{name} not supported." unless name.match(/zfs|lvm|
|
27
|
+
raise InvalidFormat, "Format #{name} not supported." unless name.match(/zfs|lvm|ext4/)
|
28
|
+
name
|
28
29
|
rescue InvalidFormat => e
|
29
30
|
puts "#{e.class} => #{e}"
|
30
31
|
exit 1
|
@@ -34,6 +35,7 @@ module Getch::Guard
|
|
34
35
|
raise InvalidZone, "No zoneinfo specified." unless name
|
35
36
|
raise InvalidZone, "Directory /usr/share/zoneinfo/ no found on this system..." unless Dir.exist? "/usr/share/zoneinfo/"
|
36
37
|
raise InvalidZone, "Zoneinfo #{name} is no found in /usr/share/zoneinfo/." unless File.exist? "/usr/share/zoneinfo/#{name}"
|
38
|
+
name
|
37
39
|
rescue InvalidZone => e
|
38
40
|
puts "#{e.class} => #{e}"
|
39
41
|
exit 1
|
data/lib/getch/helpers.rb
CHANGED
@@ -38,6 +38,11 @@ module Helpers
|
|
38
38
|
File.write file, '' if ! File.exist? file
|
39
39
|
end
|
40
40
|
|
41
|
+
def self.cp(src, dest)
|
42
|
+
raise "Src file #{src} no found" unless File.exist? src
|
43
|
+
FileUtils.cp(src, dest)
|
44
|
+
end
|
45
|
+
|
41
46
|
def self.grep?(file, regex)
|
42
47
|
is_found = false
|
43
48
|
return is_found if ! File.exist? file
|
@@ -61,7 +66,11 @@ module Helpers
|
|
61
66
|
end
|
62
67
|
|
63
68
|
def self.uuid(dev)
|
64
|
-
|
69
|
+
Dir.glob("/dev/disk/by-uuid/*").each { |f|
|
70
|
+
if File.readlink(f).match(/#{dev}/)
|
71
|
+
return f.delete_prefix("/dev/disk/by-uuid/")
|
72
|
+
end
|
73
|
+
}
|
65
74
|
end
|
66
75
|
|
67
76
|
# Used with ZFS for the pool name
|
@@ -82,4 +91,101 @@ module Helpers
|
|
82
91
|
end
|
83
92
|
end
|
84
93
|
end
|
94
|
+
|
95
|
+
module Void
|
96
|
+
def command(args)
|
97
|
+
print " => Exec: #{args}..."
|
98
|
+
cmd = "chroot #{Getch::MOUNTPOINT} /bin/bash -c \"#{args}\""
|
99
|
+
_, stderr, status = Open3.capture3(cmd)
|
100
|
+
if status.success? then
|
101
|
+
puts "\s[OK]"
|
102
|
+
return
|
103
|
+
end
|
104
|
+
raise "\n[-] Fail cmd #{args} - #{stderr}."
|
105
|
+
end
|
106
|
+
|
107
|
+
def command_output(args)
|
108
|
+
print " => Exec: #{args}..."
|
109
|
+
cmd = "chroot #{Getch::MOUNTPOINT} /bin/bash -c \"#{args}\""
|
110
|
+
Open3.popen2e(cmd) do |stdin, stdout_err, wait_thr|
|
111
|
+
puts
|
112
|
+
while line = stdout_err.gets
|
113
|
+
puts line
|
114
|
+
end
|
115
|
+
|
116
|
+
exit_status = wait_thr.value
|
117
|
+
unless exit_status.success?
|
118
|
+
raise "\n[-] Fail cmd #{args} - #{stdout_err}."
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def add_line(file, line)
|
124
|
+
raise "No file #{file} found !" unless File.exist? file
|
125
|
+
File.write(file, "#{line}\n", mode: 'a')
|
126
|
+
end
|
127
|
+
|
128
|
+
def search(file, text)
|
129
|
+
File.open(file).each { |line|
|
130
|
+
return true if line.match(/#{text}/)
|
131
|
+
}
|
132
|
+
return false
|
133
|
+
end
|
134
|
+
|
135
|
+
# Used only when need password
|
136
|
+
def chroot(cmd)
|
137
|
+
if !system("chroot", Getch::MOUNTPOINT, "/bin/bash", "-c", cmd)
|
138
|
+
raise "[-] Error with: #{cmd}"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def s_uuid(dev)
|
143
|
+
device = dev.delete_prefix("/dev/")
|
144
|
+
Dir.glob("/dev/disk/by-partuuid/*").each { |f|
|
145
|
+
link = File.readlink(f)
|
146
|
+
return f.delete_prefix("/dev/disk/by-partuuid/") if link.match(/#{device}$/)
|
147
|
+
}
|
148
|
+
end
|
149
|
+
|
150
|
+
def line_fstab(dev, rest)
|
151
|
+
conf = "#{Getch::MOUNTPOINT}/etc/fstab"
|
152
|
+
device = s_uuid(dev)
|
153
|
+
raise "No partuuid for #{dev} #{device}" if !device
|
154
|
+
raise "Bad partuuid for #{dev} #{device}" if device.kind_of? Array
|
155
|
+
add_line(conf, "PARTUUID=#{device} #{rest}")
|
156
|
+
end
|
157
|
+
|
158
|
+
def grub_cmdline(*args)
|
159
|
+
conf = "#{Getch::MOUNTPOINT}/etc/default/grub"
|
160
|
+
list = args.join(" ")
|
161
|
+
secs = "GRUB_CMDLINE_LINUX=\"#{list} init_on_alloc=1 init_on_free=1"
|
162
|
+
secs += " slab_nomerge pti=on slub_debug=ZF vsyscall=none\""
|
163
|
+
raise "No default/grub found" unless File.exist? conf
|
164
|
+
unless search(conf, "GRUB_CMDLINE_LINUX=")
|
165
|
+
File.write(conf, "#{secs}\n", mode: 'a')
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
module Cryptsetup
|
171
|
+
def encrypt(dev)
|
172
|
+
raise "No device #{dev}" unless File.exist? dev
|
173
|
+
puts " => Encrypting device #{dev}..."
|
174
|
+
if Helpers::efi? && Getch::OPTIONS[:os] == 'gentoo'
|
175
|
+
Helpers::sys("cryptsetup luksFormat --type luks #{dev}")
|
176
|
+
else
|
177
|
+
Helpers::sys("cryptsetup luksFormat --type luks1 #{dev}")
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
def open_crypt(dev, map_name)
|
182
|
+
raise "No device #{dev}" unless File.exist? dev
|
183
|
+
puts " => Opening encrypted device #{dev}..."
|
184
|
+
if Helpers::efi? && Getch::OPTIONS[:os] == 'gentoo'
|
185
|
+
Helpers::sys("cryptsetup open --type luks #{dev} #{map_name}")
|
186
|
+
else
|
187
|
+
Helpers::sys("cryptsetup open --type luks1 #{dev} #{map_name}")
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
85
191
|
end
|
data/lib/getch/log.rb
CHANGED
@@ -2,8 +2,9 @@ require 'logger'
|
|
2
2
|
|
3
3
|
module Getch
|
4
4
|
class Log
|
5
|
-
def initialize
|
5
|
+
def initialize(verbose = false)
|
6
6
|
@log_file = '/tmp/log_install.txt'
|
7
|
+
@verbose = verbose
|
7
8
|
check_file
|
8
9
|
init_log
|
9
10
|
init_log_text
|
@@ -37,7 +38,7 @@ module Getch
|
|
37
38
|
|
38
39
|
def init_log
|
39
40
|
@logger = Logger.new(STDOUT)
|
40
|
-
@logger.level =
|
41
|
+
@logger.level = @verbose ? Logger::DEBUG : Logger::INFO
|
41
42
|
@logger.formatter = proc { |severity, datetime, progname, msg|
|
42
43
|
"#{severity}, #{msg}\n"
|
43
44
|
}
|
data/lib/getch/options.rb
CHANGED
@@ -2,20 +2,7 @@ require 'optparse'
|
|
2
2
|
|
3
3
|
module Getch
|
4
4
|
class Options
|
5
|
-
attr_reader :language, :zoneinfo, :keymap, :disk, :fs, :username, :boot_disk, :cache_disk, :home_disk, :encrypt, :verbose
|
6
|
-
|
7
5
|
def initialize(argv)
|
8
|
-
@language = DEFAULT_OPTIONS[:language]
|
9
|
-
@zoneinfo = DEFAULT_OPTIONS[:zoneinfo]
|
10
|
-
@keymap = DEFAULT_OPTIONS[:keymap]
|
11
|
-
@disk = DEFAULT_OPTIONS[:disk]
|
12
|
-
@fs = DEFAULT_OPTIONS[:fs]
|
13
|
-
@username = DEFAULT_OPTIONS[:username]
|
14
|
-
@boot_disk = DEFAULT_OPTIONS[:boot_disk]
|
15
|
-
@cache_disk = DEFAULT_OPTIONS[:cache_disk]
|
16
|
-
@home_disk = DEFAULT_OPTIONS[:home_disk]
|
17
|
-
@encrypt = DEFAULT_OPTIONS[:encrypt]
|
18
|
-
@verbose = DEFAULT_OPTIONS[:verbose]
|
19
6
|
parse(argv)
|
20
7
|
end
|
21
8
|
|
@@ -23,48 +10,68 @@ module Getch
|
|
23
10
|
|
24
11
|
def parse(argv)
|
25
12
|
OptionParser.new do |opts|
|
13
|
+
opts.version = VERSION
|
14
|
+
|
26
15
|
opts.on("-l", "--language LANG", "Default is en_US") do |lang|
|
27
|
-
|
16
|
+
OPTIONS[:language] = lang
|
28
17
|
end
|
18
|
+
|
29
19
|
opts.on("-z", "--zoneinfo ZONE", "Default is US/Eastern") do |zone|
|
30
|
-
|
20
|
+
OPTIONS[:zoneinfo] = Getch::Guard.zone(zone)
|
31
21
|
end
|
22
|
+
|
32
23
|
opts.on("-k", "--keymap KEY", "Default is us") do |key|
|
33
|
-
|
24
|
+
OPTIONS[:keymap] = Getch::Guard.keymap(key)
|
34
25
|
end
|
35
|
-
|
36
|
-
|
26
|
+
|
27
|
+
opts.on("-d", "--disk DISK", "Root Disk where install the system (sda,sdb)") do |disk|
|
28
|
+
OPTIONS[:disk] = Getch::Guard.disk(disk)
|
37
29
|
end
|
30
|
+
|
38
31
|
opts.on("-f", "--format FS", "Can be ext4, lvm or zfs. Default use ext4") do |fs|
|
39
|
-
|
40
|
-
DEFAULT_OPTIONS[:fs] = fs # dont known why, but it should be enforce
|
32
|
+
OPTIONS[:fs] = Getch::Guard.format(fs)
|
41
33
|
end
|
34
|
+
|
42
35
|
opts.on("-u", "--username USERNAME", "Create a new user /home/USERNAME with password.") do |user|
|
43
|
-
|
36
|
+
OPTIONS[:username] = user
|
44
37
|
end
|
45
|
-
|
46
|
-
|
47
|
-
|
38
|
+
|
39
|
+
opts.on("-o", "--os NAME", /gentoo|void/, "Instal distro NAME, can be gentoo or void.") do |name|
|
40
|
+
OPTIONS[:os] = name
|
48
41
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
42
|
+
|
43
|
+
opts.on("--separate-boot DISK", "Use a different DISK for the /boot or /efi partition.") do |boot|
|
44
|
+
OPTIONS[:boot_disk] = Getch::Guard.disk(boot)
|
52
45
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
46
|
+
|
47
|
+
opts.on("--separate-cache DISK", "Use a different DISK for the swap partition, add ZIL/L2ARC for ZFS when set.") do |swap|
|
48
|
+
OPTIONS[:cache_disk] = Getch::Guard.disk(swap)
|
49
|
+
end
|
50
|
+
|
51
|
+
opts.on("--separate-home DISK", "Use a different DISK for the /home partition.") do |home|
|
52
|
+
OPTIONS[:home_disk] = Getch::Guard.disk(home)
|
56
53
|
end
|
57
|
-
|
58
|
-
|
54
|
+
|
55
|
+
opts.on("--encrypt", "Encrypt your system, use LUKS or native encryption for ZFS.") do
|
56
|
+
OPTIONS[:encrypt] = true
|
59
57
|
end
|
58
|
+
|
60
59
|
opts.on("--verbose", "Write more messages to the standard output.") do
|
61
|
-
|
60
|
+
OPTIONS[:verbose] = true
|
62
61
|
end
|
62
|
+
|
63
63
|
opts.on("-h", "--help", "Display this") do
|
64
64
|
puts opts
|
65
65
|
exit
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
|
+
begin
|
69
|
+
opts.parse!(argv)
|
70
|
+
rescue OptionParser::ParseError => e
|
71
|
+
STDERR.puts e.message, "\n", opts
|
72
|
+
exit 1
|
73
|
+
end
|
74
|
+
end
|
68
75
|
end
|
69
76
|
end
|
70
77
|
end
|