getch 0.1.3 → 0.3.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.
Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.md +75 -35
  4. data/assets/network-stack.conf +63 -0
  5. data/assets/system.conf +38 -0
  6. data/bin/getch +14 -4
  7. data/lib/clean.rb +149 -0
  8. data/lib/cmdline.rb +128 -0
  9. data/lib/cryptsetup.rb +132 -0
  10. data/lib/devs.rb +199 -0
  11. data/lib/dracut/encrypt.rb +36 -0
  12. data/lib/dracut/hybrid.rb +15 -0
  13. data/lib/dracut/lvm.rb +14 -0
  14. data/lib/dracut/minimal.rb +11 -0
  15. data/lib/dracut/root.rb +45 -0
  16. data/lib/dracut/zfs.rb +35 -0
  17. data/lib/dracut.rb +11 -0
  18. data/lib/fstab/encrypt.rb +44 -0
  19. data/lib/fstab/hybrid.rb +34 -0
  20. data/lib/fstab/lvm.rb +25 -0
  21. data/lib/fstab/minimal.rb +6 -0
  22. data/lib/fstab/root.rb +93 -0
  23. data/lib/fstab/zfs.rb +23 -0
  24. data/lib/fstab.rb +11 -0
  25. data/lib/getch/assembly.rb +150 -0
  26. data/lib/getch/command.rb +94 -124
  27. data/lib/getch/config/account.rb +39 -0
  28. data/lib/getch/config/dhcp.rb +104 -0
  29. data/lib/getch/config/grub.rb +42 -0
  30. data/lib/getch/config/iwd.rb +60 -0
  31. data/lib/getch/config/keymap.rb +78 -0
  32. data/lib/getch/config/locale.rb +96 -0
  33. data/lib/getch/config/portage.rb +90 -0
  34. data/lib/getch/config/pre_network.rb +37 -0
  35. data/lib/getch/config/timezone.rb +52 -0
  36. data/lib/getch/config/void.rb +11 -0
  37. data/lib/getch/config.rb +19 -53
  38. data/lib/getch/device.rb +67 -0
  39. data/lib/getch/filesystem/ext4/encrypt/config.rb +11 -68
  40. data/lib/getch/filesystem/ext4/encrypt/deps.rb +17 -25
  41. data/lib/getch/filesystem/ext4/encrypt/device.rb +13 -5
  42. data/lib/getch/filesystem/ext4/encrypt/format.rb +8 -15
  43. data/lib/getch/filesystem/ext4/encrypt/mount.rb +9 -13
  44. data/lib/getch/filesystem/ext4/encrypt/partition.rb +10 -82
  45. data/lib/getch/filesystem/ext4/encrypt/void.rb +63 -0
  46. data/lib/getch/filesystem/ext4/encrypt.rb +4 -0
  47. data/lib/getch/filesystem/ext4/hybrid/config.rb +27 -0
  48. data/lib/getch/filesystem/ext4/hybrid/deps.rb +55 -0
  49. data/lib/getch/filesystem/ext4/hybrid/device.rb +24 -0
  50. data/lib/getch/filesystem/ext4/hybrid/format.rb +23 -0
  51. data/lib/getch/filesystem/ext4/hybrid/mount.rb +21 -0
  52. data/lib/getch/filesystem/ext4/hybrid/partition.rb +27 -0
  53. data/lib/getch/filesystem/ext4/hybrid/void.rb +62 -0
  54. data/lib/getch/filesystem/ext4/hybrid.rb +19 -0
  55. data/lib/getch/filesystem/ext4/lvm/config.rb +25 -0
  56. data/lib/getch/filesystem/ext4/lvm/deps.rb +56 -0
  57. data/lib/getch/filesystem/ext4/lvm/device.rb +28 -0
  58. data/lib/getch/filesystem/ext4/lvm/format.rb +21 -0
  59. data/lib/getch/filesystem/ext4/lvm/mount.rb +21 -0
  60. data/lib/getch/filesystem/ext4/lvm/partition.rb +28 -0
  61. data/lib/getch/filesystem/{lvm.rb → ext4/lvm.rb} +8 -3
  62. data/lib/getch/filesystem/ext4/minimal/config.rb +25 -0
  63. data/lib/getch/filesystem/ext4/{device.rb → minimal/deps.rb} +4 -3
  64. data/lib/getch/filesystem/ext4/minimal/device.rb +22 -0
  65. data/lib/getch/filesystem/ext4/minimal/format.rb +23 -0
  66. data/lib/getch/filesystem/ext4/minimal/mount.rb +21 -0
  67. data/lib/getch/filesystem/ext4/minimal/partition.rb +28 -0
  68. data/lib/getch/filesystem/ext4/minimal.rb +19 -0
  69. data/lib/getch/filesystem/ext4.rb +9 -6
  70. data/lib/getch/filesystem/zfs/encrypt/config.rb +12 -57
  71. data/lib/getch/filesystem/zfs/encrypt/deps.rb +7 -86
  72. data/lib/getch/filesystem/zfs/encrypt/device.rb +9 -45
  73. data/lib/getch/filesystem/zfs/encrypt/format.rb +8 -90
  74. data/lib/getch/filesystem/zfs/encrypt/mount.rb +16 -34
  75. data/lib/getch/filesystem/zfs/encrypt/partition.rb +8 -50
  76. data/lib/getch/filesystem/zfs/encrypt.rb +4 -0
  77. data/lib/getch/filesystem/zfs/minimal/config.rb +37 -0
  78. data/lib/getch/filesystem/zfs/minimal/deps.rb +126 -0
  79. data/lib/getch/filesystem/zfs/minimal/device.rb +24 -0
  80. data/lib/getch/filesystem/zfs/minimal/format.rb +23 -0
  81. data/lib/getch/filesystem/zfs/minimal/mount.rb +23 -0
  82. data/lib/getch/filesystem/zfs/minimal/partition.rb +23 -0
  83. data/lib/getch/filesystem/zfs/minimal.rb +19 -0
  84. data/lib/getch/filesystem/zfs.rb +3 -6
  85. data/lib/getch/filesystem.rb +2 -6
  86. data/lib/getch/gentoo/bootloader.rb +47 -0
  87. data/lib/getch/gentoo/finalize.rb +25 -0
  88. data/lib/getch/gentoo/post_config.rb +75 -0
  89. data/lib/getch/gentoo/pre_config.rb +37 -0
  90. data/lib/getch/gentoo/services.rb +18 -0
  91. data/lib/getch/gentoo/sources.rb +82 -52
  92. data/lib/getch/gentoo/tarball.rb +91 -0
  93. data/lib/getch/gentoo/terraform.rb +34 -0
  94. data/lib/getch/gentoo/update.rb +54 -0
  95. data/lib/getch/gentoo/use.rb +11 -12
  96. data/lib/getch/gentoo/use_flag.rb +74 -52
  97. data/lib/getch/gentoo.rb +11 -63
  98. data/lib/getch/guard.rb +71 -0
  99. data/lib/getch/helpers.rb +128 -48
  100. data/lib/getch/log.rb +91 -26
  101. data/lib/getch/options.rb +79 -40
  102. data/lib/getch/states.rb +37 -10
  103. data/lib/getch/tree.rb +56 -0
  104. data/lib/getch/version.rb +1 -1
  105. data/lib/getch/void/bootloader.rb +18 -0
  106. data/lib/getch/void/finalize.rb +31 -0
  107. data/lib/getch/void/post_config.rb +19 -0
  108. data/lib/getch/void/pre_config.rb +18 -0
  109. data/lib/getch/void/services.rb +18 -0
  110. data/lib/getch/void/tarball.rb +89 -0
  111. data/lib/getch/void/terraform.rb +28 -0
  112. data/lib/getch/void/update.rb +33 -0
  113. data/lib/getch/void.rb +15 -0
  114. data/lib/getch.rb +104 -92
  115. data/lib/luks.rb +239 -0
  116. data/lib/lvm2.rb +112 -0
  117. data/lib/mkfs/zfs.rb +167 -0
  118. data/lib/mkfs.rb +140 -0
  119. data/lib/mountfs.rb +154 -0
  120. data/lib/nito.rb +131 -0
  121. data/lib/sgdisk.rb +160 -0
  122. data.tar.gz.sig +0 -0
  123. metadata +96 -45
  124. metadata.gz.sig +0 -0
  125. data/.gitignore +0 -2
  126. data/CHANGELOG.md +0 -90
  127. data/Rakefile +0 -21
  128. data/bin/setup.sh +0 -90
  129. data/getch.gemspec +0 -25
  130. data/lib/getch/filesystem/clean.rb +0 -51
  131. data/lib/getch/filesystem/device.rb +0 -61
  132. data/lib/getch/filesystem/ext4/config.rb +0 -58
  133. data/lib/getch/filesystem/ext4/deps.rb +0 -22
  134. data/lib/getch/filesystem/ext4/format.rb +0 -28
  135. data/lib/getch/filesystem/ext4/mount.rb +0 -23
  136. data/lib/getch/filesystem/ext4/partition.rb +0 -52
  137. data/lib/getch/filesystem/lvm/config.rb +0 -59
  138. data/lib/getch/filesystem/lvm/deps.rb +0 -42
  139. data/lib/getch/filesystem/lvm/device.rb +0 -43
  140. data/lib/getch/filesystem/lvm/encrypt/config.rb +0 -71
  141. data/lib/getch/filesystem/lvm/encrypt/deps.rb +0 -46
  142. data/lib/getch/filesystem/lvm/encrypt/device.rb +0 -46
  143. data/lib/getch/filesystem/lvm/encrypt/format.rb +0 -32
  144. data/lib/getch/filesystem/lvm/encrypt/mount.rb +0 -25
  145. data/lib/getch/filesystem/lvm/encrypt/partition.rb +0 -80
  146. data/lib/getch/filesystem/lvm/encrypt.rb +0 -15
  147. data/lib/getch/filesystem/lvm/format.rb +0 -29
  148. data/lib/getch/filesystem/lvm/mount.rb +0 -23
  149. data/lib/getch/filesystem/lvm/partition.rb +0 -69
  150. data/lib/getch/filesystem/mount.rb +0 -56
  151. data/lib/getch/filesystem/partition.rb +0 -77
  152. data/lib/getch/filesystem/zfs/config.rb +0 -57
  153. data/lib/getch/filesystem/zfs/deps.rb +0 -95
  154. data/lib/getch/filesystem/zfs/device.rb +0 -58
  155. data/lib/getch/filesystem/zfs/format.rb +0 -114
  156. data/lib/getch/filesystem/zfs/mount.rb +0 -48
  157. data/lib/getch/filesystem/zfs/partition.rb +0 -64
  158. data/lib/getch/gentoo/boot.rb +0 -109
  159. data/lib/getch/gentoo/chroot.rb +0 -77
  160. data/lib/getch/gentoo/config.rb +0 -129
  161. data/lib/getch/gentoo/stage.rb +0 -74
