getch 0.0.4 → 0.0.9
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.tar.gz.sig +0 -0
- data/CHANGELOG.md +40 -5
- data/README.md +31 -2
- data/bin/setup.sh +25 -11
- data/lib/getch.rb +41 -30
- data/lib/getch/command.rb +156 -0
- data/lib/getch/filesystem.rb +7 -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/gentoo.rb +4 -2
- data/lib/getch/gentoo/boot.rb +46 -11
- data/lib/getch/gentoo/chroot.rb +18 -14
- data/lib/getch/gentoo/config.rb +24 -9
- data/lib/getch/gentoo/sources.rb +54 -29
- data/lib/getch/gentoo/stage.rb +2 -2
- data/lib/getch/helpers.rb +28 -1
- data/lib/getch/log.rb +54 -0
- data/lib/getch/options.rb +16 -7
- data/lib/getch/version.rb +1 -1
- metadata +34 -5
- metadata.gz.sig +3 -4
- data/lib/getch/disk.rb +0 -77
- data/lib/getch/mount.rb +0 -73
@@ -0,0 +1,22 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Lvm
|
4
|
+
module Encrypt
|
5
|
+
class Device
|
6
|
+
def initialize
|
7
|
+
@disk = DEFAULT_OPTIONS[:disk]
|
8
|
+
@user = DEFAULT_OPTIONS[:username]
|
9
|
+
@dev_boot_efi = Helpers::efi? ? "/dev/#{@disk}1" : nil
|
10
|
+
@dev_boot = Helpers::efi? ? nil : "/dev/#{@disk}2"
|
11
|
+
@dev_root = Helpers::efi? ? "/dev/#{@disk}2" : "/dev/#{@disk}3"
|
12
|
+
@vg = 'vg0'
|
13
|
+
@lv_root = "/dev/mapper/#{@vg}-root"
|
14
|
+
@lv_swap = "/dev/mapper/#{@vg}-swap"
|
15
|
+
@lv_home = @user ? "/dev/mapper/#{@vg}-home" : nil
|
16
|
+
@luks_root = "/dev/mapper/cryptroot"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,32 @@
|
|
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} with #{@fs}"
|
16
|
+
exec("mkfs.fat -F32 #{@dev_boot_efi}") if @dev_boot_efi
|
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
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Getch
|
4
|
+
module FileSystem
|
5
|
+
module Lvm
|
6
|
+
module Encrypt
|
7
|
+
class Mount < Getch::FileSystem::Lvm::Encrypt::Device
|
8
|
+
def initialize
|
9
|
+
super
|
10
|
+
@root_dir = MOUNTPOINT
|
11
|
+
@boot_dir = "#{@root_dir}/boot"
|
12
|
+
@boot_efi_dir = "#{@root_dir}/boot/efi"
|
13
|
+
@home_dir = @user ? "#{@root_dir}/home/#{@user}" : nil
|
14
|
+
@state = Getch::States.new()
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
return if STATES[:mount]
|
19
|
+
mount_swap
|
20
|
+
mount_root
|
21
|
+
mount_boot
|
22
|
+
mount_home
|
23
|
+
mount_boot_efi
|
24
|
+
@state.mount
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def mount_swap
|
30
|
+
return if ! @lv_swap
|
31
|
+
system("swapon #{@lv_swap}")
|
32
|
+
end
|
33
|
+
|
34
|
+
def mount_root
|
35
|
+
return if ! @lv_root
|
36
|
+
Dir.mkdir(@root_dir, 0700) if ! Dir.exist?(@root_dir)
|
37
|
+
system("mount #{@lv_root} #{@root_dir}")
|
38
|
+
end
|
39
|
+
|
40
|
+
def mount_boot_efi
|
41
|
+
return if ! @dev_boot_efi
|
42
|
+
FileUtils.mkdir_p @boot_efi_dir, mode: 0700 if ! Dir.exist?(@boot_efi_dir)
|
43
|
+
system("mount #{@dev_boot_efi} #{@boot_efi_dir}")
|
44
|
+
end
|
45
|
+
|
46
|
+
def mount_boot
|
47
|
+
return if ! @dev_boot
|
48
|
+
FileUtils.mkdir_p @boot_dir, mode: 0700 if ! Dir.exist?(@boot_dir)
|
49
|
+
system("mount #{@dev_boot} #{@boot_dir}")
|
50
|
+
end
|
51
|
+
|
52
|
+
def mount_home
|
53
|
+
return if ! @lv_home
|
54
|
+
if @user != nil then
|
55
|
+
FileUtils.mkdir_p @home_dir, mode: 0700 if ! Dir.exist?(@home_dir)
|
56
|
+
system("mount #{@lv_home} #{@home_dir}")
|
57
|
+
end
|
58
|
+
@state.mount
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Lvm
|
4
|
+
module Encrypt
|
5
|
+
class Partition < Getch::FileSystem::Lvm::Encrypt::Device
|
6
|
+
def initialize
|
7
|
+
super
|
8
|
+
@state = Getch::States.new()
|
9
|
+
@log = Log.new
|
10
|
+
run_partition
|
11
|
+
end
|
12
|
+
|
13
|
+
def run_partition
|
14
|
+
return if STATES[:partition ]
|
15
|
+
clear_struct
|
16
|
+
cleaning
|
17
|
+
partition
|
18
|
+
encrypt
|
19
|
+
lvm
|
20
|
+
@state.partition
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def clear_struct
|
26
|
+
oldvg = `vgdisplay | grep #{@vg}`.chomp
|
27
|
+
exec("vgremove -f #{@vg}") if oldvg != '' # remove older volume group
|
28
|
+
exec("pvremove -f #{@dev_root}") if oldvg != '' and File.exist? @dev_root # remove older volume group
|
29
|
+
|
30
|
+
exec("sgdisk -Z /dev/#{@disk}")
|
31
|
+
exec("wipefs -a /dev/#{@disk}")
|
32
|
+
end
|
33
|
+
|
34
|
+
def cleaning
|
35
|
+
puts
|
36
|
+
print "Cleaning data on #{@disk}, can be long, avoid this on Flash Memory (SSD,USB,...) ? (n,y) "
|
37
|
+
case gets.chomp
|
38
|
+
when /^y|^Y/
|
39
|
+
bloc=`blockdev --getbsz /dev/#{@disk}`.chomp
|
40
|
+
exec("dd if=/dev/urandom of=/dev/#{@disk} bs=#{bloc} status=progress")
|
41
|
+
else
|
42
|
+
return
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def partition
|
47
|
+
if Helpers::efi?
|
48
|
+
exec("sgdisk -n1:1M:+260M -t1:EF00 /dev/#{@disk}")
|
49
|
+
exec("sgdisk -n2:0:+0 -t2:8e00 /dev/#{@disk}")
|
50
|
+
else
|
51
|
+
exec("sgdisk -n1:1MiB:+1MiB -t1:EF02 /dev/#{@disk}")
|
52
|
+
exec("sgdisk -n2:0:+128MiB -t2:8300 /dev/#{@disk}")
|
53
|
+
exec("sgdisk -n3:0:+0 -t3:8e00 /dev/#{@disk}")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def encrypt
|
58
|
+
@log.info("Format root")
|
59
|
+
Helpers::sys("cryptsetup luksFormat #{@dev_root}")
|
60
|
+
@log.debug("Opening root")
|
61
|
+
Helpers::sys("cryptsetup open --type luks #{@dev_root} cryptroot")
|
62
|
+
end
|
63
|
+
|
64
|
+
def lvm
|
65
|
+
mem=`awk '/MemTotal/ {print $2}' /proc/meminfo`.chomp + 'K'
|
66
|
+
exec("pvcreate -f #{@luks_root}")
|
67
|
+
exec("vgcreate -f #{@vg} #{@luks_root}")
|
68
|
+
# Wipe old signature: https://github.com/chef-cookbooks/lvm/issues/45
|
69
|
+
exec("lvcreate -y -Wy -Zy -L 15G -n root #{@vg}")
|
70
|
+
exec("lvcreate -y -Wy -Zy -L #{mem} -n swap #{@vg}")
|
71
|
+
exec("lvcreate -y -Wy -Zy -l 100%FREE -n home #{@vg}") if @user
|
72
|
+
exec("vgchange --available y")
|
73
|
+
end
|
74
|
+
|
75
|
+
# Follow https://wiki.archlinux.org/index.php/Partitioning
|
76
|
+
# Partition_efi
|
77
|
+
# /boot/efi - EFI system partition - 260MB
|
78
|
+
# / - Root
|
79
|
+
|
80
|
+
# Partition_bios
|
81
|
+
# None - Bios Boot Partition - 1MiB
|
82
|
+
# /boot - Boot - 8300
|
83
|
+
# / - Root
|
84
|
+
|
85
|
+
def exec(cmd)
|
86
|
+
Getch::Command.new(cmd).run!
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Lvm
|
4
|
+
class Format < Getch::FileSystem::Lvm::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
|
+
system("mkfs.fat -F32 #{@dev_boot_efi}") if @dev_boot_efi
|
16
|
+
system("mkfs.#{@fs} -F #{@dev_boot}") if @dev_boot
|
17
|
+
system("mkswap -f #{@lv_swap}")
|
18
|
+
system("mkfs.#{@fs} -F #{@lv_root}")
|
19
|
+
system("mkfs.#{@fs} -F #{@lv_home}") if @lv_home
|
20
|
+
@state.format
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Getch
|
4
|
+
module FileSystem
|
5
|
+
module Lvm
|
6
|
+
class Mount < Getch::FileSystem::Lvm::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 ! @lv_swap
|
30
|
+
system("swapon #{@lv_swap}")
|
31
|
+
end
|
32
|
+
|
33
|
+
def mount_root
|
34
|
+
return if ! @lv_root
|
35
|
+
Dir.mkdir(@root_dir, 0700) if ! Dir.exist?(@root_dir)
|
36
|
+
system("mount #{@lv_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 ! @lv_home
|
53
|
+
if @user != nil then
|
54
|
+
FileUtils.mkdir_p @home_dir, mode: 0700 if ! Dir.exist?(@home_dir)
|
55
|
+
system("mount #{@lv_home} #{@home_dir}")
|
56
|
+
end
|
57
|
+
@state.mount
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Lvm
|
4
|
+
class Partition < Getch::FileSystem::Lvm::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
|
+
partition
|
16
|
+
lvm
|
17
|
+
@state.partition
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def clear_struct
|
23
|
+
oldvg = `vgdisplay | grep #{@vg}`.chomp
|
24
|
+
exec("vgremove -f #{@vg}") if oldvg != '' # remove older volume group
|
25
|
+
exec("pvremove -f #{@dev_root}") if oldvg != '' and File.exist? @dev_root # remove older volume group
|
26
|
+
|
27
|
+
exec("sgdisk -Z /dev/#{@disk}")
|
28
|
+
exec("wipefs -a /dev/#{@disk}")
|
29
|
+
end
|
30
|
+
|
31
|
+
def cleaning
|
32
|
+
puts
|
33
|
+
print "Cleaning data on #{@disk}, can be long, avoid this on Flash Memory (SSD,USB,...) ? (n,y) "
|
34
|
+
case gets.chomp
|
35
|
+
when /^y|^Y/
|
36
|
+
bloc=`blockdev --getbsz /dev/#{@disk}`.chomp
|
37
|
+
exec("dd if=/dev/urandom of=/dev/#{@disk} bs=#{bloc} status=progress")
|
38
|
+
else
|
39
|
+
return
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def partition
|
44
|
+
if Helpers::efi?
|
45
|
+
exec("sgdisk -n1:1M:+260M -t1:EF00 /dev/#{@disk}")
|
46
|
+
exec("sgdisk -n2:0:+0 -t2:8e00 /dev/#{@disk}")
|
47
|
+
else
|
48
|
+
exec("sgdisk -n1:1MiB:+1MiB -t1:EF02 /dev/#{@disk}")
|
49
|
+
exec("sgdisk -n2:0:+128MiB -t2:8300 /dev/#{@disk}")
|
50
|
+
exec("sgdisk -n3:0:+0 -t3:8e00 /dev/#{@disk}")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def lvm
|
55
|
+
mem=`awk '/MemTotal/ {print $2}' /proc/meminfo`.chomp + 'K'
|
56
|
+
exec("pvcreate -f #{@dev_root}")
|
57
|
+
exec("vgcreate -f #{@vg} #{@dev_root}")
|
58
|
+
# Wipe old signature: https://github.com/chef-cookbooks/lvm/issues/45
|
59
|
+
exec("lvcreate -y -Wy -Zy -L 15G -n root #{@vg}")
|
60
|
+
exec("lvcreate -y -Wy -Zy -L #{mem} -n swap #{@vg}")
|
61
|
+
exec("lvcreate -y -Wy -Zy -l 100%FREE -n home #{@vg}") if @user
|
62
|
+
exec("vgchange --available y")
|
63
|
+
end
|
64
|
+
|
65
|
+
# Follow https://wiki.archlinux.org/index.php/Partitioning
|
66
|
+
# Partition_efi
|
67
|
+
# /boot/efi - EFI system partition - 260MB
|
68
|
+
# / - Root
|
69
|
+
|
70
|
+
# Partition_bios
|
71
|
+
# None - Bios Boot Partition - 1MiB
|
72
|
+
# /boot - Boot - 8300
|
73
|
+
# / - Root
|
74
|
+
|
75
|
+
def exec(cmd)
|
76
|
+
Getch::Command.new(cmd).run!
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/getch/gentoo.rb
CHANGED
@@ -32,18 +32,19 @@ module Getch
|
|
32
32
|
config.repo
|
33
33
|
config.network
|
34
34
|
config.systemd(options)
|
35
|
+
config.hostname
|
35
36
|
@state.config
|
36
37
|
end
|
37
38
|
|
38
39
|
def chroot
|
39
40
|
chroot = Getch::Gentoo::Chroot.new()
|
40
41
|
chroot.update
|
41
|
-
chroot.world
|
42
42
|
chroot.systemd
|
43
|
+
chroot.world
|
43
44
|
return if STATES[:gentoo_kernel]
|
44
45
|
chroot.kernel
|
45
46
|
chroot.kernel_deps
|
46
|
-
chroot.
|
47
|
+
chroot.install_pkgs
|
47
48
|
end
|
48
49
|
|
49
50
|
def kernel
|
@@ -51,6 +52,7 @@ module Getch
|
|
51
52
|
source = Getch::Gentoo::Sources.new()
|
52
53
|
new
|
53
54
|
source.build_kspp
|
55
|
+
source.init_config
|
54
56
|
source.build_others
|
55
57
|
source.make
|
56
58
|
@state.kernel
|
data/lib/getch/gentoo/boot.rb
CHANGED
@@ -1,22 +1,62 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
module Getch
|
2
4
|
module Gentoo
|
3
5
|
class Boot
|
4
6
|
def initialize(opts)
|
5
7
|
@disk = opts.disk
|
6
8
|
@user = opts.username
|
9
|
+
@config = Getch.class_fs::Config.new()
|
7
10
|
end
|
8
11
|
|
9
12
|
def start
|
10
|
-
|
11
|
-
|
13
|
+
@config.fstab
|
14
|
+
bootloader
|
12
15
|
password
|
13
16
|
umount
|
14
17
|
end
|
15
18
|
|
19
|
+
def bootloader
|
20
|
+
if Helpers::efi?
|
21
|
+
bootctl
|
22
|
+
else
|
23
|
+
grub
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# bootctl is alrealy installed with the stage3-amd64-systemd
|
28
|
+
def bootctl
|
29
|
+
bootctl_dep
|
30
|
+
puts "Configuring systemd-boot."
|
31
|
+
# ref: https://forums.gentoo.org/viewtopic-p-8118822.html
|
32
|
+
esp = '/boot/efi'
|
33
|
+
exec_chroot("bootctl --path #{esp} install")
|
34
|
+
datas_loader = [
|
35
|
+
'default gentoo',
|
36
|
+
'timeout 3',
|
37
|
+
'editor 0'
|
38
|
+
]
|
39
|
+
@config.systemd_boot
|
40
|
+
File.write("#{MOUNTPOINT}/#{esp}/loader/loader.conf", datas_loader.join("\n"))
|
41
|
+
|
42
|
+
FileUtils.cp("#{MOUNTPOINT}/usr/src/linux/arch/x86/boot/bzImage", "#{MOUNTPOINT}/#{esp}/vmlinuz", preserve: true)
|
43
|
+
|
44
|
+
initramfs = Dir.glob("#{MOUNTPOINT}/boot/initramfs-*.img")
|
45
|
+
FileUtils.cp("#{initramfs[0]}", "#{MOUNTPOINT}/#{esp}/initramfs", preserve: true) if initramfs != []
|
46
|
+
|
47
|
+
exec_chroot("bootctl --path #{esp} update")
|
48
|
+
end
|
49
|
+
|
50
|
+
def bootctl_dep
|
51
|
+
puts 'Installing systemd-boot...'
|
52
|
+
exec_chroot("euse -p sys-apps/systemd -E gnuefi")
|
53
|
+
Getch::Emerge.new("sys-apps/systemd efivar").pkg!
|
54
|
+
end
|
55
|
+
|
16
56
|
def grub
|
17
|
-
return if Helpers::efi?
|
18
57
|
puts 'Installing GRUB...'
|
19
|
-
|
58
|
+
Getch::Emerge.new("sys-boot/grub:2").pkg!
|
59
|
+
@config.grub
|
20
60
|
exec_chroot("grub-install /dev/#{@disk}")
|
21
61
|
exec_chroot('grub-mkconfig -o /boot/grub/grub.cfg')
|
22
62
|
end
|
@@ -36,23 +76,18 @@ module Getch
|
|
36
76
|
|
37
77
|
def umount
|
38
78
|
Helpers::exec_or_die("umount -l /mnt/gentoo/dev{/shm,/pts,}")
|
39
|
-
Helpers::exec_or_die("umount -R #{
|
79
|
+
Helpers::exec_or_die("umount -R #{MOUNTPOINT}")
|
40
80
|
puts "Reboot when you have done"
|
41
81
|
end
|
42
82
|
|
43
83
|
private
|
44
84
|
|
45
|
-
def gen_fstab
|
46
|
-
mount = Getch::Mount.new(@disk, @user)
|
47
|
-
mount.gen_fstab
|
48
|
-
end
|
49
|
-
|
50
85
|
def exec_chroot(cmd)
|
51
86
|
script = "chroot #{MOUNTPOINT} /bin/bash -c \"
|
52
87
|
source /etc/profile
|
53
88
|
#{cmd}
|
54
89
|
\""
|
55
|
-
|
90
|
+
Getch::Command.new(script).run!
|
56
91
|
end
|
57
92
|
end
|
58
93
|
end
|