getch 0.1.0 → 0.1.6
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/README.md +95 -22
- data/assets/network-stack.conf +63 -0
- data/bin/getch +12 -4
- data/lib/getch.rb +116 -66
- data/lib/getch/command.rb +19 -5
- data/lib/getch/config.rb +42 -0
- data/lib/getch/config/gentoo.rb +59 -0
- data/lib/getch/config/void.rb +49 -0
- data/lib/getch/filesystem.rb +5 -0
- data/lib/getch/filesystem/.mount.rb.swp +0 -0
- data/lib/getch/filesystem/clean.rb +58 -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.rb +1 -0
- data/lib/getch/filesystem/ext4/encrypt/config.rb +8 -9
- data/lib/getch/filesystem/ext4/encrypt/deps.rb +3 -19
- data/lib/getch/filesystem/ext4/encrypt/device.rb +3 -8
- data/lib/getch/filesystem/ext4/encrypt/format.rb +3 -6
- data/lib/getch/filesystem/ext4/encrypt/mount.rb +5 -43
- data/lib/getch/filesystem/ext4/encrypt/partition.rb +29 -54
- data/lib/getch/filesystem/ext4/encrypt/void.rb +100 -0
- data/lib/getch/filesystem/ext4/format.rb +4 -6
- data/lib/getch/filesystem/ext4/mount.rb +7 -46
- data/lib/getch/filesystem/ext4/partition.rb +16 -39
- data/lib/getch/filesystem/ext4/void.rb +43 -0
- data/lib/getch/filesystem/lvm.rb +1 -0
- data/lib/getch/filesystem/lvm/config.rb +11 -15
- data/lib/getch/filesystem/lvm/deps.rb +4 -19
- data/lib/getch/filesystem/lvm/device.rb +33 -9
- data/lib/getch/filesystem/lvm/encrypt.rb +1 -0
- data/lib/getch/filesystem/lvm/encrypt/config.rb +9 -12
- data/lib/getch/filesystem/lvm/encrypt/deps.rb +4 -21
- data/lib/getch/filesystem/lvm/encrypt/device.rb +33 -9
- data/lib/getch/filesystem/lvm/encrypt/format.rb +3 -4
- data/lib/getch/filesystem/lvm/encrypt/mount.rb +7 -47
- data/lib/getch/filesystem/lvm/encrypt/partition.rb +30 -38
- data/lib/getch/filesystem/lvm/encrypt/void.rb +100 -0
- data/lib/getch/filesystem/lvm/format.rb +12 -8
- data/lib/getch/filesystem/lvm/mount.rb +7 -46
- data/lib/getch/filesystem/lvm/partition.rb +19 -31
- data/lib/getch/filesystem/lvm/void.rb +45 -0
- data/lib/getch/filesystem/mount.rb +56 -0
- data/lib/getch/filesystem/partition.rb +77 -0
- data/lib/getch/filesystem/zfs.rb +1 -0
- data/lib/getch/filesystem/zfs/config.rb +7 -8
- data/lib/getch/filesystem/zfs/deps.rb +24 -12
- data/lib/getch/filesystem/zfs/device.rb +54 -9
- data/lib/getch/filesystem/zfs/encrypt.rb +1 -0
- data/lib/getch/filesystem/zfs/encrypt/.mount.rb.swp +0 -0
- data/lib/getch/filesystem/zfs/encrypt/config.rb +11 -11
- data/lib/getch/filesystem/zfs/encrypt/deps.rb +24 -14
- data/lib/getch/filesystem/zfs/encrypt/device.rb +54 -9
- data/lib/getch/filesystem/zfs/encrypt/format.rb +84 -3
- data/lib/getch/filesystem/zfs/encrypt/mount.rb +8 -28
- data/lib/getch/filesystem/zfs/encrypt/partition.rb +26 -109
- data/lib/getch/filesystem/zfs/encrypt/void.rb +96 -0
- data/lib/getch/filesystem/zfs/format.rb +97 -4
- data/lib/getch/filesystem/zfs/mount.rb +10 -32
- data/lib/getch/filesystem/zfs/partition.rb +25 -106
- data/lib/getch/filesystem/zfs/void.rb +81 -0
- data/lib/getch/gentoo.rb +20 -16
- data/lib/getch/gentoo/boot.rb +24 -16
- data/lib/getch/gentoo/chroot.rb +16 -25
- data/lib/getch/gentoo/config.rb +67 -15
- data/lib/getch/gentoo/sources.rb +55 -13
- data/lib/getch/gentoo/stage.rb +0 -1
- data/lib/getch/gentoo/use.rb +43 -0
- data/lib/getch/gentoo/use_flag.rb +63 -0
- data/lib/getch/guard.rb +64 -0
- data/lib/getch/helpers.rb +133 -0
- data/lib/getch/log.rb +3 -2
- data/lib/getch/options.rb +46 -24
- data/lib/getch/version.rb +1 -1
- data/lib/getch/void.rb +59 -0
- data/lib/getch/void/boot.rb +80 -0
- data/lib/getch/void/chroot.rb +55 -0
- data/lib/getch/void/config.rb +87 -0
- data/lib/getch/void/stage.rb +70 -0
- metadata +46 -25
- metadata.gz.sig +0 -0
- data/.gitignore +0 -2
- data/CHANGELOG.md +0 -60
- data/Rakefile +0 -21
- data/bin/setup.sh +0 -90
- data/getch.gemspec +0 -25
data/lib/getch/log.rb
CHANGED
|
@@ -2,8 +2,9 @@ require 'logger'
|
|
|
2
2
|
|
|
3
3
|
module Getch
|
|
4
4
|
class Log
|
|
5
|
-
def initialize
|
|
5
|
+
def initialize(verbose = false)
|
|
6
6
|
@log_file = '/tmp/log_install.txt'
|
|
7
|
+
@verbose = verbose
|
|
7
8
|
check_file
|
|
8
9
|
init_log
|
|
9
10
|
init_log_text
|
|
@@ -37,7 +38,7 @@ module Getch
|
|
|
37
38
|
|
|
38
39
|
def init_log
|
|
39
40
|
@logger = Logger.new(STDOUT)
|
|
40
|
-
@logger.level =
|
|
41
|
+
@logger.level = @verbose ? Logger::DEBUG : Logger::INFO
|
|
41
42
|
@logger.formatter = proc { |severity, datetime, progname, msg|
|
|
42
43
|
"#{severity}, #{msg}\n"
|
|
43
44
|
}
|
data/lib/getch/options.rb
CHANGED
|
@@ -2,17 +2,7 @@ require 'optparse'
|
|
|
2
2
|
|
|
3
3
|
module Getch
|
|
4
4
|
class Options
|
|
5
|
-
attr_reader :language, :zoneinfo, :keymap, :disk, :fs, :username, :encrypt, :verbose
|
|
6
|
-
|
|
7
5
|
def initialize(argv)
|
|
8
|
-
@language = DEFAULT_OPTIONS[:language]
|
|
9
|
-
@zoneinfo = DEFAULT_OPTIONS[:zoneinfo]
|
|
10
|
-
@keymap = DEFAULT_OPTIONS[:keymap]
|
|
11
|
-
@disk = DEFAULT_OPTIONS[:disk]
|
|
12
|
-
@fs = DEFAULT_OPTIONS[:fs]
|
|
13
|
-
@username = DEFAULT_OPTIONS[:username]
|
|
14
|
-
@encrypt = DEFAULT_OPTIONS[:encrypt]
|
|
15
|
-
@verbose = DEFAULT_OPTIONS[:verbose]
|
|
16
6
|
parse(argv)
|
|
17
7
|
end
|
|
18
8
|
|
|
@@ -20,36 +10,68 @@ module Getch
|
|
|
20
10
|
|
|
21
11
|
def parse(argv)
|
|
22
12
|
OptionParser.new do |opts|
|
|
13
|
+
opts.version = VERSION
|
|
14
|
+
|
|
23
15
|
opts.on("-l", "--language LANG", "Default is en_US") do |lang|
|
|
24
|
-
|
|
16
|
+
OPTIONS[:language] = lang
|
|
25
17
|
end
|
|
18
|
+
|
|
26
19
|
opts.on("-z", "--zoneinfo ZONE", "Default is US/Eastern") do |zone|
|
|
27
|
-
|
|
20
|
+
OPTIONS[:zoneinfo] = Getch::Guard.zone(zone)
|
|
28
21
|
end
|
|
22
|
+
|
|
29
23
|
opts.on("-k", "--keymap KEY", "Default is us") do |key|
|
|
30
|
-
|
|
24
|
+
OPTIONS[:keymap] = Getch::Guard.keymap(key)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
opts.on("-d", "--disk DISK", "Root Disk where install the system (sda,sdb)") do |disk|
|
|
28
|
+
OPTIONS[:disk] = Getch::Guard.disk(disk)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
opts.on("-f", "--format FS", "Can be ext4, lvm or zfs. Default use ext4") do |fs|
|
|
32
|
+
OPTIONS[:fs] = Getch::Guard.format(fs)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
opts.on("-u", "--username USERNAME", "Create a new user /home/USERNAME with password.") do |user|
|
|
36
|
+
OPTIONS[:username] = user
|
|
31
37
|
end
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
|
|
39
|
+
opts.on("-o", "--os NAME", /gentoo|void/, "Instal distro NAME, can be gentoo or void.") do |name|
|
|
40
|
+
OPTIONS[:os] = name
|
|
34
41
|
end
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
|
|
43
|
+
opts.on("--separate-boot DISK", "Use a different DISK for the /boot or /efi partition.") do |boot|
|
|
44
|
+
OPTIONS[:boot_disk] = Getch::Guard.disk(boot)
|
|
38
45
|
end
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
|
|
47
|
+
opts.on("--separate-cache DISK", "Use a different DISK for the swap partition, add ZIL/L2ARC for ZFS when set.") do |swap|
|
|
48
|
+
OPTIONS[:cache_disk] = Getch::Guard.disk(swap)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
opts.on("--separate-home DISK", "Use a different DISK for the /home partition.") do |home|
|
|
52
|
+
OPTIONS[:home_disk] = Getch::Guard.disk(home)
|
|
41
53
|
end
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
|
|
55
|
+
opts.on("--encrypt", "Encrypt your system, use LUKS or native encryption for ZFS.") do
|
|
56
|
+
OPTIONS[:encrypt] = true
|
|
44
57
|
end
|
|
58
|
+
|
|
45
59
|
opts.on("--verbose", "Write more messages to the standard output.") do
|
|
46
|
-
|
|
60
|
+
OPTIONS[:verbose] = true
|
|
47
61
|
end
|
|
62
|
+
|
|
48
63
|
opts.on("-h", "--help", "Display this") do
|
|
49
64
|
puts opts
|
|
50
65
|
exit
|
|
51
66
|
end
|
|
52
|
-
|
|
67
|
+
|
|
68
|
+
begin
|
|
69
|
+
opts.parse!(argv)
|
|
70
|
+
rescue OptionParser::ParseError => e
|
|
71
|
+
STDERR.puts e.message, "\n", opts
|
|
72
|
+
exit 1
|
|
73
|
+
end
|
|
74
|
+
end
|
|
53
75
|
end
|
|
54
76
|
end
|
|
55
77
|
end
|
data/lib/getch/version.rb
CHANGED
data/lib/getch/void.rb
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require_relative 'void/stage'
|
|
2
|
+
require_relative 'void/config'
|
|
3
|
+
require_relative 'void/chroot'
|
|
4
|
+
#require_relative 'void/sources'
|
|
5
|
+
require_relative 'void/boot'
|
|
6
|
+
|
|
7
|
+
module Getch
|
|
8
|
+
module Void
|
|
9
|
+
class Main
|
|
10
|
+
def initialize
|
|
11
|
+
@state = Getch::States.new()
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def root_fs
|
|
15
|
+
return if STATES[:gentoo_base]
|
|
16
|
+
xbps = Getch::Void::RootFS.new
|
|
17
|
+
xbps.search_archive
|
|
18
|
+
xbps.download
|
|
19
|
+
xbps.checksum
|
|
20
|
+
@state.stage3
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def config
|
|
24
|
+
return if STATES[:gentoo_config]
|
|
25
|
+
config = Getch::Void::Config.new
|
|
26
|
+
config.host
|
|
27
|
+
config.network
|
|
28
|
+
config.system
|
|
29
|
+
config.locale
|
|
30
|
+
@state.config
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def chroot
|
|
34
|
+
return if STATES[:gentoo_kernel]
|
|
35
|
+
chroot = Getch::Void::Chroot.new
|
|
36
|
+
chroot.update
|
|
37
|
+
chroot.fs
|
|
38
|
+
chroot.extras
|
|
39
|
+
chroot.install_pkgs
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def kernel
|
|
43
|
+
return if STATES[:gentoo_kernel]
|
|
44
|
+
Getch::Void::Sources.new
|
|
45
|
+
@state.kernel
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def boot
|
|
49
|
+
boot = Getch::Void::Boot.new
|
|
50
|
+
boot.new_user
|
|
51
|
+
boot.fstab
|
|
52
|
+
boot.dracut
|
|
53
|
+
boot.grub
|
|
54
|
+
boot.initramfs
|
|
55
|
+
boot.finish
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
require_relative '../helpers'
|
|
3
|
+
|
|
4
|
+
module Getch
|
|
5
|
+
module Void
|
|
6
|
+
class Boot
|
|
7
|
+
include Helpers::Void
|
|
8
|
+
|
|
9
|
+
def initialize
|
|
10
|
+
@efi = Helpers::efi?
|
|
11
|
+
@class_fs = Getch::select_fs
|
|
12
|
+
@fs = @class_fs::Void.new
|
|
13
|
+
@user = OPTIONS[:username]
|
|
14
|
+
@fs.create_key if @class_fs::Void.method_defined? :create_key
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def new_user
|
|
18
|
+
puts " => Add a password for root."
|
|
19
|
+
chroot "passwd"
|
|
20
|
+
puts
|
|
21
|
+
return unless @user
|
|
22
|
+
print " => Creating a new user #{@user}..."
|
|
23
|
+
puts "\s[OK]"
|
|
24
|
+
command "useradd -m -G users,wheel,audio,video #{@user}"
|
|
25
|
+
puts " => Add a password for #{@user}."
|
|
26
|
+
chroot "passwd #{@user}"
|
|
27
|
+
puts
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def fstab
|
|
31
|
+
print " => Configuring fstab..."
|
|
32
|
+
@fs.fstab
|
|
33
|
+
puts "\s[OK]"
|
|
34
|
+
@fs.crypttab if @class_fs::Void.method_defined? :crypttab
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Test dracut in chroot (version in /lib/modules/5.1.7-1):
|
|
38
|
+
# dracut -H -f --kver 5.1.7-1
|
|
39
|
+
def dracut
|
|
40
|
+
print " => Configuring Dracut..."
|
|
41
|
+
@fs.config_dracut
|
|
42
|
+
@fs.kernel_cmdline_dracut
|
|
43
|
+
puts "\s[OK]"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def grub
|
|
47
|
+
disk = OPTIONS[:boot_disk] ||= OPTIONS[:disk]
|
|
48
|
+
print " => Installing Grub on #{disk}..."
|
|
49
|
+
if @efi
|
|
50
|
+
command_output "xbps-install -y grub-x86_64-efi"
|
|
51
|
+
@fs.config_grub if @class_fs::Void.method_defined? :config_grub
|
|
52
|
+
command_output "grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=\"Void\""
|
|
53
|
+
else
|
|
54
|
+
command_output "xbps-install -y grub"
|
|
55
|
+
@fs.config_grub if @class_fs::Void.method_defined? :config_grub
|
|
56
|
+
command_output "grub-install /dev/#{disk}"
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def initramfs
|
|
61
|
+
puts " => Generating an initramfs..."
|
|
62
|
+
command_output "xbps-reconfigure -fa" # this command also start grub-mkconfig
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def finish
|
|
66
|
+
puts
|
|
67
|
+
puts "[*!*] Install finished [*!*]"
|
|
68
|
+
puts
|
|
69
|
+
@fs.finish
|
|
70
|
+
puts
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
private
|
|
74
|
+
|
|
75
|
+
def chroot(cmd)
|
|
76
|
+
system("chroot", MOUNTPOINT, "/bin/bash", "-c", cmd)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require_relative '../helpers'
|
|
2
|
+
|
|
3
|
+
module Getch
|
|
4
|
+
module Void
|
|
5
|
+
class Chroot
|
|
6
|
+
include Helpers::Void
|
|
7
|
+
|
|
8
|
+
def initialize
|
|
9
|
+
@state = Getch::States.new()
|
|
10
|
+
@pkgs = []
|
|
11
|
+
mount
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# https://docs.voidlinux.org/installation/guides/chroot.html#install-base-system-rootfs-method-only
|
|
15
|
+
def update
|
|
16
|
+
return if STATES[:gentoo_update]
|
|
17
|
+
command_output "/usr/bin/xbps-install -Suy xbps" # y to force (--yes)
|
|
18
|
+
command_output "/usr/bin/xbps-install -uy"
|
|
19
|
+
command_output "/usr/bin/xbps-install -y base-system"
|
|
20
|
+
#command_output "/usr/bin/xbps-remove base-voidstrap"
|
|
21
|
+
@state.update
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def extras
|
|
25
|
+
@pkgs << "vim"
|
|
26
|
+
@pkgs << "iptables"
|
|
27
|
+
@pkgs << "iwd"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def fs
|
|
31
|
+
@pkgs << "lvm2" if OPTIONS[:fs] == 'lvm'
|
|
32
|
+
@pkgs << "zfs" if OPTIONS[:fs] == 'zfs'
|
|
33
|
+
@pkgs << "cryptsetup" if OPTIONS[:encrypt]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def install_pkgs
|
|
37
|
+
all_pkgs = @pkgs.join(" ")
|
|
38
|
+
command_output "/usr/bin/xbps-install -y #{all_pkgs}"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
def mount
|
|
44
|
+
puts "Populate /proc, /sys and /dev."
|
|
45
|
+
Helpers::exec_or_die("mount --types proc /proc \"#{MOUNTPOINT}/proc\"")
|
|
46
|
+
Helpers::exec_or_die("mount --rbind /sys \"#{MOUNTPOINT}/sys\"")
|
|
47
|
+
Helpers::exec_or_die("mount --make-rslave \"#{MOUNTPOINT}/sys\"")
|
|
48
|
+
Helpers::exec_or_die("mount --rbind /dev \"#{MOUNTPOINT}/dev\"")
|
|
49
|
+
Helpers::exec_or_die("mount --make-rslave \"#{MOUNTPOINT}/dev\"")
|
|
50
|
+
# Maybe add /dev/shm like describe here:
|
|
51
|
+
# https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Base
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
require 'securerandom'
|
|
3
|
+
require_relative '../helpers'
|
|
4
|
+
|
|
5
|
+
module Getch
|
|
6
|
+
module Void
|
|
7
|
+
class Config
|
|
8
|
+
include Helpers::Void
|
|
9
|
+
|
|
10
|
+
def initialize
|
|
11
|
+
@log = Getch::Log.new
|
|
12
|
+
@network_dir = "#{MOUNTPOINT}/etc"
|
|
13
|
+
@id = SecureRandom.hex(2)
|
|
14
|
+
@hostname = "void-hatch-#{@id}"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def host
|
|
18
|
+
print " => Adding hostname #{@hostname}..."
|
|
19
|
+
conf = "#{@network_dir}/hostname"
|
|
20
|
+
File.write(conf, "#{@hostname}\n", mode: 'w', chmod: 0744)
|
|
21
|
+
puts "\s[OK]"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def network
|
|
25
|
+
print " => Copying /etc/resolv.conf..."
|
|
26
|
+
src = '/etc/resolv.conf'
|
|
27
|
+
dest = "#{@network_dir}/resolv.conf"
|
|
28
|
+
FileUtils.copy_file(src, dest, preserve = true)
|
|
29
|
+
puts "\s[Ok]"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def system
|
|
33
|
+
print " => Updating configs system..."
|
|
34
|
+
control_options
|
|
35
|
+
rc = "#{MOUNTPOINT}/etc/rc.conf"
|
|
36
|
+
add_line(rc, "HARDWARECLOCK=\"UTC\"") if !search(rc, /^HARDWARECLOCK/)
|
|
37
|
+
add_line(rc, "KEYMAP=\"#{OPTIONS[:keymap]}\"") if !search(rc, /^KEYMAP/)
|
|
38
|
+
add_line(rc, "TIMEZONE=\"#{OPTIONS[:zoneinfo]}\"") if !search(rc, /^TIMEZONE/)
|
|
39
|
+
add_line(rc, "HOSTNAME=\"#{@hostname}\"") if !search(rc, /^HOSTNAME/)
|
|
40
|
+
puts "\s[OK]"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def locale
|
|
44
|
+
print " => Updating locale system..."
|
|
45
|
+
control_options
|
|
46
|
+
conf = "#{MOUNTPOINT}/etc/locale.conf"
|
|
47
|
+
File.write(conf, "LANG=#{@lang}\n")
|
|
48
|
+
add_line(conf, "LC_COLLATE=C")
|
|
49
|
+
conf = "#{MOUNTPOINT}/etc/default/libc-locales"
|
|
50
|
+
add_line(conf, @utf8)
|
|
51
|
+
puts "\s[OK]"
|
|
52
|
+
command "xbps-reconfigure -f glibc-locales"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def control_options
|
|
58
|
+
search_zone(OPTIONS[:zoneinfo])
|
|
59
|
+
search_utf8(OPTIONS[:language])
|
|
60
|
+
search_key(OPTIONS[:keymap])
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def search_key(keys)
|
|
64
|
+
@keymap = nil
|
|
65
|
+
Dir.glob("#{MOUNTPOINT}/usr/share/kbd/keymaps/**/#{keys}.map.gz") { |f|
|
|
66
|
+
@keymap = f
|
|
67
|
+
}
|
|
68
|
+
raise ArgumentError, "No keymap #{@keymap} found" if ! @keymap
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def search_zone(zone)
|
|
72
|
+
unless File.exist? "#{MOUNTPOINT}/usr/share/zoneinfo/#{zone}"
|
|
73
|
+
raise ArgumentError, "Zoneinfo #{zone} doesn\'t exist."
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def search_utf8(lang)
|
|
78
|
+
@utf8, @lang = nil, nil
|
|
79
|
+
File.open("#{MOUNTPOINT}/etc/default/libc-locales").each { |l|
|
|
80
|
+
@utf8 = $~[0] if l.match(/#{lang}[. ]+[utf\-8 ]+/i)
|
|
81
|
+
@lang = $~[0] if l.match(/#{lang}[. ]+utf\-8/i)
|
|
82
|
+
}
|
|
83
|
+
raise ArgumentError, "Lang #{lang} no found" if !@utf8
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'open-uri'
|
|
2
|
+
require 'open3'
|
|
3
|
+
|
|
4
|
+
module Getch
|
|
5
|
+
module Void
|
|
6
|
+
class RootFS
|
|
7
|
+
def initialize
|
|
8
|
+
@url = "https://alpha.de.repo.voidlinux.org/live/current"
|
|
9
|
+
@file = "sha256sum.sig"
|
|
10
|
+
@xbps = false
|
|
11
|
+
Dir.chdir(MOUNTPOINT)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Search only the glibc x86_64 for now
|
|
15
|
+
def search_archive
|
|
16
|
+
yurl = "#{@url}/#{@file}"
|
|
17
|
+
puts "Open #{yurl}"
|
|
18
|
+
Helpers::get_file_online(yurl, @file)
|
|
19
|
+
File.open(@file).each { |l|
|
|
20
|
+
@xbps = l.tr('()', '').split(" ") if l.match(/void-x86_64-ROOTFS-[\d._]+.tar.xz/)
|
|
21
|
+
}
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def download
|
|
25
|
+
raise StandardError, "No file found, retry later." if !@xbps
|
|
26
|
+
return if File.exist? @xbps[1]
|
|
27
|
+
puts "Downloading #{@xbps[1]}..."
|
|
28
|
+
Helpers::get_file_online("#{@url}/#{@xbps[1]}", @xbps[1])
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def checksum
|
|
32
|
+
print ' => Checking SHA256 checksum...'
|
|
33
|
+
# Should contain 2 spaces...
|
|
34
|
+
command = "echo #{@xbps[3]} #{@xbps[1]} | sha256sum --check"
|
|
35
|
+
_, stderr, status = Open3.capture3(command)
|
|
36
|
+
if status.success? then
|
|
37
|
+
puts "\t[OK]"
|
|
38
|
+
decompress
|
|
39
|
+
cleaning
|
|
40
|
+
return
|
|
41
|
+
end
|
|
42
|
+
cleaning
|
|
43
|
+
raise "Problem with the checksum, stderr\n#{stderr}"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
def decompress
|
|
49
|
+
print " => Decompressing archive #{@xbps[1]}..."
|
|
50
|
+
cmd = "tar xpf #{@xbps[1]} --xattrs-include=\'*.*\' --numeric-owner"
|
|
51
|
+
_, stderr, status = Open3.capture3(cmd)
|
|
52
|
+
if status.success? then
|
|
53
|
+
puts "\s[OK]"
|
|
54
|
+
return
|
|
55
|
+
end
|
|
56
|
+
cleaning
|
|
57
|
+
raise "Fail to decompress archive #{@xbps[1]} - #{stderr}."
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def cleaning
|
|
61
|
+
Dir.glob("void-x86_64*.tar.xz").each do |f|
|
|
62
|
+
File.delete(f)
|
|
63
|
+
end
|
|
64
|
+
Dir.glob("sha256*").each do |f|
|
|
65
|
+
File.delete(f)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|