@@ -1,61 +0,0 @@
1
- module Getch
2
- module FileSystem
3
- class Device
4
- def initialize
5
- @efi = Helpers::efi?
6
- @root_part = 1
7
- @user = DEFAULT_OPTIONS[:username]
8
-
9
- @disk = DEFAULT_OPTIONS[:disk]
10
- @boot_disk = DEFAULT_OPTIONS[:boot_disk]
11
- @cache_disk = DEFAULT_OPTIONS[:cache_disk]
12
- @home_disk = DEFAULT_OPTIONS[:home_disk]
13
-
14
- search_boot
15
- search_swap
16
- search_root
17
- search_home
18
- end
19
-
20
- private
21
- def search_boot
22
- if @efi
23
- if @boot_disk
24
- @dev_esp = "/dev/#{@boot_disk}#{@root_part}"
25
- else
26
- @dev_esp = "/dev/#{@disk}#{@root_part}"
27
- @root_part += 1
28
- end
29
- else
30
- if @boot_disk
31
- @dev_gpt = "/dev/#{@boot_disk}#{@root_part}"
32
- @dev_grub = "/dev/#{@boot_disk}"
33
- else
34
- @dev_gpt = "/dev/#{@disk}#{@root_part}"
35
- @dev_grub = "/dev/#{@disk}"
36
- @root_part += 1
37
- end
38
- end
39
- end
40
-
41
- def search_swap
42
- if @cache_disk
43
- @dev_swap = "/dev/#{@cache_disk}1"
44
- else
45
- @dev_swap = "/dev/#{@disk}#{@root_part}"
46
- @root_part += 1
47
- end
48
- end
49
-
50
- def search_root
51
- @dev_root = "/dev/#{@disk}#{@root_part}"
52
- end
53
-
54
- def search_home
55
- if @home_disk
56
- @dev_home = "/dev/#{@home_disk}1"
57
- end
58
- end
59
- end
60
- end
61
- end
@@ -1,58 +0,0 @@
1
- module Getch
2
- module FileSystem
3
- module Ext4
4
- class Config < Getch::FileSystem::Ext4::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 = '/efi'
21
- dir = "#{@root_dir}/#{esp}/loader/entries/"
22
- datas_gentoo = [
23
- 'title Gentoo Linux',
24
- 'linux /vmlinuz',
25
- "options root=PARTUUID=#{@partuuid_root} init=#{@init} rw"
26
- ]
27
- File.write("#{dir}/gentoo.conf", datas_gentoo.join("\n"))
28
- end
29
-
30
- def grub
31
- return if Helpers::efi?
32
- file = "#{@root_dir}/etc/default/grub"
33
- cmdline = "GRUB_CMDLINE_LINUX=\"resume=PARTUUID=#{@partuuid_swap} root=PARTUUID=#{@partuuid_root} init=#{@init} rw slub_debug=P page_poison=1 slab_nomerge pti=on vsyscall=none spectre_v2=on spec_store_bypass_disable=seccomp iommu=force\"\n"
34
- File.write(file, cmdline, mode: 'a')
35
- end
36
-
37
- private
38
-
39
- def gen_uuid
40
- @partuuid_root = Helpers::partuuid(@dev_root)
41
- @partuuid_swap = Helpers::partuuid(@dev_swap)
42
- @uuid_root = `lsblk -o "UUID" #{@dev_root} | tail -1`.chomp() if @dev_root
43
- @uuid_esp = `lsblk -o "UUID" #{@dev_esp} | tail -1`.chomp() if @dev_esp
44
- @uuid_home = `lsblk -o "UUID" #{@dev_home} | tail -1`.chomp() if @dev_home
45
- end
46
-
47
- def data_fstab
48
- esp = @dev_esp ? "UUID=#{@uuid_esp} /efi vfat noauto,noatime 1 2" : ''
49
- swap = @dev_swap ? "PARTUUID=#{@partuuid_swap} none swap discard 0 0" : ''
50
- root = @dev_root ? "UUID=#{@uuid_root} / ext4 defaults 0 1" : ''
51
- home = @dev_home ? "UUID=#{@uuid_home} /home/#{@user} ext4 defaults 0 2" : ''
52
-
53
- [ esp, swap, root, home ]
54
- end
55
- end
56
- end
57
- end
58
- end
@@ -1,22 +0,0 @@
1
- module Getch
2
- module FileSystem
3
- module Ext4
4
- class Deps
5
- def initialize
6
- if Helpers::efi?
7
- install_efi
8
- else
9
- install_bios
10
- end
11
- end
12
-
13
- private
14
- def install_efi
15
- end
16
-
17
- def install_bios
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,28 +0,0 @@
1
- module Getch
2
- module FileSystem
3
- module Ext4
4
- class Format < Getch::FileSystem::Ext4::Device
5
- def initialize
6
- super
7
- @state = Getch::States.new()
8
- format
9
- end
10
-
11
- def format
12
- return if STATES[:format]
13
- exec("mkfs.fat -F32 #{@dev_esp}") if @dev_esp
14
- exec("mkswap -f #{@dev_swap}")
15
- exec("mkfs.ext4 -F #{@dev_root}")
16
- exec("mkfs.ext4 -F #{@dev_home}") if @dev_home
17
- @state.format
18
- end
19
-
20
- private
21
-
22
- def exec(cmd)
23
- Getch::Command.new(cmd).run!
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,23 +0,0 @@
1
- module Getch
2
- module FileSystem
3
- module Ext4
4
- class Mount < Getch::FileSystem::Ext4::Device
5
- def initialize
6
- super
7
- @mount = Getch::FileSystem::Mount.new
8
- @state = Getch::States.new
9
- end
10
-
11
- def run
12
- return if STATES[:mount]
13
- @mount.swap(@dev_swap)
14
- @mount.root(@dev_root)
15
- @mount.boot(@dev_boot)
16
- @mount.esp(@dev_esp)
17
- @mount.home(@dev_home)
18
- @state.mount
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,52 +0,0 @@
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
- @clean = Getch::FileSystem::Clean
9
- @partition = Getch::FileSystem::Partition.new
10
- run_partition
11
- end
12
-
13
- def run_partition
14
- return if STATES[:partition ]
15
- @clean.struct(@disk, @cache_disk, @home_disk)
16
- @clean.hdd(@disk, @cache_disk, @home_disk)
17
- if Helpers::efi?
18
- partition_efi
19
- else
20
- partition_bios
21
- end
22
- @state.partition
23
- end
24
-
25
- private
26
-
27
- # Follow https://wiki.archlinux.org/index.php/Partitioning
28
- def partition_efi
29
- # /efi - EFI system partition - 260MB
30
- # swap - Linux Swap - size of the ram
31
- # / - Root
32
- # /home - Home
33
- @partition.efi(@dev_esp)
34
- @partition.swap(@dev_swap)
35
- @partition.root(@dev_root, "8304")
36
- @partition.home(@dev_home, "8302") if @dev_home
37
- end
38
-
39
- def partition_bios
40
- # None - Bios Boot Partition - 1MiB
41
- # / - Root
42
- # swap - Linux Swap - size of the ram
43
- # /home - Home
44
- @partition.gpt(@dev_gpt)
45
- @partition.swap(@dev_swap)
46
- @partition.root(@dev_root, "8304")
47
- @partition.home(@dev_home, "8302") if @dev_home
48
- end
49
- end
50
- end
51
- end
52
- end
@@ -1,59 +0,0 @@
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 !@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=#{@lv_swap} root=#{@lv_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 @efi
33
- file = "#{@root_dir}/etc/default/grub"
34
- cmdline = [
35
- "GRUB_CMDLINE_LINUX=\"resume=#{@lv_swap} root=#{@lv_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_boot = `lsblk -o "UUID" #{@dev_boot} | tail -1`.chomp() if @dev_boot
44
- @uuid_esp = `lsblk -o "UUID" #{@dev_esp} | tail -1`.chomp() if @dev_esp
45
- end
46
-
47
- def data_fstab
48
- efi = @dev_esp ? "UUID=#{@uuid_esp} /efi vfat noauto,noatime 1 2" : ''
49
- boot = @dev_boot ? "UUID=#{@uuid_boot} /boot ext4 noauto,noatime 1 2" : ''
50
- swap = "#{@lv_swap} none swap discard 0 0"
51
- root = "#{@lv_root} / ext4 defaults 0 1"
52
- home = @lv_home ? "#{@lv_home} /home/#{@user} ext4 defaults 0 2" : ''
53
-
54
- [ efi, boot, swap, root, home ]
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,42 +0,0 @@
1
- module Getch
2
- module FileSystem
3
- module Lvm
4
- class Deps
5
- def make
6
- install_bios unless Helpers::efi?
7
- install_deps
8
- options_make
9
- Getch::Make.new("genkernel --kernel-config=/usr/src/linux/.config all").run!
10
- end
11
-
12
- private
13
- def options_make
14
- grub = Helpers::efi? ? 'BOOTLOADER="no"' : 'BOOTLOADER="grub2"'
15
- datas = [
16
- '',
17
- grub,
18
- 'INSTALL="yes"',
19
- 'MENUCONFIG="no"',
20
- 'CLEAN="yes"',
21
- 'SAVE_CONFIG="yes"',
22
- 'MOUNTBOOT="yes"',
23
- 'MRPROPER="no"',
24
- 'LVM="yes"',
25
- ]
26
- file = "#{MOUNTPOINT}/etc/genkernel.conf"
27
- File.write(file, datas.join("\n"), mode: 'a')
28
- end
29
-
30
- def install_deps
31
- Getch::Bask.new('-a lvm').run!
32
- Getch::Emerge.new('sys-fs/lvm2 genkernel').pkg!
33
- exec("systemctl enable lvm2-monitor")
34
- end
35
-
36
- def exec(cmd)
37
- Getch::Chroot.new(cmd).run!
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,43 +0,0 @@
1
- module Getch
2
- module FileSystem
3
- module Lvm
4
- class Device < Getch::FileSystem::Device
5
- def initialize
6
- super
7
- @vg = 'vg0'
8
- @lv_root = "/dev/#{@vg}/root"
9
- @lv_swap = "/dev/#{@vg}/swap"
10
- @lv_home = @home_disk ? "/dev/#{@vg}/home" : nil
11
- end
12
-
13
- private
14
-
15
- def search_boot
16
- if @efi
17
- if @boot_disk
18
- @dev_esp = "/dev/#{@boot_disk}1"
19
- else
20
- @dev_esp = "/dev/#{@disk}1"
21
- @root_part += 1
22
- end
23
- else
24
- if @boot_disk
25
- @dev_gpt = "/dev/#{@boot_disk}1"
26
- @dev_boot = "/dev/#{@boot_disk}2"
27
- @dev_grub = "/dev/#{@boot_disk}"
28
- else
29
- @dev_gpt = "/dev/#{@disk}1"
30
- @dev_boot = "/dev/#{@disk}2"
31
- @dev_grub = "/dev/#{@disk}"
32
- @root_part += 2
33
- end
34
- end
35
- end
36
-
37
- # The swap is a part of the LVM volume, so we clean the func
38
- def search_swap
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,71 +0,0 @@
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 = '/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=/dev/mapper/root real_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=512"
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=/dev/mapper/root real_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_dev_root = `lsblk -d -o "UUID" #{@dev_root} | tail -1`.chomp() if @dev_root
54
- @uuid_boot = `lsblk -o "UUID" #{@dev_boot} | tail -1`.chomp() if @dev_boot
55
- @uuid_esp = `lsblk -o "UUID" #{@dev_esp} | tail -1`.chomp() if @dev_esp
56
- end
57
-
58
- def data_fstab
59
- boot_efi = @dev_esp ? "UUID=#{@uuid_esp} /efi vfat noauto,noatime 1 2" : ''
60
- boot = @dev_boot ? "UUID=#{@uuid_boot} /boot ext4 noauto,noatime 1 2" : ''
61
- swap = "/dev/mapper/cryptswap none swap discard 0 0"
62
- root = "#{@lv_root} / ext4 defaults 0 1"
63
- home = @lv_home ? "#{@lv_home} /home/#{@user} ext4 defaults 0 2" : ''
64
-
65
- [ boot_efi, boot, swap, root, home ]
66
- end
67
- end
68
- end
69
- end
70
- end
71
- end
@@ -1,46 +0,0 @@
1
- module Getch
2
- module FileSystem
3
- module Lvm
4
- module Encrypt
5
- class Deps
6
- def make
7
- install_deps
8
- options_make
9
- Getch::Make.new("genkernel --kernel-config=/usr/src/linux/.config all").run!
10
- end
11
-
12
- private
13
- def options_make
14
- grub = Helpers::efi? ? 'BOOTLOADER="no"' : 'BOOTLOADER="grub2"'
15
- datas = [
16
- '',
17
- grub,
18
- 'INSTALL="yes"',
19
- 'MENUCONFIG="no"',
20
- 'CLEAN="yes"',
21
- 'KEYMAP="yes"',
22
- 'SAVE_CONFIG="yes"',
23
- 'MOUNTBOOT="yes"',
24
- 'MRPROPER="no"',
25
- 'LVM="yes"',
26
- 'LUKS="yes"',
27
- ]
28
- file = "#{MOUNTPOINT}/etc/genkernel.conf"
29
- File.write(file, datas.join("\n"), mode: 'a')
30
- end
31
-
32
- def install_deps
33
- # lvm2, cryptsetup alrealy installed
34
- Getch::Bask.new('-a lvm').run!
35
- Getch::Emerge.new('genkernel').pkg!
36
- exec("systemctl enable lvm2-monitor")
37
- end
38
-
39
- def exec(cmd)
40
- Getch::Chroot.new(cmd).run!
41
- end
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,46 +0,0 @@
1
- module Getch
2
- module FileSystem
3
- module Lvm
4
- module Encrypt
5
- class Device < Getch::FileSystem::Device
6
- def initialize
7
- super
8
- @vg = 'vg0'
9
- @lv_root = "/dev/#{@vg}/root"
10
- @lv_swap = "/dev/#{@vg}/swap"
11
- @lv_home = @home_disk ? "/dev/#{@vg}/home" : nil
12
- @luks_root = "/dev/mapper/cryptroot"
13
- @luks_home = @home_disk ? "/dev/mapper/crypthome" : nil
14
- end
15
-
16
- private
17
-
18
- def search_boot
19
- if @efi
20
- if @boot_disk
21
- @dev_esp = "/dev/#{@boot_disk}1"
22
- else
23
- @dev_esp = "/dev/#{@disk}1"
24
- @root_part += 1
25
- end
26
- else
27
- if @boot_disk
28
- @dev_gpt = "/dev/#{@boot_disk}1"
29
- @dev_boot = "/dev/#{@boot_disk}2"
30
- @dev_grub = "/dev/#{@boot_disk}"
31
- else
32
- @dev_gpt = "/dev/#{@disk}1"
33
- @dev_boot = "/dev/#{@disk}2"
34
- @dev_grub = "/dev/#{@disk}"
35
- @root_part += 2
36
- end
37
- end
38
- end
39
-
40
- def search_swap
41
- end
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,32 +0,0 @@
1
- module Getch
2
- module FileSystem
3
- module Lvm
4
- module Encrypt
5
- class Format < Getch::FileSystem::Lvm::Encrypt::Device
6
- def initialize
7
- super
8
- @fs = 'ext4'
9
- @state = Getch::States.new()
10
- format
11
- end
12
-
13
- def format
14
- return if STATES[:format]
15
- puts "Format #{@disk}"
16
- exec("mkfs.fat -F32 #{@dev_esp}") if @dev_esp
17
- exec("mkfs.#{@fs} -F #{@dev_boot}") if @dev_boot
18
- exec("mkswap -f #{@lv_swap}")
19
- exec("mkfs.#{@fs} -F #{@lv_root}")
20
- exec("mkfs.#{@fs} -F #{@lv_home}") if @lv_home
21
- @state.format
22
- end
23
-
24
- private
25
- def exec(cmd)
26
- Getch::Command.new(cmd).run!
27
- end
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,25 +0,0 @@
1
- module Getch
2
- module FileSystem
3
- module Lvm
4
- module Encrypt
5
- class Mount < Getch::FileSystem::Lvm::Encrypt::Device
6
- def initialize
7
- super
8
- @mount = Getch::FileSystem::Mount.new
9
- @state = Getch::States.new
10
- end
11
-
12
- def run
13
- return if STATES[:mount]
14
- @mount.swap(@lv_swap)
15
- @mount.root(@lv_root)
16
- @mount.boot(@dev_boot)
17
- @mount.esp(@dev_esp)
18
- @mount.home(@lv_home)
19
- @state.mount
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end