getch 0.0.6 → 0.1.1
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 +35 -2
- data/README.md +44 -7
- data/bin/setup.sh +29 -13
- data/lib/getch.rb +40 -16
- data/lib/getch/command.rb +138 -16
- data/lib/getch/filesystem.rb +7 -1
- data/lib/getch/filesystem/clean.rb +51 -0
- data/lib/getch/filesystem/device.rb +55 -0
- data/lib/getch/filesystem/ext4.rb +9 -70
- data/lib/getch/filesystem/ext4/config.rb +58 -0
- data/lib/getch/filesystem/ext4/deps.rb +22 -0
- data/lib/getch/filesystem/ext4/device.rb +11 -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 +16 -0
- data/lib/getch/filesystem/ext4/encrypt/format.rb +30 -0
- data/lib/getch/filesystem/ext4/encrypt/mount.rb +27 -0
- data/lib/getch/filesystem/ext4/encrypt/partition.rb +97 -0
- data/lib/getch/filesystem/ext4/format.rb +28 -0
- data/lib/getch/filesystem/ext4/mount.rb +23 -0
- data/lib/getch/filesystem/ext4/partition.rb +52 -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 +58 -0
- data/lib/getch/filesystem/lvm/device.rb +35 -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 +38 -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 +29 -0
- data/lib/getch/filesystem/lvm/mount.rb +23 -0
- data/lib/getch/filesystem/lvm/partition.rb +69 -0
- 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 +87 -0
- data/lib/getch/filesystem/zfs/device.rb +40 -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 +90 -0
- data/lib/getch/filesystem/zfs/encrypt/device.rb +42 -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 +55 -0
- data/lib/getch/filesystem/zfs/format.rb +102 -0
- data/lib/getch/filesystem/zfs/mount.rb +48 -0
- data/lib/getch/filesystem/zfs/partition.rb +54 -0
- data/lib/getch/gentoo.rb +4 -3
- data/lib/getch/gentoo/boot.rb +30 -26
- data/lib/getch/gentoo/chroot.rb +23 -33
- data/lib/getch/gentoo/config.rb +39 -10
- data/lib/getch/gentoo/sources.rb +37 -38
- data/lib/getch/gentoo/stage.rb +1 -1
- data/lib/getch/helpers.rb +37 -7
- data/lib/getch/log.rb +54 -0
- data/lib/getch/options.rb +28 -8
- data/lib/getch/version.rb +1 -1
- metadata +49 -5
- metadata.gz.sig +0 -0
- data/lib/getch/filesystem/root.rb +0 -63
- data/lib/getch/mount.rb +0 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80a9841959ac12d1fccf5a4dc5834001e802b36dd1798e297db0cd85f772be03
|
4
|
+
data.tar.gz: 4bcdc9927577f8de4ba1d992e055d00cc11fe42f8aa8a66b52fff06f2c93ca95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 837136b17e66962df98d4e982a4fc10bcd3aefd58fdcf72014079d639d605c1f41b7e9663e1d8e95dba8e78705e448b06a86c36158b8b2590d34febbfdfcd541
|
7
|
+
data.tar.gz: cb9b794f65827c4c7facc6441bd17ebb01409c3d07fc1fc68ca9e7ee6f741b4571cc19e62634069e3eeb4c45ca055c4eb0c2babc58cad033d1e32996c53e0b76
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,41 @@
|
|
1
|
+
* Change mountpoint for the esp at /efi rather than /boot/efi
|
2
|
+
* Replace Garden by Bask https://github.com/szorfein/bask
|
3
|
+
* Correct option --username USERNAME, do not create a new partition.
|
4
|
+
* New set of options --separate-{boot,cache,home} to install them on another disk
|
5
|
+
* Refactor codes
|
6
|
+
* Add cpu name to COMMON_FLAGS
|
7
|
+
* Add cpuflags with app-portage/cpuid2cpuflags
|
8
|
+
+ Use the whole disk space available for / when option --username is unset
|
9
|
+
|
10
|
+
## 0.1.0, release 2020-10-15
|
11
|
+
* Add the (Zeta) filesystem ZFS
|
12
|
+
* `emerge --depclean` to save space.
|
13
|
+
* Add a message when getch have finish, keep /mnt/gentoo if you need to add something.
|
14
|
+
* Use systemd-detect-virt to detect a Virtual Guest.
|
15
|
+
|
16
|
+
## 0.0.9, release 2020-10-03
|
17
|
+
* Add encryption on ext4 and lvm (BIOS,UEFI)
|
18
|
+
* Correct KEYMAP="yes" with genkernel
|
19
|
+
* Renaming option keyboard with keymap
|
20
|
+
* GPG verification for ebuild
|
21
|
+
|
22
|
+
## 0.0.8, release 2020-09-30
|
23
|
+
* Adding LVM via the option fs, `--fs lvm`.
|
24
|
+
* Systemd-boot use the value of PARTUUID without initramfs.
|
25
|
+
* Include lib logger.
|
26
|
+
* Enhance functions to call program system Emerge, Make, ...
|
27
|
+
|
28
|
+
## 0.0.7, release 2020-09-22
|
29
|
+
* Correct fstab.
|
30
|
+
* Repair GRUB/fstab for BIOS system, add secure cmdline.
|
31
|
+
* Create a swap volume equal to the memory installed.
|
32
|
+
* Add vim and sudo
|
33
|
+
|
1
34
|
## 0.0.6, release 2020-09-19
|
2
|
-
* Add support for QEMU guest
|
35
|
+
* Add support for QEMU guest with KVM and Virtio driver
|
3
36
|
* Kernel compilation, initialize a config file with `make localyesconfig`.
|
4
37
|
* More modular codes to start with encryption and other filesystems.
|
5
|
-
* Add the new option --verbose to display output of compilation, etc...
|
38
|
+
* Add the new option --verbose to display output of compilation, etc...
|
6
39
|
|
7
40
|
## 0.0.5, release 2020-09-17
|
8
41
|
* Generate a hostname
|
data/README.md
CHANGED
@@ -5,13 +5,16 @@ A CLI tool to install Gentoo.
|
|
5
5
|
Actually, Getch support only the [AMD64 handbook](https://wiki.gentoo.org/wiki/Handbook:AMD64) and only with the last `stage3-amd64-systemd`.
|
6
6
|
It also require a disk (only one for now) with a minimum of 20G.
|
7
7
|
|
8
|
-
Filesystem supported by Getch are
|
9
|
-
+
|
8
|
+
BIOS system will use `Grub2` and `systemd-boot` for UEFI. Filesystem supported by Getch are for now:
|
9
|
+
+ Ext4
|
10
|
+
+ LVM
|
11
|
+
+ ZFS
|
10
12
|
|
11
|
-
|
13
|
+
Encryption is also supported.
|
12
14
|
|
13
15
|
The ISO images i was able to test and that works:
|
14
16
|
+ [Archlinux](https://www.archlinux.org/download/)
|
17
|
+
+ [Archaeidae](https://github.com/szorfein/archaeidae): Custom Archiso that includes ZFS support.
|
15
18
|
|
16
19
|
## Install
|
17
20
|
Getch is cryptographically signed, so add my public key (if you haven’t already) as a trusted certificate.
|
@@ -23,19 +26,53 @@ With `gem` installed:
|
|
23
26
|
|
24
27
|
When you boot from an `iso`, you can install `ruby`, `getch` and correct your `PATH=` directly with the `bin/setup.sh`:
|
25
28
|
|
26
|
-
# curl https://raw.githubusercontent.com/szorfein/getch/master/bin/setup.sh
|
29
|
+
# sh <(curl -L https://raw.githubusercontent.com/szorfein/getch/master/bin/setup.sh)
|
27
30
|
# source ~/.zshrc # or ~/.bashrc
|
28
31
|
|
29
32
|
## Usage
|
33
|
+
Just ensure than the script is run with a root account.
|
30
34
|
|
31
|
-
|
35
|
+
# getch -h
|
36
|
+
|
37
|
+
After an install by Getch, take a look on the [wiki](https://github.com/szorfein/getch/wiki).
|
32
38
|
|
33
39
|
## Examples
|
34
40
|
For a french user:
|
35
41
|
|
36
|
-
# getch --
|
42
|
+
# getch --zoneinfo "Europe/Paris" --language fr_FR --keymap fr
|
37
43
|
|
38
|
-
|
44
|
+
Install Gentoo on LVM:
|
45
|
+
|
46
|
+
# getch --format lvm --disk sda
|
47
|
+
|
48
|
+
Encrypt your disk with LVM with a french keymap
|
49
|
+
|
50
|
+
# getch --format lvm --encrypt --keymap fr
|
51
|
+
|
52
|
+
Encrypt with ext4 and create a home directory /home/ninja
|
53
|
+
|
54
|
+
# getch --format ext4 --encrypt --username ninja
|
55
|
+
|
56
|
+
With ZFS:
|
57
|
+
|
58
|
+
# getch --format zfs
|
59
|
+
|
60
|
+
## Troubleshooting
|
61
|
+
|
62
|
+
#### LVM
|
63
|
+
Unless your old LVM volume group is also named `vg0`, `getch` may fail to partition your disk. You have to clean up your device before proceed with `vgremove` and `pvremove`.
|
64
|
+
|
65
|
+
#### Encryption enable on BIOS with ext4
|
66
|
+
To decrypt your disk on BIOS system, you have to enter your password two times. One time for Grub and another time for the initramfs (Genkernel). [post](https://wiki.archlinux.org/index.php/GRUB#Encrypted_/boot).
|
67
|
+
Also with GRUB, only a `us` keymap is working.
|
68
|
+
|
69
|
+
#### With ZFS
|
70
|
+
When you boot, the pool may fail to start, it's happen when the pool has not been `export` to the ISO. So just reboot on your ISO:
|
71
|
+
|
72
|
+
# zpool import -N -R /mnt zpool
|
73
|
+
# zpool export -a
|
74
|
+
|
75
|
+
And it's all.
|
39
76
|
|
40
77
|
## Issues
|
41
78
|
If need more support for your hardware (network, sound card, ...), you can submit a [new issue](https://github.com/szorfein/getch/issues/new) and post the output of the following command:
|
data/bin/setup.sh
CHANGED
@@ -26,7 +26,7 @@ search_ruby() {
|
|
26
26
|
else
|
27
27
|
echo "Install ruby"
|
28
28
|
if hash pacman 2>/dev/null ; then
|
29
|
-
pacman -Syy libyaml ruby ruby-irb ruby-reline rubygems
|
29
|
+
pacman -Syy --noconfirm libyaml ruby ruby-irb ruby-reline rubygems
|
30
30
|
elif hash emerge 2>/dev/null ; then
|
31
31
|
emerge -av dev-lang/ruby
|
32
32
|
elif hash apt-get 2>/dev/null ; then
|
@@ -37,19 +37,33 @@ search_ruby() {
|
|
37
37
|
fi
|
38
38
|
}
|
39
39
|
|
40
|
+
install_with_gem() {
|
41
|
+
gem install getch
|
42
|
+
getch -h
|
43
|
+
}
|
44
|
+
|
45
|
+
dll_test_version() {
|
46
|
+
echo "Downloading the test version..."
|
47
|
+
cd /tmp
|
48
|
+
[ -f ./getch.tar.gz ] && rm ./getch.tar.gz
|
49
|
+
[ -d ./getch-master ] && rm -rf ./getch-master
|
50
|
+
|
51
|
+
curl -s -L -o getch.tar.gz https://github.com/szorfein/getch/archive/master.tar.gz
|
52
|
+
tar xzf getch.tar.gz \
|
53
|
+
&& cd $DIR \
|
54
|
+
&& ruby -I lib bin/getch -h
|
55
|
+
}
|
56
|
+
|
40
57
|
get_getch() {
|
41
58
|
if hash gem 2>/dev/null ; then
|
42
|
-
|
43
|
-
|
59
|
+
printf "Which version? [1] stable , [2] test (no recommended) " ; read -r
|
60
|
+
if echo "$REPLY" | grep -qP "2" ; then
|
61
|
+
dll_test_version
|
62
|
+
else
|
63
|
+
install_with_gem
|
64
|
+
fi
|
44
65
|
else
|
45
|
-
|
46
|
-
[ -f ./getch.tar.gz ] && rm ./getch.tar.gz
|
47
|
-
[ -d ./getch-master ] && rm -rf ./getch-master
|
48
|
-
|
49
|
-
curl -s -L -o getch.tar.gz https://github.com/szorfein/getch/archive/master.tar.gz
|
50
|
-
tar xzf getch.tar.gz \
|
51
|
-
&& cd $DIR \
|
52
|
-
&& ruby -I lib bin/getch -h
|
66
|
+
dll_test_version
|
53
67
|
fi
|
54
68
|
}
|
55
69
|
|
@@ -58,10 +72,12 @@ set_shell() {
|
|
58
72
|
[ -f ~/.zshrc ] && your_shell=~/.zshrc
|
59
73
|
|
60
74
|
[ -f "$your_shell" ] && {
|
61
|
-
if ! grep -q "
|
75
|
+
if ! grep -q "ruby" "$your_shell" ; then
|
62
76
|
echo "export PATH=\$PATH:$(ruby -e 'puts Gem.user_dir')/bin" >> "$your_shell"
|
63
77
|
fi
|
64
|
-
. "$your_shell"
|
78
|
+
if $(. "$your_shell") ; then
|
79
|
+
echo "Shell loaded"
|
80
|
+
fi
|
65
81
|
}
|
66
82
|
}
|
67
83
|
|
data/lib/getch.rb
CHANGED
@@ -1,20 +1,24 @@
|
|
1
1
|
require_relative 'getch/options'
|
2
2
|
require_relative 'getch/states'
|
3
|
-
require_relative 'getch/mount'
|
4
3
|
require_relative 'getch/gentoo'
|
5
4
|
require_relative 'getch/filesystem'
|
6
5
|
require_relative 'getch/command'
|
7
6
|
require_relative 'getch/helpers'
|
7
|
+
require_relative 'getch/log'
|
8
8
|
|
9
9
|
module Getch
|
10
10
|
|
11
11
|
DEFAULT_OPTIONS = {
|
12
12
|
language: 'en_US',
|
13
13
|
zoneinfo: 'US/Eastern',
|
14
|
-
|
14
|
+
keymap: 'us',
|
15
15
|
disk: 'sda',
|
16
16
|
fs: 'ext4',
|
17
17
|
username: nil,
|
18
|
+
boot_disk: nil,
|
19
|
+
cache_disk: nil,
|
20
|
+
home_disk: nil,
|
21
|
+
encrypt: false,
|
18
22
|
verbose: false
|
19
23
|
}
|
20
24
|
|
@@ -29,18 +33,38 @@ module Getch
|
|
29
33
|
}
|
30
34
|
|
31
35
|
MOUNTPOINT = "/mnt/gentoo".freeze
|
32
|
-
|
33
|
-
|
36
|
+
DEFAULT_FS = {
|
37
|
+
true => {
|
38
|
+
ext4: Getch::FileSystem::Ext4::Encrypt,
|
39
|
+
lvm: Getch::FileSystem::Lvm::Encrypt,
|
40
|
+
zfs: Getch::FileSystem::Zfs::Encrypt
|
41
|
+
},
|
42
|
+
false => {
|
43
|
+
ext4: Getch::FileSystem::Ext4,
|
44
|
+
lvm: Getch::FileSystem::Lvm,
|
45
|
+
zfs: Getch::FileSystem::Zfs,
|
46
|
+
}
|
34
47
|
}.freeze
|
35
48
|
|
49
|
+
def self.class_fs
|
50
|
+
encrypt = DEFAULT_OPTIONS[:encrypt]
|
51
|
+
fs = DEFAULT_OPTIONS[:fs].to_sym
|
52
|
+
DEFAULT_FS[encrypt][fs]
|
53
|
+
end
|
54
|
+
|
36
55
|
def self.resume_options(opts)
|
37
56
|
puts "\nBuild Gentoo with the following args:\n"
|
38
|
-
puts "
|
39
|
-
puts "
|
40
|
-
puts "
|
41
|
-
puts "
|
42
|
-
puts "
|
43
|
-
puts "
|
57
|
+
puts "Lang: #{DEFAULT_OPTIONS[:language]}"
|
58
|
+
puts "Zoneinfo: #{DEFAULT_OPTIONS[:zoneinfo]}"
|
59
|
+
puts "Keymap: #{DEFAULT_OPTIONS[:keymap]}"
|
60
|
+
puts "Disk: #{DEFAULT_OPTIONS[:disk]}"
|
61
|
+
puts "Filesystem: #{DEFAULT_OPTIONS[:fs]}"
|
62
|
+
puts "Username: #{DEFAULT_OPTIONS[:username]}"
|
63
|
+
puts "Encrypt: #{DEFAULT_OPTIONS[:encrypt]}"
|
64
|
+
puts
|
65
|
+
puts "separate-boot disk: #{DEFAULT_OPTIONS[:boot_disk]}"
|
66
|
+
puts "separate-cache disk: #{DEFAULT_OPTIONS[:cache_disk]}"
|
67
|
+
puts "separate-home disk: #{DEFAULT_OPTIONS[:home_disk]}"
|
44
68
|
puts
|
45
69
|
print "Continue? (n,y) "
|
46
70
|
case gets.chomp
|
@@ -53,15 +77,14 @@ module Getch
|
|
53
77
|
|
54
78
|
def self.format(disk, fs, user)
|
55
79
|
return if STATES[:format] and STATES[:partition]
|
80
|
+
log = Log.new
|
56
81
|
puts
|
57
82
|
print "Partition and format disk #{disk}, this will erase all data, continue? (n,y) "
|
58
83
|
case gets.chomp
|
59
84
|
when /^y|^Y/
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
filesystem.format
|
64
|
-
OPTIONS_FS[fs]::Mount.new(disk, user).run
|
85
|
+
log.info("Partition start")
|
86
|
+
class_fs::Partition.new
|
87
|
+
class_fs::Format.new
|
65
88
|
else
|
66
89
|
exit 1
|
67
90
|
end
|
@@ -80,8 +103,9 @@ module Getch
|
|
80
103
|
options = Options.new(argv)
|
81
104
|
DEFAULT_OPTIONS.freeze
|
82
105
|
resume_options(options)
|
83
|
-
Getch::States.new
|
106
|
+
Getch::States.new # Update States
|
84
107
|
format(options.disk, options.fs, options.username)
|
108
|
+
class_fs::Mount.new.run
|
85
109
|
init_gentoo(options)
|
86
110
|
end
|
87
111
|
end
|
data/lib/getch/command.rb
CHANGED
@@ -4,14 +4,22 @@ module Getch
|
|
4
4
|
class Command
|
5
5
|
def initialize(cmd)
|
6
6
|
@cmd = cmd
|
7
|
-
@block_size =
|
7
|
+
@block_size = 1024
|
8
|
+
@log = Getch::Log.new
|
8
9
|
end
|
9
10
|
|
10
11
|
def run!
|
11
|
-
|
12
|
+
@log.info "Running command: " + @cmd.gsub(/\"/, '')
|
12
13
|
|
13
|
-
Open3.popen3(@cmd) do |stdin, stdout, stderr|
|
14
|
+
Open3.popen3(@cmd) do |stdin, stdout, stderr, wait_thr|
|
14
15
|
stdin.close_write
|
16
|
+
code = wait_thr.value
|
17
|
+
|
18
|
+
# only stderr
|
19
|
+
begin
|
20
|
+
@log.debug stderr.readline until stderr.eof.nil?
|
21
|
+
rescue EOFError
|
22
|
+
end
|
15
23
|
|
16
24
|
begin
|
17
25
|
files = [stdout, stderr]
|
@@ -24,25 +32,20 @@ module Getch
|
|
24
32
|
# writable = ready[1]
|
25
33
|
# exceptions = ready[2]
|
26
34
|
|
27
|
-
readable
|
28
|
-
fileno = f.fileno
|
29
|
-
|
30
|
-
begin
|
31
|
-
data = f.read_nonblock(@block_size)
|
32
|
-
|
33
|
-
# Do something with the data...
|
34
|
-
puts "#{data}" if DEFAULT_OPTIONS[:verbose]
|
35
|
-
rescue EOFError
|
36
|
-
puts "fileno: #{fileno} EOF"
|
37
|
-
end
|
38
|
-
end
|
35
|
+
display_lines(readable)
|
39
36
|
end
|
40
37
|
end
|
41
38
|
rescue IOError => e
|
42
39
|
puts "IOError: #{e}"
|
43
40
|
end
|
41
|
+
|
42
|
+
unless code.success?
|
43
|
+
@log.fatal "Running #{@cmd}"
|
44
|
+
exit 1
|
45
|
+
end
|
46
|
+
|
47
|
+
@log.debug "Done - #{@cmd} - #{code}"
|
44
48
|
end
|
45
|
-
puts "Done"
|
46
49
|
end
|
47
50
|
|
48
51
|
private
|
@@ -51,5 +54,124 @@ module Getch
|
|
51
54
|
def all_eof(files)
|
52
55
|
files.find { |f| !f.eof }.nil?
|
53
56
|
end
|
57
|
+
|
58
|
+
def display_lines(block)
|
59
|
+
block.each do |f|
|
60
|
+
begin
|
61
|
+
data = f.read_nonblock(@block_size)
|
62
|
+
puts data if DEFAULT_OPTIONS[:verbose]
|
63
|
+
rescue EOFError
|
64
|
+
puts ""
|
65
|
+
rescue => e
|
66
|
+
puts "Fatal - #{e}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Use system, the only ruby method to display stdout with colors !
|
73
|
+
class Emerge
|
74
|
+
def initialize(cmd)
|
75
|
+
@gentoo = MOUNTPOINT
|
76
|
+
@cmd = cmd
|
77
|
+
@log = Getch::Log.new
|
78
|
+
end
|
79
|
+
|
80
|
+
def run!
|
81
|
+
@log.info "Running emerge: #{@cmd}"
|
82
|
+
system("chroot", @gentoo, "/bin/bash", "-c", "source /etc/profile && #{@cmd}")
|
83
|
+
read_exit
|
84
|
+
end
|
85
|
+
|
86
|
+
def pkg!
|
87
|
+
@log.info "Running emerge pkg: #{@cmd}"
|
88
|
+
system("chroot", @gentoo, "/bin/bash", "-c", "source /etc/profile && emerge --changed-use #{@cmd}")
|
89
|
+
read_exit
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def read_exit
|
95
|
+
if $?.exitstatus > 0
|
96
|
+
@log.fatal "Running #{@cmd}"
|
97
|
+
else
|
98
|
+
@log.info "Done #{@cmd}"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
class Make
|
104
|
+
def initialize(cmd)
|
105
|
+
@gentoo = MOUNTPOINT
|
106
|
+
@cmd = cmd
|
107
|
+
@log = Getch::Log.new
|
108
|
+
end
|
109
|
+
|
110
|
+
def run!
|
111
|
+
@log.info "Running Make: #{@cmd}"
|
112
|
+
cmd = "chroot #{@gentoo} /bin/bash -c \"source /etc/profile \
|
113
|
+
&& env-update \
|
114
|
+
&& cd /usr/src/linux \
|
115
|
+
&& #{@cmd}\""
|
116
|
+
Open3.popen2e(cmd) do |stdin, stdout_err, wait_thr|
|
117
|
+
while line = stdout_err.gets
|
118
|
+
puts line
|
119
|
+
end
|
120
|
+
|
121
|
+
exit_status = wait_thr.value
|
122
|
+
unless exit_status.success?
|
123
|
+
@log.fatal "Running #{cmd}"
|
124
|
+
exit 1
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
class Bask
|
131
|
+
def initialize(cmd)
|
132
|
+
@gentoo = MOUNTPOINT
|
133
|
+
@cmd = cmd
|
134
|
+
@log = Getch::Log.new
|
135
|
+
@version = "0.4"
|
136
|
+
end
|
137
|
+
|
138
|
+
def run!
|
139
|
+
download_bask if ! Dir.exist? "#{MOUNTPOINT}/root/bask-#{@version}"
|
140
|
+
@log.info "Running Bask: #{@cmd}"
|
141
|
+
cmd = "chroot #{@gentoo} /bin/bash -c \"source /etc/profile \
|
142
|
+
&& env-update \
|
143
|
+
&& cd /root/bask-#{@version} \
|
144
|
+
&& ./bask.sh #{@cmd} -k /usr/src/linux\""
|
145
|
+
Open3.popen2e(cmd) do |stdin, stdout_err, wait_thr|
|
146
|
+
while line = stdout_err.gets
|
147
|
+
puts line
|
148
|
+
end
|
149
|
+
|
150
|
+
exit_status = wait_thr.value
|
151
|
+
unless exit_status.success?
|
152
|
+
@log.fatal "Running #{cmd}"
|
153
|
+
exit 1
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
private
|
159
|
+
|
160
|
+
def download_bask
|
161
|
+
@log.info "Installing Bask..."
|
162
|
+
url = "https://github.com/szorfein/bask/archive/v#{@version}.tar.gz"
|
163
|
+
file = "bask-#{@version}.tar.gz"
|
164
|
+
|
165
|
+
Dir.chdir("#{MOUNTPOINT}/root")
|
166
|
+
Helpers::get_file_online(url, file)
|
167
|
+
Getch::Command.new("tar xzf #{file}").run!
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
class Chroot < Command
|
172
|
+
def initialize(cmd)
|
173
|
+
super
|
174
|
+
@cmd = "chroot #{MOUNTPOINT} /bin/bash -c \"source /etc/profile; #{cmd}\""
|
175
|
+
end
|
54
176
|
end
|
55
177
|
end
|