getch 0.1.3 → 0.1.5
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/CHANGELOG.md +9 -0
- data/README.md +14 -11
- data/lib/getch.rb +1 -0
- data/lib/getch/filesystem/clean.rb +10 -3
- data/lib/getch/filesystem/ext4/encrypt/partition.rb +2 -2
- data/lib/getch/filesystem/ext4/partition.rb +2 -2
- data/lib/getch/filesystem/lvm/encrypt/partition.rb +3 -2
- data/lib/getch/filesystem/lvm/partition.rb +2 -2
- data/lib/getch/filesystem/zfs/encrypt/format.rb +3 -4
- data/lib/getch/filesystem/zfs/encrypt/partition.rb +10 -9
- data/lib/getch/filesystem/zfs/format.rb +3 -4
- data/lib/getch/filesystem/zfs/partition.rb +10 -9
- data/lib/getch/gentoo.rb +3 -0
- data/lib/getch/gentoo/boot.rb +3 -0
- data/lib/getch/gentoo/chroot.rb +6 -1
- data/lib/getch/gentoo/config.rb +34 -0
- data/lib/getch/gentoo/sources.rb +33 -1
- data/lib/getch/guard.rb +62 -0
- data/lib/getch/helpers.rb +15 -1
- data/lib/getch/options.rb +7 -7
- data/lib/getch/version.rb +1 -1
- metadata +3 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb3fc628a7308969d14505c6f56623c11c5adda014841e162b264f189b5ad54c
|
4
|
+
data.tar.gz: ea50a6890b8c0c718ec38876809144fab98442daeddad2db85bc591a77996948
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2395983c7fc521cc7867cdd54550177a2ed3f5eccdcd070f36eec256e73d06b8bfe961dc3f922fa9c5afac30d28e898625b32655ee89d45bc8e1da79dbf54d15
|
7
|
+
data.tar.gz: 1e8eeda1ff45f0d633820ced177fb6ae97645d5aa2e7f02e69279f0b9e611035269c23707f6677820886c92122a27e92d3906401a873fc60a1e1e9064c8de3bf
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 0.1.4, release 2021-06-20
|
2
|
+
* Install `iptables` by default.
|
3
|
+
* Control input for options `--disk`, `--format`, `--zoneinfo`, `--keymap`.
|
4
|
+
* Add a `/etc/portage/bashrc` to automatically signing kernel modules with `emerge`.
|
5
|
+
* Now clean properly another disk used with option `--separate-x DISK`.
|
6
|
+
* For ZFS, use `blockdev --getpbsz` to find correct bloc (sector) size.
|
7
|
+
* Populate `/etc/modules-load.d/` with modules found with `lsmod` (only few wifi's, flash usb related (ehci, ohci, xhci, etc)).
|
8
|
+
* Remove the package `dev-util/dwarves`.
|
9
|
+
|
1
10
|
## 0.1.3, release 2021-05-17
|
2
11
|
* LVM use the format /dev/vg_name/lv_name for mount/format/fstab.
|
3
12
|
* Stop using `euse` from `gentoolkit`, use native Ruby code here.
|
data/README.md
CHANGED
@@ -72,25 +72,28 @@ Unless your old LVM volume group is also named `vg0`, `getch` may fail to partit
|
|
72
72
|
# pvremove -f /dev/sdb
|
73
73
|
|
74
74
|
#### Encryption enable on BIOS with ext4
|
75
|
-
To decrypt your disk on BIOS system, you have to enter your password
|
75
|
+
To decrypt your disk on BIOS system, you have to enter your password twice. One time for Grub and another time for Genkernel. [post](https://wiki.archlinux.org/index.php/GRUB#Encrypted_/boot).
|
76
76
|
Also with GRUB, only a `us` keymap is working.
|
77
77
|
|
78
|
-
####
|
79
|
-
When Gentoo boot, the pool may fail to start, it's happen when the pool has not been `export` to the ISO. So just
|
78
|
+
#### ZFS
|
79
|
+
When Gentoo boot the first time, the pool may fail to start, it's happen when the pool has not been `export` to the ISO. So just `export` your pool from the genkernel shell:
|
80
80
|
|
81
|
-
|
81
|
+
The zpool name should be visible (rpool-150ed here), so enter in the Genkernel shell:
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
> shell
|
84
|
+
zpool import -f -N -R /mnt rpool-150ed
|
85
|
+
zpool export -a
|
86
|
+
|
87
|
+
Then, just reboot now, it's all.
|
86
88
|
|
87
|
-
|
89
|
+
*INFO*: To create the zpool, getch use the 5 fist characters from the `partuuid`, just replace `sdX` by your real device:
|
88
90
|
|
89
|
-
#
|
91
|
+
# ls -l /dev/disk/by-partuuid/ | grep sdX4
|
92
|
+
-> 150ed969...
|
90
93
|
|
91
|
-
|
94
|
+
The pool will be called `rpool-150ed`.
|
92
95
|
|
93
96
|
## Issues
|
94
97
|
If need more support for your hardware (network, sound card, ...), you can submit a [new issue](https://github.com/szorfein/getch/issues/new) and post the output of the following command:
|
95
98
|
+ lspci
|
96
|
-
+
|
99
|
+
+ cat /proc/modules
|
data/lib/getch.rb
CHANGED
@@ -23,15 +23,22 @@ module Getch
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.hdd(*disks)
|
26
|
-
disks.each { |d|
|
26
|
+
disks.each { |d|
|
27
|
+
clean_struct(d)
|
28
|
+
clean_hdd(d)
|
29
|
+
}
|
27
30
|
end
|
28
31
|
# See https://wiki.archlinux.org/index.php/Solid_state_drive/Memory_cell_clearing
|
29
32
|
# for SSD
|
30
33
|
def self.sdd
|
31
34
|
end
|
32
35
|
|
33
|
-
def self.
|
34
|
-
disks.each { |d|
|
36
|
+
def self.external_disk(root_disk, *disks)
|
37
|
+
disks.each { |d|
|
38
|
+
unless d && d != "" && d != nil && d == root_disk
|
39
|
+
hdd(d)
|
40
|
+
end
|
41
|
+
}
|
35
42
|
end
|
36
43
|
|
37
44
|
def self.old_vg(disk, vg)
|
@@ -14,8 +14,8 @@ module Getch
|
|
14
14
|
|
15
15
|
def run_partition
|
16
16
|
return if STATES[:partition ]
|
17
|
-
@clean.
|
18
|
-
@clean.
|
17
|
+
@clean.hdd(@disk)
|
18
|
+
@clean.external_disk(@disk, @boot_disk, @cache_disk, @home_disk)
|
19
19
|
if Helpers::efi?
|
20
20
|
partition_efi
|
21
21
|
encrypt_efi
|
@@ -12,8 +12,8 @@ module Getch
|
|
12
12
|
|
13
13
|
def run_partition
|
14
14
|
return if STATES[:partition ]
|
15
|
-
@clean.
|
16
|
-
@clean.
|
15
|
+
@clean.hdd(@disk)
|
16
|
+
@clean.external_disk(@disk, @boot_disk, @cache_disk, @home_disk)
|
17
17
|
if Helpers::efi?
|
18
18
|
partition_efi
|
19
19
|
else
|
@@ -15,8 +15,9 @@ module Getch
|
|
15
15
|
def run_partition
|
16
16
|
return if STATES[:partition ]
|
17
17
|
@clean.old_vg(@dev_root, @vg)
|
18
|
-
@clean.
|
19
|
-
@clean.
|
18
|
+
@clean.hdd(@disk)
|
19
|
+
@clean.external_disk(@disk, @boot_disk, @cache_disk, @home_disk)
|
20
|
+
|
20
21
|
partition
|
21
22
|
encrypt
|
22
23
|
lvm
|
@@ -13,8 +13,8 @@ module Getch
|
|
13
13
|
def run_partition
|
14
14
|
return if STATES[:partition ]
|
15
15
|
@clean.old_vg(@dev_root, @vg)
|
16
|
-
@clean.
|
17
|
-
@clean.
|
16
|
+
@clean.hdd(@disk)
|
17
|
+
@clean.external_disk(@disk, @boot_disk, @cache_disk, @home_disk)
|
18
18
|
partition
|
19
19
|
lvm
|
20
20
|
@state.partition
|
@@ -9,7 +9,6 @@ module Getch
|
|
9
9
|
@state = Getch::States.new()
|
10
10
|
if ! @id
|
11
11
|
@log.info "Research pool id for #{@dev_root}..."
|
12
|
-
sleep 2 until Helpers::pool_id(@dev_root)
|
13
12
|
@id = Helpers::pool_id(@dev_root)
|
14
13
|
@boot_pool_name = "bpool-#{@id}"
|
15
14
|
@pool_name = "rpool-#{@id}"
|
@@ -30,11 +29,11 @@ module Getch
|
|
30
29
|
end
|
31
30
|
|
32
31
|
def zfs
|
33
|
-
bloc=`blockdev --
|
32
|
+
bloc=`blockdev --getpbsz #{@dev_root}`
|
34
33
|
ashift = case bloc
|
35
|
-
when 8096
|
34
|
+
when /8096/
|
36
35
|
13
|
37
|
-
when 4096
|
36
|
+
when /4096/
|
38
37
|
12
|
39
38
|
else # 512
|
40
39
|
9
|
@@ -15,8 +15,9 @@ module Getch
|
|
15
15
|
def run
|
16
16
|
return if STATES[:partition ]
|
17
17
|
@clean.old_zpool
|
18
|
-
@clean.
|
19
|
-
@clean.
|
18
|
+
@clean.hdd(@disk)
|
19
|
+
@clean.external_disk(@disk, @boot_disk, @cache_disk, @home_disk)
|
20
|
+
|
20
21
|
partition
|
21
22
|
cache
|
22
23
|
@state.partition
|
@@ -27,22 +28,22 @@ module Getch
|
|
27
28
|
def partition
|
28
29
|
if Helpers::efi?
|
29
30
|
@partition.efi(@dev_esp)
|
30
|
-
@partition.swap(@dev_swap)
|
31
|
+
@partition.swap(@dev_swap) if !@cache_disk
|
31
32
|
@partition.root(@dev_root, "BF00") if @root_part != 1
|
32
33
|
else
|
33
34
|
@partition.gpt(@dev_gpt)
|
34
35
|
@partition.boot(@dev_boot)
|
35
|
-
@partition.swap(@dev_swap)
|
36
|
+
@partition.swap(@dev_swap) if !@cache_disk
|
36
37
|
@partition.root(@dev_root, "BF00") if @root_part != 1
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
41
|
def cache
|
41
|
-
if @
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
exec("sgdisk -n3:0:0 -t3:BF08
|
42
|
+
if @cache_disk
|
43
|
+
mem=`awk '/MemTotal/ {print $2}' /proc/meminfo`.chomp + 'K'
|
44
|
+
exec("sgdisk -n1:0:+#{mem} -t1:8200 /dev/#{@cache_disk}")
|
45
|
+
exec("sgdisk -n2:0:+4G -t2:BF07 /dev/#{@cache_disk}")
|
46
|
+
exec("sgdisk -n3:0:0 -t3:BF08 /dev/#{@cache_disk}")
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
@@ -8,7 +8,6 @@ module Getch
|
|
8
8
|
@state = Getch::States.new
|
9
9
|
if ! @id
|
10
10
|
@log.info "Research pool id for #{@dev_root}..."
|
11
|
-
sleep 2 until Helpers::pool_id(@dev_root)
|
12
11
|
@id = Helpers::pool_id(@dev_root)
|
13
12
|
@boot_pool_name = "bpool-#{@id}"
|
14
13
|
@pool_name = "rpool-#{@id}"
|
@@ -30,11 +29,11 @@ module Getch
|
|
30
29
|
end
|
31
30
|
|
32
31
|
def zfs
|
33
|
-
bloc=`blockdev --
|
32
|
+
bloc=`blockdev --getpbsz #{@dev_root}`
|
34
33
|
ashift = case bloc
|
35
|
-
when 8096
|
34
|
+
when /8096/
|
36
35
|
13
|
37
|
-
when 4096
|
36
|
+
when /4096/
|
38
37
|
12
|
39
38
|
else # 512
|
40
39
|
9
|
@@ -14,8 +14,9 @@ module Getch
|
|
14
14
|
def run_partition
|
15
15
|
return if STATES[:partition ]
|
16
16
|
@clean.old_zpool
|
17
|
-
@clean.
|
18
|
-
@clean.
|
17
|
+
@clean.hdd(@disk)
|
18
|
+
@clean.external_disk(@disk, @boot_disk, @cache_disk, @home_disk)
|
19
|
+
|
19
20
|
partition
|
20
21
|
cache
|
21
22
|
@state.partition
|
@@ -26,23 +27,23 @@ module Getch
|
|
26
27
|
def partition
|
27
28
|
if @efi
|
28
29
|
@partition.efi(@dev_esp)
|
29
|
-
@partition.swap(@dev_swap)
|
30
|
+
@partition.swap(@dev_swap) if !@cache_disk
|
30
31
|
@partition.root(@dev_root, "BF00") if @root_part != 1
|
31
32
|
else
|
32
33
|
@partition.gpt(@dev_gpt)
|
33
34
|
# Boot pool for GRUB2
|
34
35
|
@partition.boot(@dev_boot)
|
35
|
-
@partition.swap(@dev_swap)
|
36
|
+
@partition.swap(@dev_swap) if !@cache_disk
|
36
37
|
@partition.root(@dev_root, "BF00") if @root_part != 1
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
41
|
def cache
|
41
|
-
if @
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
exec("sgdisk -n3:0:0 -t3:
|
42
|
+
if @cache_disk
|
43
|
+
mem=`awk '/MemTotal/ {print $2}' /proc/meminfo`.chomp + 'K'
|
44
|
+
exec("sgdisk -n1:0:+#{mem} -t1:8200 /dev/#{@cache_disk}")
|
45
|
+
exec("sgdisk -n2:0:+4G -t2:BF07 /dev/#{@cache_disk}")
|
46
|
+
exec("sgdisk -n3:0:0 -t3:BF00 /dev/#{@cache_disk}")
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
data/lib/getch/gentoo.rb
CHANGED
@@ -29,6 +29,7 @@ module Getch
|
|
29
29
|
config = Getch::Gentoo::Config.new()
|
30
30
|
config.portage
|
31
31
|
config.portage_fs
|
32
|
+
config.portage_bashrc
|
32
33
|
config.repo
|
33
34
|
config.network
|
34
35
|
config.systemd(options)
|
@@ -50,6 +51,7 @@ module Getch
|
|
50
51
|
chroot.kernel
|
51
52
|
chroot.kernel_deps
|
52
53
|
chroot.install_pkgs
|
54
|
+
chroot.kernel_link
|
53
55
|
end
|
54
56
|
|
55
57
|
def kernel
|
@@ -58,6 +60,7 @@ module Getch
|
|
58
60
|
new
|
59
61
|
source.build_kspp
|
60
62
|
source.build_others
|
63
|
+
source.firewall
|
61
64
|
source.make
|
62
65
|
@state.kernel
|
63
66
|
end
|
data/lib/getch/gentoo/boot.rb
CHANGED
data/lib/getch/gentoo/chroot.rb
CHANGED
@@ -39,7 +39,6 @@ module Getch
|
|
39
39
|
license = "#{MOUNTPOINT}/etc/portage/package.license"
|
40
40
|
File.write(license, "sys-kernel/linux-firmware linux-fw-redistributable no-source-code\n")
|
41
41
|
@pkgs << "sys-kernel/gentoo-sources"
|
42
|
-
@pkgs << "dev-util/dwarves"
|
43
42
|
end
|
44
43
|
|
45
44
|
def kernel_deps
|
@@ -56,6 +55,12 @@ module Getch
|
|
56
55
|
Getch::Emerge.new(all_pkgs).pkg!
|
57
56
|
end
|
58
57
|
|
58
|
+
# create a symbolic link for /usr/src/linux
|
59
|
+
def kernel_link
|
60
|
+
cmd = "eselect kernel set 1"
|
61
|
+
exec_chroot(cmd)
|
62
|
+
end
|
63
|
+
|
59
64
|
private
|
60
65
|
|
61
66
|
def mount
|
data/lib/getch/gentoo/config.rb
CHANGED
@@ -94,6 +94,40 @@ module Getch
|
|
94
94
|
Helpers::add_file("#{portage}/package.unmask/zzz_via_autounmask")
|
95
95
|
end
|
96
96
|
|
97
|
+
def portage_bashrc
|
98
|
+
conf = "#{MOUNTPOINT}/etc/portage/bashrc"
|
99
|
+
content = %q{
|
100
|
+
# https://wiki.gentoo.org/wiki/Signed_kernel_module_support
|
101
|
+
function pre_pkg_preinst() {
|
102
|
+
# This hook signs any out-of-tree kernel modules.
|
103
|
+
if [[ "$(type -t linux-mod_pkg_preinst)" != "function" ]]; then
|
104
|
+
# The package does not seem to install any kernel modules.
|
105
|
+
return
|
106
|
+
fi
|
107
|
+
# Get the signature algorithm used by the kernel.
|
108
|
+
local module_sig_hash="$(grep -Po '(?<=CONFIG_MODULE_SIG_HASH=").*(?=")' "${KERNEL_DIR}/.config")"
|
109
|
+
# Get the key file used by the kernel.
|
110
|
+
local module_sig_key="$(grep -Po '(?<=CONFIG_MODULE_SIG_KEY=").*(?=")' "${KERNEL_DIR}/.config")"
|
111
|
+
module_sig_key="${module_sig_key:-certs/signing_key.pem}"
|
112
|
+
# Path to the key file or PKCS11 URI
|
113
|
+
if [[ "${module_sig_key#pkcs11:}" == "${module_sig_key}" && "${module_sig_key#/}" == "${module_sig_key}" ]]; then
|
114
|
+
local key_path="${KERNEL_DIR}/${module_sig_key}"
|
115
|
+
else
|
116
|
+
local key_path="${module_sig_key}"
|
117
|
+
fi
|
118
|
+
# Certificate path
|
119
|
+
local cert_path="${KERNEL_DIR}/certs/signing_key.x509"
|
120
|
+
# Sign all installed modules before merging.
|
121
|
+
find "${D%/}/${INSDESTTREE#/}/" -name "*.ko" -exec "${KERNEL_DIR}/scripts/sign-file" "${module_sig_hash}" "${key_path}" "${cert_path}" '{}' \;
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
f = File.new(conf, "w")
|
126
|
+
f.write("#{content}\n")
|
127
|
+
f.chmod(0644)
|
128
|
+
f.close
|
129
|
+
end
|
130
|
+
|
97
131
|
private
|
98
132
|
|
99
133
|
def control_options(options)
|
data/lib/getch/gentoo/sources.rb
CHANGED
@@ -12,6 +12,7 @@ module Getch
|
|
12
12
|
qemu_guest
|
13
13
|
install_wifi
|
14
14
|
install_audio
|
15
|
+
flash_mod
|
15
16
|
end
|
16
17
|
|
17
18
|
def build_kspp
|
@@ -27,6 +28,11 @@ module Getch
|
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
31
|
+
def firewall
|
32
|
+
bask("-a iptables")
|
33
|
+
Getch::Emerge.new("net-firewall/iptables").pkg!
|
34
|
+
end
|
35
|
+
|
30
36
|
private
|
31
37
|
|
32
38
|
def make_kernel
|
@@ -80,7 +86,33 @@ module Getch
|
|
80
86
|
end
|
81
87
|
|
82
88
|
def wifi_drivers
|
83
|
-
|
89
|
+
conf = "#{MOUNTPOINT}/etc/modules-load.d/wifi.conf"
|
90
|
+
File.delete(conf) if File.exists? conf
|
91
|
+
|
92
|
+
if ismatch?('ath9k')
|
93
|
+
bask("-a ath9k-driver")
|
94
|
+
end
|
95
|
+
|
96
|
+
module_load("iwlmvm", conf)
|
97
|
+
module_load("ath9k", conf)
|
98
|
+
end
|
99
|
+
|
100
|
+
def flash_mod
|
101
|
+
conf = "#{MOUNTPOINT}/etc/modules-load.d/usb.conf"
|
102
|
+
File.delete(conf) if File.exists? conf
|
103
|
+
|
104
|
+
module_load("ehci_pci", conf)
|
105
|
+
module_load("rtsx_pci_sdmmc", conf)
|
106
|
+
module_load("sdhci_pci", conf)
|
107
|
+
module_load("uas", conf)
|
108
|
+
module_load("uhci_hcd", conf)
|
109
|
+
module_load("xhci_pci", conf)
|
110
|
+
end
|
111
|
+
|
112
|
+
def module_load(name, file)
|
113
|
+
return unless name
|
114
|
+
return unless ismatch?(name)
|
115
|
+
File.write(file, "#{name}\n", mode: 'a')
|
84
116
|
end
|
85
117
|
end
|
86
118
|
end
|
data/lib/getch/guard.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
class InvalidDisk < StandardError
|
2
|
+
end
|
3
|
+
|
4
|
+
class InvalidFormat < StandardError
|
5
|
+
end
|
6
|
+
|
7
|
+
class InvalidZone < StandardError
|
8
|
+
end
|
9
|
+
|
10
|
+
class InvalidKeymap < StandardError
|
11
|
+
end
|
12
|
+
|
13
|
+
module Getch::Guard
|
14
|
+
def self.disk(name)
|
15
|
+
raise InvalidDisk, "No disk." unless name
|
16
|
+
raise InvalidDisk, "Bad device name #{name}." unless name.match(/^sd[a-z]{1}$/)
|
17
|
+
raise InvalidDisk, "Disk /dev/#{name} no found." unless File.exist? "/dev/#{name}"
|
18
|
+
name
|
19
|
+
rescue InvalidDisk => e
|
20
|
+
puts "#{e.class} => #{e}"
|
21
|
+
exit 1
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.format(name)
|
25
|
+
raise InvalidFormat, "No format specified." unless name
|
26
|
+
raise InvalidFormat, "Format #{name} not yet available." if name.match(/btrfs/)
|
27
|
+
raise InvalidFormat, "Format #{name} not supported." unless name.match(/zfs|lvm|zfs/)
|
28
|
+
rescue InvalidFormat => e
|
29
|
+
puts "#{e.class} => #{e}"
|
30
|
+
exit 1
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.zone(name)
|
34
|
+
raise InvalidZone, "No zoneinfo specified." unless name
|
35
|
+
raise InvalidZone, "Directory /usr/share/zoneinfo/ no found on this system..." unless Dir.exist? "/usr/share/zoneinfo/"
|
36
|
+
raise InvalidZone, "Zoneinfo #{name} is no found in /usr/share/zoneinfo/." unless File.exist? "/usr/share/zoneinfo/#{name}"
|
37
|
+
rescue InvalidZone => e
|
38
|
+
puts "#{e.class} => #{e}"
|
39
|
+
exit 1
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.keymap(name)
|
43
|
+
raise InvalidKeymap, "No keymap specified." unless name
|
44
|
+
key = []
|
45
|
+
|
46
|
+
if Dir.exist? '/usr/share/keymaps'
|
47
|
+
key = Dir.glob("/usr/share/keymaps/**/#{name}.map.gz")
|
48
|
+
elsif Dir.exist? '/usr/share/kbd/keymaps'
|
49
|
+
key = Dir.glob("/usr/share/kbd/keymaps/**/#{name}.map.gz")
|
50
|
+
else
|
51
|
+
raise InvalidKeymap, "No directory found for keymap."
|
52
|
+
end
|
53
|
+
|
54
|
+
if key == []
|
55
|
+
raise InvalidKeymap, "Keymap #{name} no found."
|
56
|
+
end
|
57
|
+
name
|
58
|
+
rescue InvalidKeymap => e
|
59
|
+
puts "#{e.class} => #{e}"
|
60
|
+
exit 1
|
61
|
+
end
|
62
|
+
end
|
data/lib/getch/helpers.rb
CHANGED
@@ -66,6 +66,20 @@ module Helpers
|
|
66
66
|
|
67
67
|
# Used with ZFS for the pool name
|
68
68
|
def self.pool_id(dev)
|
69
|
-
|
69
|
+
if dev.match(/[0-9]/)
|
70
|
+
sleep 1
|
71
|
+
`lsblk -o PARTUUID #{dev}`.delete("\n").delete("PARTUUID").match(/[\w]{5}/)
|
72
|
+
else
|
73
|
+
puts "Please, enter a pool name"
|
74
|
+
while true
|
75
|
+
print "\n> "
|
76
|
+
value = gets
|
77
|
+
if value.match(/[a-z]{4,20}/)
|
78
|
+
return value
|
79
|
+
end
|
80
|
+
puts "Bad name, you enter: #{value}"
|
81
|
+
puts "Valid pool name use character only, between 4-20."
|
82
|
+
end
|
83
|
+
end
|
70
84
|
end
|
71
85
|
end
|
data/lib/getch/options.rb
CHANGED
@@ -27,31 +27,31 @@ module Getch
|
|
27
27
|
@language = lang
|
28
28
|
end
|
29
29
|
opts.on("-z", "--zoneinfo ZONE", "Default is US/Eastern") do |zone|
|
30
|
-
@zoneinfo = zone
|
30
|
+
@zoneinfo = Getch::Guard.zone(zone)
|
31
31
|
end
|
32
32
|
opts.on("-k", "--keymap KEY", "Default is us") do |key|
|
33
|
-
@keymap = key
|
33
|
+
@keymap = Getch::Guard.keymap(key)
|
34
34
|
end
|
35
35
|
opts.on("-d", "--disk DISK", "Disk where install Gentoo (sda,sdb), default use #{@disk}") do |disk|
|
36
|
-
@disk = disk
|
36
|
+
@disk = Getch::Guard.disk(disk)
|
37
37
|
end
|
38
38
|
opts.on("-f", "--format FS", "Can be ext4, lvm or zfs. Default use ext4") do |fs|
|
39
|
-
@fs = fs
|
39
|
+
@fs = Getch::Guard.format(fs)
|
40
40
|
DEFAULT_OPTIONS[:fs] = fs # dont known why, but it should be enforce
|
41
41
|
end
|
42
42
|
opts.on("-u", "--username USERNAME", "Create a new user /home/USERNAME with password.") do |user|
|
43
43
|
@username = user
|
44
44
|
end
|
45
45
|
opts.on("--separate-boot DISK", "Disk for the boot/efi partition, default use #{@disk}") do |boot|
|
46
|
-
@boot_disk = boot
|
46
|
+
@boot_disk = Getch::Guard.disk(boot)
|
47
47
|
DEFAULT_OPTIONS[:boot_disk] = boot
|
48
48
|
end
|
49
49
|
opts.on("--separate-cache DISK", "Disk for the swap partition, add ZIL/L2ARC for ZFS when set, default use #{@disk}") do |swap|
|
50
|
-
@cache_disk = swap
|
50
|
+
@cache_disk = Getch::Guard.disk(swap)
|
51
51
|
DEFAULT_OPTIONS[:cache_disk] = swap
|
52
52
|
end
|
53
53
|
opts.on("--separate-home DISK", "Disk for the /home partition, default is nil") do |home|
|
54
|
-
@home_disk = home
|
54
|
+
@home_disk = Getch::Guard.disk(home)
|
55
55
|
DEFAULT_OPTIONS[:home_disk] = home
|
56
56
|
end
|
57
57
|
opts.on("--encrypt", "Encrypt your system.") do
|
data/lib/getch/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: getch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- szorfein
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
F9Dl4EPzjBJOgQWf+NxzxNuNKI46Lp5Q8AI+xtDUHAPbSswHa40BA6ChFehP+j0L
|
36
36
|
fg==
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2021-
|
38
|
+
date: 2021-06-20 00:00:00.000000000 Z
|
39
39
|
dependencies: []
|
40
40
|
description:
|
41
41
|
email:
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- lib/getch/gentoo/stage.rb
|
111
111
|
- lib/getch/gentoo/use.rb
|
112
112
|
- lib/getch/gentoo/use_flag.rb
|
113
|
+
- lib/getch/guard.rb
|
113
114
|
- lib/getch/helpers.rb
|
114
115
|
- lib/getch/log.rb
|
115
116
|
- lib/getch/options.rb
|
metadata.gz.sig
CHANGED
Binary file
|