getch 0.1.2 → 0.1.3
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 +10 -0
- data/lib/getch.rb +8 -1
- data/lib/getch/command.rb +1 -1
- data/lib/getch/config.rb +58 -0
- data/lib/getch/filesystem/ext4/encrypt/config.rb +3 -4
- data/lib/getch/filesystem/ext4/encrypt/deps.rb +1 -8
- data/lib/getch/filesystem/lvm/config.rb +5 -9
- data/lib/getch/filesystem/lvm/deps.rb +1 -7
- data/lib/getch/filesystem/lvm/device.rb +3 -3
- data/lib/getch/filesystem/lvm/encrypt/config.rb +5 -8
- data/lib/getch/filesystem/lvm/encrypt/deps.rb +2 -9
- data/lib/getch/filesystem/lvm/encrypt/device.rb +3 -3
- data/lib/getch/filesystem/zfs/deps.rb +0 -2
- data/lib/getch/filesystem/zfs/encrypt/deps.rb +1 -4
- data/lib/getch/gentoo.rb +7 -3
- data/lib/getch/gentoo/boot.rb +14 -7
- data/lib/getch/gentoo/chroot.rb +2 -3
- data/lib/getch/gentoo/sources.rb +11 -0
- data/lib/getch/gentoo/use.rb +43 -0
- data/lib/getch/gentoo/use_flag.rb +64 -0
- data/lib/getch/version.rb +1 -1
- metadata +5 -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: c141cfefd0484364edafbbf424bc6e3d1fe98d26d5a2fa96411ae88efaae501a
|
4
|
+
data.tar.gz: 117fb8c04c3525ac5c5be3da0683eac0b68de537f674955fe6d363091233ab0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbf00fb976d8e4a1ea8a4e3abf64de42f9804b4b33b125548021f733d27e2458d6c6ec2e9712f3f92806b66253550c600c217f3ece4bf3310f5b39c5cb58aebf
|
7
|
+
data.tar.gz: ed7af46af82c816f17296ba01301aece81d6655d4fc31c166fce5a013be8c20e5b89b8965c3d855913628c3566a47bd8b2ed123263c7dedaef5b3e3fdd0a6b4e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 0.1.3, release 2021-05-17
|
2
|
+
* LVM use the format /dev/vg_name/lv_name for mount/format/fstab.
|
3
|
+
* Stop using `euse` from `gentoolkit`, use native Ruby code here.
|
4
|
+
* Optimization on package installation, they shouln't be installed more than once.
|
5
|
+
* Regroup use flags under Getch::Gentoo::UseFlag.
|
6
|
+
* Upd Bask v0.5 (zstd compression, better support for wifi...)
|
7
|
+
* Config for systemd-resolved, enable DNS over TLS with Quad9 (9.9.9.9)
|
8
|
+
* Add configs for systemd-network with DHCP for wifi and ethernet.
|
9
|
+
* Correct permissions (/home/[user] and /etc/portage)
|
10
|
+
|
1
11
|
## 0.1.2, release 2021-05-12
|
2
12
|
* DOCS update.
|
3
13
|
* Keep Nano for those who need :)
|
data/lib/getch.rb
CHANGED
@@ -5,6 +5,7 @@ require_relative 'getch/filesystem'
|
|
5
5
|
require_relative 'getch/command'
|
6
6
|
require_relative 'getch/helpers'
|
7
7
|
require_relative 'getch/log'
|
8
|
+
require_relative 'getch/config'
|
8
9
|
|
9
10
|
module Getch
|
10
11
|
|
@@ -94,11 +95,16 @@ module Getch
|
|
94
95
|
gentoo = Getch::Gentoo
|
95
96
|
gentoo.stage3
|
96
97
|
gentoo.config(options)
|
97
|
-
gentoo.chroot
|
98
|
+
gentoo.chroot(options)
|
98
99
|
gentoo.kernel
|
99
100
|
gentoo.boot(options)
|
100
101
|
end
|
101
102
|
|
103
|
+
def self.configure(options)
|
104
|
+
config = Getch::Config.new
|
105
|
+
config.network
|
106
|
+
end
|
107
|
+
|
102
108
|
def self.main(argv)
|
103
109
|
options = Options.new(argv)
|
104
110
|
DEFAULT_OPTIONS.freeze
|
@@ -107,5 +113,6 @@ module Getch
|
|
107
113
|
format(options.disk, options.fs, options.username)
|
108
114
|
class_fs::Mount.new.run
|
109
115
|
init_gentoo(options)
|
116
|
+
configure(options)
|
110
117
|
end
|
111
118
|
end
|
data/lib/getch/command.rb
CHANGED
data/lib/getch/config.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
module Getch
|
2
|
+
class Config
|
3
|
+
def initialize
|
4
|
+
@systemd_net_dir = "#{MOUNTPOINT}/etc/systemd"
|
5
|
+
end
|
6
|
+
|
7
|
+
def network
|
8
|
+
ethernet
|
9
|
+
wifi
|
10
|
+
resolved
|
11
|
+
Getch::Chroot.new('systemctl enable systemd-networkd').run!
|
12
|
+
Getch::Chroot.new('systemctl enable systemd-resolved').run!
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def ethernet
|
18
|
+
conf = "#{@systemd_net_dir}/network/20-ethernet.network"
|
19
|
+
datas = [
|
20
|
+
"[Match]",
|
21
|
+
"Name=en*",
|
22
|
+
"Name=eth*",
|
23
|
+
"[Network]",
|
24
|
+
"DHCP=yes",
|
25
|
+
"IPv6PrivacyExtensions=yes",
|
26
|
+
"[DHCP]",
|
27
|
+
"RouteMetric=512"
|
28
|
+
]
|
29
|
+
File.write(conf, datas.join("\n"), mode: 'w')
|
30
|
+
end
|
31
|
+
|
32
|
+
def wifi
|
33
|
+
conf = "#{@systemd_net_dir}/network/20-wireless.network"
|
34
|
+
datas = [
|
35
|
+
"[Match]",
|
36
|
+
"Name=wlp*",
|
37
|
+
"Name=wlan*",
|
38
|
+
"[Network]",
|
39
|
+
"DHCP=yes",
|
40
|
+
"IPv6PrivacyExtensions=yes",
|
41
|
+
"[DHCP]",
|
42
|
+
"RouteMetric=1024",
|
43
|
+
]
|
44
|
+
File.write(conf, datas.join("\n"), mode: 'w')
|
45
|
+
end
|
46
|
+
|
47
|
+
def resolved
|
48
|
+
conf = "#{@systemd_net_dir}/resolved.conf.d/dns_over_tls.conf"
|
49
|
+
datas = [
|
50
|
+
"[Resolve]",
|
51
|
+
"DNS=9.9.9.9#dns.quad9.net",
|
52
|
+
"DNSOverTLS=yes",
|
53
|
+
]
|
54
|
+
Helpers::create_dir("#{@systemd_net_dir}/resolved.conf.d")
|
55
|
+
File.write(conf, datas.join("\n"), mode: 'w')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -28,7 +28,7 @@ module Getch
|
|
28
28
|
'title Gentoo Linux',
|
29
29
|
'linux /vmlinuz',
|
30
30
|
'initrd /initramfs',
|
31
|
-
"options crypt_root=
|
31
|
+
"options crypt_root=UUID=#{@uuid_dev_root} root=/dev/mapper/root init=#{@init} keymap=#{DEFAULT_OPTIONS[:keymap]} rw"
|
32
32
|
]
|
33
33
|
File.write("#{dir}/gentoo.conf", datas_gentoo.join("\n"))
|
34
34
|
end
|
@@ -36,7 +36,7 @@ module Getch
|
|
36
36
|
def crypttab
|
37
37
|
home = @home_disk ? "crypthome UUID=#{@uuid_home} /root/secretkeys/crypto_keyfile.bin luks" : ''
|
38
38
|
datas = [
|
39
|
-
"cryptswap PARTUUID=#{@partuuid_swap} /dev/urandom swap,cipher=aes-xts-plain64:sha256,size=
|
39
|
+
"cryptswap PARTUUID=#{@partuuid_swap} /dev/urandom swap,cipher=aes-xts-plain64:sha256,size=512",
|
40
40
|
home
|
41
41
|
]
|
42
42
|
File.write("#{@root_dir}/etc/crypttab", datas.join("\n"))
|
@@ -46,7 +46,7 @@ module Getch
|
|
46
46
|
return if Helpers::efi?
|
47
47
|
file = "#{@root_dir}/etc/default/grub"
|
48
48
|
cmdline = [
|
49
|
-
"GRUB_CMDLINE_LINUX=\"crypt_root=
|
49
|
+
"GRUB_CMDLINE_LINUX=\"crypt_root=UUID=#{@uuid_dev_root} root=/dev/mapper/root init=#{@init} rw slub_debug=P page_poison=1 slab_nomerge pti=on vsyscall=none spectre_v2=on spec_store_bypass_disable=seccomp iommu=force keymap=#{DEFAULT_OPTIONS[:keymap]}\"",
|
50
50
|
"GRUB_ENABLE_CRYPTODISK=y"
|
51
51
|
]
|
52
52
|
File.write(file, cmdline.join("\n"), mode: 'a')
|
@@ -55,7 +55,6 @@ module Getch
|
|
55
55
|
private
|
56
56
|
|
57
57
|
def gen_uuid
|
58
|
-
@partuuid_root = Helpers::partuuid(@dev_root)
|
59
58
|
@partuuid_swap = Helpers::partuuid(@dev_swap)
|
60
59
|
@uuid_dev_root = `lsblk -d -o "UUID" #{@dev_root} | tail -1`.chomp() if @dev_root
|
61
60
|
@uuid_esp = Helpers::uuid(@dev_esp) if @dev_esp
|
@@ -4,7 +4,6 @@ module Getch
|
|
4
4
|
module Encrypt
|
5
5
|
class Deps
|
6
6
|
def make
|
7
|
-
install_bios unless Helpers::efi?
|
8
7
|
install_deps
|
9
8
|
genkernel
|
10
9
|
Getch::Make.new("genkernel --kernel-config=/usr/src/linux/.config all").run!
|
@@ -30,14 +29,8 @@ module Getch
|
|
30
29
|
File.write(file, datas.join("\n"), mode: 'a')
|
31
30
|
end
|
32
31
|
|
33
|
-
def install_bios
|
34
|
-
exec("euse -p sys-boot/grub -E device-mapper")
|
35
|
-
exec("euse -p sys-fs/cryptsetup -E luks1_default")
|
36
|
-
end
|
37
|
-
|
38
32
|
def install_deps
|
39
|
-
|
40
|
-
Getch::Emerge.new('genkernel sys-apps/systemd sys-fs/cryptsetup').pkg!
|
33
|
+
Getch::Emerge.new('genkernel').pkg!
|
41
34
|
end
|
42
35
|
|
43
36
|
def exec(cmd)
|
@@ -23,7 +23,7 @@ module Getch
|
|
23
23
|
'title Gentoo Linux',
|
24
24
|
'linux /vmlinuz',
|
25
25
|
'initrd /initramfs',
|
26
|
-
"options resume
|
26
|
+
"options resume=#{@lv_swap} root=#{@lv_root} init=#{@init} dolvm rw"
|
27
27
|
]
|
28
28
|
File.write("#{dir}/gentoo.conf", datas_gentoo.join("\n"))
|
29
29
|
end
|
@@ -32,7 +32,7 @@ module Getch
|
|
32
32
|
return if @efi
|
33
33
|
file = "#{@root_dir}/etc/default/grub"
|
34
34
|
cmdline = [
|
35
|
-
"GRUB_CMDLINE_LINUX=\"resume
|
35
|
+
"GRUB_CMDLINE_LINUX=\"resume=#{@lv_swap} root=#{@lv_root} init=#{@init} dolvm rw\""
|
36
36
|
]
|
37
37
|
File.write("#{file}", cmdline.join("\n"), mode: 'a')
|
38
38
|
end
|
@@ -40,20 +40,16 @@ module Getch
|
|
40
40
|
private
|
41
41
|
|
42
42
|
def gen_uuid
|
43
|
-
@uuid_swap = `lsblk -o "UUID" #{@lv_swap} | tail -1`.chomp() if @lv_swap
|
44
|
-
@uuid_root = `lsblk -o "UUID" #{@lv_root} | tail -1`.chomp() if @lv_root
|
45
|
-
@uuid_dev_root = `lsblk -o "UUID" #{@dev_root} | tail -1`.chomp() if @dev_root
|
46
43
|
@uuid_boot = `lsblk -o "UUID" #{@dev_boot} | tail -1`.chomp() if @dev_boot
|
47
44
|
@uuid_esp = `lsblk -o "UUID" #{@dev_esp} | tail -1`.chomp() if @dev_esp
|
48
|
-
@uuid_home = `lsblk -o "UUID" #{@lv_home} | tail -1`.chomp() if @lv_home
|
49
45
|
end
|
50
46
|
|
51
47
|
def data_fstab
|
52
48
|
efi = @dev_esp ? "UUID=#{@uuid_esp} /efi vfat noauto,noatime 1 2" : ''
|
53
49
|
boot = @dev_boot ? "UUID=#{@uuid_boot} /boot ext4 noauto,noatime 1 2" : ''
|
54
|
-
swap =
|
55
|
-
root =
|
56
|
-
home = @lv_home ? "
|
50
|
+
swap = "#{@lv_swap} none swap discard 0 0"
|
51
|
+
root = "#{@lv_root} / ext4 defaults 0 1"
|
52
|
+
home = @lv_home ? "#{@lv_home} /home/#{@user} ext4 defaults 0 2" : ''
|
57
53
|
|
58
54
|
[ efi, boot, swap, root, home ]
|
59
55
|
end
|
@@ -27,15 +27,9 @@ module Getch
|
|
27
27
|
File.write(file, datas.join("\n"), mode: 'a')
|
28
28
|
end
|
29
29
|
|
30
|
-
def install_bios
|
31
|
-
exec("euse -p sys-boot/grub -E device-mapper")
|
32
|
-
end
|
33
|
-
|
34
30
|
def install_deps
|
35
|
-
make_conf = "#{MOUNTPOINT}/etc/portage/make.conf"
|
36
|
-
exec("euse -E lvm") if ! Helpers::grep?(make_conf, /lvm/)
|
37
|
-
Getch::Emerge.new('genkernel lvm2').pkg!
|
38
31
|
Getch::Bask.new('-a lvm').run!
|
32
|
+
Getch::Emerge.new('sys-fs/lvm2 genkernel').pkg!
|
39
33
|
exec("systemctl enable lvm2-monitor")
|
40
34
|
end
|
41
35
|
|
@@ -5,9 +5,9 @@ module Getch
|
|
5
5
|
def initialize
|
6
6
|
super
|
7
7
|
@vg = 'vg0'
|
8
|
-
@lv_root = "/dev
|
9
|
-
@lv_swap = "/dev
|
10
|
-
@lv_home = @home_disk ? "/dev
|
8
|
+
@lv_root = "/dev/#{@vg}/root"
|
9
|
+
@lv_swap = "/dev/#{@vg}/swap"
|
10
|
+
@lv_home = @home_disk ? "/dev/#{@vg}/home" : nil
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
@@ -25,7 +25,7 @@ module Getch
|
|
25
25
|
'title Gentoo Linux',
|
26
26
|
'linux /vmlinuz',
|
27
27
|
'initrd /initramfs',
|
28
|
-
"options crypt_root=UUID=#{@uuid_dev_root} root=#{@lv_root} init=#{@init} keymap=#{DEFAULT_OPTIONS[:keymap]} dolvm rw"
|
28
|
+
"options crypt_root=UUID=#{@uuid_dev_root} root=/dev/mapper/root real_root=#{@lv_root} init=#{@init} keymap=#{DEFAULT_OPTIONS[:keymap]} dolvm rw"
|
29
29
|
]
|
30
30
|
File.write("#{dir}/gentoo.conf", datas_gentoo.join("\n"))
|
31
31
|
end
|
@@ -41,7 +41,7 @@ module Getch
|
|
41
41
|
return if Helpers::efi?
|
42
42
|
file = "#{@root_dir}/etc/default/grub"
|
43
43
|
cmdline = [
|
44
|
-
"GRUB_CMDLINE_LINUX=\"crypt_root=UUID=#{@uuid_dev_root} root=#{@lv_root} init=#{@init} dolvm rw slub_debug=P page_poison=1 slab_nomerge pti=on vsyscall=none spectre_v2=on spec_store_bypass_disable=seccomp iommu=force keymap=#{DEFAULT_OPTIONS[:keymap]}\"",
|
44
|
+
"GRUB_CMDLINE_LINUX=\"crypt_root=UUID=#{@uuid_dev_root} root=/dev/mapper/root real_root=#{@lv_root} init=#{@init} dolvm rw slub_debug=P page_poison=1 slab_nomerge pti=on vsyscall=none spectre_v2=on spec_store_bypass_disable=seccomp iommu=force keymap=#{DEFAULT_OPTIONS[:keymap]}\"",
|
45
45
|
"GRUB_ENABLE_CRYPTODISK=y"
|
46
46
|
]
|
47
47
|
File.write("#{file}", cmdline.join("\n"), mode: 'a')
|
@@ -50,20 +50,17 @@ module Getch
|
|
50
50
|
private
|
51
51
|
|
52
52
|
def gen_uuid
|
53
|
-
@uuid_swap = `lsblk -o "UUID" #{@lv_swap} | tail -1`.chomp() if @lv_swap
|
54
|
-
@uuid_root = `lsblk -d -o "UUID" #{@lv_root} | tail -1`.chomp() if @lv_root
|
55
53
|
@uuid_dev_root = `lsblk -d -o "UUID" #{@dev_root} | tail -1`.chomp() if @dev_root
|
56
54
|
@uuid_boot = `lsblk -o "UUID" #{@dev_boot} | tail -1`.chomp() if @dev_boot
|
57
55
|
@uuid_esp = `lsblk -o "UUID" #{@dev_esp} | tail -1`.chomp() if @dev_esp
|
58
|
-
@uuid_home = `lsblk -o "UUID" #{@lv_home} | tail -1`.chomp() if @lv_home
|
59
56
|
end
|
60
57
|
|
61
58
|
def data_fstab
|
62
59
|
boot_efi = @dev_esp ? "UUID=#{@uuid_esp} /efi vfat noauto,noatime 1 2" : ''
|
63
60
|
boot = @dev_boot ? "UUID=#{@uuid_boot} /boot ext4 noauto,noatime 1 2" : ''
|
64
|
-
swap =
|
65
|
-
root =
|
66
|
-
home = @lv_home ? "
|
61
|
+
swap = "/dev/mapper/cryptswap none swap discard 0 0"
|
62
|
+
root = "#{@lv_root} / ext4 defaults 0 1"
|
63
|
+
home = @lv_home ? "#{@lv_home} /home/#{@user} ext4 defaults 0 2" : ''
|
67
64
|
|
68
65
|
[ boot_efi, boot, swap, root, home ]
|
69
66
|
end
|
@@ -4,7 +4,6 @@ module Getch
|
|
4
4
|
module Encrypt
|
5
5
|
class Deps
|
6
6
|
def make
|
7
|
-
install_bios unless Helpers::efi?
|
8
7
|
install_deps
|
9
8
|
options_make
|
10
9
|
Getch::Make.new("genkernel --kernel-config=/usr/src/linux/.config all").run!
|
@@ -30,16 +29,10 @@ module Getch
|
|
30
29
|
File.write(file, datas.join("\n"), mode: 'a')
|
31
30
|
end
|
32
31
|
|
33
|
-
def install_bios
|
34
|
-
exec("euse -p sys-boot/grub -E device-mapper")
|
35
|
-
end
|
36
|
-
|
37
32
|
def install_deps
|
38
|
-
|
39
|
-
exec("euse -E lvm") if ! Helpers::grep?(make_conf, /lvm/)
|
40
|
-
exec("euse -E cryptsetup") if ! Helpers::grep?(make_conf, /cryptsetup/)
|
41
|
-
Getch::Emerge.new('genkernel systemd sys-fs/cryptsetup lvm2').pkg!
|
33
|
+
# lvm2, cryptsetup alrealy installed
|
42
34
|
Getch::Bask.new('-a lvm').run!
|
35
|
+
Getch::Emerge.new('genkernel').pkg!
|
43
36
|
exec("systemctl enable lvm2-monitor")
|
44
37
|
end
|
45
38
|
|
@@ -6,9 +6,9 @@ module Getch
|
|
6
6
|
def initialize
|
7
7
|
super
|
8
8
|
@vg = 'vg0'
|
9
|
-
@lv_root = "/dev
|
10
|
-
@lv_swap = "/dev
|
11
|
-
@lv_home = @home_disk ? "/dev
|
9
|
+
@lv_root = "/dev/#{@vg}/root"
|
10
|
+
@lv_swap = "/dev/#{@vg}/swap"
|
11
|
+
@lv_home = @home_disk ? "/dev/#{@vg}/home" : nil
|
12
12
|
@luks_root = "/dev/mapper/cryptroot"
|
13
13
|
@luks_home = @home_disk ? "/dev/mapper/crypthome" : nil
|
14
14
|
end
|
@@ -24,8 +24,6 @@ module Getch
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def install_deps
|
27
|
-
exec("euse -E libzfs") if ! Helpers::grep?("#{MOUNTPOINT}/etc/portage/make.conf", /libzfs/)
|
28
|
-
exec("euse -E rootfs") if ! Helpers::grep?("#{MOUNTPOINT}/etc/portage/make.conf", /rootfs/)
|
29
27
|
Getch::Bask.new('-a zfs').run!
|
30
28
|
Getch::Make.new("make modules_prepare").run!
|
31
29
|
Getch::Make.new("make -j$(nproc)").run!
|
@@ -24,13 +24,10 @@ module Getch
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def install_deps
|
27
|
-
exec("euse -E libzfs") if ! Helpers::grep?("#{MOUNTPOINT}/etc/portage/make.conf", /libzfs/)
|
28
|
-
exec("euse -E rootfs") if ! Helpers::grep?("#{MOUNTPOINT}/etc/portage/make.conf", /rootfs/)
|
29
|
-
exec("euse -E cryptsetup") if ! Helpers::grep?("#{MOUNTPOINT}/etc/portage/make.conf", /cryptsetup/)
|
30
27
|
Getch::Bask.new('-a zfs').run!
|
31
28
|
Getch::Make.new("make modules_prepare").run!
|
32
29
|
Getch::Make.new("make -j$(nproc)").run!
|
33
|
-
Getch::Emerge.new('genkernel sys-fs/zfs
|
30
|
+
Getch::Emerge.new('genkernel sys-fs/zfs').pkg!
|
34
31
|
end
|
35
32
|
|
36
33
|
# See: https://wiki.archlinux.org/index.php/ZFS#Using_zfs-mount-generator
|
data/lib/getch/gentoo.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'open-uri'
|
2
|
-
require 'open3'
|
3
1
|
require_relative 'gentoo/stage'
|
4
2
|
require_relative 'gentoo/config'
|
5
3
|
require_relative 'gentoo/chroot'
|
6
4
|
require_relative 'gentoo/sources'
|
7
5
|
require_relative 'gentoo/boot'
|
6
|
+
require_relative 'gentoo/use'
|
7
|
+
require_relative 'gentoo/use_flag'
|
8
8
|
|
9
9
|
module Getch
|
10
10
|
module Gentoo
|
@@ -36,11 +36,15 @@ module Getch
|
|
36
36
|
@state.config
|
37
37
|
end
|
38
38
|
|
39
|
-
def chroot
|
39
|
+
def chroot(options)
|
40
40
|
chroot = Getch::Gentoo::Chroot.new()
|
41
41
|
chroot.update
|
42
42
|
chroot.cpuflags
|
43
43
|
chroot.systemd
|
44
|
+
|
45
|
+
flags = Getch::Gentoo::UseFlag.new(options)
|
46
|
+
flags.apply
|
47
|
+
|
44
48
|
chroot.world
|
45
49
|
return if STATES[:gentoo_kernel]
|
46
50
|
chroot.kernel
|
data/lib/getch/gentoo/boot.rb
CHANGED
@@ -13,6 +13,7 @@ module Getch
|
|
13
13
|
@config.fstab
|
14
14
|
bootloader
|
15
15
|
password
|
16
|
+
permission
|
16
17
|
the_end
|
17
18
|
end
|
18
19
|
|
@@ -30,7 +31,7 @@ module Getch
|
|
30
31
|
puts "Configuring systemd-boot."
|
31
32
|
# ref: https://forums.gentoo.org/viewtopic-p-8118822.html
|
32
33
|
esp = '/efi'
|
33
|
-
|
34
|
+
Getch::Chroot.new("bootctl --path #{esp} install").run!
|
34
35
|
datas_loader = [
|
35
36
|
'default gentoo',
|
36
37
|
'timeout 3',
|
@@ -44,21 +45,20 @@ module Getch
|
|
44
45
|
initramfs = Dir.glob("#{MOUNTPOINT}/boot/initramfs-*.img")
|
45
46
|
FileUtils.cp("#{initramfs[0]}", "#{MOUNTPOINT}/#{esp}/initramfs", preserve: true) if initramfs != []
|
46
47
|
|
47
|
-
|
48
|
+
Getch::Chroot.new("bootctl --path #{esp} update").run!
|
48
49
|
end
|
49
50
|
|
50
51
|
def bootctl_dep
|
51
52
|
puts 'Installing systemd-boot...'
|
52
|
-
|
53
|
-
Getch::Emerge.new("sys-apps/systemd efivar").pkg!
|
53
|
+
Getch::Emerge.new("efivar").pkg!
|
54
54
|
end
|
55
55
|
|
56
56
|
def grub
|
57
57
|
puts 'Installing GRUB...'
|
58
58
|
Getch::Emerge.new("sys-boot/grub:2").pkg!
|
59
59
|
@config.grub
|
60
|
-
|
61
|
-
|
60
|
+
Getch::Chroot.new("grub-install /dev/#{@disk}").run!
|
61
|
+
Getch::Chroot.new("grub-mkconfig -o /boot/grub/grub.cfg").run!
|
62
62
|
end
|
63
63
|
|
64
64
|
def password
|
@@ -67,7 +67,7 @@ module Getch
|
|
67
67
|
system(cmd)
|
68
68
|
if @user
|
69
69
|
puts "Creating user #{@user}"
|
70
|
-
|
70
|
+
Getch::Chroot.new("useradd -m -G users,wheel,audio,video #{@user}").run!
|
71
71
|
puts "Password for your user #{@user}"
|
72
72
|
cmd = "chroot #{MOUNTPOINT} /bin/bash -c \"source /etc/profile && passwd #{@user}\""
|
73
73
|
system(cmd)
|
@@ -76,6 +76,13 @@ module Getch
|
|
76
76
|
|
77
77
|
private
|
78
78
|
|
79
|
+
def permission
|
80
|
+
FileUtils.chmod_R 0755, "#{MOUNTPOINT}/etc/portage"
|
81
|
+
if @user
|
82
|
+
Getch::Chroot.new("chown -R #{@user}:#{@user} /home/#{@user}").run!
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
79
86
|
def the_end
|
80
87
|
#Helpers::exec_or_die("umount -l /mnt/gentoo/dev{/shm,/pts,}")
|
81
88
|
#Helpers::exec_or_die("umount -R #{MOUNTPOINT}")
|
data/lib/getch/gentoo/chroot.rb
CHANGED
@@ -24,7 +24,7 @@ module Getch
|
|
24
24
|
def world
|
25
25
|
return if STATES[:gentoo_update]
|
26
26
|
puts "Update Gentoo world"
|
27
|
-
Getch::Emerge.new("emerge --update --deep --newuse @world").run!
|
27
|
+
Getch::Emerge.new("emerge --update --deep --changed-use --newuse @world").run!
|
28
28
|
@state.update
|
29
29
|
end
|
30
30
|
|
@@ -43,12 +43,11 @@ module Getch
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def kernel_deps
|
46
|
-
Getch::Emerge.new("gentoolkit").pkg!
|
47
|
-
exec_chroot("euse -p sys-apps/kmod -E lzma")
|
48
46
|
@pkgs << "sys-apps/kmod"
|
49
47
|
end
|
50
48
|
|
51
49
|
def install_pkgs
|
50
|
+
@pkgs << "app-portage/gentoolkit"
|
52
51
|
@pkgs << "app-admin/sudo"
|
53
52
|
@pkgs << "app-editors/vim"
|
54
53
|
@pkgs << "sys-kernel/linux-firmware"
|
data/lib/getch/gentoo/sources.rb
CHANGED
@@ -7,6 +7,7 @@ module Getch
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def build_others
|
10
|
+
cryptsetup
|
10
11
|
virtualbox_guest
|
11
12
|
qemu_guest
|
12
13
|
install_wifi
|
@@ -36,6 +37,16 @@ module Getch
|
|
36
37
|
raise "No kernel installed, compiling source fail..." if is_kernel == []
|
37
38
|
end
|
38
39
|
|
40
|
+
def cryptsetup
|
41
|
+
return unless DEFAULT_OPTIONS[:encrypt]
|
42
|
+
make_conf = "#{MOUNTPOINT}/etc/portage/make.conf"
|
43
|
+
|
44
|
+
puts "Adding support for cryptsetup."
|
45
|
+
bask("-a cryptsetup")
|
46
|
+
Getch::Chroot.new("euse -E cryptsetup").run! unless Helpers::grep?(make_conf, /cryptsetup/)
|
47
|
+
Getch::Emerge.new("sys-fs/cryptsetup").pkg!
|
48
|
+
end
|
49
|
+
|
39
50
|
def virtualbox_guest
|
40
51
|
systemd=`systemd-detect-virt`.chomp
|
41
52
|
return if ! ismatch?('vmwgfx') || systemd.match(/none/)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Getch
|
2
|
+
module Gentoo
|
3
|
+
class Use
|
4
|
+
def initialize(pkg = nil)
|
5
|
+
@use_dir = "#{MOUNTPOINT}/etc/portage/package.use"
|
6
|
+
@pkg = pkg
|
7
|
+
@file = @pkg ? @pkg.match(/[\w]+$/) : nil
|
8
|
+
@make = "#{MOUNTPOINT}/etc/portage/make.conf"
|
9
|
+
end
|
10
|
+
|
11
|
+
def add(*flags)
|
12
|
+
@flags = flags.join(' ')
|
13
|
+
write
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_global(*flags)
|
17
|
+
@flags = flags
|
18
|
+
write_global
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def write
|
24
|
+
content = "#{@pkg} #{@flags}\n"
|
25
|
+
File.write("#{@use_dir}/#{@file}", content, mode: 'w')
|
26
|
+
end
|
27
|
+
|
28
|
+
def write_global
|
29
|
+
list = []
|
30
|
+
|
31
|
+
@flags.each { |f|
|
32
|
+
unless Helpers::grep?(@make, /#{f}/)
|
33
|
+
list << f
|
34
|
+
end
|
35
|
+
}
|
36
|
+
|
37
|
+
use = list.join(' ')
|
38
|
+
line = "USE=\"${USE} #{use}\"\n"
|
39
|
+
File.write(@make, line, mode: 'a')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# lib/use_flag.rb
|
2
|
+
|
3
|
+
module Getch::Gentoo
|
4
|
+
class UseFlag
|
5
|
+
def initialize(options)
|
6
|
+
@efi = Helpers::efi?
|
7
|
+
@o = options
|
8
|
+
end
|
9
|
+
|
10
|
+
def apply
|
11
|
+
systemd
|
12
|
+
kmod
|
13
|
+
grub
|
14
|
+
zfs
|
15
|
+
lvm
|
16
|
+
cryptsetup
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def systemd
|
22
|
+
flags = []
|
23
|
+
use = Getch::Gentoo::Use.new('sys-apps/systemd')
|
24
|
+
flags << 'dns-over-tls'
|
25
|
+
flags << 'gnuefi' if @efi
|
26
|
+
use.add(flags)
|
27
|
+
end
|
28
|
+
|
29
|
+
def kmod
|
30
|
+
use = Getch::Gentoo::Use.new('sys-apps/kmod')
|
31
|
+
use.add('zstd', 'lzma')
|
32
|
+
end
|
33
|
+
|
34
|
+
def grub
|
35
|
+
return if @efi
|
36
|
+
flags = []
|
37
|
+
use = Getch::Gentoo::Use.new('sys-boot/grub')
|
38
|
+
flags << '-grub_platforms_efi-64'
|
39
|
+
flags << 'libzfs' if @o.fs == 'zfs'
|
40
|
+
flags << 'device-mapper' if @o.fs == 'lvm'
|
41
|
+
use.add(flags)
|
42
|
+
end
|
43
|
+
|
44
|
+
def zfs
|
45
|
+
return unless @o.fs == 'zfs'
|
46
|
+
use = Getch::Gentoo::Use.new('sys-fs/zfs-kmod')
|
47
|
+
use.add('rootfs')
|
48
|
+
use = Getch::Gentoo::Use.new('sys-fs/zfs')
|
49
|
+
use.add('rootfs')
|
50
|
+
end
|
51
|
+
|
52
|
+
def lvm
|
53
|
+
return unless @o.fs == 'lvm'
|
54
|
+
use = Getch::Gentoo::Use.new
|
55
|
+
use.add_global('lvm', 'device-mapper')
|
56
|
+
end
|
57
|
+
|
58
|
+
def cryptsetup
|
59
|
+
return unless @o.encrypt
|
60
|
+
use = Getch::Gentoo::Use.new
|
61
|
+
use.add_global('cryptsetup')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
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.3
|
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-05-
|
38
|
+
date: 2021-05-17 00:00:00.000000000 Z
|
39
39
|
dependencies: []
|
40
40
|
description:
|
41
41
|
email:
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- getch.gemspec
|
55
55
|
- lib/getch.rb
|
56
56
|
- lib/getch/command.rb
|
57
|
+
- lib/getch/config.rb
|
57
58
|
- lib/getch/filesystem.rb
|
58
59
|
- lib/getch/filesystem/clean.rb
|
59
60
|
- lib/getch/filesystem/device.rb
|
@@ -107,6 +108,8 @@ files:
|
|
107
108
|
- lib/getch/gentoo/config.rb
|
108
109
|
- lib/getch/gentoo/sources.rb
|
109
110
|
- lib/getch/gentoo/stage.rb
|
111
|
+
- lib/getch/gentoo/use.rb
|
112
|
+
- lib/getch/gentoo/use_flag.rb
|
110
113
|
- lib/getch/helpers.rb
|
111
114
|
- lib/getch/log.rb
|
112
115
|
- lib/getch/options.rb
|
metadata.gz.sig
CHANGED
Binary file
|