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
@@ -1,62 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sgdisk'
|
4
|
+
|
1
5
|
module Getch
|
2
6
|
module FileSystem
|
3
7
|
module Zfs
|
4
8
|
module Encrypt
|
5
|
-
class Partition
|
9
|
+
class Partition
|
6
10
|
def initialize
|
7
|
-
|
8
|
-
@state = Getch::States.new()
|
9
|
-
@clean = Getch::FileSystem::Clean
|
10
|
-
@partition = Getch::FileSystem::Partition.new
|
11
|
-
@log = Getch::Log.new()
|
12
|
-
run
|
13
|
-
end
|
14
|
-
|
15
|
-
def run
|
16
|
-
return if STATES[:partition ]
|
17
|
-
@clean.old_zpool
|
18
|
-
@clean.struct(@disk, @cache_disk, @home_disk)
|
19
|
-
@clean.hdd(@disk, @cache_disk, @home_disk)
|
20
|
-
partition
|
21
|
-
cache
|
22
|
-
@state.partition
|
11
|
+
x
|
23
12
|
end
|
24
13
|
|
25
14
|
private
|
26
15
|
|
27
|
-
def
|
28
|
-
|
29
|
-
@partition.efi(@dev_esp)
|
30
|
-
@partition.swap(@dev_swap)
|
31
|
-
@partition.root(@dev_root, "BF00") if @root_part != 1
|
32
|
-
else
|
33
|
-
@partition.gpt(@dev_gpt)
|
34
|
-
@partition.boot(@dev_boot)
|
35
|
-
@partition.swap(@dev_swap)
|
36
|
-
@partition.root(@dev_root, "BF00") if @root_part != 1
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def cache
|
41
|
-
if @dev_log
|
42
|
-
exec("sgdisk -n2:0:+4G -t2:BF07 #{cache_disk}")
|
43
|
-
end
|
44
|
-
if @dev_cache
|
45
|
-
exec("sgdisk -n3:0:0 -t3:BF08 #{cache_disk}")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# Partition_efi
|
50
|
-
# /efi - EFI system partition - 260MB
|
51
|
-
# / - Root
|
52
|
-
|
53
|
-
# Partition_bios
|
54
|
-
# None - Bios Boot Partition - 1MiB
|
55
|
-
# /boot - Boot - 8300
|
56
|
-
# / - Root
|
57
|
-
|
58
|
-
def exec(cmd)
|
59
|
-
Helpers::sys(cmd)
|
16
|
+
def x
|
17
|
+
Sgdisk::Zfs.new(DEVS)
|
60
18
|
end
|
61
19
|
end
|
62
20
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'fstab'
|
2
|
+
require 'dracut'
|
3
|
+
|
4
|
+
module Getch
|
5
|
+
module FileSystem
|
6
|
+
module Zfs
|
7
|
+
module Minimal
|
8
|
+
class Config
|
9
|
+
def initialize
|
10
|
+
@mountpoint = OPTIONS[:mountpoint]
|
11
|
+
@zfs = OPTIONS[:zfs_name] ||= 'pool'
|
12
|
+
@os = OPTIONS[:os]
|
13
|
+
x
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def x
|
19
|
+
Fstab::Zfs.new(DEVS, OPTIONS).generate
|
20
|
+
Dracut::Zfs.new(DEVS, OPTIONS).generate
|
21
|
+
grub_broken_root
|
22
|
+
end
|
23
|
+
|
24
|
+
# https://wiki.archlinux.org/title/Install_Arch_Linux_on_ZFS#Using_GRUB_for_EFI/BIOS
|
25
|
+
def grub_broken_root
|
26
|
+
return unless Helpers.grub?
|
27
|
+
|
28
|
+
file = "#{@mountpoint}/etc/default/grub"
|
29
|
+
content = "GRUB_CMDLINE_LINUX=\"$GRUB_CMDLINE_LINUX"
|
30
|
+
content << " root=ZFS=r#{@zfs}/ROOT/#{@os}\""
|
31
|
+
NiTo.echo_a file, content
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'nito'
|
4
|
+
|
5
|
+
module Getch
|
6
|
+
module FileSystem
|
7
|
+
module Zfs
|
8
|
+
module Minimal
|
9
|
+
class Deps
|
10
|
+
include NiTo
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@mountpoint = OPTIONS[:mountpoint]
|
14
|
+
@zfs = OPTIONS[:zfs_name] ||= 'pool'
|
15
|
+
@os = OPTIONS[:os]
|
16
|
+
x
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def x
|
22
|
+
unstable_zfs
|
23
|
+
install_deps
|
24
|
+
hostid
|
25
|
+
zfs_mountpoint
|
26
|
+
sleep 6
|
27
|
+
zfs_set
|
28
|
+
zed_update_path
|
29
|
+
Log.new.fatal('zed - no pool') unless grep?("#{@mountpoint}/etc/zfs/zfs-list.cache/r#{@zfs}", "r#{@zfs}")
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def zfs_set
|
35
|
+
Command.new("zfs set canmount=noauto b#{@zfs}/BOOT/#{@os}") if DEVS[:boot]
|
36
|
+
Command.new("zfs set canmount=noauto r#{@zfs}/ROOT/#{@os}")
|
37
|
+
Command.new("zpool set bootfs=r#{@zfs}/ROOT/#{@os} r#{@zfs}")
|
38
|
+
end
|
39
|
+
|
40
|
+
def unstable_zfs
|
41
|
+
return unless OPTIONS[:os] == 'gentoo'
|
42
|
+
|
43
|
+
conf = "#{@mountpoint}/etc/portage/package.accept_keywords/zfs"
|
44
|
+
data = [
|
45
|
+
'sys-fs/zfs-kmod',
|
46
|
+
'sys-fs/zfs'
|
47
|
+
]
|
48
|
+
File.write(conf, data.join("\n"), mode: 'w')
|
49
|
+
end
|
50
|
+
|
51
|
+
def install_deps
|
52
|
+
case OPTIONS[:os]
|
53
|
+
when 'gentoo' then Install.new('sys-fs/zfs')
|
54
|
+
when 'void' then Install.new('zfs')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# See: https://wiki.archlinux.org/index.php/ZFS#Using_zfs-mount-generator
|
59
|
+
def zfs_mountpoint
|
60
|
+
exec("zpool set cachefile=/etc/zfs/zpool.cache r#{@zfs}")
|
61
|
+
exec("zpool set cachefile=/etc/zfs/zpool.cache b#{@zfs}") if DEVS[:boot]
|
62
|
+
exec('ln -fs /usr/libexec/zfs/zed.d/history_event-zfs-list-cacher.sh /etc/zfs/zed.d/')
|
63
|
+
add_service
|
64
|
+
mkdir "#{@mountpoint}/etc/zfs/zfs-list.cache"
|
65
|
+
touch "#{@mountpoint}/etc/zfs/zfs-list.cache/b#{@zfs}" if DEVS[:boot]
|
66
|
+
touch "#{@mountpoint}/etc/zfs/zfs-list.cache/r#{@zfs}"
|
67
|
+
end
|
68
|
+
|
69
|
+
def zed_update_path
|
70
|
+
Dir.glob("#{@mountpoint}/etc/zfs/zfs-list.cache/*").each do |f|
|
71
|
+
Command.new('sed', '-Ei', "\"s|#{@mountpoint}/?|/|\"", f)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def hostid
|
76
|
+
exec 'zgenhostid -f $(hostid)'
|
77
|
+
end
|
78
|
+
|
79
|
+
def add_service
|
80
|
+
systemd
|
81
|
+
openrc
|
82
|
+
runit
|
83
|
+
end
|
84
|
+
|
85
|
+
def systemd
|
86
|
+
Helpers.systemd? || return
|
87
|
+
|
88
|
+
exec('systemctl enable zfs-import-cache')
|
89
|
+
exec('systemctl enable zfs-import.target')
|
90
|
+
exec('systemctl enable zfs-zed.service')
|
91
|
+
exec('systemctl enable zfs.target')
|
92
|
+
fork_d('zed -F')
|
93
|
+
end
|
94
|
+
|
95
|
+
def openrc
|
96
|
+
Helpers.openrc? || return
|
97
|
+
|
98
|
+
exec('rc-update add zfs-import boot')
|
99
|
+
exec('rc-update add zfs-mount boot')
|
100
|
+
exec('rc-update add zfs-zed default')
|
101
|
+
fork_d('zed -F')
|
102
|
+
end
|
103
|
+
|
104
|
+
def runit
|
105
|
+
Helpers.runit? || return
|
106
|
+
|
107
|
+
exec('ln -fs /etc/sv/zed /etc/runit/runsvdir/default/')
|
108
|
+
fork_d('/etc/sv/zed/run')
|
109
|
+
end
|
110
|
+
|
111
|
+
def fork_d(cmd)
|
112
|
+
job = fork do
|
113
|
+
Getch::Chroot.new(cmd)
|
114
|
+
end
|
115
|
+
Process.detach(job)
|
116
|
+
puts
|
117
|
+
end
|
118
|
+
|
119
|
+
def exec(cmd)
|
120
|
+
Getch::Chroot.new(cmd)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'devs'
|
4
|
+
|
5
|
+
module Getch
|
6
|
+
module FileSystem
|
7
|
+
module Zfs
|
8
|
+
module Minimal
|
9
|
+
class Device
|
10
|
+
def initialize
|
11
|
+
@args = { start: true, boot: true, swap: true, root: true }
|
12
|
+
x
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def x
|
18
|
+
Devs::Settings.new(@args, OPTIONS)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mkfs'
|
4
|
+
|
5
|
+
module Getch
|
6
|
+
module FileSystem
|
7
|
+
module Zfs
|
8
|
+
module Minimal
|
9
|
+
class Format
|
10
|
+
def initialize
|
11
|
+
x
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def x
|
17
|
+
Mkfs::Zfs.new(DEVS, OPTIONS)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mountfs'
|
4
|
+
|
5
|
+
module Getch
|
6
|
+
module FileSystem
|
7
|
+
module Zfs
|
8
|
+
module Minimal
|
9
|
+
class Mount
|
10
|
+
def initialize
|
11
|
+
x
|
12
|
+
end
|
13
|
+
|
14
|
+
def x
|
15
|
+
MountFs::Zfs.new(DEVS, OPTIONS)
|
16
|
+
#exec("zpool import -N -d #{@import} -R #{MOUNTPOINT} #{@pool_name}")
|
17
|
+
#exec("zpool import -f -N -d #{@import} -R #{MOUNTPOINT} #{@boot_pool_name}") if @dev_boot
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sgdisk'
|
4
|
+
|
5
|
+
module Getch
|
6
|
+
module FileSystem
|
7
|
+
module Zfs
|
8
|
+
module Minimal
|
9
|
+
class Partition
|
10
|
+
def initialize
|
11
|
+
x
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def x
|
17
|
+
Sgdisk::Zfs.new(DEVS)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Getch
|
4
|
+
module FileSystem
|
5
|
+
module Zfs
|
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/config'
|
19
|
+
require_relative 'minimal/deps'
|
data/lib/getch/filesystem/zfs.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Getch
|
2
4
|
module FileSystem
|
3
5
|
module Zfs
|
@@ -5,10 +7,5 @@ module Getch
|
|
5
7
|
end
|
6
8
|
end
|
7
9
|
|
8
|
-
require_relative 'zfs/
|
9
|
-
require_relative 'zfs/partition'
|
10
|
-
require_relative 'zfs/format'
|
11
|
-
require_relative 'zfs/mount'
|
12
|
-
require_relative 'zfs/config'
|
13
|
-
require_relative 'zfs/deps'
|
10
|
+
require_relative 'zfs/minimal'
|
14
11
|
require_relative 'zfs/encrypt'
|
data/lib/getch/filesystem.rb
CHANGED
@@ -1,13 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Getch
|
2
4
|
module FileSystem
|
3
5
|
end
|
4
6
|
end
|
5
7
|
|
6
|
-
require_relative 'filesystem/device'
|
7
|
-
require_relative 'filesystem/clean'
|
8
|
-
require_relative 'filesystem/partition'
|
9
|
-
require_relative 'filesystem/mount'
|
10
|
-
|
11
8
|
require_relative 'filesystem/ext4'
|
12
|
-
require_relative 'filesystem/lvm'
|
13
9
|
require_relative 'filesystem/zfs'
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Getch
|
4
|
+
module Gentoo
|
5
|
+
class Bootloader
|
6
|
+
def initialize
|
7
|
+
@esp = '/efi'
|
8
|
+
@boot = DEVS[:boot] ||= nil
|
9
|
+
@encrypt = OPTIONS[:encrypt] ||= false
|
10
|
+
end
|
11
|
+
|
12
|
+
# Dracut is used by sys-kernel/gentoo-kernel
|
13
|
+
def dependencies
|
14
|
+
Install.new('app-shells/dash')
|
15
|
+
if Helpers.systemd? and Helpers.efi?
|
16
|
+
Log.new.info "Systemd-boot alrealy installed...\n"
|
17
|
+
else
|
18
|
+
ChrootOutput.new('emerge --update --newuse sys-boot/grub')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def install
|
23
|
+
Helpers.grub? ?
|
24
|
+
Config::Grub.new :
|
25
|
+
bootctl
|
26
|
+
|
27
|
+
#ChrootOutput.new('emerge --config sys-kernel/gentoo-kernel')
|
28
|
+
ChrootOutput.new('emerge --config sys-kernel/gentoo-kernel-bin')
|
29
|
+
end
|
30
|
+
|
31
|
+
def bootctl
|
32
|
+
@boot ?
|
33
|
+
with_boot :
|
34
|
+
Chroot.new("bootctl --path #{@esp} install")
|
35
|
+
end
|
36
|
+
|
37
|
+
# We need to umount the encrypted /boot first
|
38
|
+
# https://github.com/systemd/systemd/issues/16151
|
39
|
+
def with_boot
|
40
|
+
boot = @encrypt ? '/dev/mapper/boot-luks' : "/dev/#{DEVS[:boot]}"
|
41
|
+
NiTo.umount "#{OPTIONS[:mountpoint]}/boot"
|
42
|
+
Chroot.new("bootctl --path #{@esp} install")
|
43
|
+
NiTo.mount boot, "#{OPTIONS[:mountpoint]}/boot"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Getch
|
4
|
+
module Gentoo
|
5
|
+
class Finalize
|
6
|
+
def initialize
|
7
|
+
x
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def x
|
13
|
+
accounts
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def accounts
|
19
|
+
account = Config::Account.new
|
20
|
+
account.root
|
21
|
+
account.new_user
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'nito'
|
4
|
+
|
5
|
+
module Getch
|
6
|
+
module Gentoo
|
7
|
+
class PostConfig
|
8
|
+
include NiTo
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@make = "#{OPTIONS[:mountpoint]}/etc/portage/make.conf"
|
12
|
+
x
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
def x
|
18
|
+
Getch::Config::Locale.new
|
19
|
+
Getch::Config::Keymap.new
|
20
|
+
Getch::Config::TimeZone.new
|
21
|
+
cpuflags
|
22
|
+
Gentoo::UseFlag.new
|
23
|
+
grub
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
def cpuflags
|
29
|
+
conf = "#{OPTIONS[:mountpoint]}/etc/portage/package.use/00cpuflags"
|
30
|
+
Install.new('app-portage/cpuid2cpuflags')
|
31
|
+
cpuflags = Chroot.new('cpuid2cpuflags')
|
32
|
+
File.write(conf, "*/* #{cpuflags}\n")
|
33
|
+
end
|
34
|
+
|
35
|
+
def grub
|
36
|
+
grub_pc = Helpers.efi? ? 'GRUB_PLATFORMS="efi-64"' : 'GRUB_PLATFORMS="pc"'
|
37
|
+
echo_a "#{OPTIONS[:mountpoint]}/etc/portage/make.conf", grub_pc
|
38
|
+
end
|
39
|
+
|
40
|
+
# https://wiki.gentoo.org/wiki/Signed_kernel_module_support
|
41
|
+
def portage_bashrc
|
42
|
+
conf = "#{MOUNTPOINT}/etc/portage/bashrc"
|
43
|
+
content = %q{
|
44
|
+
function pre_pkg_preinst() {
|
45
|
+
# This hook signs any out-of-tree kernel modules.
|
46
|
+
if [[ "$(type -t linux-mod_pkg_preinst)" != "function" ]]; then
|
47
|
+
# The package does not seem to install any kernel modules.
|
48
|
+
return
|
49
|
+
fi
|
50
|
+
# Get the signature algorithm used by the kernel.
|
51
|
+
local module_sig_hash="$(grep -Po '(?<=CONFIG_MODULE_SIG_HASH=").*(?=")' "${KERNEL_DIR}/.config")"
|
52
|
+
# Get the key file used by the kernel.
|
53
|
+
local module_sig_key="$(grep -Po '(?<=CONFIG_MODULE_SIG_KEY=").*(?=")' "${KERNEL_DIR}/.config")"
|
54
|
+
module_sig_key="${module_sig_key:-certs/signing_key.pem}"
|
55
|
+
# Path to the key file or PKCS11 URI
|
56
|
+
if [[ "${module_sig_key#pkcs11:}" == "${module_sig_key}" && "${module_sig_key#/}" == "${module_sig_key}" ]]; then
|
57
|
+
local key_path="${KERNEL_DIR}/${module_sig_key}"
|
58
|
+
else
|
59
|
+
local key_path="${module_sig_key}"
|
60
|
+
fi
|
61
|
+
# Certificate path
|
62
|
+
local cert_path="${KERNEL_DIR}/certs/signing_key.x509"
|
63
|
+
# Sign all installed modules before merging.
|
64
|
+
find "${D%/}/${INSDESTTREE#/}/" -name "*.ko" -exec "${KERNEL_DIR}/scripts/sign-file" "${module_sig_hash}" "${key_path}" "${cert_path}" '{}' \;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
f = File.new(conf, 'w')
|
69
|
+
f.write("#{content}\n")
|
70
|
+
f.chmod(0700)
|
71
|
+
f.close
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'nito'
|
4
|
+
|
5
|
+
module Getch
|
6
|
+
module Gentoo
|
7
|
+
class PreConfig
|
8
|
+
include NiTo
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
x
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def x
|
17
|
+
Getch::Config::Portage.new
|
18
|
+
Getch::Config::Locale.new
|
19
|
+
Getch::Config::PreNetwork.new
|
20
|
+
github
|
21
|
+
end
|
22
|
+
|
23
|
+
# Trouble to find host github
|
24
|
+
def github
|
25
|
+
github = check_ip 'github.com'
|
26
|
+
codeload = check_ip 'codeload.github.com'
|
27
|
+
echo_a "#{OPTIONS[:mountpoint]}/etc/hosts", "#{github} github.com"
|
28
|
+
echo_a "#{OPTIONS[:mountpoint]}/etc/hosts", "#{codeload} codeload.github.com"
|
29
|
+
end
|
30
|
+
|
31
|
+
def check_ip(host)
|
32
|
+
ip = `ping -c1 #{host}`.match(/\([0-9]*.[0-9]*.[0-9]*.[0-9]*\)/)
|
33
|
+
ip[0].tr('()','')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|