getch 0.1.0 → 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 +95 -22
- data/assets/network-stack.conf +63 -0
- data/bin/getch +12 -4
- data/lib/getch.rb +116 -66
- data/lib/getch/command.rb +19 -5
- data/lib/getch/config.rb +42 -0
- data/lib/getch/config/gentoo.rb +59 -0
- data/lib/getch/config/void.rb +49 -0
- data/lib/getch/filesystem.rb +5 -0
- data/lib/getch/filesystem/.mount.rb.swp +0 -0
- data/lib/getch/filesystem/clean.rb +58 -0
- data/lib/getch/filesystem/device.rb +61 -0
- data/lib/getch/filesystem/ext4.rb +1 -0
- data/lib/getch/filesystem/ext4/config.rb +8 -9
- data/lib/getch/filesystem/ext4/device.rb +2 -7
- data/lib/getch/filesystem/ext4/encrypt.rb +1 -0
- data/lib/getch/filesystem/ext4/encrypt/config.rb +8 -9
- data/lib/getch/filesystem/ext4/encrypt/deps.rb +3 -19
- data/lib/getch/filesystem/ext4/encrypt/device.rb +3 -8
- data/lib/getch/filesystem/ext4/encrypt/format.rb +3 -6
- data/lib/getch/filesystem/ext4/encrypt/mount.rb +5 -43
- data/lib/getch/filesystem/ext4/encrypt/partition.rb +29 -54
- data/lib/getch/filesystem/ext4/encrypt/void.rb +100 -0
- data/lib/getch/filesystem/ext4/format.rb +4 -6
- data/lib/getch/filesystem/ext4/mount.rb +7 -46
- data/lib/getch/filesystem/ext4/partition.rb +16 -39
- data/lib/getch/filesystem/ext4/void.rb +43 -0
- data/lib/getch/filesystem/lvm.rb +1 -0
- data/lib/getch/filesystem/lvm/config.rb +11 -15
- data/lib/getch/filesystem/lvm/deps.rb +4 -19
- data/lib/getch/filesystem/lvm/device.rb +33 -9
- data/lib/getch/filesystem/lvm/encrypt.rb +1 -0
- data/lib/getch/filesystem/lvm/encrypt/config.rb +9 -12
- data/lib/getch/filesystem/lvm/encrypt/deps.rb +4 -21
- data/lib/getch/filesystem/lvm/encrypt/device.rb +33 -9
- data/lib/getch/filesystem/lvm/encrypt/format.rb +3 -4
- data/lib/getch/filesystem/lvm/encrypt/mount.rb +7 -47
- data/lib/getch/filesystem/lvm/encrypt/partition.rb +30 -38
- data/lib/getch/filesystem/lvm/encrypt/void.rb +100 -0
- data/lib/getch/filesystem/lvm/format.rb +12 -8
- data/lib/getch/filesystem/lvm/mount.rb +7 -46
- data/lib/getch/filesystem/lvm/partition.rb +19 -31
- data/lib/getch/filesystem/lvm/void.rb +45 -0
- data/lib/getch/filesystem/mount.rb +56 -0
- data/lib/getch/filesystem/partition.rb +77 -0
- data/lib/getch/filesystem/zfs.rb +1 -0
- data/lib/getch/filesystem/zfs/config.rb +7 -8
- data/lib/getch/filesystem/zfs/deps.rb +24 -12
- data/lib/getch/filesystem/zfs/device.rb +54 -9
- 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 +11 -11
- data/lib/getch/filesystem/zfs/encrypt/deps.rb +24 -14
- data/lib/getch/filesystem/zfs/encrypt/device.rb +54 -9
- data/lib/getch/filesystem/zfs/encrypt/format.rb +84 -3
- data/lib/getch/filesystem/zfs/encrypt/mount.rb +8 -28
- data/lib/getch/filesystem/zfs/encrypt/partition.rb +26 -109
- data/lib/getch/filesystem/zfs/encrypt/void.rb +96 -0
- data/lib/getch/filesystem/zfs/format.rb +97 -4
- data/lib/getch/filesystem/zfs/mount.rb +10 -32
- data/lib/getch/filesystem/zfs/partition.rb +25 -106
- data/lib/getch/filesystem/zfs/void.rb +81 -0
- data/lib/getch/gentoo.rb +20 -16
- data/lib/getch/gentoo/boot.rb +24 -16
- data/lib/getch/gentoo/chroot.rb +16 -25
- data/lib/getch/gentoo/config.rb +67 -15
- data/lib/getch/gentoo/sources.rb +55 -13
- data/lib/getch/gentoo/stage.rb +0 -1
- data/lib/getch/gentoo/use.rb +43 -0
- data/lib/getch/gentoo/use_flag.rb +63 -0
- data/lib/getch/guard.rb +64 -0
- data/lib/getch/helpers.rb +133 -0
- data/lib/getch/log.rb +3 -2
- data/lib/getch/options.rb +46 -24
- 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 +46 -25
- metadata.gz.sig +0 -0
- data/.gitignore +0 -2
- data/CHANGELOG.md +0 -60
- data/Rakefile +0 -21
- data/bin/setup.sh +0 -90
- data/getch.gemspec +0 -25
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require_relative '../../helpers'
|
|
2
|
+
|
|
3
|
+
module Getch
|
|
4
|
+
module FileSystem
|
|
5
|
+
module Lvm
|
|
6
|
+
class Void < Device
|
|
7
|
+
include Helpers::Void
|
|
8
|
+
attr_reader :boot_disk
|
|
9
|
+
|
|
10
|
+
def fstab
|
|
11
|
+
conf = "#{MOUNTPOINT}/etc/fstab"
|
|
12
|
+
File.write(conf, "\n", mode: 'w', chmod: 0644)
|
|
13
|
+
line_fstab(@dev_esp, "/efi vfat noauto,rw,relatime 0 0") if @dev_esp
|
|
14
|
+
line_fstab(@dev_boot, "/boot ext4 noauto,rw,relatime 0 0") if @dev_boot
|
|
15
|
+
add_line(conf, "#{@lv_swap} swap swap rw,noatime,discard 0 0") if @lv_swap
|
|
16
|
+
add_line(conf, "#{@lv_home} /home/#{@user} ext4 rw,noatime,discard 0 2") if @lv_home
|
|
17
|
+
add_line(conf, "#{@lv_root} / ext4 rw,relatime 0 1")
|
|
18
|
+
add_line(conf, "tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def config_dracut
|
|
22
|
+
conf = "#{MOUNTPOINT}/etc/dracut.conf.d/lvm.conf"
|
|
23
|
+
# dracut: value+= should be surrounding by white space
|
|
24
|
+
content = [
|
|
25
|
+
"hostonly=\"yes\"",
|
|
26
|
+
"omit_dracutmodules+=\" btrfs \"",
|
|
27
|
+
""
|
|
28
|
+
]
|
|
29
|
+
File.write(conf, content.join("\n"), mode: 'w', chmod: 0644)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def kernel_cmdline_dracut
|
|
33
|
+
conf = "#{MOUNTPOINT}/etc/dracut.conf.d/cmdline.conf"
|
|
34
|
+
c="kernel_cmdline=\"rd.lvm.vg=#{@vg} rootflags=rw,relatime\""
|
|
35
|
+
File.write(conf, "#{c}\n", mode: 'w', chmod: 0644)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def finish
|
|
39
|
+
puts "+ Enter in your system: chroot /mnt /bin/bash"
|
|
40
|
+
puts "+ Reboot with: shutdown -r now"
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
|
|
3
|
+
module Getch
|
|
4
|
+
module FileSystem
|
|
5
|
+
class Mount
|
|
6
|
+
def initialize
|
|
7
|
+
@root_dir = MOUNTPOINT
|
|
8
|
+
@boot_dir = "#{@root_dir}/boot"
|
|
9
|
+
@boot_efi_dir = "#{@root_dir}/efi"
|
|
10
|
+
@home_dir = "#{@root_dir}/home"
|
|
11
|
+
@state = Getch::States.new()
|
|
12
|
+
@log = Getch::Log.new
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def swap(dev)
|
|
16
|
+
return if ! dev
|
|
17
|
+
if Helpers::grep?('/proc/swaps', /^\/dev/)
|
|
18
|
+
exec("swapoff #{dev}")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
exec("swapon #{dev}")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def root(dev)
|
|
25
|
+
return if ! dev
|
|
26
|
+
Helpers::mkdir(@root_dir)
|
|
27
|
+
exec("mount #{dev} #{@root_dir}")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def esp(dev)
|
|
31
|
+
return if ! dev
|
|
32
|
+
Helpers::mkdir(@boot_efi_dir)
|
|
33
|
+
exec("mount #{dev} #{@boot_efi_dir}")
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def boot(dev)
|
|
37
|
+
return if ! dev
|
|
38
|
+
Helpers::mkdir(@boot_dir)
|
|
39
|
+
exec("mount #{dev} #{@boot_dir}")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def home(dev)
|
|
43
|
+
return if ! dev
|
|
44
|
+
Helpers::mkdir(@home_dir)
|
|
45
|
+
exec("mount #{dev} #{@home_dir}")
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
def exec(cmd)
|
|
51
|
+
@log.info("==> #{cmd}")
|
|
52
|
+
Helpers::sys(cmd)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
module Getch
|
|
2
|
+
module FileSystem
|
|
3
|
+
class Partition
|
|
4
|
+
def initialize
|
|
5
|
+
@log = Getch::Log.new
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def gpt(dev)
|
|
9
|
+
return if ! dev
|
|
10
|
+
disk = disk_name(dev)
|
|
11
|
+
part = dev.match(/[0-9]/)
|
|
12
|
+
exec("sgdisk -n#{part}:1MiB:+1MiB -t#{part}:EF02 #{disk}")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def boot(dev)
|
|
16
|
+
return if ! dev
|
|
17
|
+
disk = disk_name(dev)
|
|
18
|
+
part = dev.match(/[0-9]/)
|
|
19
|
+
if Getch::OPTIONS[:fs] == "zfs"
|
|
20
|
+
exec("sgdisk -n#{part}:0:+2G -t#{part}:BE00 #{disk}")
|
|
21
|
+
else
|
|
22
|
+
exec("sgdisk -n#{part}:0:+128MiB -t#{part}:8300 #{disk}")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def efi(dev)
|
|
27
|
+
return if ! dev
|
|
28
|
+
disk = disk_name(dev)
|
|
29
|
+
part = dev.match(/[0-9]/)
|
|
30
|
+
exec("sgdisk -n#{part}:1M:+260M -t#{part}:EF00 #{disk}")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def swap(dev)
|
|
34
|
+
return if ! dev
|
|
35
|
+
disk = disk_name(dev)
|
|
36
|
+
part = dev.match(/[0-9]/)
|
|
37
|
+
if Getch::OPTIONS[:cache_disk]
|
|
38
|
+
exec("sgdisk -n#{part}:0:0 -t#{part}:8200 #{disk}")
|
|
39
|
+
else
|
|
40
|
+
mem=`awk '/MemTotal/ {print $2}' /proc/meminfo`.chomp + 'K'
|
|
41
|
+
exec("sgdisk -n#{part}:0:+#{mem} -t#{part}:8200 #{disk}")
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def root(dev, code)
|
|
46
|
+
return if ! dev
|
|
47
|
+
disk = disk_name(dev)
|
|
48
|
+
part = dev.match(/[0-9]/)
|
|
49
|
+
exec("sgdisk -n#{part}:0:0 -t#{part}:#{code} #{disk}")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def home(dev, code)
|
|
53
|
+
return if ! dev
|
|
54
|
+
disk = disk_name(dev)
|
|
55
|
+
part = dev.match(/[0-9]/)
|
|
56
|
+
if Getch::OPTIONS[:home_disk]
|
|
57
|
+
exec("sgdisk -n#{part}:0:0 -t#{part}:#{code} #{disk}")
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
private
|
|
62
|
+
|
|
63
|
+
def disk_name(dev)
|
|
64
|
+
dev.match(/[^0-9]+/)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def exec(cmd)
|
|
68
|
+
@log.debug "Partition disk with #{cmd}"
|
|
69
|
+
if Getch::OPTIONS[:encrypt]
|
|
70
|
+
Helpers::sys(cmd)
|
|
71
|
+
else
|
|
72
|
+
Getch::Command.new(cmd).run!
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
data/lib/getch/filesystem/zfs.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Getch
|
|
2
2
|
module FileSystem
|
|
3
3
|
module Zfs
|
|
4
|
-
class Config <
|
|
4
|
+
class Config < Device
|
|
5
5
|
def initialize
|
|
6
6
|
super
|
|
7
7
|
gen_uuid
|
|
@@ -17,13 +17,13 @@ module Getch
|
|
|
17
17
|
|
|
18
18
|
def systemd_boot
|
|
19
19
|
return if ! Helpers::efi?
|
|
20
|
-
esp = '/
|
|
20
|
+
esp = '/efi'
|
|
21
21
|
dir = "#{@root_dir}/#{esp}/loader/entries/"
|
|
22
22
|
datas_gentoo = [
|
|
23
23
|
'title Gentoo Linux',
|
|
24
24
|
'linux /vmlinuz',
|
|
25
25
|
'initrd /initramfs',
|
|
26
|
-
"options resume=UUID=#{@uuid_swap} root=ZFS=#{@pool_name}/ROOT
|
|
26
|
+
"options resume=UUID=#{@uuid_swap} root=ZFS=#{@pool_name}/ROOT/#{@n} init=#{@init} dozfs"
|
|
27
27
|
]
|
|
28
28
|
File.write("#{dir}/gentoo.conf", datas_gentoo.join("\n"))
|
|
29
29
|
end
|
|
@@ -33,7 +33,7 @@ module Getch
|
|
|
33
33
|
return if Helpers::efi?
|
|
34
34
|
file = "#{@root_dir}/etc/default/grub"
|
|
35
35
|
cmdline = [
|
|
36
|
-
"GRUB_CMDLINE_LINUX=\"resume=UUID=#{@uuid_swap} root=ZFS=#{@pool_name}/ROOT
|
|
36
|
+
"GRUB_CMDLINE_LINUX=\"resume=UUID=#{@uuid_swap} root=ZFS=#{@pool_name}/ROOT/#{@n} init=#{@init} dozfs\""
|
|
37
37
|
]
|
|
38
38
|
File.write("#{file}", cmdline.join("\n"), mode: 'a')
|
|
39
39
|
end
|
|
@@ -42,15 +42,14 @@ module Getch
|
|
|
42
42
|
|
|
43
43
|
def gen_uuid
|
|
44
44
|
@uuid_swap = `lsblk -o "UUID" #{@dev_swap} | tail -1`.chomp()
|
|
45
|
-
@
|
|
46
|
-
@uuid_boot_efi = `lsblk -o "UUID" #{@dev_boot_efi} | tail -1`.chomp() if @dev_boot_efi
|
|
45
|
+
@uuid_esp = `lsblk -o "UUID" #{@dev_esp} | tail -1`.chomp() if @dev_esp
|
|
47
46
|
end
|
|
48
47
|
|
|
49
48
|
def data_fstab
|
|
50
|
-
|
|
49
|
+
efi = @dev_esp ? "UUID=#{@uuid_esp} /efi vfat noauto,noatime 1 2" : ''
|
|
51
50
|
swap = @dev_swap ? "UUID=#{@uuid_swap} none swap discard 0 0" : ''
|
|
52
51
|
|
|
53
|
-
[
|
|
52
|
+
[ efi, swap ]
|
|
54
53
|
end
|
|
55
54
|
end
|
|
56
55
|
end
|
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
module Getch
|
|
2
2
|
module FileSystem
|
|
3
3
|
module Zfs
|
|
4
|
-
class Deps <
|
|
5
|
-
def
|
|
6
|
-
|
|
4
|
+
class Deps < Device
|
|
5
|
+
def make
|
|
6
|
+
unstable_zfs
|
|
7
7
|
install_deps
|
|
8
8
|
zfs_mountpoint
|
|
9
9
|
auto_module_rebuild
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def make
|
|
13
10
|
hostid
|
|
14
11
|
options_make
|
|
15
12
|
Getch::Make.new("genkernel --kernel-config=/usr/src/linux/.config all").run!
|
|
13
|
+
zed_update_path
|
|
16
14
|
end
|
|
17
15
|
|
|
18
16
|
private
|
|
17
|
+
|
|
18
|
+
def unstable_zfs
|
|
19
|
+
conf = "#{MOUNTPOINT}/etc/portage/package.accept_keywords/zfs"
|
|
20
|
+
data = [
|
|
21
|
+
"sys-fs/zfs-kmod",
|
|
22
|
+
"sys-fs/zfs"
|
|
23
|
+
]
|
|
24
|
+
File.write(conf, data.join("\n"), mode: "w")
|
|
25
|
+
end
|
|
26
|
+
|
|
19
27
|
def install_deps
|
|
20
|
-
|
|
21
|
-
exec("euse -E rootfs") if ! Helpers::grep?("#{MOUNTPOINT}/etc/portage/make.conf", /rootfs/)
|
|
22
|
-
Getch::Garden.new('-a zfs').run!
|
|
28
|
+
Getch::Bask.new('-a zfs').run!
|
|
23
29
|
Getch::Make.new("make modules_prepare").run!
|
|
24
30
|
Getch::Make.new("make -j$(nproc)").run!
|
|
25
31
|
Getch::Emerge.new('genkernel sys-fs/zfs').pkg!
|
|
@@ -32,11 +38,18 @@ module Getch
|
|
|
32
38
|
Helpers::touch("#{MOUNTPOINT}/etc/zfs/zfs-list.cache/#{@pool_name}")
|
|
33
39
|
exec("ln -fs /usr/libexec/zfs/zed.d/history_event-zfs-list-cacher.sh /etc/zfs/zed.d/")
|
|
34
40
|
exec("systemctl start zfs-zed.service")
|
|
35
|
-
Helpers::sys("sed -Ei \"s|/mnt/?|/|\" #{MOUNTPOINT}/etc/zfs/zfs-list.cache/*")
|
|
36
41
|
exec("systemctl enable zfs-zed.service")
|
|
37
42
|
exec("systemctl enable zfs.target")
|
|
38
43
|
end
|
|
39
44
|
|
|
45
|
+
def zed_update_path
|
|
46
|
+
Dir.glob("#{MOUNTPOINT}/etc/zfs/zfs-list.cache/*").each { |f|
|
|
47
|
+
if !system("sed", "-Ei", "s|#{MOUNTPOINT}/?|/|", f)
|
|
48
|
+
raise "system exec sed"
|
|
49
|
+
end
|
|
50
|
+
}
|
|
51
|
+
end
|
|
52
|
+
|
|
40
53
|
def auto_module_rebuild
|
|
41
54
|
g_dir="#{MOUNTPOINT}/etc/portage/env/sys-kernel"
|
|
42
55
|
Helpers::mkdir(g_dir)
|
|
@@ -59,8 +72,7 @@ EOF
|
|
|
59
72
|
end
|
|
60
73
|
|
|
61
74
|
def hostid
|
|
62
|
-
|
|
63
|
-
File.write("#{MOUNTPOINT}/etc/hostid", hostid_value, mode: 'w')
|
|
75
|
+
exec "zgenhostid $(hostid)"
|
|
64
76
|
end
|
|
65
77
|
|
|
66
78
|
def options_make
|
|
@@ -1,17 +1,62 @@
|
|
|
1
1
|
module Getch
|
|
2
2
|
module FileSystem
|
|
3
3
|
module Zfs
|
|
4
|
-
class Device
|
|
4
|
+
class Device < Getch::FileSystem::Device
|
|
5
5
|
def initialize
|
|
6
|
-
|
|
7
|
-
@
|
|
8
|
-
@
|
|
9
|
-
@
|
|
10
|
-
@dev_swap = Helpers::efi? ? "/dev/#{@disk}2" : "/dev/#{@disk}3"
|
|
11
|
-
@dev_root = Helpers::efi? ? "/dev/#{@disk}3" : "/dev/#{@disk}4"
|
|
12
|
-
@boot_pool_name = 'bpool'
|
|
13
|
-
@pool_name = 'zpool'
|
|
6
|
+
super
|
|
7
|
+
@id = Helpers::pool_id(@dev_root)
|
|
8
|
+
@boot_pool_name = "bpool-#{@id}"
|
|
9
|
+
@pool_name = "rpool-#{@id}"
|
|
14
10
|
@zfs_home = @user ? true : false
|
|
11
|
+
@n = Getch::OPTIONS[:os]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def search_boot
|
|
17
|
+
if @efi
|
|
18
|
+
if @boot_disk
|
|
19
|
+
@dev_esp = "/dev/#{@boot_disk}1"
|
|
20
|
+
@dev_boot = "/dev/#{@boot_disk}2" if Getch::OPTIONS[:os] == 'void'
|
|
21
|
+
else
|
|
22
|
+
@dev_esp = "/dev/#{@disk}1"
|
|
23
|
+
@root_part += 1
|
|
24
|
+
if Getch::OPTIONS[:os] == 'void'
|
|
25
|
+
@dev_boot = "/dev/#{@disk}#{@root_part}"
|
|
26
|
+
@root_part += 1
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
else
|
|
30
|
+
if @boot_disk
|
|
31
|
+
@dev_gpt = "/dev/#{@boot_disk}1"
|
|
32
|
+
@dev_boot = "/dev/#{@boot_disk}2"
|
|
33
|
+
@dev_grub = "/dev/#{@boot_disk}"
|
|
34
|
+
else
|
|
35
|
+
@dev_gpt = "/dev/#{@disk}1"
|
|
36
|
+
@dev_boot = "/dev/#{@disk}2"
|
|
37
|
+
@dev_grub = "/dev/#{@disk}"
|
|
38
|
+
@root_part += 2
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def search_swap
|
|
44
|
+
if @cache_disk
|
|
45
|
+
@dev_swap = "/dev/#{@cache_disk}1"
|
|
46
|
+
@dev_log = "/dev/#{@cache_disk}2"
|
|
47
|
+
@dev_cache = "/dev/#{@cache_disk}3"
|
|
48
|
+
else
|
|
49
|
+
@dev_swap = "/dev/#{@disk}#{@root_part}"
|
|
50
|
+
@root_part += 1
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def search_root
|
|
55
|
+
if @root_part == 1
|
|
56
|
+
@dev_root = "/dev/#{@disk}"
|
|
57
|
+
else
|
|
58
|
+
@dev_root = "/dev/#{@disk}#{@root_part}"
|
|
59
|
+
end
|
|
15
60
|
end
|
|
16
61
|
end
|
|
17
62
|
end
|
|
Binary file
|
|
@@ -2,7 +2,7 @@ module Getch
|
|
|
2
2
|
module FileSystem
|
|
3
3
|
module Zfs
|
|
4
4
|
module Encrypt
|
|
5
|
-
class Config <
|
|
5
|
+
class Config < Device
|
|
6
6
|
def initialize
|
|
7
7
|
super
|
|
8
8
|
gen_uuid
|
|
@@ -18,31 +18,31 @@ module Getch
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def systemd_boot
|
|
21
|
-
return if !
|
|
22
|
-
esp = '/
|
|
21
|
+
return if ! @efi
|
|
22
|
+
esp = '/efi'
|
|
23
23
|
dir = "#{@root_dir}/#{esp}/loader/entries/"
|
|
24
24
|
datas_gentoo = [
|
|
25
25
|
'title Gentoo Linux',
|
|
26
26
|
'linux /vmlinuz',
|
|
27
27
|
'initrd /initramfs',
|
|
28
|
-
"options root=ZFS=#{@pool_name}/ROOT
|
|
28
|
+
"options root=ZFS=#{@pool_name}/ROOT/#{@n} init=#{@init} dozfs keymap=#{Getch::OPTIONS[:keymap]}"
|
|
29
29
|
]
|
|
30
30
|
File.write("#{dir}/gentoo.conf", datas_gentoo.join("\n"))
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def crypttab
|
|
34
34
|
datas = [
|
|
35
|
-
"cryptswap
|
|
35
|
+
"cryptswap PARTUUID=#{@partuuid_swap} /dev/urandom swap,discard,cipher=aes-xts-plain64:sha256,size=512"
|
|
36
36
|
]
|
|
37
37
|
File.write("#{@root_dir}/etc/crypttab", datas.join("\n"))
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
# See https://wiki.gentoo.org/wiki/ZFS#ZFS_root
|
|
41
41
|
def grub
|
|
42
|
-
return if
|
|
42
|
+
return if @efi
|
|
43
43
|
file = "#{@root_dir}/etc/default/grub"
|
|
44
44
|
cmdline = [
|
|
45
|
-
"GRUB_CMDLINE_LINUX=\"root=ZFS=#{@pool_name}/ROOT
|
|
45
|
+
"GRUB_CMDLINE_LINUX=\"root=ZFS=#{@pool_name}/ROOT/#{@n} init=#{@init} dozfs keymap=#{Getch::OPTIONS[:keymap]}\""
|
|
46
46
|
]
|
|
47
47
|
File.write("#{file}", cmdline.join("\n"), mode: 'a')
|
|
48
48
|
end
|
|
@@ -50,13 +50,13 @@ module Getch
|
|
|
50
50
|
private
|
|
51
51
|
|
|
52
52
|
def gen_uuid
|
|
53
|
-
@
|
|
54
|
-
@
|
|
53
|
+
@partuuid_swap = Helpers::partuuid(@dev_swap)
|
|
54
|
+
@uuid_esp = `lsblk -o "UUID" #{@dev_esp} | tail -1`.chomp() if @dev_esp
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def data_fstab
|
|
58
|
-
boot_efi = @
|
|
59
|
-
swap = @dev_swap ? "/dev/mapper/cryptswap none swap
|
|
58
|
+
boot_efi = @dev_esp ? "UUID=#{@uuid_esp} /efi vfat noauto,noatime 1 2" : ''
|
|
59
|
+
swap = @dev_swap ? "/dev/mapper/cryptswap none swap sw 0 0" : ''
|
|
60
60
|
|
|
61
61
|
[ boot_efi, swap ]
|
|
62
62
|
end
|