getch 0.0.8 → 0.1.3
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 +44 -0
- data/README.md +57 -8
- data/bin/setup.sh +4 -2
- data/lib/getch.rb +43 -15
- data/lib/getch/command.rb +26 -5
- data/lib/getch/config.rb +58 -0
- data/lib/getch/filesystem.rb +6 -0
- data/lib/getch/filesystem/clean.rb +51 -0
- data/lib/getch/filesystem/device.rb +61 -0
- data/lib/getch/filesystem/ext4.rb +1 -0
- data/lib/getch/filesystem/ext4/config.rb +8 -9
- data/lib/getch/filesystem/ext4/device.rb +2 -7
- data/lib/getch/filesystem/ext4/encrypt/config.rb +69 -47
- data/lib/getch/filesystem/ext4/encrypt/deps.rb +21 -15
- data/lib/getch/filesystem/ext4/encrypt/device.rb +5 -9
- data/lib/getch/filesystem/ext4/encrypt/format.rb +10 -6
- data/lib/getch/filesystem/ext4/encrypt/mount.rb +6 -43
- data/lib/getch/filesystem/ext4/encrypt/partition.rb +57 -55
- data/lib/getch/filesystem/ext4/format.rb +3 -5
- data/lib/getch/filesystem/ext4/mount.rb +7 -46
- data/lib/getch/filesystem/ext4/partition.rb +16 -39
- data/lib/getch/filesystem/lvm.rb +1 -0
- data/lib/getch/filesystem/lvm/config.rb +12 -15
- data/lib/getch/filesystem/lvm/deps.rb +5 -20
- data/lib/getch/filesystem/lvm/device.rb +33 -9
- data/lib/getch/filesystem/lvm/encrypt.rb +15 -0
- data/lib/getch/filesystem/lvm/encrypt/config.rb +71 -0
- data/lib/getch/filesystem/lvm/encrypt/deps.rb +46 -0
- data/lib/getch/filesystem/lvm/encrypt/device.rb +46 -0
- data/lib/getch/filesystem/lvm/encrypt/format.rb +32 -0
- data/lib/getch/filesystem/lvm/encrypt/mount.rb +25 -0
- data/lib/getch/filesystem/lvm/encrypt/partition.rb +80 -0
- data/lib/getch/filesystem/lvm/format.rb +11 -7
- data/lib/getch/filesystem/lvm/mount.rb +7 -46
- data/lib/getch/filesystem/lvm/partition.rb +19 -31
- data/lib/getch/filesystem/mount.rb +56 -0
- data/lib/getch/filesystem/partition.rb +77 -0
- data/lib/getch/filesystem/zfs.rb +14 -0
- data/lib/getch/filesystem/zfs/config.rb +57 -0
- data/lib/getch/filesystem/zfs/deps.rb +95 -0
- data/lib/getch/filesystem/zfs/device.rb +58 -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 +97 -0
- data/lib/getch/filesystem/zfs/encrypt/device.rb +60 -0
- data/lib/getch/filesystem/zfs/encrypt/format.rb +105 -0
- data/lib/getch/filesystem/zfs/encrypt/mount.rb +51 -0
- data/lib/getch/filesystem/zfs/encrypt/partition.rb +65 -0
- data/lib/getch/filesystem/zfs/format.rb +114 -0
- data/lib/getch/filesystem/zfs/mount.rb +48 -0
- data/lib/getch/filesystem/zfs/partition.rb +64 -0
- data/lib/getch/gentoo.rb +8 -4
- data/lib/getch/gentoo/boot.rb +32 -17
- data/lib/getch/gentoo/chroot.rb +12 -26
- data/lib/getch/gentoo/config.rb +37 -12
- data/lib/getch/gentoo/sources.rb +26 -29
- data/lib/getch/gentoo/use.rb +43 -0
- data/lib/getch/gentoo/use_flag.rb +64 -0
- data/lib/getch/helpers.rb +35 -13
- data/lib/getch/options.rb +23 -8
- data/lib/getch/version.rb +1 -1
- metadata +46 -18
- metadata.gz.sig +0 -0
data/lib/getch/gentoo.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'open-uri'
|
2
|
-
require 'open3'
|
3
1
|
require_relative 'gentoo/stage'
|
4
2
|
require_relative 'gentoo/config'
|
5
3
|
require_relative 'gentoo/chroot'
|
6
4
|
require_relative 'gentoo/sources'
|
7
5
|
require_relative 'gentoo/boot'
|
6
|
+
require_relative 'gentoo/use'
|
7
|
+
require_relative 'gentoo/use_flag'
|
8
8
|
|
9
9
|
module Getch
|
10
10
|
module Gentoo
|
@@ -36,10 +36,15 @@ module Getch
|
|
36
36
|
@state.config
|
37
37
|
end
|
38
38
|
|
39
|
-
def chroot
|
39
|
+
def chroot(options)
|
40
40
|
chroot = Getch::Gentoo::Chroot.new()
|
41
41
|
chroot.update
|
42
|
+
chroot.cpuflags
|
42
43
|
chroot.systemd
|
44
|
+
|
45
|
+
flags = Getch::Gentoo::UseFlag.new(options)
|
46
|
+
flags.apply
|
47
|
+
|
43
48
|
chroot.world
|
44
49
|
return if STATES[:gentoo_kernel]
|
45
50
|
chroot.kernel
|
@@ -51,7 +56,6 @@ module Getch
|
|
51
56
|
return if STATES[:gentoo_kernel]
|
52
57
|
source = Getch::Gentoo::Sources.new()
|
53
58
|
new
|
54
|
-
source.init_config
|
55
59
|
source.build_kspp
|
56
60
|
source.build_others
|
57
61
|
source.make
|
data/lib/getch/gentoo/boot.rb
CHANGED
@@ -4,16 +4,17 @@ module Getch
|
|
4
4
|
module Gentoo
|
5
5
|
class Boot
|
6
6
|
def initialize(opts)
|
7
|
-
@disk = opts.disk
|
7
|
+
@disk = opts.boot_disk ? opts.boot_disk : opts.disk
|
8
8
|
@user = opts.username
|
9
|
-
@config =
|
9
|
+
@config = Getch.class_fs::Config.new()
|
10
10
|
end
|
11
11
|
|
12
12
|
def start
|
13
13
|
@config.fstab
|
14
14
|
bootloader
|
15
15
|
password
|
16
|
-
|
16
|
+
permission
|
17
|
+
the_end
|
17
18
|
end
|
18
19
|
|
19
20
|
def bootloader
|
@@ -29,8 +30,8 @@ module Getch
|
|
29
30
|
bootctl_dep
|
30
31
|
puts "Configuring systemd-boot."
|
31
32
|
# ref: https://forums.gentoo.org/viewtopic-p-8118822.html
|
32
|
-
esp = '/
|
33
|
-
|
33
|
+
esp = '/efi'
|
34
|
+
Getch::Chroot.new("bootctl --path #{esp} install").run!
|
34
35
|
datas_loader = [
|
35
36
|
'default gentoo',
|
36
37
|
'timeout 3',
|
@@ -44,43 +45,57 @@ module Getch
|
|
44
45
|
initramfs = Dir.glob("#{MOUNTPOINT}/boot/initramfs-*.img")
|
45
46
|
FileUtils.cp("#{initramfs[0]}", "#{MOUNTPOINT}/#{esp}/initramfs", preserve: true) if initramfs != []
|
46
47
|
|
47
|
-
|
48
|
+
Getch::Chroot.new("bootctl --path #{esp} update").run!
|
48
49
|
end
|
49
50
|
|
50
51
|
def bootctl_dep
|
51
52
|
puts 'Installing systemd-boot...'
|
52
|
-
|
53
|
-
Getch::Emerge.new("sys-apps/systemd efivar").pkg!
|
53
|
+
Getch::Emerge.new("efivar").pkg!
|
54
54
|
end
|
55
55
|
|
56
56
|
def grub
|
57
57
|
puts 'Installing GRUB...'
|
58
58
|
Getch::Emerge.new("sys-boot/grub:2").pkg!
|
59
59
|
@config.grub
|
60
|
-
|
61
|
-
|
60
|
+
Getch::Chroot.new("grub-install /dev/#{@disk}").run!
|
61
|
+
Getch::Chroot.new("grub-mkconfig -o /boot/grub/grub.cfg").run!
|
62
62
|
end
|
63
63
|
|
64
64
|
def password
|
65
65
|
puts 'Password for root'
|
66
66
|
cmd = "chroot #{MOUNTPOINT} /bin/bash -c \"source /etc/profile && passwd\""
|
67
67
|
system(cmd)
|
68
|
-
if @user
|
68
|
+
if @user
|
69
69
|
puts "Creating user #{@user}"
|
70
|
-
|
70
|
+
Getch::Chroot.new("useradd -m -G users,wheel,audio,video #{@user}").run!
|
71
71
|
puts "Password for your user #{@user}"
|
72
72
|
cmd = "chroot #{MOUNTPOINT} /bin/bash -c \"source /etc/profile && passwd #{@user}\""
|
73
73
|
system(cmd)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
private
|
78
|
+
|
79
|
+
def permission
|
80
|
+
FileUtils.chmod_R 0755, "#{MOUNTPOINT}/etc/portage"
|
81
|
+
if @user
|
82
|
+
Getch::Chroot.new("chown -R #{@user}:#{@user} /home/#{@user}").run!
|
83
|
+
end
|
81
84
|
end
|
82
85
|
|
83
|
-
|
86
|
+
def the_end
|
87
|
+
#Helpers::exec_or_die("umount -l /mnt/gentoo/dev{/shm,/pts,}")
|
88
|
+
#Helpers::exec_or_die("umount -R #{MOUNTPOINT}")
|
89
|
+
puts
|
90
|
+
puts "getch has finish, before reboot, you can:"
|
91
|
+
puts " + Chroot on your system with: chroot #{MOUNTPOINT} /bin/bash"
|
92
|
+
puts " + Install more packages like networkmanager or emacs"
|
93
|
+
puts
|
94
|
+
puts " + Add more modules for your kernel (graphic, wifi card) and recompile it with:"
|
95
|
+
puts " genkernel --kernel-config=/usr/src/linux/.config all "
|
96
|
+
puts
|
97
|
+
puts "Reboot the system when you have done !"
|
98
|
+
end
|
84
99
|
|
85
100
|
def exec_chroot(cmd)
|
86
101
|
script = "chroot #{MOUNTPOINT} /bin/bash -c \"
|
data/lib/getch/gentoo/chroot.rb
CHANGED
@@ -7,18 +7,24 @@ module Getch
|
|
7
7
|
mount
|
8
8
|
end
|
9
9
|
|
10
|
+
def cpuflags
|
11
|
+
Getch::Emerge.new("app-portage/cpuid2cpuflags").pkg!
|
12
|
+
cpuflags = `chroot #{MOUNTPOINT} /bin/bash -c "source /etc/profile; cpuid2cpuflags"`.chomp
|
13
|
+
File.write("#{MOUNTPOINT}/etc/portage/package.use/00cpuflags", "*/* #{cpuflags}")
|
14
|
+
end
|
15
|
+
|
10
16
|
def update
|
11
17
|
return if STATES[:gentoo_update]
|
12
18
|
puts "Downloading the last ebuilds for Gentoo..."
|
13
19
|
Helpers::create_dir("#{MOUNTPOINT}/var/db/repos/gentoo")
|
14
|
-
cmd = "
|
20
|
+
cmd = "emaint sync --auto"
|
15
21
|
exec_chroot(cmd)
|
16
22
|
end
|
17
23
|
|
18
24
|
def world
|
19
25
|
return if STATES[:gentoo_update]
|
20
26
|
puts "Update Gentoo world"
|
21
|
-
Getch::Emerge.new("emerge --update --deep --newuse @world").run!
|
27
|
+
Getch::Emerge.new("emerge --update --deep --changed-use --newuse @world").run!
|
22
28
|
@state.update
|
23
29
|
end
|
24
30
|
|
@@ -37,14 +43,14 @@ module Getch
|
|
37
43
|
end
|
38
44
|
|
39
45
|
def kernel_deps
|
40
|
-
|
41
|
-
get_garden
|
42
|
-
garden_dep
|
46
|
+
@pkgs << "sys-apps/kmod"
|
43
47
|
end
|
44
48
|
|
45
49
|
def install_pkgs
|
50
|
+
@pkgs << "app-portage/gentoolkit"
|
46
51
|
@pkgs << "app-admin/sudo"
|
47
52
|
@pkgs << "app-editors/vim"
|
53
|
+
@pkgs << "sys-kernel/linux-firmware"
|
48
54
|
all_pkgs = @pkgs.join(" ")
|
49
55
|
puts "Installing #{all_pkgs}..."
|
50
56
|
Getch::Emerge.new(all_pkgs).pkg!
|
@@ -52,22 +58,6 @@ module Getch
|
|
52
58
|
|
53
59
|
private
|
54
60
|
|
55
|
-
def get_garden
|
56
|
-
return if Dir.exist? "#{MOUNTPOINT}/root/garden-master"
|
57
|
-
url = 'https://github.com/szorfein/garden/archive/master.tar.gz'
|
58
|
-
file = 'garden-master.tar.gz'
|
59
|
-
|
60
|
-
Dir.chdir("#{MOUNTPOINT}/root")
|
61
|
-
Helpers::get_file_online(url, file)
|
62
|
-
Getch::Command.new("tar xzf #{file}").run! if ! Dir.exist? 'garden-master'
|
63
|
-
end
|
64
|
-
|
65
|
-
def garden_dep
|
66
|
-
Getch::Emerge.new("gentoolkit").pkg!
|
67
|
-
exec_chroot("euse -p sys-apps/kmod -E lzma")
|
68
|
-
@pkgs << "sys-apps/kmod"
|
69
|
-
end
|
70
|
-
|
71
61
|
def mount
|
72
62
|
puts "Populate /proc, /sys and /dev."
|
73
63
|
Helpers::exec_or_die("mount --types proc /proc \"#{MOUNTPOINT}/proc\"")
|
@@ -80,11 +70,7 @@ module Getch
|
|
80
70
|
end
|
81
71
|
|
82
72
|
def exec_chroot(cmd)
|
83
|
-
|
84
|
-
source /etc/profile
|
85
|
-
#{cmd}
|
86
|
-
\""
|
87
|
-
Getch::Command.new(script).run!
|
73
|
+
Getch::Chroot.new(cmd).run!
|
88
74
|
end
|
89
75
|
end
|
90
76
|
end
|
data/lib/getch/gentoo/config.rb
CHANGED
@@ -7,41 +7,66 @@ module Getch
|
|
7
7
|
class Config
|
8
8
|
def initialize
|
9
9
|
@make = "#{MOUNTPOINT}/etc/portage/make.conf"
|
10
|
+
@log = Getch::Log.new
|
10
11
|
end
|
11
12
|
|
12
13
|
def portage
|
13
|
-
nproc = `nproc`.chomp()
|
14
14
|
grub_pc = Helpers::efi? ? '' : 'GRUB_PLATFORMS="pc"'
|
15
|
-
|
15
|
+
nproc = `nproc`.chomp()
|
16
|
+
|
17
|
+
# Add cpu name
|
18
|
+
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 "Error, no cpu found" if ! cpu or cpu == ""
|
20
|
+
@log.debug "CPU found ==> #{cpu}"
|
21
|
+
|
22
|
+
tmp = Tempfile.new('make.conf')
|
23
|
+
|
24
|
+
File.open(@make).each { |l|
|
25
|
+
if l.match(/^COMMON_FLAGS/)
|
26
|
+
File.write(tmp, "COMMON_FLAGS=\"-march=#{cpu} -O2 -pipe -fomit-frame-pointer\"\n", mode: 'a')
|
27
|
+
else
|
28
|
+
File.write(tmp, l, mode: 'a')
|
29
|
+
end
|
30
|
+
}
|
31
|
+
|
32
|
+
FileUtils.copy_file(tmp, @make, preserve = true)
|
33
|
+
|
34
|
+
# Add the rest
|
16
35
|
data = [
|
17
36
|
'',
|
37
|
+
"MAKEOPTS=\"-j#{nproc}\"",
|
18
38
|
'ACCEPT_KEYWORDS="amd64"',
|
19
|
-
"MAKEOPTS=\"-j#{nproc} -l#{nproc}\"",
|
20
|
-
quiet,
|
21
39
|
'INPUT_DEVICES="libinput"',
|
22
40
|
grub_pc
|
23
41
|
]
|
24
42
|
File.write(@make, data.join("\n"), mode: "a")
|
25
43
|
end
|
26
44
|
|
45
|
+
# Write a repos.conf/gentoo.conf with the gpg verification
|
27
46
|
def repo
|
28
47
|
src = "#{MOUNTPOINT}/usr/share/portage/config/repos.conf"
|
29
48
|
dest = "#{MOUNTPOINT}/etc/portage/repos.conf"
|
30
49
|
FileUtils.mkdir dest, mode: 0644 if ! Dir.exist?(dest)
|
50
|
+
tmp = Tempfile.new('gentoo.conf')
|
31
51
|
line_count = 0
|
32
|
-
|
52
|
+
|
33
53
|
File.open(src).each { |l|
|
34
|
-
File.write(
|
35
|
-
|
54
|
+
File.write(tmp, "sync-allow-hardlinks = yes\n", mode: 'a') if line_count == 2
|
55
|
+
if l.match(/^sync-type = rsync/)
|
56
|
+
File.write(tmp, "sync-type = webrsync\n", mode: 'a')
|
57
|
+
else
|
58
|
+
File.write(tmp, l, mode: 'a')
|
59
|
+
end
|
36
60
|
line_count += 1
|
37
61
|
}
|
38
|
-
|
62
|
+
|
63
|
+
FileUtils.copy_file(tmp, "#{dest}/gentoo.conf", preserve = true)
|
39
64
|
end
|
40
65
|
|
41
66
|
def network
|
42
67
|
src = '/etc/resolv.conf'
|
43
68
|
dest = "#{MOUNTPOINT}/etc/resolv.conf"
|
44
|
-
FileUtils.copy_file(src, dest, preserve =
|
69
|
+
FileUtils.copy_file(src, dest, preserve = true)
|
45
70
|
end
|
46
71
|
|
47
72
|
def systemd(options)
|
@@ -50,7 +75,7 @@ module Getch
|
|
50
75
|
File.write("#{MOUNTPOINT}/etc/locale.conf", "LANG=#{@lang}\n")
|
51
76
|
File.write("#{MOUNTPOINT}/etc/locale.conf", 'LC_COLLATE=C', mode: 'a')
|
52
77
|
File.write("#{MOUNTPOINT}/etc/timezone", "#{options.zoneinfo}")
|
53
|
-
File.write("#{MOUNTPOINT}/etc/vconsole.conf", "KEYMAP=#{options.
|
78
|
+
File.write("#{MOUNTPOINT}/etc/vconsole.conf", "KEYMAP=#{options.keymap}")
|
54
79
|
end
|
55
80
|
|
56
81
|
def hostname
|
@@ -74,7 +99,7 @@ module Getch
|
|
74
99
|
def control_options(options)
|
75
100
|
search_zone(options.zoneinfo)
|
76
101
|
search_utf8(options.language)
|
77
|
-
search_key(options.
|
102
|
+
search_key(options.keymap)
|
78
103
|
end
|
79
104
|
|
80
105
|
def search_key(keys)
|
@@ -86,7 +111,7 @@ module Getch
|
|
86
111
|
end
|
87
112
|
|
88
113
|
def search_zone(zone)
|
89
|
-
if !
|
114
|
+
if !File.exist?("#{MOUNTPOINT}/usr/share/zoneinfo/#{zone}")
|
90
115
|
raise ArgumentError, "Zoneinfo #{zone} doesn\'t exist."
|
91
116
|
end
|
92
117
|
end
|
data/lib/getch/gentoo/sources.rb
CHANGED
@@ -3,11 +3,11 @@ module Getch
|
|
3
3
|
class Sources
|
4
4
|
def initialize
|
5
5
|
@lsmod = `lsmod`.chomp
|
6
|
-
@filesystem =
|
6
|
+
@filesystem = Getch.class_fs::Deps.new()
|
7
7
|
end
|
8
8
|
|
9
9
|
def build_others
|
10
|
-
|
10
|
+
cryptsetup
|
11
11
|
virtualbox_guest
|
12
12
|
qemu_guest
|
13
13
|
install_wifi
|
@@ -16,28 +16,20 @@ module Getch
|
|
16
16
|
|
17
17
|
def build_kspp
|
18
18
|
puts "Adding KSPP to the kernel source"
|
19
|
-
|
19
|
+
bask("-b -a systemd")
|
20
20
|
end
|
21
21
|
|
22
22
|
def make
|
23
|
-
if DEFAULT_OPTIONS[:fs] == 'lvm'
|
23
|
+
if DEFAULT_OPTIONS[:fs] == 'lvm' || DEFAULT_OPTIONS[:fs] == 'zfs' || DEFAULT_OPTIONS[:encrypt]
|
24
24
|
@filesystem.make
|
25
25
|
else
|
26
|
-
|
26
|
+
make_kernel
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def init_config
|
31
|
-
Getch::Make.new("make localyesconfig").run!
|
32
|
-
end
|
33
|
-
|
34
30
|
private
|
35
31
|
|
36
|
-
def
|
37
|
-
Getch::Make.new("make -j$(nproc)").run!
|
38
|
-
end
|
39
|
-
|
40
|
-
def just_make
|
32
|
+
def make_kernel
|
41
33
|
puts "Compiling kernel sources"
|
42
34
|
cmd = "make -j$(nproc) && make modules_install && make install"
|
43
35
|
Getch::Make.new(cmd).run!
|
@@ -45,45 +37,50 @@ module Getch
|
|
45
37
|
raise "No kernel installed, compiling source fail..." if is_kernel == []
|
46
38
|
end
|
47
39
|
|
40
|
+
def cryptsetup
|
41
|
+
return unless DEFAULT_OPTIONS[:encrypt]
|
42
|
+
make_conf = "#{MOUNTPOINT}/etc/portage/make.conf"
|
43
|
+
|
44
|
+
puts "Adding support for cryptsetup."
|
45
|
+
bask("-a cryptsetup")
|
46
|
+
Getch::Chroot.new("euse -E cryptsetup").run! unless Helpers::grep?(make_conf, /cryptsetup/)
|
47
|
+
Getch::Emerge.new("sys-fs/cryptsetup").pkg!
|
48
|
+
end
|
49
|
+
|
48
50
|
def virtualbox_guest
|
49
|
-
|
50
|
-
|
51
|
+
systemd=`systemd-detect-virt`.chomp
|
52
|
+
return if ! ismatch?('vmwgfx') || systemd.match(/none/)
|
53
|
+
bask("-a virtualbox-guest")
|
51
54
|
Getch::Emerge.new("app-emulation/virtualbox-guest-additions").pkg!
|
52
55
|
end
|
53
56
|
|
54
57
|
def qemu_guest
|
55
|
-
|
56
|
-
|
58
|
+
bask("-a kvm-host") if ismatch?('kvm')
|
59
|
+
bask("-a kvm-guest") if ismatch?('virtio')
|
57
60
|
end
|
58
61
|
|
59
62
|
def ismatch?(arg)
|
60
63
|
@lsmod.match?(/#{arg}/)
|
61
64
|
end
|
62
65
|
|
63
|
-
def
|
64
|
-
Getch::
|
66
|
+
def bask(cmd)
|
67
|
+
Getch::Bask.new(cmd).run!
|
65
68
|
end
|
66
69
|
|
67
70
|
def install_wifi
|
68
71
|
return if ! ismatch?('cfg80211')
|
69
|
-
|
72
|
+
bask("-a wifi")
|
70
73
|
wifi_drivers
|
71
74
|
Getch::Emerge.new("net-wireless/iw wpa_supplicant net-wireless/iwd").pkg!
|
72
75
|
end
|
73
76
|
|
74
77
|
def install_audio
|
75
78
|
return if ! ismatch?('snd_pcm')
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
def install_zfs
|
80
|
-
garden("-a zfs")
|
81
|
-
only_make # a first 'make' is necessary before emerge zfs
|
82
|
-
Getch::Emerge.new("sys-fs/zfs").pkg!
|
79
|
+
bask("-a sound")
|
83
80
|
end
|
84
81
|
|
85
82
|
def wifi_drivers
|
86
|
-
|
83
|
+
bask("-a ath9k-driver") if ismatch?('ath9k')
|
87
84
|
end
|
88
85
|
end
|
89
86
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Getch
|
2
|
+
module Gentoo
|
3
|
+
class Use
|
4
|
+
def initialize(pkg = nil)
|
5
|
+
@use_dir = "#{MOUNTPOINT}/etc/portage/package.use"
|
6
|
+
@pkg = pkg
|
7
|
+
@file = @pkg ? @pkg.match(/[\w]+$/) : nil
|
8
|
+
@make = "#{MOUNTPOINT}/etc/portage/make.conf"
|
9
|
+
end
|
10
|
+
|
11
|
+
def add(*flags)
|
12
|
+
@flags = flags.join(' ')
|
13
|
+
write
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_global(*flags)
|
17
|
+
@flags = flags
|
18
|
+
write_global
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def write
|
24
|
+
content = "#{@pkg} #{@flags}\n"
|
25
|
+
File.write("#{@use_dir}/#{@file}", content, mode: 'w')
|
26
|
+
end
|
27
|
+
|
28
|
+
def write_global
|
29
|
+
list = []
|
30
|
+
|
31
|
+
@flags.each { |f|
|
32
|
+
unless Helpers::grep?(@make, /#{f}/)
|
33
|
+
list << f
|
34
|
+
end
|
35
|
+
}
|
36
|
+
|
37
|
+
use = list.join(' ')
|
38
|
+
line = "USE=\"${USE} #{use}\"\n"
|
39
|
+
File.write(@make, line, mode: 'a')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|