getch 0.1.6 → 0.1.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/README.md +17 -26
- data/assets/system.conf +38 -0
- data/lib/cmdline.rb +128 -0
- data/lib/getch/command.rb +31 -21
- data/lib/getch/config/gentoo.rb +22 -23
- data/lib/getch/config/void.rb +8 -10
- data/lib/getch/config.rb +5 -2
- data/lib/getch/filesystem/clean.rb +15 -15
- data/lib/getch/filesystem/device.rb +3 -1
- data/lib/getch/filesystem/ext4/config.rb +8 -4
- data/lib/getch/filesystem/ext4/deps.rb +3 -1
- data/lib/getch/filesystem/ext4/device.rb +2 -3
- data/lib/getch/filesystem/ext4/encrypt/config.rb +12 -7
- data/lib/getch/filesystem/ext4/encrypt/deps.rb +4 -2
- data/lib/getch/filesystem/ext4/encrypt/device.rb +5 -3
- data/lib/getch/filesystem/ext4/encrypt/format.rb +4 -1
- data/lib/getch/filesystem/ext4/encrypt/mount.rb +3 -2
- data/lib/getch/filesystem/ext4/encrypt/partition.rb +21 -21
- data/lib/getch/filesystem/ext4/encrypt/void.rb +22 -21
- data/lib/getch/filesystem/ext4/encrypt.rb +2 -0
- data/lib/getch/filesystem/ext4/format.rb +3 -0
- data/lib/getch/filesystem/ext4/mount.rb +3 -0
- data/lib/getch/filesystem/ext4/partition.rb +9 -6
- data/lib/getch/filesystem/ext4/void.rb +8 -7
- data/lib/getch/filesystem/ext4.rb +2 -0
- data/lib/getch/filesystem/lvm/config.rb +7 -22
- data/lib/getch/filesystem/lvm/deps.rb +6 -4
- data/lib/getch/filesystem/lvm/device.rb +2 -0
- data/lib/getch/filesystem/lvm/encrypt/config.rb +12 -9
- data/lib/getch/filesystem/lvm/encrypt/deps.rb +6 -3
- data/lib/getch/filesystem/lvm/encrypt/device.rb +4 -2
- data/lib/getch/filesystem/lvm/encrypt/format.rb +4 -0
- data/lib/getch/filesystem/lvm/encrypt/mount.rb +3 -0
- data/lib/getch/filesystem/lvm/encrypt/partition.rb +7 -7
- data/lib/getch/filesystem/lvm/encrypt/void.rb +20 -19
- data/lib/getch/filesystem/lvm/encrypt.rb +2 -0
- data/lib/getch/filesystem/lvm/format.rb +3 -0
- data/lib/getch/filesystem/lvm/mount.rb +3 -0
- data/lib/getch/filesystem/lvm/partition.rb +8 -5
- data/lib/getch/filesystem/lvm/void.rb +7 -6
- data/lib/getch/filesystem/lvm.rb +2 -0
- data/lib/getch/filesystem/mount.rb +19 -12
- data/lib/getch/filesystem/partition.rb +16 -8
- data/lib/getch/filesystem/zfs/config.rb +9 -23
- data/lib/getch/filesystem/zfs/deps.rb +22 -57
- data/lib/getch/filesystem/zfs/device.rb +3 -1
- data/lib/getch/filesystem/zfs/encrypt/config.rb +10 -26
- data/lib/getch/filesystem/zfs/encrypt/deps.rb +25 -60
- data/lib/getch/filesystem/zfs/encrypt/device.rb +3 -1
- data/lib/getch/filesystem/zfs/encrypt/format.rb +12 -8
- data/lib/getch/filesystem/zfs/encrypt/mount.rb +13 -8
- data/lib/getch/filesystem/zfs/encrypt/partition.rb +18 -15
- data/lib/getch/filesystem/zfs/encrypt/void.rb +23 -22
- data/lib/getch/filesystem/zfs/encrypt.rb +2 -0
- data/lib/getch/filesystem/zfs/format.rb +9 -5
- data/lib/getch/filesystem/zfs/mount.rb +9 -7
- data/lib/getch/filesystem/zfs/partition.rb +15 -12
- data/lib/getch/filesystem/zfs/void.rb +20 -20
- data/lib/getch/filesystem/zfs.rb +2 -0
- data/lib/getch/filesystem.rb +2 -0
- data/lib/getch/gentoo/boot.rb +21 -72
- data/lib/getch/gentoo/bootloader.rb +68 -0
- data/lib/getch/gentoo/chroot.rb +26 -33
- data/lib/getch/gentoo/config.rb +30 -26
- data/lib/getch/gentoo/sources.rb +55 -66
- data/lib/getch/gentoo/stage.rb +12 -12
- data/lib/getch/gentoo/use.rb +3 -7
- data/lib/getch/gentoo/use_flag.rb +77 -51
- data/lib/getch/gentoo.rb +22 -8
- data/lib/getch/guard.rb +50 -43
- data/lib/getch/helpers.rb +155 -143
- data/lib/getch/log.rb +7 -5
- data/lib/getch/options.rb +16 -14
- data/lib/getch/states.rb +10 -3
- data/lib/getch/version.rb +1 -1
- data/lib/getch/void/boot.rb +18 -14
- data/lib/getch/void/chroot.rb +20 -19
- data/lib/getch/void/config.rb +20 -17
- data/lib/getch/void/stage.rb +13 -14
- data/lib/getch/void.rb +7 -1
- data/lib/getch.rb +13 -5
- data.tar.gz.sig +0 -0
- metadata +6 -5
- metadata.gz.sig +0 -0
- data/lib/getch/filesystem/.mount.rb.swp +0 -0
- data/lib/getch/filesystem/zfs/encrypt/.mount.rb.swp +0 -0
@@ -1,10 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Getch
|
4
4
|
module FileSystem
|
5
5
|
module Zfs
|
6
6
|
class Void < Device
|
7
7
|
include Helpers::Void
|
8
|
+
|
8
9
|
attr_reader :boot_disk
|
9
10
|
|
10
11
|
def initialize
|
@@ -21,19 +22,18 @@ module Getch
|
|
21
22
|
def fstab
|
22
23
|
conf = "#{MOUNTPOINT}/etc/fstab"
|
23
24
|
File.write(conf, "\n", mode: 'w', chmod: 0644)
|
24
|
-
line_fstab(@dev_esp,
|
25
|
-
line_fstab(@dev_swap,
|
25
|
+
line_fstab(@dev_esp, '/efi vfat noauto,rw,relatime 0 0') if @dev_esp
|
26
|
+
line_fstab(@dev_swap, 'swap swap rw,noatime,discard 0 0') if @dev_swap
|
26
27
|
#add_line(conf, "#{@boot_pool_name}/BOOT/#{@n} /boot zfs defaults 0 0") if @dev_boot
|
27
|
-
add_line(conf,
|
28
|
+
add_line(conf, 'tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0')
|
28
29
|
end
|
29
30
|
|
30
31
|
def config_dracut
|
31
32
|
conf = "#{MOUNTPOINT}/etc/dracut.conf.d/zfs.conf"
|
32
33
|
# dracut: value+= should be surrounding by white space
|
33
34
|
content = [
|
34
|
-
|
35
|
-
|
36
|
-
""
|
35
|
+
'hostonly="yes"',
|
36
|
+
'omit_dracutmodules+=" btrfs lvm "',
|
37
37
|
]
|
38
38
|
File.write(conf, content.join("\n"), mode: 'w', chmod: 0644)
|
39
39
|
end
|
@@ -43,37 +43,37 @@ module Getch
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def config_grub
|
46
|
-
grub_cmdline("root=zfs:#{@pool_name}/ROOT/#{@n}",
|
46
|
+
grub_cmdline("root=zfs:#{@pool_name}/ROOT/#{@n}", 'zfs_force=1', 'zfs.zfs_arc_max=536870912')
|
47
47
|
end
|
48
48
|
|
49
49
|
def finish
|
50
50
|
zed_update_path
|
51
|
-
puts
|
52
|
-
puts
|
51
|
+
puts '+ Enter in your system: chroot /mnt /bin/bash'
|
52
|
+
puts '+ Reboot with: shutdown -r now'
|
53
53
|
end
|
54
54
|
|
55
55
|
private
|
56
56
|
|
57
57
|
def zfs_zed
|
58
|
-
service_dir =
|
58
|
+
service_dir = '/etc/runit/runsvdir/default/'
|
59
59
|
|
60
|
-
Helpers
|
61
|
-
Helpers
|
62
|
-
Helpers
|
63
|
-
fork { command
|
60
|
+
Helpers.mkdir("#{MOUNTPOINT}/etc/zfs/zfs-list.cache")
|
61
|
+
Helpers.touch("#{MOUNTPOINT}/etc/zfs/zfs-list.cache/#{@boot_pool_name}") if @dev_boot
|
62
|
+
Helpers.touch("#{MOUNTPOINT}/etc/zfs/zfs-list.cache/#{@pool_name}")
|
63
|
+
fork { command '/etc/sv/zed/run' }
|
64
64
|
command "ln -fs /etc/sv/zed #{service_dir}"
|
65
65
|
end
|
66
66
|
|
67
67
|
def zed_update_path
|
68
|
-
Dir.glob("#{MOUNTPOINT}/etc/zfs/zfs-list.cache/*").each
|
69
|
-
|
70
|
-
raise
|
68
|
+
Dir.glob("#{MOUNTPOINT}/etc/zfs/zfs-list.cache/*").each do |f|
|
69
|
+
unless system('sed', '-Ei', "s|#{MOUNTPOINT}/?|/|", f)
|
70
|
+
raise 'System exec sed'
|
71
71
|
end
|
72
|
-
|
72
|
+
end
|
73
73
|
end
|
74
74
|
|
75
75
|
def hostid
|
76
|
-
command
|
76
|
+
command 'zgenhostid $(hostid)'
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
data/lib/getch/filesystem/zfs.rb
CHANGED
data/lib/getch/filesystem.rb
CHANGED
data/lib/getch/gentoo/boot.rb
CHANGED
@@ -1,19 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'fileutils'
|
2
4
|
|
3
5
|
module Getch
|
4
6
|
module Gentoo
|
5
7
|
class Boot
|
6
8
|
def initialize
|
7
|
-
@disk = Getch::OPTIONS[:boot_disk] ?
|
8
|
-
Getch::OPTIONS[:boot_disk] :
|
9
|
-
Getch::OPTIONS[:disk]
|
10
9
|
@user = Getch::OPTIONS[:username]
|
11
|
-
@class_fs = Getch::select_fs
|
12
|
-
@config = @class_fs::Config.new
|
13
10
|
end
|
14
11
|
|
15
12
|
def start
|
16
|
-
@config.fstab
|
17
13
|
bootloader
|
18
14
|
password
|
19
15
|
permission
|
@@ -21,63 +17,22 @@ module Getch
|
|
21
17
|
end
|
22
18
|
|
23
19
|
def bootloader
|
24
|
-
# Ensure
|
25
|
-
Getch::Emerge.new(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
else
|
30
|
-
grub
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# bootctl is alrealy installed with the stage3-amd64-systemd
|
35
|
-
def bootctl
|
36
|
-
bootctl_dep
|
37
|
-
puts "Configuring systemd-boot."
|
38
|
-
# ref: https://forums.gentoo.org/viewtopic-p-8118822.html
|
39
|
-
esp = '/efi'
|
40
|
-
Getch::Chroot.new("bootctl --path #{esp} install").run!
|
41
|
-
datas_loader = [
|
42
|
-
'default gentoo',
|
43
|
-
'timeout 3',
|
44
|
-
'editor 0'
|
45
|
-
]
|
46
|
-
@config.systemd_boot
|
47
|
-
File.write("#{MOUNTPOINT}/#{esp}/loader/loader.conf", datas_loader.join("\n"))
|
48
|
-
|
49
|
-
FileUtils.cp("#{MOUNTPOINT}/usr/src/linux/arch/x86/boot/bzImage", "#{MOUNTPOINT}/#{esp}/vmlinuz", preserve: true)
|
50
|
-
|
51
|
-
initramfs = Dir.glob("#{MOUNTPOINT}/boot/initramfs-*.img")
|
52
|
-
FileUtils.cp("#{initramfs[0]}", "#{MOUNTPOINT}/#{esp}/initramfs", preserve: true) if initramfs != []
|
53
|
-
|
54
|
-
Getch::Chroot.new("bootctl --path #{esp} update").run!
|
55
|
-
end
|
56
|
-
|
57
|
-
def bootctl_dep
|
58
|
-
puts 'Installing systemd-boot...'
|
59
|
-
Getch::Emerge.new("efivar").pkg!
|
60
|
-
end
|
61
|
-
|
62
|
-
def grub
|
63
|
-
puts 'Installing GRUB...'
|
64
|
-
Getch::Emerge.new("sys-boot/grub:2").pkg!
|
65
|
-
@config.grub
|
66
|
-
Getch::Chroot.new("grub-install /dev/#{@disk}").run!
|
67
|
-
Getch::Chroot.new("grub-mkconfig -o /boot/grub/grub.cfg").run!
|
20
|
+
# Ensure all packages are build
|
21
|
+
Getch::Emerge.new('@world').pkg!
|
22
|
+
bootloader = Getch::Gentoo::Bootloader.new
|
23
|
+
bootloader.setup
|
24
|
+
bootloader.update
|
68
25
|
end
|
69
26
|
|
70
27
|
def password
|
71
28
|
puts 'Password for root'
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
system(cmd)
|
80
|
-
end
|
29
|
+
chroot "passwd"
|
30
|
+
return unless @user
|
31
|
+
|
32
|
+
puts "Creating user #{@user}"
|
33
|
+
Getch::Chroot.new("useradd -m -G users,wheel,audio,video #{@user}").run!
|
34
|
+
puts "Password for your user #{@user}"
|
35
|
+
chroot "passwd #{@user}"
|
81
36
|
end
|
82
37
|
|
83
38
|
private
|
@@ -90,25 +45,19 @@ module Getch
|
|
90
45
|
end
|
91
46
|
|
92
47
|
def the_end
|
93
|
-
#Helpers::exec_or_die("umount -l /mnt/gentoo/dev{/shm,/pts,}")
|
94
|
-
#Helpers::exec_or_die("umount -R #{MOUNTPOINT}")
|
95
48
|
puts
|
96
|
-
puts
|
49
|
+
puts 'getch has finish, before reboot, you can:'
|
97
50
|
puts " + Chroot on your system with: chroot #{MOUNTPOINT} /bin/bash"
|
98
|
-
puts
|
51
|
+
puts ' + Install more packages like networkmanager or emacs'
|
99
52
|
puts
|
100
|
-
puts
|
101
|
-
puts
|
53
|
+
puts ' + Add more modules for your kernel (graphic, wifi card) and recompile it with:'
|
54
|
+
puts ' genkernel --kernel-config=/usr/src/linux/.config all '
|
102
55
|
puts
|
103
|
-
puts
|
56
|
+
puts 'Reboot the system when you have done !'
|
104
57
|
end
|
105
58
|
|
106
|
-
def
|
107
|
-
|
108
|
-
source /etc/profile
|
109
|
-
#{cmd}
|
110
|
-
\""
|
111
|
-
Getch::Command.new(script).run!
|
59
|
+
def chroot(cmd)
|
60
|
+
system('chroot', MOUNTPOINT, '/bin/bash', '-c', cmd)
|
112
61
|
end
|
113
62
|
end
|
114
63
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_strin_literal: true
|
2
|
+
|
3
|
+
module Getch
|
4
|
+
module Gentoo
|
5
|
+
class Bootloader
|
6
|
+
def initialize
|
7
|
+
@pkgs = []
|
8
|
+
@class_fs = Getch.select_fs
|
9
|
+
@config = @class_fs::Config.new
|
10
|
+
@disk = Getch::OPTIONS[:boot_disk] ?
|
11
|
+
Getch::OPTIONS[:boot_disk] :
|
12
|
+
Getch::OPTIONS[:disk]
|
13
|
+
@esp = '/efi'
|
14
|
+
end
|
15
|
+
|
16
|
+
def start
|
17
|
+
@config.fstab
|
18
|
+
config_useflag
|
19
|
+
dependencies
|
20
|
+
install
|
21
|
+
@config.cmdline
|
22
|
+
end
|
23
|
+
|
24
|
+
def config_useflag
|
25
|
+
end
|
26
|
+
|
27
|
+
# Dracut is used by sys-kernel/gentoo-kernel
|
28
|
+
def dependencies
|
29
|
+
@pkgs << 'app-shells/dash'
|
30
|
+
@pkgs << 'sys-kernel/dracut'
|
31
|
+
if Helpers.efi?
|
32
|
+
@pkgs << 'efivar'
|
33
|
+
@pkgs << 'sys-kernel/installkernel-systemd-boot'
|
34
|
+
else
|
35
|
+
@pkgs << 'sys-boot/grub:2'
|
36
|
+
@pkgs << 'sys-kernel/installkernel-gentoo' # for Grub
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def install
|
41
|
+
all_pkgs = @pkgs.join(' ')
|
42
|
+
Getch::Emerge.new(all_pkgs).pkg!
|
43
|
+
end
|
44
|
+
|
45
|
+
def setup
|
46
|
+
if Helpers.efi?
|
47
|
+
Getch::Chroot.new("bootctl --path #{@esp} install").run!
|
48
|
+
else
|
49
|
+
Getch::Chroot.new("grub-install /dev/#{@disk}").run!
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def update
|
54
|
+
Getch::Emerge.new('--config sys-kernel/gentoo-kernel').pkg!
|
55
|
+
if Helpers.efi?
|
56
|
+
puts ' => Updating systemd-boot...'
|
57
|
+
Getch::Chroot.new("bootctl --path #{@esp} update").run!
|
58
|
+
else
|
59
|
+
puts ' => Updating grub...'
|
60
|
+
Getch::Chroot.new('grub-mkconfig -o /boot/grub/grub.cfg').run!
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def config
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/getch/gentoo/chroot.rb
CHANGED
@@ -1,75 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Getch
|
2
4
|
module Gentoo
|
3
5
|
class Chroot
|
4
6
|
def initialize
|
5
|
-
@state = Getch::States.new()
|
6
7
|
@pkgs = []
|
7
8
|
mount
|
8
9
|
end
|
9
10
|
|
10
11
|
def cpuflags
|
11
|
-
Getch::Emerge.new(
|
12
|
+
Getch::Emerge.new('app-portage/cpuid2cpuflags').pkg!
|
12
13
|
cpuflags = `chroot #{MOUNTPOINT} /bin/bash -c "source /etc/profile; cpuid2cpuflags"`.chomp
|
13
14
|
File.write("#{MOUNTPOINT}/etc/portage/package.use/00cpuflags", "*/* #{cpuflags}")
|
14
15
|
end
|
15
16
|
|
16
17
|
def update
|
17
18
|
return if STATES[:gentoo_update]
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
|
20
|
+
puts 'Downloading the last ebuilds for Gentoo...'
|
21
|
+
Helpers.create_dir("#{MOUNTPOINT}/var/db/repos/gentoo")
|
22
|
+
cmd = 'emaint sync --auto'
|
21
23
|
exec_chroot(cmd)
|
22
24
|
end
|
23
25
|
|
24
26
|
def world
|
25
27
|
return if STATES[:gentoo_update]
|
26
|
-
|
27
|
-
|
28
|
-
@
|
28
|
+
|
29
|
+
puts 'Update Gentoo world'
|
30
|
+
Getch::Emerge.new('emerge --update --deep --changed-use --newuse @world').run!
|
29
31
|
end
|
30
32
|
|
31
33
|
def systemd
|
32
|
-
puts
|
33
|
-
cmd =
|
34
|
+
puts 'Updating locale, keymap...'
|
35
|
+
cmd = 'locale-gen; emerge --config sys-libs/timezone-data'
|
34
36
|
exec_chroot(cmd)
|
35
37
|
end
|
36
38
|
|
37
|
-
def
|
39
|
+
def kernel_license
|
38
40
|
return if Dir.exist? "#{MOUNTPOINT}/usr/src/linux"
|
41
|
+
|
39
42
|
license = "#{MOUNTPOINT}/etc/portage/package.license"
|
40
43
|
File.write(license, "sys-kernel/linux-firmware linux-fw-redistributable no-source-code\n")
|
41
|
-
@pkgs << "sys-kernel/gentoo-sources"
|
42
|
-
end
|
43
|
-
|
44
|
-
def kernel_deps
|
45
|
-
@pkgs << "sys-apps/kmod"
|
46
44
|
end
|
47
45
|
|
48
46
|
def install_pkgs
|
49
|
-
@pkgs <<
|
50
|
-
@pkgs <<
|
51
|
-
@pkgs <<
|
52
|
-
@pkgs <<
|
53
|
-
|
47
|
+
@pkgs << 'app-portage/gentoolkit'
|
48
|
+
@pkgs << 'app-admin/sudo'
|
49
|
+
@pkgs << 'app-editors/vim'
|
50
|
+
@pkgs << 'net-firewall/iptables'
|
51
|
+
@pkgs << 'sys-fs/dosftools' if Helpers.efi?
|
52
|
+
all_pkgs = @pkgs.join(' ')
|
54
53
|
puts "Installing #{all_pkgs}..."
|
55
54
|
Getch::Emerge.new(all_pkgs).pkg!
|
56
55
|
end
|
57
56
|
|
58
|
-
# create a symbolic link for /usr/src/linux
|
59
|
-
def kernel_link
|
60
|
-
cmd = "eselect kernel set 1"
|
61
|
-
exec_chroot(cmd)
|
62
|
-
end
|
63
|
-
|
64
57
|
private
|
65
58
|
|
66
59
|
def mount
|
67
|
-
puts
|
68
|
-
Helpers
|
69
|
-
Helpers
|
70
|
-
Helpers
|
71
|
-
Helpers
|
72
|
-
Helpers
|
60
|
+
puts 'Populate /proc, /sys and /dev.'
|
61
|
+
Helpers.exec_or_die("mount --types proc /proc \"#{MOUNTPOINT}/proc\"")
|
62
|
+
Helpers.exec_or_die("mount --rbind /sys \"#{MOUNTPOINT}/sys\"")
|
63
|
+
Helpers.exec_or_die("mount --make-rslave \"#{MOUNTPOINT}/sys\"")
|
64
|
+
Helpers.exec_or_die("mount --rbind /dev \"#{MOUNTPOINT}/dev\"")
|
65
|
+
Helpers.exec_or_die("mount --make-rslave \"#{MOUNTPOINT}/dev\"")
|
73
66
|
# Maybe add /dev/shm like describe here:
|
74
67
|
# https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Base
|
75
68
|
end
|
data/lib/getch/gentoo/config.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'fileutils'
|
2
4
|
require 'tempfile'
|
3
5
|
require 'securerandom'
|
@@ -11,12 +13,13 @@ module Getch
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def portage
|
14
|
-
grub_pc = Helpers
|
16
|
+
grub_pc = Helpers.efi? ? '' : 'GRUB_PLATFORMS="pc"'
|
15
17
|
nproc = `nproc`.chomp()
|
16
18
|
|
17
19
|
# Add cpu name
|
18
20
|
cpu=`chroot #{MOUNTPOINT} /bin/bash -c \"source /etc/profile ; gcc -c -Q -march=native --help=target | grep march\" | awk '{print $2}' | head -1`.chomp
|
19
|
-
raise
|
21
|
+
raise 'Error, no cpu found' unless cpu || cpu == ''
|
22
|
+
|
20
23
|
@log.debug "CPU found ==> #{cpu}"
|
21
24
|
|
22
25
|
tmp = Tempfile.new('make.conf')
|
@@ -29,7 +32,7 @@ module Getch
|
|
29
32
|
end
|
30
33
|
}
|
31
34
|
|
32
|
-
FileUtils.copy_file(tmp, @make
|
35
|
+
FileUtils.copy_file(tmp, @make)
|
33
36
|
|
34
37
|
# Add the rest
|
35
38
|
data = [
|
@@ -37,16 +40,17 @@ module Getch
|
|
37
40
|
"MAKEOPTS=\"-j#{nproc}\"",
|
38
41
|
'ACCEPT_KEYWORDS="amd64"',
|
39
42
|
'INPUT_DEVICES="libinput"',
|
43
|
+
'USE="${USE} audit"',
|
40
44
|
grub_pc
|
41
45
|
]
|
42
|
-
File.write(@make, data.join("\n"), mode:
|
46
|
+
File.write(@make, data.join("\n"), mode: 'a')
|
43
47
|
end
|
44
48
|
|
45
49
|
# Write a repos.conf/gentoo.conf with the gpg verification
|
46
50
|
def repo
|
47
51
|
src = "#{MOUNTPOINT}/usr/share/portage/config/repos.conf"
|
48
52
|
dest = "#{MOUNTPOINT}/etc/portage/repos.conf"
|
49
|
-
FileUtils.mkdir dest, mode: 0644
|
53
|
+
FileUtils.mkdir dest, mode: 0644 unless Dir.exist?(dest)
|
50
54
|
tmp = Tempfile.new('gentoo.conf')
|
51
55
|
line_count = 0
|
52
56
|
|
@@ -60,20 +64,20 @@ module Getch
|
|
60
64
|
line_count += 1
|
61
65
|
}
|
62
66
|
|
63
|
-
FileUtils.copy_file(tmp, "#{dest}/gentoo.conf"
|
67
|
+
FileUtils.copy_file(tmp, "#{dest}/gentoo.conf")
|
64
68
|
end
|
65
69
|
|
66
70
|
def network
|
67
71
|
src = '/etc/resolv.conf'
|
68
72
|
dest = "#{MOUNTPOINT}/etc/resolv.conf"
|
69
|
-
FileUtils.copy_file(src, dest
|
73
|
+
FileUtils.copy_file(src, dest)
|
70
74
|
end
|
71
75
|
|
72
76
|
def systemd
|
73
77
|
control_options
|
74
|
-
|
75
|
-
|
76
|
-
|
78
|
+
Helpers.echo "#{MOUNTPOINT}/etc/locale.gen", @utf8
|
79
|
+
Helpers.echo "#{MOUNTPOINT}/etc/locale.conf", "LANG=#{@lang}"
|
80
|
+
Helpers.echo_a "#{MOUNTPOINT}/etc/locale.conf", 'LC_COLLATE=C'
|
77
81
|
File.write("#{MOUNTPOINT}/etc/timezone", "#{Getch::OPTIONS[:zoneinfo]}\n")
|
78
82
|
File.write("#{MOUNTPOINT}/etc/vconsole.conf", "KEYMAP=#{Getch::OPTIONS[:keymap]}\n")
|
79
83
|
end
|
@@ -85,19 +89,19 @@ module Getch
|
|
85
89
|
|
86
90
|
def portage_fs
|
87
91
|
portage = "#{MOUNTPOINT}/etc/portage"
|
88
|
-
Helpers
|
89
|
-
Helpers
|
90
|
-
Helpers
|
92
|
+
Helpers.mkdir("#{portage}/package.use")
|
93
|
+
Helpers.mkdir("#{portage}/package.accept_keywords")
|
94
|
+
Helpers.mkdir("#{portage}/package.unmask")
|
91
95
|
|
92
|
-
Helpers
|
93
|
-
Helpers
|
94
|
-
Helpers
|
96
|
+
Helpers.add_file("#{portage}/package.use/zzz_via_autounmask")
|
97
|
+
Helpers.add_file("#{portage}/package.accept_keywords/zzz_via_autounmask")
|
98
|
+
Helpers.add_file("#{portage}/package.unmask/zzz_via_autounmask")
|
95
99
|
end
|
96
100
|
|
101
|
+
# https://wiki.gentoo.org/wiki/Signed_kernel_module_support
|
97
102
|
def portage_bashrc
|
98
103
|
conf = "#{MOUNTPOINT}/etc/portage/bashrc"
|
99
104
|
content = %q{
|
100
|
-
# https://wiki.gentoo.org/wiki/Signed_kernel_module_support
|
101
105
|
function pre_pkg_preinst() {
|
102
106
|
# This hook signs any out-of-tree kernel modules.
|
103
107
|
if [[ "$(type -t linux-mod_pkg_preinst)" != "function" ]]; then
|
@@ -122,9 +126,9 @@ function pre_pkg_preinst() {
|
|
122
126
|
}
|
123
127
|
}
|
124
128
|
|
125
|
-
f = File.new(conf,
|
129
|
+
f = File.new(conf, 'w')
|
126
130
|
f.write("#{content}\n")
|
127
|
-
f.chmod(
|
131
|
+
f.chmod(0700)
|
128
132
|
f.close
|
129
133
|
end
|
130
134
|
|
@@ -141,22 +145,22 @@ function pre_pkg_preinst() {
|
|
141
145
|
Dir.glob("#{MOUNTPOINT}/usr/share/keymaps/**/#{keys}.map.gz") { |f|
|
142
146
|
@keymap = f
|
143
147
|
}
|
144
|
-
raise ArgumentError, "No keymap #{@keymap} found"
|
148
|
+
raise ArgumentError, "No keymap #{@keymap} found" unless @keymap
|
145
149
|
end
|
146
150
|
|
147
151
|
def search_zone(zone)
|
148
|
-
|
152
|
+
unless File.exist? "#{MOUNTPOINT}/usr/share/zoneinfo/#{zone}"
|
149
153
|
raise ArgumentError, "Zoneinfo #{zone} doesn\'t exist."
|
150
154
|
end
|
151
155
|
end
|
152
156
|
|
153
157
|
def search_utf8(lang)
|
154
158
|
@utf8, @lang = nil, nil
|
155
|
-
File.open("#{MOUNTPOINT}/usr/share/i18n/SUPPORTED").each
|
156
|
-
@utf8 =
|
157
|
-
@lang = $~[0] if l.match(/^#{lang}[. ]+utf
|
158
|
-
|
159
|
-
raise ArgumentError, "Lang #{lang} no found"
|
159
|
+
File.open("#{MOUNTPOINT}/usr/share/i18n/SUPPORTED").each do |l|
|
160
|
+
@utf8 = l if l.match(/^#{lang}[. ]+utf-8 /i)
|
161
|
+
@lang = $~[0] if l.match(/^#{lang}[. ]+utf-8/i)
|
162
|
+
end
|
163
|
+
raise ArgumentError, "Lang #{lang} no found" unless @utf8
|
160
164
|
end
|
161
165
|
end
|
162
166
|
end
|