getch 0.1.2 → 0.1.9
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 +66 -32
- data/assets/network-stack.conf +63 -0
- data/assets/system.conf +38 -0
- data/bin/getch +12 -4
- data/lib/cmdline.rb +128 -0
- data/lib/getch/command.rb +32 -22
- data/lib/getch/config/gentoo.rb +58 -0
- data/lib/getch/config/void.rb +47 -0
- data/lib/getch/config.rb +45 -0
- data/lib/getch/filesystem/clean.rb +22 -15
- data/lib/getch/filesystem/device.rb +8 -6
- data/lib/getch/filesystem/ext4/config.rb +8 -4
- data/lib/getch/filesystem/ext4/deps.rb +3 -1
- data/lib/getch/filesystem/ext4/device.rb +2 -3
- data/lib/getch/filesystem/ext4/encrypt/config.rb +15 -11
- data/lib/getch/filesystem/ext4/encrypt/deps.rb +5 -10
- data/lib/getch/filesystem/ext4/encrypt/device.rb +5 -3
- data/lib/getch/filesystem/ext4/encrypt/format.rb +4 -2
- data/lib/getch/filesystem/ext4/encrypt/mount.rb +3 -3
- data/lib/getch/filesystem/ext4/encrypt/partition.rb +29 -35
- data/lib/getch/filesystem/ext4/encrypt/void.rb +101 -0
- data/lib/getch/filesystem/ext4/encrypt.rb +3 -0
- data/lib/getch/filesystem/ext4/format.rb +4 -1
- data/lib/getch/filesystem/ext4/mount.rb +3 -0
- data/lib/getch/filesystem/ext4/partition.rb +11 -8
- data/lib/getch/filesystem/ext4/void.rb +44 -0
- data/lib/getch/filesystem/ext4.rb +3 -0
- data/lib/getch/filesystem/lvm/config.rb +10 -29
- data/lib/getch/filesystem/lvm/deps.rb +7 -11
- data/lib/getch/filesystem/lvm/device.rb +5 -3
- data/lib/getch/filesystem/lvm/encrypt/config.rb +17 -17
- data/lib/getch/filesystem/lvm/encrypt/deps.rb +8 -12
- data/lib/getch/filesystem/lvm/encrypt/device.rb +7 -5
- data/lib/getch/filesystem/lvm/encrypt/format.rb +5 -2
- data/lib/getch/filesystem/lvm/encrypt/mount.rb +4 -2
- data/lib/getch/filesystem/lvm/encrypt/partition.rb +17 -13
- data/lib/getch/filesystem/lvm/encrypt/void.rb +101 -0
- data/lib/getch/filesystem/lvm/encrypt.rb +3 -0
- data/lib/getch/filesystem/lvm/format.rb +4 -1
- data/lib/getch/filesystem/lvm/mount.rb +3 -0
- data/lib/getch/filesystem/lvm/partition.rb +10 -7
- data/lib/getch/filesystem/lvm/void.rb +46 -0
- data/lib/getch/filesystem/lvm.rb +3 -0
- data/lib/getch/filesystem/mount.rb +19 -12
- data/lib/getch/filesystem/partition.rb +19 -11
- data/lib/getch/filesystem/zfs/config.rb +10 -24
- data/lib/getch/filesystem/zfs/deps.rb +28 -58
- data/lib/getch/filesystem/zfs/device.rb +9 -1
- data/lib/getch/filesystem/zfs/encrypt/config.rb +12 -28
- data/lib/getch/filesystem/zfs/encrypt/deps.rb +29 -60
- data/lib/getch/filesystem/zfs/encrypt/device.rb +9 -1
- data/lib/getch/filesystem/zfs/encrypt/format.rb +24 -22
- data/lib/getch/filesystem/zfs/encrypt/mount.rb +15 -14
- data/lib/getch/filesystem/zfs/encrypt/partition.rb +24 -18
- data/lib/getch/filesystem/zfs/encrypt/void.rb +97 -0
- data/lib/getch/filesystem/zfs/encrypt.rb +3 -0
- data/lib/getch/filesystem/zfs/format.rb +21 -18
- data/lib/getch/filesystem/zfs/mount.rb +12 -13
- data/lib/getch/filesystem/zfs/partition.rb +20 -15
- data/lib/getch/filesystem/zfs/void.rb +81 -0
- data/lib/getch/filesystem/zfs.rb +3 -0
- data/lib/getch/filesystem.rb +2 -0
- data/lib/getch/gentoo/boot.rb +29 -67
- data/lib/getch/gentoo/bootloader.rb +68 -0
- data/lib/getch/gentoo/chroot.rb +26 -29
- data/lib/getch/gentoo/config.rb +69 -31
- data/lib/getch/gentoo/sources.rb +73 -38
- data/lib/getch/gentoo/stage.rb +12 -13
- data/lib/getch/gentoo/use.rb +39 -0
- data/lib/getch/gentoo/use_flag.rb +89 -0
- data/lib/getch/gentoo.rb +39 -21
- data/lib/getch/guard.rb +71 -0
- data/lib/getch/helpers.rb +180 -48
- data/lib/getch/log.rb +10 -7
- data/lib/getch/options.rb +50 -41
- data/lib/getch/states.rb +10 -3
- data/lib/getch/version.rb +1 -1
- data/lib/getch/void/boot.rb +84 -0
- data/lib/getch/void/chroot.rb +56 -0
- data/lib/getch/void/config.rb +90 -0
- data/lib/getch/void/stage.rb +69 -0
- data/lib/getch/void.rb +65 -0
- data/lib/getch.rb +125 -74
- data.tar.gz.sig +0 -0
- metadata +28 -10
- metadata.gz.sig +0 -0
- data/.gitignore +0 -2
- data/CHANGELOG.md +0 -80
- data/Rakefile +0 -21
- data/bin/setup.sh +0 -90
- data/getch.gemspec +0 -25
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Getch
|
|
2
4
|
module FileSystem
|
|
3
5
|
module Lvm
|
|
4
6
|
class Partition < Getch::FileSystem::Lvm::Device
|
|
5
7
|
def initialize
|
|
6
8
|
super
|
|
7
|
-
@state = Getch::States.new
|
|
9
|
+
@state = Getch::States.new
|
|
8
10
|
@partition = Getch::FileSystem::Partition.new
|
|
9
11
|
@clean = Getch::FileSystem::Clean
|
|
10
12
|
run_partition
|
|
@@ -12,9 +14,10 @@ module Getch
|
|
|
12
14
|
|
|
13
15
|
def run_partition
|
|
14
16
|
return if STATES[:partition ]
|
|
17
|
+
|
|
15
18
|
@clean.old_vg(@dev_root, @vg)
|
|
16
|
-
@clean.
|
|
17
|
-
@clean.
|
|
19
|
+
@clean.hdd(@disk)
|
|
20
|
+
@clean.external_disk(@disk, @boot_disk, @cache_disk, @home_disk)
|
|
18
21
|
partition
|
|
19
22
|
lvm
|
|
20
23
|
@state.partition
|
|
@@ -23,13 +26,13 @@ module Getch
|
|
|
23
26
|
private
|
|
24
27
|
|
|
25
28
|
def partition
|
|
26
|
-
if Helpers
|
|
29
|
+
if Helpers.efi?
|
|
27
30
|
@partition.efi(@dev_esp)
|
|
28
|
-
@partition.root(@dev_root,
|
|
31
|
+
@partition.root(@dev_root, '8e00')
|
|
29
32
|
else
|
|
30
33
|
@partition.gpt(@dev_gpt)
|
|
31
34
|
@partition.boot(@dev_boot)
|
|
32
|
-
@partition.root(@dev_root,
|
|
35
|
+
@partition.root(@dev_root, '8e00')
|
|
33
36
|
end
|
|
34
37
|
end
|
|
35
38
|
|
|
@@ -47,7 +50,7 @@ module Getch
|
|
|
47
50
|
exec("lvcreate -y -Wy -Zy -l 100%FREE -n root #{@vg}")
|
|
48
51
|
end
|
|
49
52
|
|
|
50
|
-
exec(
|
|
53
|
+
exec('vgchange --available y')
|
|
51
54
|
end
|
|
52
55
|
|
|
53
56
|
# Follow https://wiki.archlinux.org/index.php/Partitioning
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Getch
|
|
4
|
+
module FileSystem
|
|
5
|
+
module Lvm
|
|
6
|
+
class Void < Device
|
|
7
|
+
include Helpers::Void
|
|
8
|
+
|
|
9
|
+
attr_reader :boot_disk
|
|
10
|
+
|
|
11
|
+
def fstab
|
|
12
|
+
conf = "#{MOUNTPOINT}/etc/fstab"
|
|
13
|
+
File.write(conf, "\n", mode: 'w', chmod: 0644)
|
|
14
|
+
line_fstab(@dev_esp, '/efi vfat noauto,rw,relatime 0 0') if @dev_esp
|
|
15
|
+
line_fstab(@dev_boot, '/boot ext4 noauto,rw,relatime 0 0') if @dev_boot
|
|
16
|
+
add_line(conf, "#{@lv_swap} swap swap rw,noatime,discard 0 0") if @lv_swap
|
|
17
|
+
add_line(conf, "#{@lv_home} /home/#{@user} ext4 rw,noatime,discard 0 2") if @lv_home
|
|
18
|
+
add_line(conf, "#{@lv_root} / ext4 rw,relatime 0 1")
|
|
19
|
+
add_line(conf, 'tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0')
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def config_dracut
|
|
23
|
+
conf = "#{MOUNTPOINT}/etc/dracut.conf.d/lvm.conf"
|
|
24
|
+
# dracut: value+= should be surrounding by white space
|
|
25
|
+
content = [
|
|
26
|
+
"hostonly=\"yes\"",
|
|
27
|
+
"omit_dracutmodules+=\" btrfs \"",
|
|
28
|
+
""
|
|
29
|
+
]
|
|
30
|
+
File.write(conf, content.join("\n"), mode: 'w', chmod: 0644)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def kernel_cmdline_dracut
|
|
34
|
+
conf = "#{MOUNTPOINT}/etc/dracut.conf.d/cmdline.conf"
|
|
35
|
+
c="kernel_cmdline=\"rd.lvm.vg=#{@vg} rootflags=rw,relatime\""
|
|
36
|
+
File.write(conf, "#{c}\n", mode: 'w', chmod: 0644)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def finish
|
|
40
|
+
puts '+ Enter in your system: chroot /mnt /bin/bash'
|
|
41
|
+
puts '+ Reboot with: shutdown -r now'
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
data/lib/getch/filesystem/lvm.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Getch
|
|
2
4
|
module FileSystem
|
|
3
5
|
module Lvm
|
|
@@ -11,4 +13,5 @@ require_relative 'lvm/format'
|
|
|
11
13
|
require_relative 'lvm/mount'
|
|
12
14
|
require_relative 'lvm/config'
|
|
13
15
|
require_relative 'lvm/deps'
|
|
16
|
+
require_relative 'lvm/void'
|
|
14
17
|
require_relative 'lvm/encrypt'
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'fileutils'
|
|
2
4
|
|
|
3
5
|
module Getch
|
|
@@ -8,13 +10,14 @@ module Getch
|
|
|
8
10
|
@boot_dir = "#{@root_dir}/boot"
|
|
9
11
|
@boot_efi_dir = "#{@root_dir}/efi"
|
|
10
12
|
@home_dir = "#{@root_dir}/home"
|
|
11
|
-
@state = Getch::States.new
|
|
13
|
+
@state = Getch::States.new
|
|
12
14
|
@log = Getch::Log.new
|
|
13
15
|
end
|
|
14
16
|
|
|
15
17
|
def swap(dev)
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
+
return unless dev
|
|
19
|
+
|
|
20
|
+
if Helpers.grep?('/proc/swaps', /^\/dev/)
|
|
18
21
|
exec("swapoff #{dev}")
|
|
19
22
|
end
|
|
20
23
|
|
|
@@ -22,26 +25,30 @@ module Getch
|
|
|
22
25
|
end
|
|
23
26
|
|
|
24
27
|
def root(dev)
|
|
25
|
-
return
|
|
26
|
-
|
|
28
|
+
return unless dev
|
|
29
|
+
|
|
30
|
+
Helpers.mkdir(@root_dir)
|
|
27
31
|
exec("mount #{dev} #{@root_dir}")
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
def esp(dev)
|
|
31
|
-
return
|
|
32
|
-
|
|
35
|
+
return unless dev
|
|
36
|
+
|
|
37
|
+
Helpers.mkdir(@boot_efi_dir)
|
|
33
38
|
exec("mount #{dev} #{@boot_efi_dir}")
|
|
34
39
|
end
|
|
35
40
|
|
|
36
41
|
def boot(dev)
|
|
37
|
-
return
|
|
38
|
-
|
|
42
|
+
return unless dev
|
|
43
|
+
|
|
44
|
+
Helpers.mkdir(@boot_dir)
|
|
39
45
|
exec("mount #{dev} #{@boot_dir}")
|
|
40
46
|
end
|
|
41
47
|
|
|
42
48
|
def home(dev)
|
|
43
|
-
return
|
|
44
|
-
|
|
49
|
+
return unless dev
|
|
50
|
+
|
|
51
|
+
Helpers.mkdir(@home_dir)
|
|
45
52
|
exec("mount #{dev} #{@home_dir}")
|
|
46
53
|
end
|
|
47
54
|
|
|
@@ -49,7 +56,7 @@ module Getch
|
|
|
49
56
|
|
|
50
57
|
def exec(cmd)
|
|
51
58
|
@log.info("==> #{cmd}")
|
|
52
|
-
Helpers
|
|
59
|
+
Helpers.sys(cmd)
|
|
53
60
|
end
|
|
54
61
|
end
|
|
55
62
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Getch
|
|
2
4
|
module FileSystem
|
|
3
5
|
class Partition
|
|
@@ -6,17 +8,19 @@ module Getch
|
|
|
6
8
|
end
|
|
7
9
|
|
|
8
10
|
def gpt(dev)
|
|
9
|
-
return
|
|
11
|
+
return unless dev
|
|
12
|
+
|
|
10
13
|
disk = disk_name(dev)
|
|
11
14
|
part = dev.match(/[0-9]/)
|
|
12
15
|
exec("sgdisk -n#{part}:1MiB:+1MiB -t#{part}:EF02 #{disk}")
|
|
13
16
|
end
|
|
14
17
|
|
|
15
18
|
def boot(dev)
|
|
16
|
-
return
|
|
19
|
+
return unless dev
|
|
20
|
+
|
|
17
21
|
disk = disk_name(dev)
|
|
18
22
|
part = dev.match(/[0-9]/)
|
|
19
|
-
if
|
|
23
|
+
if Getch::OPTIONS[:fs] == 'zfs'
|
|
20
24
|
exec("sgdisk -n#{part}:0:+2G -t#{part}:BE00 #{disk}")
|
|
21
25
|
else
|
|
22
26
|
exec("sgdisk -n#{part}:0:+128MiB -t#{part}:8300 #{disk}")
|
|
@@ -24,17 +28,19 @@ module Getch
|
|
|
24
28
|
end
|
|
25
29
|
|
|
26
30
|
def efi(dev)
|
|
27
|
-
return
|
|
31
|
+
return unless dev
|
|
32
|
+
|
|
28
33
|
disk = disk_name(dev)
|
|
29
34
|
part = dev.match(/[0-9]/)
|
|
30
35
|
exec("sgdisk -n#{part}:1M:+260M -t#{part}:EF00 #{disk}")
|
|
31
36
|
end
|
|
32
37
|
|
|
33
38
|
def swap(dev)
|
|
34
|
-
return
|
|
39
|
+
return unless dev
|
|
40
|
+
|
|
35
41
|
disk = disk_name(dev)
|
|
36
42
|
part = dev.match(/[0-9]/)
|
|
37
|
-
if
|
|
43
|
+
if Getch::OPTIONS[:cache_disk]
|
|
38
44
|
exec("sgdisk -n#{part}:0:0 -t#{part}:8200 #{disk}")
|
|
39
45
|
else
|
|
40
46
|
mem=`awk '/MemTotal/ {print $2}' /proc/meminfo`.chomp + 'K'
|
|
@@ -43,17 +49,19 @@ module Getch
|
|
|
43
49
|
end
|
|
44
50
|
|
|
45
51
|
def root(dev, code)
|
|
46
|
-
return
|
|
52
|
+
return unless dev
|
|
53
|
+
|
|
47
54
|
disk = disk_name(dev)
|
|
48
55
|
part = dev.match(/[0-9]/)
|
|
49
56
|
exec("sgdisk -n#{part}:0:0 -t#{part}:#{code} #{disk}")
|
|
50
57
|
end
|
|
51
58
|
|
|
52
59
|
def home(dev, code)
|
|
53
|
-
return
|
|
60
|
+
return unless dev
|
|
61
|
+
|
|
54
62
|
disk = disk_name(dev)
|
|
55
63
|
part = dev.match(/[0-9]/)
|
|
56
|
-
if
|
|
64
|
+
if Getch::OPTIONS[:home_disk]
|
|
57
65
|
exec("sgdisk -n#{part}:0:0 -t#{part}:#{code} #{disk}")
|
|
58
66
|
end
|
|
59
67
|
end
|
|
@@ -66,8 +74,8 @@ module Getch
|
|
|
66
74
|
|
|
67
75
|
def exec(cmd)
|
|
68
76
|
@log.debug "Partition disk with #{cmd}"
|
|
69
|
-
if
|
|
70
|
-
Helpers
|
|
77
|
+
if Getch::OPTIONS[:encrypt]
|
|
78
|
+
Helpers.sys(cmd)
|
|
71
79
|
else
|
|
72
80
|
Getch::Command.new(cmd).run!
|
|
73
81
|
end
|
|
@@ -1,41 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Getch
|
|
2
4
|
module FileSystem
|
|
3
5
|
module Zfs
|
|
4
|
-
class Config <
|
|
6
|
+
class Config < Device
|
|
5
7
|
def initialize
|
|
6
8
|
super
|
|
7
9
|
gen_uuid
|
|
8
|
-
@root_dir = MOUNTPOINT
|
|
9
10
|
@init = '/usr/lib/systemd/systemd'
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
def fstab
|
|
13
|
-
file = "#{
|
|
14
|
+
file = "#{MOUNTPOINT}/etc/fstab"
|
|
14
15
|
datas = data_fstab
|
|
15
|
-
File.write
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def systemd_boot
|
|
19
|
-
return if ! Helpers::efi?
|
|
20
|
-
esp = '/efi'
|
|
21
|
-
dir = "#{@root_dir}/#{esp}/loader/entries/"
|
|
22
|
-
datas_gentoo = [
|
|
23
|
-
'title Gentoo Linux',
|
|
24
|
-
'linux /vmlinuz',
|
|
25
|
-
'initrd /initramfs',
|
|
26
|
-
"options resume=UUID=#{@uuid_swap} root=ZFS=#{@pool_name}/ROOT/gentoo init=#{@init} dozfs"
|
|
27
|
-
]
|
|
28
|
-
File.write("#{dir}/gentoo.conf", datas_gentoo.join("\n"))
|
|
16
|
+
File.write file, datas.join("\n")
|
|
29
17
|
end
|
|
30
18
|
|
|
31
19
|
# See https://wiki.gentoo.org/wiki/ZFS#ZFS_root
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
]
|
|
38
|
-
File.write("#{file}", cmdline.join("\n"), mode: 'a')
|
|
20
|
+
# https://github.com/openzfs/zfs/blob/master/contrib/dracut/README.dracut.markdown
|
|
21
|
+
def cmdline
|
|
22
|
+
src = "#{MOUNTPOINT}/etc/dracut.conf.d/cmdline.conf"
|
|
23
|
+
line = "kernel_cmdline=\"resume=UUID=#{@uuid_swap} root=zfs:#{@pool_name}/ROOT/#{@n} init=#{@init} zfs.force=1 zfs.zfs_arc_max=536870912\""
|
|
24
|
+
Helpers.echo src, line
|
|
39
25
|
end
|
|
40
26
|
|
|
41
27
|
private
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Getch
|
|
2
4
|
module FileSystem
|
|
3
5
|
module Zfs
|
|
4
|
-
class Deps <
|
|
6
|
+
class Deps < Device
|
|
5
7
|
def make
|
|
6
8
|
unstable_zfs
|
|
7
9
|
install_deps
|
|
8
10
|
zfs_mountpoint
|
|
9
|
-
auto_module_rebuild
|
|
10
11
|
hostid
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
config_dracut
|
|
13
|
+
zed_update_path
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
private
|
|
@@ -17,75 +18,44 @@ module Getch
|
|
|
17
18
|
def unstable_zfs
|
|
18
19
|
conf = "#{MOUNTPOINT}/etc/portage/package.accept_keywords/zfs"
|
|
19
20
|
data = [
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
'sys-fs/zfs-kmod',
|
|
22
|
+
'sys-fs/zfs'
|
|
22
23
|
]
|
|
23
|
-
File.write(conf, data.join("\n"), mode:
|
|
24
|
+
File.write(conf, data.join("\n"), mode: 'w')
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
def install_deps
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Getch::Bask.new('-a zfs').run!
|
|
30
|
-
Getch::Make.new("make modules_prepare").run!
|
|
31
|
-
Getch::Make.new("make -j$(nproc)").run!
|
|
32
|
-
Getch::Emerge.new('genkernel sys-fs/zfs').pkg!
|
|
28
|
+
Getch::Emerge.new('sys-kernel/gentoo-kernel').pkg!
|
|
29
|
+
Getch::Emerge.new('sys-fs/zfs').pkg!
|
|
33
30
|
end
|
|
34
31
|
|
|
35
32
|
# See: https://wiki.archlinux.org/index.php/ZFS#Using_zfs-mount-generator
|
|
36
33
|
def zfs_mountpoint
|
|
37
|
-
Helpers
|
|
38
|
-
Helpers
|
|
39
|
-
Helpers
|
|
40
|
-
exec(
|
|
41
|
-
exec(
|
|
42
|
-
|
|
43
|
-
exec(
|
|
44
|
-
exec("systemctl enable zfs.target")
|
|
34
|
+
Helpers.mkdir("#{MOUNTPOINT}/etc/zfs/zfs-list.cache")
|
|
35
|
+
Helpers.touch("#{MOUNTPOINT}/etc/zfs/zfs-list.cache/#{@boot_pool_name}") if @dev_boot
|
|
36
|
+
Helpers.touch("#{MOUNTPOINT}/etc/zfs/zfs-list.cache/#{@pool_name}")
|
|
37
|
+
exec('ln -fs /usr/libexec/zfs/zed.d/history_event-zfs-list-cacher.sh /etc/zfs/zed.d/')
|
|
38
|
+
exec('systemctl start zfs-zed.service')
|
|
39
|
+
exec('systemctl enable zfs-zed.service')
|
|
40
|
+
exec('systemctl enable zfs.target')
|
|
45
41
|
end
|
|
46
42
|
|
|
47
|
-
def
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
# BUG: reinstalls of a source will cause errors
|
|
54
|
-
CURRENT_KV=$(uname -r)
|
|
55
|
-
# Check to see if genkernel has been run previously for the running kernel and use that config
|
|
56
|
-
if [[ -f "${EROOT}/etc/kernels/kernel-config-${CURRENT_KV}" ]] ; then
|
|
57
|
-
genkernel --kernel-config="${EROOT}/etc/kernels/kernel-config-${CURRENT_KV}" all
|
|
58
|
-
elif [[ -f "${EROOT}/usr/src/linux-${CURRENT_KV}/.config" ]] ; then # Use latest kernel config from current kernel
|
|
59
|
-
genkernel --kernel-config="${EROOT}/usr/src/linux-${CURRENT_KV}/.config" all
|
|
60
|
-
else # No valid configs known
|
|
61
|
-
genkernel all
|
|
62
|
-
fi
|
|
63
|
-
}
|
|
64
|
-
EOF
|
|
65
|
-
File.write("#{g_dir}/gentoo-sources", content)
|
|
43
|
+
def zed_update_path
|
|
44
|
+
Dir.glob("#{MOUNTPOINT}/etc/zfs/zfs-list.cache/*").each { |f|
|
|
45
|
+
unless system('sed', '-Ei', "s|#{MOUNTPOINT}/?|/|", f)
|
|
46
|
+
raise 'system exec sed'
|
|
47
|
+
end
|
|
48
|
+
}
|
|
66
49
|
end
|
|
67
50
|
|
|
68
51
|
def hostid
|
|
69
|
-
|
|
70
|
-
File.write("#{MOUNTPOINT}/etc/hostid", hostid_value, mode: 'w')
|
|
52
|
+
exec 'zgenhostid $(hostid)'
|
|
71
53
|
end
|
|
72
54
|
|
|
73
|
-
def
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
bootloader,
|
|
78
|
-
'INSTALL="yes"',
|
|
79
|
-
'MENUCONFIG="no"',
|
|
80
|
-
'CLEAN="yes"',
|
|
81
|
-
'SAVE_CONFIG="yes"',
|
|
82
|
-
'MOUNTBOOT="no"',
|
|
83
|
-
'MRPROPER="no"',
|
|
84
|
-
'ZFS="yes"',
|
|
85
|
-
'MODULEREBUILD="yes"'
|
|
86
|
-
]
|
|
87
|
-
file = "#{MOUNTPOINT}/etc/genkernel.conf"
|
|
88
|
-
File.write(file, datas.join("\n"), mode: 'a')
|
|
55
|
+
def config_dracut
|
|
56
|
+
conf = "#{MOUNTPOINT}/etc/dracut.conf.d/zfs.conf"
|
|
57
|
+
content = 'hostonly="yes"'
|
|
58
|
+
Helpers.echo conf, content
|
|
89
59
|
end
|
|
90
60
|
|
|
91
61
|
def exec(cmd)
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Getch
|
|
2
4
|
module FileSystem
|
|
3
5
|
module Zfs
|
|
4
6
|
class Device < Getch::FileSystem::Device
|
|
5
7
|
def initialize
|
|
6
8
|
super
|
|
7
|
-
@id = Helpers
|
|
9
|
+
@id = Helpers.pool_id(@dev_root)
|
|
8
10
|
@boot_pool_name = "bpool-#{@id}"
|
|
9
11
|
@pool_name = "rpool-#{@id}"
|
|
10
12
|
@zfs_home = @user ? true : false
|
|
13
|
+
@n = Getch::OPTIONS[:os]
|
|
11
14
|
end
|
|
12
15
|
|
|
13
16
|
private
|
|
@@ -16,9 +19,14 @@ module Getch
|
|
|
16
19
|
if @efi
|
|
17
20
|
if @boot_disk
|
|
18
21
|
@dev_esp = "/dev/#{@boot_disk}1"
|
|
22
|
+
@dev_boot = "/dev/#{@boot_disk}2" if Getch::OPTIONS[:os] == 'void'
|
|
19
23
|
else
|
|
20
24
|
@dev_esp = "/dev/#{@disk}1"
|
|
21
25
|
@root_part += 1
|
|
26
|
+
if Getch::OPTIONS[:os] == 'void'
|
|
27
|
+
@dev_boot = "/dev/#{@disk}#{@root_part}"
|
|
28
|
+
@root_part += 1
|
|
29
|
+
end
|
|
22
30
|
end
|
|
23
31
|
else
|
|
24
32
|
if @boot_disk
|
|
@@ -1,62 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Getch
|
|
2
4
|
module FileSystem
|
|
3
5
|
module Zfs
|
|
4
6
|
module Encrypt
|
|
5
|
-
class Config <
|
|
7
|
+
class Config < Device
|
|
6
8
|
def initialize
|
|
7
9
|
super
|
|
8
10
|
gen_uuid
|
|
9
|
-
@root_dir = MOUNTPOINT
|
|
10
11
|
@init = '/usr/lib/systemd/systemd'
|
|
11
12
|
crypttab
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
def fstab
|
|
15
|
-
file = "#{
|
|
16
|
+
file = "#{MOUNTPOINT}/etc/fstab"
|
|
16
17
|
datas = data_fstab
|
|
17
18
|
File.write(file, datas.join("\n"))
|
|
18
19
|
end
|
|
19
20
|
|
|
20
|
-
def
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
datas_gentoo = [
|
|
25
|
-
'title Gentoo Linux',
|
|
26
|
-
'linux /vmlinuz',
|
|
27
|
-
'initrd /initramfs',
|
|
28
|
-
"options root=ZFS=#{@pool_name}/ROOT/gentoo init=#{@init} dozfs keymap=#{DEFAULT_OPTIONS[:keymap]}"
|
|
29
|
-
]
|
|
30
|
-
File.write("#{dir}/gentoo.conf", datas_gentoo.join("\n"))
|
|
21
|
+
def cmdline
|
|
22
|
+
src = "#{MOUNTPOINT}/etc/dracut.conf.d/cmdline.conf"
|
|
23
|
+
line = "kernel_cmdline=\"root=zfs:#{@pool_name}/ROOT/#{@n} init=#{@init} rd.vconsole.keymap=#{Getch::OPTIONS[:keymap]} zfs.force=1 zfs.zfs_arc_max=536870912\""
|
|
24
|
+
Helpers.echo src, line
|
|
31
25
|
end
|
|
32
26
|
|
|
33
27
|
def crypttab
|
|
34
28
|
datas = [
|
|
35
|
-
"cryptswap PARTUUID=#{@partuuid_swap} /dev/urandom swap,cipher=aes-xts-plain64:sha256,size=512"
|
|
36
|
-
]
|
|
37
|
-
File.write("#{@root_dir}/etc/crypttab", datas.join("\n"))
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# See https://wiki.gentoo.org/wiki/ZFS#ZFS_root
|
|
41
|
-
def grub
|
|
42
|
-
return if @efi
|
|
43
|
-
file = "#{@root_dir}/etc/default/grub"
|
|
44
|
-
cmdline = [
|
|
45
|
-
"GRUB_CMDLINE_LINUX=\"root=ZFS=#{@pool_name}/ROOT/gentoo init=#{@init} dozfs keymap=#{DEFAULT_OPTIONS[:keymap]}\""
|
|
29
|
+
"cryptswap PARTUUID=#{@partuuid_swap} /dev/urandom swap,discard,cipher=aes-xts-plain64:sha256,size=512"
|
|
46
30
|
]
|
|
47
|
-
File.write("#{
|
|
31
|
+
File.write("#{MOUNTPOINT}/etc/crypttab", datas.join("\n"))
|
|
48
32
|
end
|
|
49
33
|
|
|
50
34
|
private
|
|
51
35
|
|
|
52
36
|
def gen_uuid
|
|
53
|
-
@partuuid_swap = Helpers
|
|
37
|
+
@partuuid_swap = Helpers.partuuid(@dev_swap)
|
|
54
38
|
@uuid_esp = `lsblk -o "UUID" #{@dev_esp} | tail -1`.chomp() if @dev_esp
|
|
55
39
|
end
|
|
56
40
|
|
|
57
41
|
def data_fstab
|
|
58
42
|
boot_efi = @dev_esp ? "UUID=#{@uuid_esp} /efi vfat noauto,noatime 1 2" : ''
|
|
59
|
-
swap = @dev_swap ?
|
|
43
|
+
swap = @dev_swap ? '/dev/mapper/cryptswap none swap sw 0 0' : ''
|
|
60
44
|
|
|
61
45
|
[ boot_efi, swap ]
|
|
62
46
|
end
|