getch 0.1.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.md +75 -35
- data/assets/network-stack.conf +63 -0
- data/assets/system.conf +38 -0
- data/bin/getch +14 -4
- data/lib/clean.rb +149 -0
- data/lib/cmdline.rb +128 -0
- data/lib/cryptsetup.rb +132 -0
- data/lib/devs.rb +199 -0
- data/lib/dracut/encrypt.rb +36 -0
- data/lib/dracut/hybrid.rb +15 -0
- data/lib/dracut/lvm.rb +14 -0
- data/lib/dracut/minimal.rb +11 -0
- data/lib/dracut/root.rb +45 -0
- data/lib/dracut/zfs.rb +35 -0
- data/lib/dracut.rb +11 -0
- data/lib/fstab/encrypt.rb +44 -0
- data/lib/fstab/hybrid.rb +34 -0
- data/lib/fstab/lvm.rb +25 -0
- data/lib/fstab/minimal.rb +6 -0
- data/lib/fstab/root.rb +93 -0
- data/lib/fstab/zfs.rb +23 -0
- data/lib/fstab.rb +11 -0
- data/lib/getch/assembly.rb +150 -0
- data/lib/getch/command.rb +94 -124
- data/lib/getch/config/account.rb +39 -0
- data/lib/getch/config/dhcp.rb +104 -0
- data/lib/getch/config/grub.rb +42 -0
- data/lib/getch/config/iwd.rb +60 -0
- data/lib/getch/config/keymap.rb +78 -0
- data/lib/getch/config/locale.rb +96 -0
- data/lib/getch/config/portage.rb +90 -0
- data/lib/getch/config/pre_network.rb +37 -0
- data/lib/getch/config/timezone.rb +52 -0
- data/lib/getch/config/void.rb +11 -0
- data/lib/getch/config.rb +19 -53
- data/lib/getch/device.rb +67 -0
- data/lib/getch/filesystem/ext4/encrypt/config.rb +11 -68
- data/lib/getch/filesystem/ext4/encrypt/deps.rb +17 -25
- data/lib/getch/filesystem/ext4/encrypt/device.rb +13 -5
- data/lib/getch/filesystem/ext4/encrypt/format.rb +8 -15
- data/lib/getch/filesystem/ext4/encrypt/mount.rb +9 -13
- data/lib/getch/filesystem/ext4/encrypt/partition.rb +10 -82
- data/lib/getch/filesystem/ext4/encrypt/void.rb +63 -0
- data/lib/getch/filesystem/ext4/encrypt.rb +4 -0
- data/lib/getch/filesystem/ext4/hybrid/config.rb +27 -0
- data/lib/getch/filesystem/ext4/hybrid/deps.rb +55 -0
- data/lib/getch/filesystem/ext4/hybrid/device.rb +24 -0
- data/lib/getch/filesystem/ext4/hybrid/format.rb +23 -0
- data/lib/getch/filesystem/ext4/hybrid/mount.rb +21 -0
- data/lib/getch/filesystem/ext4/hybrid/partition.rb +27 -0
- data/lib/getch/filesystem/ext4/hybrid/void.rb +62 -0
- data/lib/getch/filesystem/ext4/hybrid.rb +19 -0
- data/lib/getch/filesystem/ext4/lvm/config.rb +25 -0
- data/lib/getch/filesystem/ext4/lvm/deps.rb +56 -0
- data/lib/getch/filesystem/ext4/lvm/device.rb +28 -0
- data/lib/getch/filesystem/ext4/lvm/format.rb +21 -0
- data/lib/getch/filesystem/ext4/lvm/mount.rb +21 -0
- data/lib/getch/filesystem/ext4/lvm/partition.rb +28 -0
- data/lib/getch/filesystem/{lvm.rb → ext4/lvm.rb} +8 -3
- data/lib/getch/filesystem/ext4/minimal/config.rb +25 -0
- data/lib/getch/filesystem/ext4/{device.rb → minimal/deps.rb} +4 -3
- data/lib/getch/filesystem/ext4/minimal/device.rb +22 -0
- data/lib/getch/filesystem/ext4/minimal/format.rb +23 -0
- data/lib/getch/filesystem/ext4/minimal/mount.rb +21 -0
- data/lib/getch/filesystem/ext4/minimal/partition.rb +28 -0
- data/lib/getch/filesystem/ext4/minimal.rb +19 -0
- data/lib/getch/filesystem/ext4.rb +9 -6
- data/lib/getch/filesystem/zfs/encrypt/config.rb +12 -57
- data/lib/getch/filesystem/zfs/encrypt/deps.rb +7 -86
- data/lib/getch/filesystem/zfs/encrypt/device.rb +9 -45
- data/lib/getch/filesystem/zfs/encrypt/format.rb +8 -90
- data/lib/getch/filesystem/zfs/encrypt/mount.rb +16 -34
- data/lib/getch/filesystem/zfs/encrypt/partition.rb +8 -50
- data/lib/getch/filesystem/zfs/encrypt.rb +4 -0
- data/lib/getch/filesystem/zfs/minimal/config.rb +37 -0
- data/lib/getch/filesystem/zfs/minimal/deps.rb +126 -0
- data/lib/getch/filesystem/zfs/minimal/device.rb +24 -0
- data/lib/getch/filesystem/zfs/minimal/format.rb +23 -0
- data/lib/getch/filesystem/zfs/minimal/mount.rb +23 -0
- data/lib/getch/filesystem/zfs/minimal/partition.rb +23 -0
- data/lib/getch/filesystem/zfs/minimal.rb +19 -0
- data/lib/getch/filesystem/zfs.rb +3 -6
- data/lib/getch/filesystem.rb +2 -6
- data/lib/getch/gentoo/bootloader.rb +47 -0
- data/lib/getch/gentoo/finalize.rb +25 -0
- data/lib/getch/gentoo/post_config.rb +75 -0
- data/lib/getch/gentoo/pre_config.rb +37 -0
- data/lib/getch/gentoo/services.rb +18 -0
- data/lib/getch/gentoo/sources.rb +82 -52
- data/lib/getch/gentoo/tarball.rb +91 -0
- data/lib/getch/gentoo/terraform.rb +34 -0
- data/lib/getch/gentoo/update.rb +54 -0
- data/lib/getch/gentoo/use.rb +11 -12
- data/lib/getch/gentoo/use_flag.rb +74 -52
- data/lib/getch/gentoo.rb +11 -63
- data/lib/getch/guard.rb +71 -0
- data/lib/getch/helpers.rb +128 -48
- data/lib/getch/log.rb +91 -26
- data/lib/getch/options.rb +79 -40
- data/lib/getch/states.rb +37 -10
- data/lib/getch/tree.rb +56 -0
- data/lib/getch/version.rb +1 -1
- data/lib/getch/void/bootloader.rb +18 -0
- data/lib/getch/void/finalize.rb +31 -0
- data/lib/getch/void/post_config.rb +19 -0
- data/lib/getch/void/pre_config.rb +18 -0
- data/lib/getch/void/services.rb +18 -0
- data/lib/getch/void/tarball.rb +89 -0
- data/lib/getch/void/terraform.rb +28 -0
- data/lib/getch/void/update.rb +33 -0
- data/lib/getch/void.rb +15 -0
- data/lib/getch.rb +104 -92
- data/lib/luks.rb +239 -0
- data/lib/lvm2.rb +112 -0
- data/lib/mkfs/zfs.rb +167 -0
- data/lib/mkfs.rb +140 -0
- data/lib/mountfs.rb +154 -0
- data/lib/nito.rb +131 -0
- data/lib/sgdisk.rb +160 -0
- data.tar.gz.sig +0 -0
- metadata +96 -45
- metadata.gz.sig +0 -0
- data/.gitignore +0 -2
- data/CHANGELOG.md +0 -90
- data/Rakefile +0 -21
- data/bin/setup.sh +0 -90
- data/getch.gemspec +0 -25
- data/lib/getch/filesystem/clean.rb +0 -51
- data/lib/getch/filesystem/device.rb +0 -61
- data/lib/getch/filesystem/ext4/config.rb +0 -58
- data/lib/getch/filesystem/ext4/deps.rb +0 -22
- data/lib/getch/filesystem/ext4/format.rb +0 -28
- data/lib/getch/filesystem/ext4/mount.rb +0 -23
- data/lib/getch/filesystem/ext4/partition.rb +0 -52
- data/lib/getch/filesystem/lvm/config.rb +0 -59
- data/lib/getch/filesystem/lvm/deps.rb +0 -42
- data/lib/getch/filesystem/lvm/device.rb +0 -43
- data/lib/getch/filesystem/lvm/encrypt/config.rb +0 -71
- data/lib/getch/filesystem/lvm/encrypt/deps.rb +0 -46
- data/lib/getch/filesystem/lvm/encrypt/device.rb +0 -46
- data/lib/getch/filesystem/lvm/encrypt/format.rb +0 -32
- data/lib/getch/filesystem/lvm/encrypt/mount.rb +0 -25
- data/lib/getch/filesystem/lvm/encrypt/partition.rb +0 -80
- data/lib/getch/filesystem/lvm/encrypt.rb +0 -15
- data/lib/getch/filesystem/lvm/format.rb +0 -29
- data/lib/getch/filesystem/lvm/mount.rb +0 -23
- data/lib/getch/filesystem/lvm/partition.rb +0 -69
- data/lib/getch/filesystem/mount.rb +0 -56
- data/lib/getch/filesystem/partition.rb +0 -77
- data/lib/getch/filesystem/zfs/config.rb +0 -57
- data/lib/getch/filesystem/zfs/deps.rb +0 -95
- data/lib/getch/filesystem/zfs/device.rb +0 -58
- data/lib/getch/filesystem/zfs/format.rb +0 -114
- data/lib/getch/filesystem/zfs/mount.rb +0 -48
- data/lib/getch/filesystem/zfs/partition.rb +0 -64
- data/lib/getch/gentoo/boot.rb +0 -109
- data/lib/getch/gentoo/chroot.rb +0 -77
- data/lib/getch/gentoo/config.rb +0 -129
- data/lib/getch/gentoo/stage.rb +0 -74
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sgdisk'
|
4
|
+
require 'lvm2'
|
5
|
+
|
6
|
+
module Getch
|
7
|
+
module FileSystem
|
8
|
+
module Ext4
|
9
|
+
module Lvm
|
10
|
+
class Partition
|
11
|
+
def initialize
|
12
|
+
x
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
# Follow https://wiki.archlinux.org/index.php/Partitioning
|
18
|
+
# 1 - Efi or GPT
|
19
|
+
# 2 - Root
|
20
|
+
def x
|
21
|
+
Sgdisk::Lvm.new(DEVS)
|
22
|
+
Lvm2::Root.new(DEVS, OPTIONS).x
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,6 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Getch
|
2
4
|
module FileSystem
|
3
|
-
module
|
5
|
+
module Ext4
|
6
|
+
module Lvm
|
7
|
+
def self.end
|
8
|
+
end
|
9
|
+
end
|
4
10
|
end
|
5
11
|
end
|
6
12
|
end
|
@@ -9,6 +15,5 @@ require_relative 'lvm/device'
|
|
9
15
|
require_relative 'lvm/partition'
|
10
16
|
require_relative 'lvm/format'
|
11
17
|
require_relative 'lvm/mount'
|
12
|
-
require_relative 'lvm/config'
|
13
18
|
require_relative 'lvm/deps'
|
14
|
-
require_relative 'lvm/
|
19
|
+
require_relative 'lvm/config'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fstab'
|
4
|
+
require 'dracut'
|
5
|
+
|
6
|
+
module Getch
|
7
|
+
module FileSystem
|
8
|
+
module Ext4
|
9
|
+
module Minimal
|
10
|
+
class Config
|
11
|
+
def initialize
|
12
|
+
x
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def x
|
18
|
+
Fstab::Minimal.new(DEVS, OPTIONS).generate
|
19
|
+
Dracut::Minimal.new(DEVS, OPTIONS).generate
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'devs'
|
4
|
+
|
5
|
+
module Getch
|
6
|
+
module FileSystem
|
7
|
+
module Ext4
|
8
|
+
module Minimal
|
9
|
+
class Device
|
10
|
+
def initialize
|
11
|
+
@args = { start: true, swap: true, root: true }
|
12
|
+
x
|
13
|
+
end
|
14
|
+
|
15
|
+
def x
|
16
|
+
Devs::Settings.new(@args, OPTIONS)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mkfs'
|
4
|
+
|
5
|
+
module Getch
|
6
|
+
module FileSystem
|
7
|
+
module Ext4
|
8
|
+
module Minimal
|
9
|
+
class Format
|
10
|
+
def initialize
|
11
|
+
x
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def x
|
17
|
+
Mkfs::Root.new(DEVS, OPTIONS)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mountfs'
|
4
|
+
|
5
|
+
module Getch
|
6
|
+
module FileSystem
|
7
|
+
module Ext4
|
8
|
+
module Minimal
|
9
|
+
class Mount
|
10
|
+
def initialize
|
11
|
+
x
|
12
|
+
end
|
13
|
+
|
14
|
+
def x
|
15
|
+
MountFs::Minimal.new(DEVS, OPTIONS)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sgdisk'
|
4
|
+
|
5
|
+
module Getch
|
6
|
+
module FileSystem
|
7
|
+
module Ext4
|
8
|
+
module Minimal
|
9
|
+
class Partition
|
10
|
+
def initialize
|
11
|
+
x
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
# Follow https://wiki.archlinux.org/index.php/Partitioning
|
17
|
+
# 1 - /efi of GPT
|
18
|
+
# 2 - Swap
|
19
|
+
# 3 - /
|
20
|
+
# 4 - /home if --separate-home DISK is used
|
21
|
+
def x
|
22
|
+
Sgdisk::Ext4.new(DEVS)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Getch
|
4
|
+
module FileSystem
|
5
|
+
module Ext4
|
6
|
+
module Minimal
|
7
|
+
def self.end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
require_relative 'minimal/device'
|
15
|
+
require_relative 'minimal/partition'
|
16
|
+
require_relative 'minimal/format'
|
17
|
+
require_relative 'minimal/mount'
|
18
|
+
require_relative 'minimal/deps'
|
19
|
+
require_relative 'minimal/config'
|
@@ -1,14 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Getch
|
2
4
|
module FileSystem
|
3
5
|
module Ext4
|
6
|
+
def self.end
|
7
|
+
puts '+ To enter in your system: chroot /mnt/getch /bin/bash'
|
8
|
+
puts '+ Reboot with: shutdown -r now'
|
9
|
+
end
|
4
10
|
end
|
5
11
|
end
|
6
12
|
end
|
7
13
|
|
8
|
-
require_relative 'ext4/
|
9
|
-
require_relative 'ext4/partition'
|
10
|
-
require_relative 'ext4/format'
|
11
|
-
require_relative 'ext4/mount'
|
12
|
-
require_relative 'ext4/config'
|
13
|
-
require_relative 'ext4/deps'
|
14
|
+
require_relative 'ext4/minimal'
|
14
15
|
require_relative 'ext4/encrypt'
|
16
|
+
require_relative 'ext4/lvm'
|
17
|
+
require_relative 'ext4/hybrid'
|
@@ -1,64 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fstab'
|
4
|
+
require 'dracut'
|
5
|
+
require 'cryptsetup'
|
6
|
+
|
1
7
|
module Getch
|
2
8
|
module FileSystem
|
3
9
|
module Zfs
|
4
10
|
module Encrypt
|
5
|
-
class Config <
|
6
|
-
def
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
crypttab
|
12
|
-
end
|
13
|
-
|
14
|
-
def fstab
|
15
|
-
file = "#{@root_dir}/etc/fstab"
|
16
|
-
datas = data_fstab
|
17
|
-
File.write(file, datas.join("\n"))
|
18
|
-
end
|
19
|
-
|
20
|
-
def systemd_boot
|
21
|
-
return if ! @efi
|
22
|
-
esp = '/efi'
|
23
|
-
dir = "#{@root_dir}/#{esp}/loader/entries/"
|
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"))
|
31
|
-
end
|
32
|
-
|
33
|
-
def crypttab
|
34
|
-
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]}\""
|
46
|
-
]
|
47
|
-
File.write("#{file}", cmdline.join("\n"), mode: 'a')
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def gen_uuid
|
53
|
-
@partuuid_swap = Helpers::partuuid(@dev_swap)
|
54
|
-
@uuid_esp = `lsblk -o "UUID" #{@dev_esp} | tail -1`.chomp() if @dev_esp
|
55
|
-
end
|
56
|
-
|
57
|
-
def data_fstab
|
58
|
-
boot_efi = @dev_esp ? "UUID=#{@uuid_esp} /efi vfat noauto,noatime 1 2" : ''
|
59
|
-
swap = @dev_swap ? "/dev/mapper/cryptswap none swap discard 0 0" : ''
|
60
|
-
|
61
|
-
[ boot_efi, swap ]
|
11
|
+
class Config < Minimal::Config
|
12
|
+
def x
|
13
|
+
Fstab::Zfs.new(DEVS, OPTIONS).generate
|
14
|
+
Dracut::Zfs.new(DEVS, OPTIONS).generate
|
15
|
+
CryptSetup.new(DEVS, OPTIONS).swap_conf
|
16
|
+
grub_broken_root
|
62
17
|
end
|
63
18
|
end
|
64
19
|
end
|
@@ -1,94 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Getch
|
2
4
|
module FileSystem
|
3
5
|
module Zfs
|
4
6
|
module Encrypt
|
5
|
-
class Deps <
|
6
|
-
def make
|
7
|
-
unstable_zfs
|
8
|
-
install_deps
|
9
|
-
zfs_mountpoint
|
10
|
-
auto_module_rebuild
|
11
|
-
hostid
|
12
|
-
options_make
|
13
|
-
Getch::Make.new("genkernel --kernel-config=/usr/src/linux/.config all").run!
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
def unstable_zfs
|
18
|
-
conf = "#{MOUNTPOINT}/etc/portage/package.accept_keywords/zfs"
|
19
|
-
data = [
|
20
|
-
"sys-fs/zfs-kmod",
|
21
|
-
"sys-fs/zfs"
|
22
|
-
]
|
23
|
-
File.write(conf, data.join("\n"), mode: "w")
|
24
|
-
end
|
25
|
-
|
7
|
+
class Deps < Minimal::Deps
|
26
8
|
def install_deps
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
# See: https://wiki.archlinux.org/index.php/ZFS#Using_zfs-mount-generator
|
34
|
-
def zfs_mountpoint
|
35
|
-
Helpers::mkdir("#{MOUNTPOINT}/etc/zfs/zfs-list.cache")
|
36
|
-
Helpers::touch("#{MOUNTPOINT}/etc/zfs/zfs-list.cache/#{@boot_pool_name}") if @dev_boot
|
37
|
-
Helpers::touch("#{MOUNTPOINT}/etc/zfs/zfs-list.cache/#{@pool_name}")
|
38
|
-
exec("ln -fs /usr/libexec/zfs/zed.d/history_event-zfs-list-cacher.sh /etc/zfs/zed.d/")
|
39
|
-
exec("systemctl start zfs-zed.service")
|
40
|
-
Helpers::sys("sed -Ei \"s|/mnt/?|/|\" #{MOUNTPOINT}/etc/zfs/zfs-list.cache/*")
|
41
|
-
exec("systemctl enable zfs-zed.service")
|
42
|
-
exec("systemctl enable zfs.target")
|
43
|
-
end
|
44
|
-
|
45
|
-
def auto_module_rebuild
|
46
|
-
g_dir="#{MOUNTPOINT}/etc/portage/env/sys-kernel"
|
47
|
-
Helpers::mkdir(g_dir)
|
48
|
-
# See https://wiki.gentoo.org/wiki/Kernel/Upgrade#Automated_build_and_installation
|
49
|
-
content=<<EOF
|
50
|
-
post_pkg_postinst() {
|
51
|
-
# BUG: reinstalls of a source will cause errors
|
52
|
-
CURRENT_KV=$(uname -r)
|
53
|
-
# Check to see if genkernel has been run previously for the running kernel and use that config
|
54
|
-
if [[ -f "${EROOT}/etc/kernels/kernel-config-${CURRENT_KV}" ]] ; then
|
55
|
-
genkernel --kernel-config="${EROOT}/etc/kernels/kernel-config-${CURRENT_KV}" all
|
56
|
-
elif [[ -f "${EROOT}/usr/src/linux-${CURRENT_KV}/.config" ]] ; then # Use latest kernel config from current kernel
|
57
|
-
genkernel --kernel-config="${EROOT}/usr/src/linux-${CURRENT_KV}/.config" all
|
58
|
-
else # No valid configs known
|
59
|
-
genkernel all
|
60
|
-
fi
|
61
|
-
}
|
62
|
-
EOF
|
63
|
-
File.write("#{g_dir}/gentoo-sources", content)
|
64
|
-
end
|
65
|
-
|
66
|
-
def hostid
|
67
|
-
hostid_value=`hostid`.chomp
|
68
|
-
File.write("#{MOUNTPOINT}/etc/hostid", hostid_value, mode: 'w')
|
69
|
-
end
|
70
|
-
|
71
|
-
def options_make
|
72
|
-
bootloader = Helpers::efi? ? 'BOOTLOADER="no"' : 'BOOTLOADER="grub2"'
|
73
|
-
datas = [
|
74
|
-
'',
|
75
|
-
bootloader,
|
76
|
-
'INSTALL="yes"',
|
77
|
-
'MENUCONFIG="no"',
|
78
|
-
'CLEAN="yes"',
|
79
|
-
'KEYMAP="yes"',
|
80
|
-
'SAVE_CONFIG="yes"',
|
81
|
-
'MOUNTBOOT="no"',
|
82
|
-
'MRPROPER="no"',
|
83
|
-
'ZFS="yes"',
|
84
|
-
'MODULEREBUILD="yes"'
|
85
|
-
]
|
86
|
-
file = "#{MOUNTPOINT}/etc/genkernel.conf"
|
87
|
-
File.write(file, datas.join("\n"), mode: 'a')
|
88
|
-
end
|
89
|
-
|
90
|
-
def exec(cmd)
|
91
|
-
Getch::Chroot.new(cmd).run!
|
9
|
+
case OPTIONS[:os]
|
10
|
+
when 'gentoo' then Install.new('sys-fs/cryptsetup sys-fs/zfs')
|
11
|
+
when 'void' then Install.new('cryptsetup zfs')
|
12
|
+
end
|
92
13
|
end
|
93
14
|
end
|
94
15
|
end
|
@@ -1,57 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'devs'
|
4
|
+
|
1
5
|
module Getch
|
2
6
|
module FileSystem
|
3
7
|
module Zfs
|
4
8
|
module Encrypt
|
5
|
-
class Device
|
9
|
+
class Device
|
6
10
|
def initialize
|
7
|
-
|
8
|
-
|
9
|
-
@boot_pool_name = "bpool-#{@id}"
|
10
|
-
@pool_name = "rpool-#{@id}"
|
11
|
-
@zfs_home = @user ? true : false
|
11
|
+
@args = { start: true, boot: true, swap: true, root: true }
|
12
|
+
x
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
15
16
|
|
16
|
-
def
|
17
|
-
|
18
|
-
if @boot_disk
|
19
|
-
@dev_esp = "/dev/#{@boot_disk}1"
|
20
|
-
else
|
21
|
-
@dev_esp = "/dev/#{@disk}1"
|
22
|
-
@root_part += 1
|
23
|
-
end
|
24
|
-
else
|
25
|
-
if @boot_disk
|
26
|
-
@dev_gpt = "/dev/#{@boot_disk}1"
|
27
|
-
@dev_boot = "/dev/#{@boot_disk}2"
|
28
|
-
@dev_grub = "/dev/#{@boot_disk}"
|
29
|
-
else
|
30
|
-
@dev_gpt = "/dev/#{@disk}1"
|
31
|
-
@dev_boot = "/dev/#{@disk}2"
|
32
|
-
@dev_grub = "/dev/#{@disk}"
|
33
|
-
@root_part += 2
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def search_swap
|
39
|
-
if @cache_disk
|
40
|
-
@dev_swap = "/dev/#{@cache_disk}1"
|
41
|
-
@dev_log = "/dev/#{@cache_disk}2"
|
42
|
-
@dev_cache = "/dev/#{@cache_disk}3"
|
43
|
-
else
|
44
|
-
@dev_swap = "/dev/#{@disk}#{@root_part}"
|
45
|
-
@root_part += 1
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def search_root
|
50
|
-
if @root_part == 1
|
51
|
-
@dev_root = "/dev/#{@disk}"
|
52
|
-
else
|
53
|
-
@dev_root = "/dev/#{@disk}#{@root_part}"
|
54
|
-
end
|
17
|
+
def x
|
18
|
+
Devs::Settings.new(@args, OPTIONS)
|
55
19
|
end
|
56
20
|
end
|
57
21
|
end
|
@@ -1,102 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mkfs'
|
4
|
+
|
1
5
|
module Getch
|
2
6
|
module FileSystem
|
3
7
|
module Zfs
|
4
8
|
module Encrypt
|
5
|
-
class Format
|
9
|
+
class Format
|
6
10
|
def initialize
|
7
|
-
|
8
|
-
@log = Getch::Log.new()
|
9
|
-
@state = Getch::States.new()
|
10
|
-
if ! @id
|
11
|
-
@log.info "Research pool id for #{@dev_root}..."
|
12
|
-
sleep 2 until Helpers::pool_id(@dev_root)
|
13
|
-
@id = Helpers::pool_id(@dev_root)
|
14
|
-
@boot_pool_name = "bpool-#{@id}"
|
15
|
-
@pool_name = "rpool-#{@id}"
|
16
|
-
end
|
17
|
-
format
|
11
|
+
x
|
18
12
|
end
|
19
13
|
|
20
14
|
private
|
21
15
|
|
22
|
-
def
|
23
|
-
|
24
|
-
raise "Error, no id found for #{@dev_root}." if ! @id
|
25
|
-
system("mkfs.fat -F32 #{@dev_esp}") if @dev_esp
|
26
|
-
system("mkswap -f #{@dev_swap}")
|
27
|
-
zfs
|
28
|
-
datasets
|
29
|
-
@state.format
|
30
|
-
end
|
31
|
-
|
32
|
-
def zfs
|
33
|
-
bloc=`blockdev --getbsz #{@dev_root}`.chomp
|
34
|
-
ashift = case bloc
|
35
|
-
when 8096
|
36
|
-
13
|
37
|
-
when 4096
|
38
|
-
12
|
39
|
-
else # 512
|
40
|
-
9
|
41
|
-
end
|
42
|
-
|
43
|
-
Helpers::mkdir(MOUNTPOINT)
|
44
|
-
|
45
|
-
@log.debug("ashift found for #{bloc} - #{ashift}")
|
46
|
-
if @dev_boot
|
47
|
-
# https://openzfs.github.io/openzfs-docs/Getting%20Started/Ubuntu/Ubuntu%2020.04%20Root%20on%20ZFS.html
|
48
|
-
@log.info("Creating boot pool on #{@pool_name}")
|
49
|
-
exec("zpool create -f \\
|
50
|
-
-o ashift=#{ashift} -o autotrim=on -d \\
|
51
|
-
-o feature@async_destroy=enabled \\
|
52
|
-
-o feature@bookmarks=enabled \\
|
53
|
-
-o feature@embedded_data=enabled \\
|
54
|
-
-o feature@empty_bpobj=enabled \\
|
55
|
-
-o feature@enabled_txg=enabled \\
|
56
|
-
-o feature@extensible_dataset=enabled \\
|
57
|
-
-o feature@filesystem_limits=enabled \\
|
58
|
-
-o feature@hole_birth=enabled \\
|
59
|
-
-o feature@large_blocks=enabled \\
|
60
|
-
-o feature@lz4_compress=enabled \\
|
61
|
-
-o feature@spacemap_histogram=enabled \\
|
62
|
-
-O acltype=posixacl -O canmount=off -O compression=lz4 \\
|
63
|
-
-O devices=off -O normalization=formD -O atime=off -O xattr=sa \\
|
64
|
-
-O mountpoint=/boot -R #{MOUNTPOINT} \\
|
65
|
-
#{@boot_pool_name} #{@dev_boot}
|
66
|
-
")
|
67
|
-
end
|
68
|
-
|
69
|
-
exec("zpool create -f -o ashift=#{ashift} -o autotrim=on \\
|
70
|
-
-O encryption=aes-256-gcm \\
|
71
|
-
-O keylocation=prompt -O keyformat=passphrase \\
|
72
|
-
-O acltype=posixacl -O canmount=off -O compression=lz4 \\
|
73
|
-
-O dnodesize=auto -O normalization=formD -O atime=off \\
|
74
|
-
-O xattr=sa -O mountpoint=/ -R #{MOUNTPOINT} \\
|
75
|
-
#{@pool_name} #{@dev_root}
|
76
|
-
")
|
77
|
-
end
|
78
|
-
|
79
|
-
def datasets
|
80
|
-
exec("zfs create -o canmount=off -o mountpoint=none #{@pool_name}/ROOT")
|
81
|
-
exec("zfs create -o canmount=off -o mountpoint=none #{@boot_pool_name}/BOOT") if @dev_boot
|
82
|
-
|
83
|
-
exec("zfs create -o canmount=noauto -o mountpoint=/ #{@pool_name}/ROOT/gentoo")
|
84
|
-
exec("zfs create -o canmount=noauto -o mountpoint=/boot #{@boot_pool_name}/BOOT/gentoo") if @dev_boot
|
85
|
-
|
86
|
-
exec("zfs create -o canmount=off #{@pool_name}/ROOT/gentoo/usr")
|
87
|
-
exec("zfs create #{@pool_name}/ROOT/gentoo/usr/src")
|
88
|
-
exec("zfs create -o canmount=off #{@pool_name}/ROOT/gentoo/var")
|
89
|
-
exec("zfs create #{@pool_name}/ROOT/gentoo/var/log")
|
90
|
-
exec("zfs create #{@pool_name}/ROOT/gentoo/var/db")
|
91
|
-
exec("zfs create #{@pool_name}/ROOT/gentoo/var/tmp")
|
92
|
-
|
93
|
-
exec("zfs create -o canmount=off -o mountpoint=/ #{@pool_name}/USERDATA")
|
94
|
-
exec("zfs create -o canmount=on -o mountpoint=/root #{@pool_name}/USERDATA/root")
|
95
|
-
exec("zfs create -o canmount=on -o mountpoint=/home/#{@user} #{@pool_name}/USERDATA/#{@user}") if @user
|
96
|
-
end
|
97
|
-
|
98
|
-
def exec(cmd)
|
99
|
-
Helpers::sys(cmd)
|
16
|
+
def x
|
17
|
+
Mkfs::Zfs.new(DEVS, OPTIONS)
|
100
18
|
end
|
101
19
|
end
|
102
20
|
end
|
@@ -1,48 +1,30 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mountfs'
|
2
4
|
|
3
5
|
module Getch
|
4
6
|
module FileSystem
|
5
7
|
module Zfs
|
6
8
|
module Encrypt
|
7
|
-
class Mount
|
9
|
+
class Mount
|
8
10
|
def initialize
|
9
|
-
|
10
|
-
@root_dir = MOUNTPOINT
|
11
|
-
@mount = Getch::FileSystem::Mount.new
|
12
|
-
@state = Getch::States.new
|
13
|
-
@log = Getch::Log.new
|
14
|
-
end
|
15
|
-
|
16
|
-
def run
|
17
|
-
return if STATES[:mount]
|
18
|
-
exec("zpool export -a")
|
19
|
-
exec("rm -rf #{MOUNTPOINT}/*")
|
20
|
-
exec("zpool import -N -R #{MOUNTPOINT} #{@pool_name}")
|
21
|
-
exec("zpool import -N -R #{MOUNTPOINT} #{@boot_pool_name}") if @dev_boot
|
22
|
-
exec("zfs load-key -a")
|
23
|
-
@mount.swap(@dev_swap)
|
24
|
-
mount_root
|
25
|
-
mount_boot
|
26
|
-
@mount.esp(@dev_esp)
|
27
|
-
exec("zfs mount -a")
|
28
|
-
@state.mount
|
11
|
+
x
|
29
12
|
end
|
30
13
|
|
31
14
|
private
|
32
15
|
|
33
|
-
def
|
34
|
-
|
35
|
-
exec("zfs mount #{@pool_name}/ROOT/gentoo")
|
36
|
-
end
|
37
|
-
|
38
|
-
def mount_boot
|
39
|
-
return if ! @dev_boot
|
40
|
-
exec("zfs mount #{@boot_pool_name}/BOOT/gentoo")
|
41
|
-
end
|
16
|
+
def x
|
17
|
+
MountFs::Zfs.new(DEVS, OPTIONS)
|
42
18
|
|
43
|
-
|
44
|
-
|
45
|
-
|
19
|
+
#exec('zpool export -a')
|
20
|
+
#exec("rm -rf #{MOUNTPOINT}/*")
|
21
|
+
#exec("zpool import -N -d #{@import} -R #{MOUNTPOINT} #{@pool_name}")
|
22
|
+
#exec("zpool import -f -N -d #{@import} -R #{MOUNTPOINT} #{@boot_pool_name}") if @dev_boot
|
23
|
+
#exec('zfs load-key -a')
|
24
|
+
#mount_root
|
25
|
+
#mount_boot
|
26
|
+
#@mount.esp(@dev_esp)
|
27
|
+
#exec('zfs mount -a')
|
46
28
|
end
|
47
29
|
end
|
48
30
|
end
|