getch 0.0.5 → 0.1.0
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 +30 -0
- data/README.md +31 -6
- data/bin/setup.sh +29 -13
- data/lib/getch.rb +43 -30
- data/lib/getch/command.rb +163 -0
- data/lib/getch/filesystem.rb +8 -0
- data/lib/getch/filesystem/ext4.rb +14 -0
- data/lib/getch/filesystem/ext4/config.rb +59 -0
- data/lib/getch/filesystem/ext4/deps.rb +22 -0
- data/lib/getch/filesystem/ext4/device.rb +16 -0
- data/lib/getch/filesystem/ext4/encrypt.rb +15 -0
- data/lib/getch/filesystem/ext4/encrypt/config.rb +85 -0
- data/lib/getch/filesystem/ext4/encrypt/deps.rb +59 -0
- data/lib/getch/filesystem/ext4/encrypt/device.rb +21 -0
- data/lib/getch/filesystem/ext4/encrypt/format.rb +32 -0
- data/lib/getch/filesystem/ext4/encrypt/mount.rb +64 -0
- data/lib/getch/filesystem/ext4/encrypt/partition.rb +116 -0
- data/lib/getch/filesystem/ext4/format.rb +30 -0
- data/lib/getch/filesystem/ext4/mount.rb +62 -0
- data/lib/getch/filesystem/ext4/partition.rb +75 -0
- data/lib/getch/filesystem/lvm.rb +14 -0
- data/lib/getch/filesystem/lvm/config.rb +63 -0
- data/lib/getch/filesystem/lvm/deps.rb +57 -0
- data/lib/getch/filesystem/lvm/device.rb +19 -0
- data/lib/getch/filesystem/lvm/encrypt.rb +15 -0
- data/lib/getch/filesystem/lvm/encrypt/config.rb +74 -0
- data/lib/getch/filesystem/lvm/encrypt/deps.rb +63 -0
- data/lib/getch/filesystem/lvm/encrypt/device.rb +22 -0
- data/lib/getch/filesystem/lvm/encrypt/format.rb +32 -0
- data/lib/getch/filesystem/lvm/encrypt/mount.rb +64 -0
- data/lib/getch/filesystem/lvm/encrypt/partition.rb +92 -0
- data/lib/getch/filesystem/lvm/format.rb +25 -0
- data/lib/getch/filesystem/lvm/mount.rb +62 -0
- data/lib/getch/filesystem/lvm/partition.rb +81 -0
- data/lib/getch/filesystem/zfs.rb +14 -0
- data/lib/getch/filesystem/zfs/config.rb +58 -0
- data/lib/getch/filesystem/zfs/deps.rb +90 -0
- data/lib/getch/filesystem/zfs/device.rb +19 -0
- data/lib/getch/filesystem/zfs/encrypt.rb +15 -0
- data/lib/getch/filesystem/zfs/encrypt/config.rb +67 -0
- data/lib/getch/filesystem/zfs/encrypt/deps.rb +94 -0
- data/lib/getch/filesystem/zfs/encrypt/device.rb +21 -0
- data/lib/getch/filesystem/zfs/encrypt/format.rb +22 -0
- data/lib/getch/filesystem/zfs/encrypt/mount.rb +67 -0
- data/lib/getch/filesystem/zfs/encrypt/partition.rb +151 -0
- data/lib/getch/filesystem/zfs/format.rb +20 -0
- data/lib/getch/filesystem/zfs/mount.rb +67 -0
- data/lib/getch/filesystem/zfs/partition.rb +147 -0
- data/lib/getch/gentoo.rb +3 -2
- data/lib/getch/gentoo/boot.rb +29 -25
- data/lib/getch/gentoo/chroot.rb +18 -14
- data/lib/getch/gentoo/config.rb +18 -9
- data/lib/getch/gentoo/sources.rb +45 -31
- data/lib/getch/gentoo/stage.rb +2 -2
- data/lib/getch/helpers.rb +24 -6
- data/lib/getch/log.rb +54 -0
- data/lib/getch/options.rb +16 -7
- data/lib/getch/version.rb +1 -1
- metadata +48 -5
- metadata.gz.sig +0 -0
- data/lib/getch/disk.rb +0 -77
- data/lib/getch/mount.rb +0 -73
@@ -0,0 +1,30 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Ext4
|
4
|
+
class Format < Getch::FileSystem::Ext4::Device
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@fs = 'ext4'
|
8
|
+
@state = Getch::States.new()
|
9
|
+
format
|
10
|
+
end
|
11
|
+
|
12
|
+
def format
|
13
|
+
return if STATES[:format]
|
14
|
+
puts "Format #{@disk} with #{@fs}"
|
15
|
+
exec("mkfs.fat -F32 #{@dev_boot_efi}") if Helpers::efi?
|
16
|
+
exec("mkswap -f #{@dev_swap}")
|
17
|
+
exec("mkfs.#{@fs} -F #{@dev_root}")
|
18
|
+
exec("mkfs.#{@fs} -F #{@dev_home}") if @dev_home
|
19
|
+
@state.format
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def exec(cmd)
|
25
|
+
Getch::Command.new(cmd).run!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Getch
|
4
|
+
module FileSystem
|
5
|
+
module Ext4
|
6
|
+
class Mount < Getch::FileSystem::Ext4::Device
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
@root_dir = MOUNTPOINT
|
10
|
+
@boot_dir = "#{@root_dir}/boot"
|
11
|
+
@boot_efi_dir = "#{@root_dir}/boot/efi"
|
12
|
+
@home_dir = @user ? "#{@root_dir}/home/#{@user}" : nil
|
13
|
+
@state = Getch::States.new()
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
return if STATES[:mount]
|
18
|
+
mount_swap
|
19
|
+
mount_root
|
20
|
+
mount_boot
|
21
|
+
mount_home
|
22
|
+
mount_boot_efi
|
23
|
+
@state.mount
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def mount_swap
|
29
|
+
return if ! @dev_swap
|
30
|
+
system("swapon #{@dev_swap}")
|
31
|
+
end
|
32
|
+
|
33
|
+
def mount_root
|
34
|
+
return if ! @dev_root
|
35
|
+
Dir.mkdir(@root_dir, 0700) if ! Dir.exist?(@root_dir)
|
36
|
+
system("mount #{@dev_root} #{@root_dir}")
|
37
|
+
end
|
38
|
+
|
39
|
+
def mount_boot_efi
|
40
|
+
return if ! @dev_boot_efi
|
41
|
+
FileUtils.mkdir_p @boot_efi_dir, mode: 0700 if ! Dir.exist?(@boot_efi_dir)
|
42
|
+
system("mount #{@dev_boot_efi} #{@boot_efi_dir}")
|
43
|
+
end
|
44
|
+
|
45
|
+
def mount_boot
|
46
|
+
return if ! @dev_boot
|
47
|
+
FileUtils.mkdir_p @boot_dir, mode: 0700 if ! Dir.exist?(@boot_dir)
|
48
|
+
system("mount #{@dev_boot} #{@boot_dir}")
|
49
|
+
end
|
50
|
+
|
51
|
+
def mount_home
|
52
|
+
return if ! @dev_home
|
53
|
+
if @user != nil then
|
54
|
+
FileUtils.mkdir_p @home_dir, mode: 0700 if ! Dir.exist?(@home_dir)
|
55
|
+
system("mount #{@dev_home} #{@home_dir}")
|
56
|
+
end
|
57
|
+
@state.mount
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Ext4
|
4
|
+
class Partition < Getch::FileSystem::Ext4::Device
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@state = Getch::States.new()
|
8
|
+
run_partition
|
9
|
+
end
|
10
|
+
|
11
|
+
def run_partition
|
12
|
+
return if STATES[:partition ]
|
13
|
+
clear_struct
|
14
|
+
cleaning
|
15
|
+
if Helpers::efi?
|
16
|
+
partition_efi
|
17
|
+
else
|
18
|
+
partition_bios
|
19
|
+
end
|
20
|
+
@state.partition
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def clear_struct
|
26
|
+
exec("sgdisk -Z /dev/#{@disk}")
|
27
|
+
exec("wipefs -a /dev/#{@disk}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def cleaning
|
31
|
+
puts
|
32
|
+
print "Cleaning data on #{@disk}, can be long, avoid this on Flash Memory (SSD,USB,...) ? (n,y) "
|
33
|
+
case gets.chomp
|
34
|
+
when /^y|^Y/
|
35
|
+
bloc=`blockdev --getbsz /dev/#{@disk}`.chomp
|
36
|
+
exec("dd if=/dev/urandom of=/dev/#{@disk} bs=#{bloc} status=progress")
|
37
|
+
else
|
38
|
+
return
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Follow https://wiki.archlinux.org/index.php/Partitioning
|
43
|
+
def partition_efi
|
44
|
+
# /boot/efi - EFI system partition - 260MB
|
45
|
+
# / - Root
|
46
|
+
# swap - Linux Swap - size of the ram
|
47
|
+
# /home - Home
|
48
|
+
mem=`awk '/MemTotal/ {print $2}' /proc/meminfo`.chomp + 'K'
|
49
|
+
|
50
|
+
exec("sgdisk -n1:1M:+260M -t1:EF00 /dev/#{@disk}")
|
51
|
+
exec("sgdisk -n2:0:+15G -t2:8304 /dev/#{@disk}")
|
52
|
+
exec("sgdisk -n3:0:+#{mem} -t3:8200 /dev/#{@disk}")
|
53
|
+
exec("sgdisk -n4:0:0 -t4:8302 /dev/#{@disk}") if @dev_home
|
54
|
+
end
|
55
|
+
|
56
|
+
def partition_bios
|
57
|
+
# None - Bios Boot Partition - 1MiB
|
58
|
+
# / - Root
|
59
|
+
# swap - Linux Swap - size of the ram
|
60
|
+
# /home - Home
|
61
|
+
mem=`awk '/MemTotal/ {print $2}' /proc/meminfo`.chomp + 'K'
|
62
|
+
|
63
|
+
exec("sgdisk -n1:1MiB:+1MiB -t1:EF02 /dev/#{@disk}")
|
64
|
+
exec("sgdisk -n2:0:+15G -t2:8304 /dev/#{@disk}")
|
65
|
+
exec("sgdisk -n3:0:+#{mem} -t3:8200 /dev/#{@disk}")
|
66
|
+
exec("sgdisk -n4:0:0 -t4:8302 /dev/#{@disk}") if @dev_home
|
67
|
+
end
|
68
|
+
|
69
|
+
def exec(cmd)
|
70
|
+
Getch::Command.new(cmd).run!
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Lvm
|
4
|
+
end
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
require_relative 'lvm/device'
|
9
|
+
require_relative 'lvm/partition'
|
10
|
+
require_relative 'lvm/format'
|
11
|
+
require_relative 'lvm/mount'
|
12
|
+
require_relative 'lvm/config'
|
13
|
+
require_relative 'lvm/deps'
|
14
|
+
require_relative 'lvm/encrypt'
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Lvm
|
4
|
+
class Config < Getch::FileSystem::Lvm::Device
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
gen_uuid
|
8
|
+
@root_dir = MOUNTPOINT
|
9
|
+
@init = '/usr/lib/systemd/systemd'
|
10
|
+
end
|
11
|
+
|
12
|
+
def fstab
|
13
|
+
file = "#{@root_dir}/etc/fstab"
|
14
|
+
datas = data_fstab
|
15
|
+
File.write(file, datas.join("\n"))
|
16
|
+
end
|
17
|
+
|
18
|
+
def systemd_boot
|
19
|
+
return if ! Helpers::efi?
|
20
|
+
esp = '/boot/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=UUID=#{@uuid_root} init=#{@init} dolvm rw"
|
27
|
+
]
|
28
|
+
File.write("#{dir}/gentoo.conf", datas_gentoo.join("\n"))
|
29
|
+
end
|
30
|
+
|
31
|
+
def grub
|
32
|
+
return if Helpers::efi?
|
33
|
+
file = "#{@root_dir}/etc/default/grub"
|
34
|
+
cmdline = [
|
35
|
+
"GRUB_CMDLINE_LINUX=\"resume=UUID=#{@uuid_swap} root=UUID=#{@uuid_root} init=#{@init} dolvm rw\""
|
36
|
+
]
|
37
|
+
File.write("#{file}", cmdline.join("\n"), mode: 'a')
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
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
|
+
@uuid_boot = `lsblk -o "UUID" #{@dev_boot} | tail -1`.chomp() if @dev_boot
|
47
|
+
@uuid_boot_efi = `lsblk -o "UUID" #{@dev_boot_efi} | tail -1`.chomp() if @dev_boot_efi
|
48
|
+
@uuid_home = `lsblk -o "UUID" #{@lv_home} | tail -1`.chomp() if @lv_home
|
49
|
+
end
|
50
|
+
|
51
|
+
def data_fstab
|
52
|
+
boot_efi = @dev_boot_efi ? "UUID=#{@uuid_boot_efi} /boot/efi vfat noauto,noatime 1 2" : ''
|
53
|
+
boot = @dev_boot ? "UUID=#{@uuid_boot} /boot ext4 noauto,noatime 1 2" : ''
|
54
|
+
swap = @lv_swap ? "UUID=#{@uuid_swap} none swap discard 0 0" : ''
|
55
|
+
root = @lv_root ? "UUID=#{@uuid_root} / ext4 defaults 0 1" : ''
|
56
|
+
home = @lv_home ? "UUID=#{@uuid_home} /home/#{@user} ext4 defaults 0 2" : ''
|
57
|
+
|
58
|
+
[ boot_efi, boot, swap, root, home ]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Lvm
|
4
|
+
class Deps
|
5
|
+
def initialize
|
6
|
+
if Helpers::efi?
|
7
|
+
install_efi
|
8
|
+
else
|
9
|
+
install_bios
|
10
|
+
end
|
11
|
+
install_deps
|
12
|
+
end
|
13
|
+
|
14
|
+
def make
|
15
|
+
options_make
|
16
|
+
Getch::Make.new("genkernel --kernel-config=/usr/src/linux/.config all").run!
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def options_make
|
21
|
+
grub = Helpers::efi? ? 'BOOTLOADER="no"' : 'BOOTLOADER="grub2"'
|
22
|
+
datas = [
|
23
|
+
'',
|
24
|
+
grub,
|
25
|
+
'INSTALL="yes"',
|
26
|
+
'MENUCONFIG="no"',
|
27
|
+
'CLEAN="yes"',
|
28
|
+
'SAVE_CONFIG="yes"',
|
29
|
+
'MOUNTBOOT="yes"',
|
30
|
+
'MRPROPER="no"',
|
31
|
+
'LVM="yes"',
|
32
|
+
]
|
33
|
+
file = "#{MOUNTPOINT}/etc/genkernel.conf"
|
34
|
+
File.write(file, datas.join("\n"), mode: 'a')
|
35
|
+
end
|
36
|
+
|
37
|
+
def install_efi
|
38
|
+
end
|
39
|
+
|
40
|
+
def install_bios
|
41
|
+
exec("euse -p sys-boot/grub -E device-mapper")
|
42
|
+
end
|
43
|
+
|
44
|
+
def install_deps
|
45
|
+
exec("euse -E lvm")
|
46
|
+
Getch::Emerge.new('genkernel lvm2').pkg!
|
47
|
+
Getch::Garden.new('-a lvm').run!
|
48
|
+
exec("systemctl enable lvm2-monitor")
|
49
|
+
end
|
50
|
+
|
51
|
+
def exec(cmd)
|
52
|
+
Getch::Chroot.new(cmd).run!
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Lvm
|
4
|
+
class Device
|
5
|
+
def initialize
|
6
|
+
@disk = DEFAULT_OPTIONS[:disk]
|
7
|
+
@user = DEFAULT_OPTIONS[:username]
|
8
|
+
@dev_boot_efi = Helpers::efi? ? "/dev/#{@disk}1" : nil
|
9
|
+
@dev_boot = Helpers::efi? ? nil : "/dev/#{@disk}2"
|
10
|
+
@dev_root = Helpers::efi? ? "/dev/#{@disk}2" : "/dev/#{@disk}3"
|
11
|
+
@vg = 'vg0'
|
12
|
+
@lv_root = "/dev/mapper/#{@vg}-root"
|
13
|
+
@lv_swap = "/dev/mapper/#{@vg}-swap"
|
14
|
+
@lv_home = @user ? "/dev/mapper/#{@vg}-home" : nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Lvm
|
4
|
+
module Encrypt
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
require_relative 'encrypt/device'
|
11
|
+
require_relative 'encrypt/partition'
|
12
|
+
require_relative 'encrypt/format'
|
13
|
+
require_relative 'encrypt/mount'
|
14
|
+
require_relative 'encrypt/config'
|
15
|
+
require_relative 'encrypt/deps'
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Lvm
|
4
|
+
module Encrypt
|
5
|
+
class Config < Getch::FileSystem::Lvm::Encrypt::Device
|
6
|
+
def initialize
|
7
|
+
super
|
8
|
+
gen_uuid
|
9
|
+
@root_dir = MOUNTPOINT
|
10
|
+
@init = '/usr/lib/systemd/systemd'
|
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 ! Helpers::efi?
|
22
|
+
esp = '/boot/efi'
|
23
|
+
dir = "#{@root_dir}/#{esp}/loader/entries/"
|
24
|
+
datas_gentoo = [
|
25
|
+
'title Gentoo Linux',
|
26
|
+
'linux /vmlinuz',
|
27
|
+
'initrd /initramfs',
|
28
|
+
"options crypt_root=UUID=#{@uuid_dev_root} root=#{@lv_root} init=#{@init} keymap=#{DEFAULT_OPTIONS[:keymap]} dolvm rw"
|
29
|
+
]
|
30
|
+
File.write("#{dir}/gentoo.conf", datas_gentoo.join("\n"))
|
31
|
+
end
|
32
|
+
|
33
|
+
def crypttab
|
34
|
+
datas = [
|
35
|
+
"cryptswap #{@lv_swap} /dev/urandom swap,cipher=aes-xts-plain64:sha256,size=256"
|
36
|
+
]
|
37
|
+
File.write("#{@root_dir}/etc/crypttab", datas.join("\n"))
|
38
|
+
end
|
39
|
+
|
40
|
+
def grub
|
41
|
+
return if Helpers::efi?
|
42
|
+
file = "#{@root_dir}/etc/default/grub"
|
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]}\"",
|
45
|
+
"GRUB_ENABLE_CRYPTODISK=y"
|
46
|
+
]
|
47
|
+
File.write("#{file}", cmdline.join("\n"), mode: 'a')
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
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
|
+
@uuid_dev_root = `lsblk -d -o "UUID" #{@dev_root} | tail -1`.chomp() if @dev_root
|
56
|
+
@uuid_boot = `lsblk -o "UUID" #{@dev_boot} | tail -1`.chomp() if @dev_boot
|
57
|
+
@uuid_boot_efi = `lsblk -o "UUID" #{@dev_boot_efi} | tail -1`.chomp() if @dev_boot_efi
|
58
|
+
@uuid_home = `lsblk -o "UUID" #{@lv_home} | tail -1`.chomp() if @lv_home
|
59
|
+
end
|
60
|
+
|
61
|
+
def data_fstab
|
62
|
+
boot_efi = @dev_boot_efi ? "UUID=#{@uuid_boot_efi} /boot/efi vfat noauto,noatime 1 2" : ''
|
63
|
+
boot = @dev_boot ? "UUID=#{@uuid_boot} /boot ext4 noauto,noatime 1 2" : ''
|
64
|
+
swap = @lv_swap ? "/dev/mapper/cryptswap none swap discard 0 0" : ''
|
65
|
+
root = @lv_root ? "UUID=#{@uuid_root} / ext4 defaults 0 1" : ''
|
66
|
+
home = @lv_home ? "UUID=#{@uuid_home} /home/#{@user} ext4 defaults 0 2" : ''
|
67
|
+
|
68
|
+
[ boot_efi, boot, swap, root, home ]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Lvm
|
4
|
+
module Encrypt
|
5
|
+
class Deps
|
6
|
+
def initialize
|
7
|
+
if Helpers::efi?
|
8
|
+
install_efi
|
9
|
+
else
|
10
|
+
install_bios
|
11
|
+
end
|
12
|
+
install_deps
|
13
|
+
end
|
14
|
+
|
15
|
+
def make
|
16
|
+
options_make
|
17
|
+
Getch::Make.new("genkernel --kernel-config=/usr/src/linux/.config all").run!
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def options_make
|
22
|
+
grub = Helpers::efi? ? 'BOOTLOADER="no"' : 'BOOTLOADER="grub2"'
|
23
|
+
datas = [
|
24
|
+
'',
|
25
|
+
grub,
|
26
|
+
'INSTALL="yes"',
|
27
|
+
'MENUCONFIG="no"',
|
28
|
+
'CLEAN="yes"',
|
29
|
+
'KEYMAP="yes"',
|
30
|
+
'SAVE_CONFIG="yes"',
|
31
|
+
'MOUNTBOOT="yes"',
|
32
|
+
'MRPROPER="no"',
|
33
|
+
'LVM="yes"',
|
34
|
+
'LUKS="yes"',
|
35
|
+
]
|
36
|
+
file = "#{MOUNTPOINT}/etc/genkernel.conf"
|
37
|
+
File.write(file, datas.join("\n"), mode: 'a')
|
38
|
+
end
|
39
|
+
|
40
|
+
def install_efi
|
41
|
+
end
|
42
|
+
|
43
|
+
def install_bios
|
44
|
+
exec("euse -p sys-boot/grub -E device-mapper")
|
45
|
+
end
|
46
|
+
|
47
|
+
def install_deps
|
48
|
+
make_conf = "#{MOUNTPOINT}/etc/portage/make.conf"
|
49
|
+
exec("euse -E lvm") if ! Helpers::grep?(make_conf, /lvm/)
|
50
|
+
exec("euse -E cryptsetup") if ! Helpers::grep?(make_conf, /cryptsetup/)
|
51
|
+
Getch::Emerge.new('genkernel systemd sys-fs/cryptsetup lvm2').pkg!
|
52
|
+
Getch::Garden.new('-a lvm').run!
|
53
|
+
exec("systemctl enable lvm2-monitor")
|
54
|
+
end
|
55
|
+
|
56
|
+
def exec(cmd)
|
57
|
+
Getch::Chroot.new(cmd).run!
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|