getch 0.0.5 → 0.1.0
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 +30 -0
- data/README.md +31 -6
- data/bin/setup.sh +29 -13
- data/lib/getch.rb +43 -30
- data/lib/getch/command.rb +163 -0
- data/lib/getch/filesystem.rb +8 -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/filesystem/zfs.rb +14 -0
- data/lib/getch/filesystem/zfs/config.rb +58 -0
- data/lib/getch/filesystem/zfs/deps.rb +90 -0
- data/lib/getch/filesystem/zfs/device.rb +19 -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 +94 -0
- data/lib/getch/filesystem/zfs/encrypt/device.rb +21 -0
- data/lib/getch/filesystem/zfs/encrypt/format.rb +22 -0
- data/lib/getch/filesystem/zfs/encrypt/mount.rb +67 -0
- data/lib/getch/filesystem/zfs/encrypt/partition.rb +151 -0
- data/lib/getch/filesystem/zfs/format.rb +20 -0
- data/lib/getch/filesystem/zfs/mount.rb +67 -0
- data/lib/getch/filesystem/zfs/partition.rb +147 -0
- data/lib/getch/gentoo.rb +3 -2
- data/lib/getch/gentoo/boot.rb +29 -25
- data/lib/getch/gentoo/chroot.rb +18 -14
- data/lib/getch/gentoo/config.rb +18 -9
- data/lib/getch/gentoo/sources.rb +45 -31
- data/lib/getch/gentoo/stage.rb +2 -2
- data/lib/getch/helpers.rb +24 -6
- data/lib/getch/log.rb +54 -0
- data/lib/getch/options.rb +16 -7
- data/lib/getch/version.rb +1 -1
- metadata +48 -5
- metadata.gz.sig +0 -0
- data/lib/getch/disk.rb +0 -77
- data/lib/getch/mount.rb +0 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 259461a4875fb46c062067c9663e211c206475aaaaa89d3066f85d1b3be2c19b
|
4
|
+
data.tar.gz: 3ab40d87e3f039ef840156cc81df8ee75e3f8f76c332ae4ba08335b04440625f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eef130ea5b78dcde7f2897d16f3f74293c16da487ca029c0d47c905489d5cd4d9f32d5bffeba30fe06ab13694370f99a380aceaec6da053dece11598eb938ba4
|
7
|
+
data.tar.gz: f9f4584abb87c4287ba81e16bb0274c483627a712916728fbcc9a4667a2d91f03e09a092bdf09400bd1f92318c67ddabdf4c20217eff1eeb64f2d8d0c97a1a02
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,33 @@
|
|
1
|
+
## 0.1.0, release 2020-10-15
|
2
|
+
* Add the (Zeta) filesystem ZFS
|
3
|
+
* `emerge --depclean` to save space.
|
4
|
+
* Add a message when getch have finish, keep /mnt/gentoo if you need to add something.
|
5
|
+
* Use systemd-detect-virt to detect a Virtual Guest.
|
6
|
+
|
7
|
+
## 0.0.9, release 2020-10-03
|
8
|
+
* Add encryption on ext4 and lvm (BIOS,UEFI)
|
9
|
+
* Correct KEYMAP="yes" with genkernel
|
10
|
+
* Renaming option keyboard with keymap
|
11
|
+
* GPG verification for ebuild
|
12
|
+
|
13
|
+
## 0.0.8, release 2020-09-30
|
14
|
+
* Adding LVM via the option fs, `--fs lvm`.
|
15
|
+
* Systemd-boot use the value of PARTUUID without initramfs.
|
16
|
+
* Include lib logger.
|
17
|
+
* Enhance functions to call program system Emerge, Make, ...
|
18
|
+
|
19
|
+
## 0.0.7, release 2020-09-22
|
20
|
+
* Correct fstab.
|
21
|
+
* Repair GRUB/fstab for BIOS system, add secure cmdline.
|
22
|
+
* Create a swap volume equal to the memory installed.
|
23
|
+
* Add vim and sudo
|
24
|
+
|
25
|
+
## 0.0.6, release 2020-09-19
|
26
|
+
* Add support for QEMU guest with KVM and Virtio driver
|
27
|
+
* Kernel compilation, initialize a config file with `make localyesconfig`.
|
28
|
+
* More modular codes to start with encryption and other filesystems.
|
29
|
+
* Add the new option --verbose to display output of compilation, etc...
|
30
|
+
|
1
31
|
## 0.0.5, release 2020-09-17
|
2
32
|
* Generate a hostname
|
3
33
|
* Configure systemd-boot for UEFI system
|
data/README.md
CHANGED
@@ -5,10 +5,11 @@ 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
|
-
+ ext4
|
8
|
+
BIOS system will use Grub2 and UEFI, systemd-boot. Filesystem supported by Getch are for now:
|
9
|
+
+ ext4
|
10
|
+
+ lvm
|
10
11
|
|
11
|
-
|
12
|
+
Encryption is also supported.
|
12
13
|
|
13
14
|
The ISO images i was able to test and that works:
|
14
15
|
+ [Archlinux](https://www.archlinux.org/download/)
|
@@ -23,17 +24,41 @@ With `gem` installed:
|
|
23
24
|
|
24
25
|
When you boot from an `iso`, you can install `ruby`, `getch` and correct your `PATH=` directly with the `bin/setup.sh`:
|
25
26
|
|
26
|
-
# curl https://raw.githubusercontent.com/szorfein/getch/master/bin/setup.sh
|
27
|
+
# sh <(curl -L https://raw.githubusercontent.com/szorfein/getch/master/bin/setup.sh)
|
27
28
|
# source ~/.zshrc # or ~/.bashrc
|
28
29
|
|
29
30
|
## Usage
|
31
|
+
Just ensure than the script is run with a root account, not just sudo.
|
30
32
|
|
31
|
-
|
33
|
+
# getch -h
|
34
|
+
|
35
|
+
After an install by Getch, take a look on the [wiki](https://github.com/szorfein/getch/wiki).
|
32
36
|
|
33
37
|
## Examples
|
34
38
|
For a french user:
|
35
39
|
|
36
|
-
# getch --
|
40
|
+
# getch --zoneinfo "Europe/Paris" --language fr_FR --keymap fr
|
41
|
+
|
42
|
+
Install Gentoo on LVM:
|
43
|
+
|
44
|
+
# getch --format lvm --disk sda
|
45
|
+
|
46
|
+
Encrypt your disk with LVM with a french keymap
|
47
|
+
|
48
|
+
# getch --format lvm --encrypt --keymap fr
|
49
|
+
|
50
|
+
Encrypt with ext4 and create a home directory /home/ninja
|
51
|
+
|
52
|
+
# getch --format ext4 --encrypt --username ninja
|
53
|
+
|
54
|
+
## Troubleshooting
|
55
|
+
|
56
|
+
#### LVM
|
57
|
+
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`.
|
58
|
+
|
59
|
+
#### Encryption enable on BIOS with ext4
|
60
|
+
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).
|
61
|
+
Also with GRUB, only a `us` keymap is working.
|
37
62
|
|
38
63
|
## Issues
|
39
64
|
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,23 @@
|
|
1
1
|
require_relative 'getch/options'
|
2
|
-
require_relative 'getch/disk'
|
3
2
|
require_relative 'getch/states'
|
4
|
-
require_relative 'getch/mount'
|
5
3
|
require_relative 'getch/gentoo'
|
4
|
+
require_relative 'getch/filesystem'
|
5
|
+
require_relative 'getch/command'
|
6
6
|
require_relative 'getch/helpers'
|
7
|
+
require_relative 'getch/log'
|
7
8
|
|
8
9
|
module Getch
|
9
10
|
|
10
11
|
DEFAULT_OPTIONS = {
|
11
12
|
language: 'en_US',
|
12
|
-
|
13
|
-
|
13
|
+
zoneinfo: 'US/Eastern',
|
14
|
+
keymap: 'us',
|
14
15
|
disk: 'sda',
|
15
16
|
fs: 'ext4',
|
16
|
-
username: nil
|
17
|
-
|
17
|
+
username: nil,
|
18
|
+
encrypt: false,
|
19
|
+
verbose: false
|
20
|
+
}
|
18
21
|
|
19
22
|
STATES = {
|
20
23
|
:partition => false,
|
@@ -27,16 +30,34 @@ module Getch
|
|
27
30
|
}
|
28
31
|
|
29
32
|
MOUNTPOINT = "/mnt/gentoo".freeze
|
30
|
-
|
33
|
+
DEFAULT_FS = {
|
34
|
+
true => {
|
35
|
+
ext4: Getch::FileSystem::Ext4::Encrypt,
|
36
|
+
lvm: Getch::FileSystem::Lvm::Encrypt,
|
37
|
+
zfs: Getch::FileSystem::Zfs::Encrypt
|
38
|
+
},
|
39
|
+
false => {
|
40
|
+
ext4: Getch::FileSystem::Ext4,
|
41
|
+
lvm: Getch::FileSystem::Lvm,
|
42
|
+
zfs: Getch::FileSystem::Zfs,
|
43
|
+
}
|
44
|
+
}.freeze
|
45
|
+
|
46
|
+
def self.class_fs
|
47
|
+
encrypt = DEFAULT_OPTIONS[:encrypt]
|
48
|
+
fs = DEFAULT_OPTIONS[:fs].to_sym
|
49
|
+
DEFAULT_FS[encrypt][fs]
|
50
|
+
end
|
31
51
|
|
32
52
|
def self.resume_options(opts)
|
33
53
|
puts "\nBuild Gentoo with the following args:\n"
|
34
|
-
puts "lang: #{
|
35
|
-
puts "zoneinfo: #{
|
36
|
-
puts "
|
37
|
-
puts "disk: #{
|
38
|
-
puts "fs: #{
|
39
|
-
puts "username: #{
|
54
|
+
puts "lang: #{DEFAULT_OPTIONS[:language]}"
|
55
|
+
puts "zoneinfo: #{DEFAULT_OPTIONS[:zoneinfo]}"
|
56
|
+
puts "keymap: #{DEFAULT_OPTIONS[:keymap]}"
|
57
|
+
puts "disk: #{DEFAULT_OPTIONS[:disk]}"
|
58
|
+
puts "fs: #{DEFAULT_OPTIONS[:fs]}"
|
59
|
+
puts "username: #{DEFAULT_OPTIONS[:username]}"
|
60
|
+
puts "encrypt: #{DEFAULT_OPTIONS[:encrypt]}"
|
40
61
|
puts
|
41
62
|
print "Continue? (n,y) "
|
42
63
|
case gets.chomp
|
@@ -47,30 +68,21 @@ module Getch
|
|
47
68
|
end
|
48
69
|
end
|
49
70
|
|
50
|
-
def self.format(disk, fs)
|
71
|
+
def self.format(disk, fs, user)
|
51
72
|
return if STATES[:format] and STATES[:partition]
|
73
|
+
log = Log.new
|
52
74
|
puts
|
53
75
|
print "Partition and format disk #{disk}, this will erase all data, continue? (n,y) "
|
54
76
|
case gets.chomp
|
55
77
|
when /^y|^Y/
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
disk.format
|
78
|
+
log.info("Partition start")
|
79
|
+
class_fs::Partition.new
|
80
|
+
class_fs::Format.new
|
60
81
|
else
|
61
82
|
exit 1
|
62
83
|
end
|
63
84
|
end
|
64
85
|
|
65
|
-
def self.mount(disk, user)
|
66
|
-
return if STATES[:mount]
|
67
|
-
mount = Getch::Mount.new(disk, user)
|
68
|
-
mount.swap
|
69
|
-
mount.root
|
70
|
-
mount.boot
|
71
|
-
mount.home
|
72
|
-
end
|
73
|
-
|
74
86
|
def self.init_gentoo(options)
|
75
87
|
gentoo = Getch::Gentoo
|
76
88
|
gentoo.stage3
|
@@ -82,10 +94,11 @@ module Getch
|
|
82
94
|
|
83
95
|
def self.main(argv)
|
84
96
|
options = Options.new(argv)
|
97
|
+
DEFAULT_OPTIONS.freeze
|
85
98
|
resume_options(options)
|
86
|
-
Getch::States.new
|
87
|
-
format(options.disk, options.fs)
|
88
|
-
|
99
|
+
Getch::States.new # Update States
|
100
|
+
format(options.disk, options.fs, options.username)
|
101
|
+
class_fs::Mount.new.run
|
89
102
|
init_gentoo(options)
|
90
103
|
end
|
91
104
|
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module Getch
|
4
|
+
class Command
|
5
|
+
def initialize(cmd)
|
6
|
+
@cmd = cmd
|
7
|
+
@block_size = 1024
|
8
|
+
@log = Getch::Log.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def run!
|
12
|
+
@log.info "Running command: " + @cmd.gsub(/\"/, '')
|
13
|
+
|
14
|
+
Open3.popen3(@cmd) do |stdin, stdout, stderr, wait_thr|
|
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
|
23
|
+
|
24
|
+
begin
|
25
|
+
files = [stdout, stderr]
|
26
|
+
|
27
|
+
until all_eof(files) do
|
28
|
+
ready = IO.select(files)
|
29
|
+
|
30
|
+
if ready
|
31
|
+
readable = ready[0]
|
32
|
+
# writable = ready[1]
|
33
|
+
# exceptions = ready[2]
|
34
|
+
|
35
|
+
display_lines(readable)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
rescue IOError => e
|
39
|
+
puts "IOError: #{e}"
|
40
|
+
end
|
41
|
+
|
42
|
+
unless code.success?
|
43
|
+
@log.fatal "Running #{@cmd}"
|
44
|
+
exit 1
|
45
|
+
end
|
46
|
+
|
47
|
+
@log.debug "Done - #{@cmd} - #{code}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
# Returns true if all files are EOF
|
54
|
+
def all_eof(files)
|
55
|
+
files.find { |f| !f.eof }.nil?
|
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 Garden
|
131
|
+
def initialize(cmd)
|
132
|
+
@gentoo = MOUNTPOINT
|
133
|
+
@cmd = cmd
|
134
|
+
@log = Getch::Log.new
|
135
|
+
end
|
136
|
+
|
137
|
+
def run!
|
138
|
+
@log.info "Running Garden: #{@cmd}"
|
139
|
+
cmd = "chroot #{@gentoo} /bin/bash -c \"source /etc/profile \
|
140
|
+
&& env-update \
|
141
|
+
&& cd /root/garden-master \
|
142
|
+
&& ./kernel.sh #{@cmd} -k /usr/src/linux\""
|
143
|
+
Open3.popen2e(cmd) do |stdin, stdout_err, wait_thr|
|
144
|
+
while line = stdout_err.gets
|
145
|
+
puts line
|
146
|
+
end
|
147
|
+
|
148
|
+
exit_status = wait_thr.value
|
149
|
+
unless exit_status.success?
|
150
|
+
@log.fatal "Running #{cmd}"
|
151
|
+
exit 1
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
class Chroot < Command
|
158
|
+
def initialize(cmd)
|
159
|
+
super
|
160
|
+
@cmd = "chroot #{MOUNTPOINT} /bin/bash -c \"source /etc/profile; #{cmd}\""
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|