getch 0.0.3 → 0.0.4
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 +19 -0
- data/README.md +1 -1
- data/getch.gemspec +5 -0
- data/lib/getch.rb +4 -1
- data/lib/getch/gentoo.rb +20 -0
- data/lib/getch/gentoo/boot.rb +59 -0
- data/lib/getch/gentoo/chroot.rb +30 -2
- data/lib/getch/gentoo/config.rb +8 -6
- data/lib/getch/gentoo/sources.rb +66 -0
- data/lib/getch/helpers.rb +8 -0
- data/lib/getch/mount.rb +31 -1
- data/lib/getch/states.rb +5 -0
- data/lib/getch/version.rb +1 -1
- metadata +9 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cee5eb8b60c64dd64bd0416ae0306f725b1fd58f58baec8288e6358c9ff79a8a
|
4
|
+
data.tar.gz: 315db3e29828388088d8cda3c38e5bd7ed5c57d3b9ecb324150c06e47ebd1eba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 622547ffd01a03d7a957f489014ae0c27255e868c9135326b4bd8a3e0671dca6319f9f593f3fc33f54f657089cfa5e65a8917a2e6c7201ade89682a5767a3e96
|
7
|
+
data.tar.gz: bed494285e0ec32397e37aaed1d3836fe700fe11b4c0661f1e7b68039393a2356b1ec6f16207c29988e7ff9656d573833cd5e74ecf91ee1f143639e798cea442
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
## 0.0.3, release 2020-09-14
|
2
|
+
* Add commands in the chroot
|
3
|
+
* Kernel build by using https://github.com/szorfein/garden
|
4
|
+
* Add portage fs (like /etc/portage/package.use/zzz_via_autounmask)
|
5
|
+
* Download all the lastest ebuild
|
6
|
+
* Update gentoo via emerge -uDN @world
|
7
|
+
|
8
|
+
## 0.0.2, release 2020-09-12
|
9
|
+
* Getch genere a file /tmp/install_gentoo to avoid to remake same task over and over
|
10
|
+
* Support for fs ext4
|
11
|
+
* Mount partition on /mnt/gentoo during the install
|
12
|
+
* Download, verify the checksum and decompress the last stage3-amd64-systemd
|
13
|
+
|
14
|
+
## 0.0.1, release 2020-09-10
|
15
|
+
* Format disk with sgdisk (should be installed)
|
16
|
+
* Support for one disk with -d|--disk
|
17
|
+
* Add few options for the CLI
|
18
|
+
* Add bin/setup.sh to install ruby when boot on a ISO file
|
19
|
+
* Init project
|
data/README.md
CHANGED
@@ -21,4 +21,4 @@ When you boot from an `iso`, you can install `ruby`, `getch` and correct your `P
|
|
21
21
|
## Examples
|
22
22
|
For a french user:
|
23
23
|
|
24
|
-
# getch --username ninja --zoneinfo Europe/Paris --language fr_FR --keyboard fr
|
24
|
+
# getch --username ninja --zoneinfo "Europe/Paris" --language fr_FR --keyboard fr
|
data/getch.gemspec
CHANGED
@@ -7,6 +7,11 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.authors = ["szorfein"]
|
8
8
|
s.email = ["szorfein@protonmail.com"]
|
9
9
|
s.homepage = 'https://github.com/szorfein/getch'
|
10
|
+
s.metadata = {
|
11
|
+
"changelog_uri" => "https://github.com/szorfein/getch/blob/master/CHANGELOG.md",
|
12
|
+
"bug_tracker_uri" => "https://github.com/szorfein/getch/issues",
|
13
|
+
"wiki_uri" => "https://github.com/szorfein/getch"
|
14
|
+
}
|
10
15
|
s.license = "MIT"
|
11
16
|
s.required_ruby_version = '>=2.5'
|
12
17
|
|
data/lib/getch.rb
CHANGED
@@ -22,7 +22,8 @@ module Getch
|
|
22
22
|
:mount => false,
|
23
23
|
:gentoo_base => false,
|
24
24
|
:gentoo_config => false,
|
25
|
-
:gentoo_update => false
|
25
|
+
:gentoo_update => false,
|
26
|
+
:gentoo_kernel => false
|
26
27
|
}
|
27
28
|
|
28
29
|
MOUNTPOINT = "/mnt/gentoo".freeze
|
@@ -75,6 +76,8 @@ module Getch
|
|
75
76
|
gentoo.stage3
|
76
77
|
gentoo.config(options)
|
77
78
|
gentoo.chroot
|
79
|
+
gentoo.kernel
|
80
|
+
gentoo.boot(options)
|
78
81
|
end
|
79
82
|
|
80
83
|
def self.main(argv)
|
data/lib/getch/gentoo.rb
CHANGED
@@ -3,6 +3,8 @@ require 'open3'
|
|
3
3
|
require_relative 'gentoo/stage'
|
4
4
|
require_relative 'gentoo/config'
|
5
5
|
require_relative 'gentoo/chroot'
|
6
|
+
require_relative 'gentoo/sources'
|
7
|
+
require_relative 'gentoo/boot'
|
6
8
|
|
7
9
|
module Getch
|
8
10
|
module Gentoo
|
@@ -38,7 +40,25 @@ module Getch
|
|
38
40
|
chroot.update
|
39
41
|
chroot.world
|
40
42
|
chroot.systemd
|
43
|
+
return if STATES[:gentoo_kernel]
|
41
44
|
chroot.kernel
|
45
|
+
chroot.kernel_deps
|
46
|
+
chroot.install_tools
|
47
|
+
end
|
48
|
+
|
49
|
+
def kernel
|
50
|
+
return if STATES[:gentoo_kernel]
|
51
|
+
source = Getch::Gentoo::Sources.new()
|
52
|
+
new
|
53
|
+
source.build_kspp
|
54
|
+
source.build_others
|
55
|
+
source.make
|
56
|
+
@state.kernel
|
57
|
+
end
|
58
|
+
|
59
|
+
def boot(options)
|
60
|
+
boot = Getch::Gentoo::Boot.new(options)
|
61
|
+
boot.start
|
42
62
|
end
|
43
63
|
end
|
44
64
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Getch
|
2
|
+
module Gentoo
|
3
|
+
class Boot
|
4
|
+
def initialize(opts)
|
5
|
+
@disk = opts.disk
|
6
|
+
@user = opts.username
|
7
|
+
end
|
8
|
+
|
9
|
+
def start
|
10
|
+
gen_fstab
|
11
|
+
grub
|
12
|
+
password
|
13
|
+
umount
|
14
|
+
end
|
15
|
+
|
16
|
+
def grub
|
17
|
+
return if Helpers::efi?
|
18
|
+
puts 'Installing GRUB...'
|
19
|
+
Helpers::emerge("sys-boot/grub:2", MOUNTPOINT)
|
20
|
+
exec_chroot("grub-install /dev/#{@disk}")
|
21
|
+
exec_chroot('grub-mkconfig -o /boot/grub/grub.cfg')
|
22
|
+
end
|
23
|
+
|
24
|
+
def password
|
25
|
+
puts 'Password for root'
|
26
|
+
cmd = "chroot #{MOUNTPOINT} /bin/bash -c \"source /etc/profile && passwd\""
|
27
|
+
system(cmd)
|
28
|
+
if @user != nil
|
29
|
+
puts "Creating user #{@user}"
|
30
|
+
exec_chroot("useradd -m -G users,wheel,audio,video #{@user}")
|
31
|
+
puts "Password for your user #{@user}"
|
32
|
+
cmd = "chroot #{MOUNTPOINT} /bin/bash -c \"source /etc/profile && passwd #{@user}\""
|
33
|
+
system(cmd)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def umount
|
38
|
+
Helpers::exec_or_die("umount -l /mnt/gentoo/dev{/shm,/pts,}")
|
39
|
+
Helpers::exec_or_die("umount -R #{MOUNTPONT}")
|
40
|
+
puts "Reboot when you have done"
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def gen_fstab
|
46
|
+
mount = Getch::Mount.new(@disk, @user)
|
47
|
+
mount.gen_fstab
|
48
|
+
end
|
49
|
+
|
50
|
+
def exec_chroot(cmd)
|
51
|
+
script = "chroot #{MOUNTPOINT} /bin/bash -c \"
|
52
|
+
source /etc/profile
|
53
|
+
#{cmd}
|
54
|
+
\""
|
55
|
+
Helpers::exec_or_die(script)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/getch/gentoo/chroot.rb
CHANGED
@@ -28,14 +28,42 @@ module Getch
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def kernel
|
31
|
+
return if Dir.exist? "#{MOUNTPOINT}/usr/src/linux"
|
31
32
|
puts "Installing kernel gentoo-sources..."
|
32
|
-
cmd = "emerge sys-kernel/gentoo-sources sys-kernel/linux-firmware"
|
33
33
|
license = "#{MOUNTPOINT}/etc/portage/package.license"
|
34
34
|
File.write(license, "sys-kernel/linux-firmware linux-fw-redistributable no-source-code\n")
|
35
|
-
|
35
|
+
Helpers::emerge("sys-kernel/gentoo-sources linux-firmware", MOUNTPOINT)
|
36
|
+
end
|
37
|
+
|
38
|
+
def kernel_deps
|
39
|
+
puts "Installing Garden..."
|
40
|
+
get_garden
|
41
|
+
garden_dep
|
42
|
+
end
|
43
|
+
|
44
|
+
def install_tools
|
45
|
+
Helpers::emerge("dhcpcd", MOUNTPOINT)
|
36
46
|
end
|
37
47
|
|
38
48
|
private
|
49
|
+
|
50
|
+
def get_garden
|
51
|
+
return if Dir.exist? "#{MOUNTPOINT}/root/garden-master"
|
52
|
+
url = 'https://github.com/szorfein/garden/archive/master.tar.gz'
|
53
|
+
file = 'garden-master.tar.gz'
|
54
|
+
|
55
|
+
Dir.chdir("#{MOUNTPOINT}/root")
|
56
|
+
Helpers::get_file_online(url, file)
|
57
|
+
Helpers::exec_or_die("tar xzf #{file}") if ! Dir.exist? 'garden-master'
|
58
|
+
end
|
59
|
+
|
60
|
+
def garden_dep
|
61
|
+
Helpers::emerge("gentoolkit", MOUNTPOINT)
|
62
|
+
cmd = "euse -p sys-apps/kmod -E lzma"
|
63
|
+
Helpers::emerge("kmod", MOUNTPOINT)
|
64
|
+
exec_chroot(cmd)
|
65
|
+
end
|
66
|
+
|
39
67
|
def mount
|
40
68
|
puts "Populate /proc, /sys and /dev."
|
41
69
|
Helpers::exec_or_die("mount --types proc /proc \"#{MOUNTPOINT}/proc\"")
|
data/lib/getch/gentoo/config.rb
CHANGED
@@ -10,11 +10,13 @@ module Getch
|
|
10
10
|
|
11
11
|
def portage
|
12
12
|
nproc = `nproc`.chomp()
|
13
|
+
efi = Helpers::efi? ? 'GRUB_PLATFORMS="efi-64"' : ''
|
13
14
|
data = [
|
14
15
|
'',
|
15
16
|
'ACCEPT_KEYWORD="amd64 ~amd64"',
|
16
17
|
"MAKEOPTS=\"-j#{nproc} -l#{nproc}\"",
|
17
|
-
'INPUT_DEVICES="libinput"'
|
18
|
+
'INPUT_DEVICES="libinput"',
|
19
|
+
efi
|
18
20
|
]
|
19
21
|
File.write(@make, data.join("\n"), mode: "a")
|
20
22
|
end
|
@@ -42,10 +44,10 @@ module Getch
|
|
42
44
|
def systemd(options)
|
43
45
|
control_options(options)
|
44
46
|
File.write("#{MOUNTPOINT}/etc/locale.gen", @utf8)
|
45
|
-
File.write("#{MOUNTPOINT}/etc/locale.conf", "LANG=#{@lang}")
|
47
|
+
File.write("#{MOUNTPOINT}/etc/locale.conf", "LANG=#{@lang}\n")
|
46
48
|
File.write("#{MOUNTPOINT}/etc/locale.conf", 'LC_COLLATE=C', mode: 'a')
|
47
49
|
File.write("#{MOUNTPOINT}/etc/timezone", "#{options.zoneinfo}")
|
48
|
-
File.write("#{MOUNTPOINT}/etc/vconsole.conf", "KEYMAP=#{
|
50
|
+
File.write("#{MOUNTPOINT}/etc/vconsole.conf", "KEYMAP=#{options.keyboard}")
|
49
51
|
end
|
50
52
|
|
51
53
|
def portage_fs
|
@@ -72,12 +74,12 @@ module Getch
|
|
72
74
|
Dir.glob("#{MOUNTPOINT}/usr/share/keymaps/**/#{keys}.map.gz") { |f|
|
73
75
|
@keymap = f
|
74
76
|
}
|
75
|
-
raise "No keymap #{@keymap} found" if ! @keymap
|
77
|
+
raise ArgumentError, "No keymap #{@keymap} found" if ! @keymap
|
76
78
|
end
|
77
79
|
|
78
80
|
def search_zone(zone)
|
79
81
|
if ! File.exist?("#{MOUNTPOINT}/usr/share/zoneinfo/#{zone}")
|
80
|
-
raise "Zoneinfo #{zone} doesn\'t exist."
|
82
|
+
raise ArgumentError, "Zoneinfo #{zone} doesn\'t exist."
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|
@@ -87,7 +89,7 @@ module Getch
|
|
87
89
|
@utf8 = $~[0] if l.match(/^#{lang}[. ]+[utf\-8 ]+/i)
|
88
90
|
@lang = $~[0] if l.match(/^#{lang}[. ]+utf\-8/i)
|
89
91
|
}
|
90
|
-
raise "Lang #{lang} no found" if ! @utf8
|
92
|
+
raise ArgumentError, "Lang #{lang} no found" if ! @utf8
|
91
93
|
end
|
92
94
|
end
|
93
95
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Getch
|
2
|
+
module Gentoo
|
3
|
+
class Sources
|
4
|
+
def initialize
|
5
|
+
@lsmod = `lsmod`.chomp
|
6
|
+
@linux = '/usr/src/linux'
|
7
|
+
end
|
8
|
+
|
9
|
+
def build_others
|
10
|
+
install_wifi if ismatch?('iwlwifi')
|
11
|
+
install_zfs if ismatch?('zfs')
|
12
|
+
exec("./kernel.sh -b -a virtualbox-guest -k #{@linux}") if ismatch?('vmwgfx')
|
13
|
+
end
|
14
|
+
|
15
|
+
def build_kspp
|
16
|
+
puts "Adding KSPP to the kernel source"
|
17
|
+
exec("./kernel.sh -b -a systemd -k #{@linux}")
|
18
|
+
end
|
19
|
+
|
20
|
+
def make
|
21
|
+
puts "Compiling kernel sources"
|
22
|
+
only_make
|
23
|
+
cmd = "cd #{@linux} && make modules_install && make install"
|
24
|
+
exec_chroot(cmd)
|
25
|
+
end
|
26
|
+
|
27
|
+
def only_make
|
28
|
+
exec_chroot("cd #{@linux} && make -j$(nproc)")
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def ismatch?(arg)
|
34
|
+
@lsmod.match?(/#{arg}/)
|
35
|
+
end
|
36
|
+
|
37
|
+
def exec(cmd)
|
38
|
+
script = "chroot #{MOUNTPOINT} /bin/bash -c \"
|
39
|
+
source /etc/profile
|
40
|
+
cd /root/garden-master
|
41
|
+
#{cmd}
|
42
|
+
\""
|
43
|
+
Helpers::exec_or_die(script)
|
44
|
+
end
|
45
|
+
|
46
|
+
def exec_chroot(cmd)
|
47
|
+
script = "chroot #{MOUNTPOINT} /bin/bash -c \"
|
48
|
+
source /etc/profile
|
49
|
+
#{cmd}
|
50
|
+
\""
|
51
|
+
Helpers::exec_or_die(script)
|
52
|
+
end
|
53
|
+
|
54
|
+
def install_wifi
|
55
|
+
exec("./kernel.sh -b -a wifi -k #{@linux}")
|
56
|
+
Helpers::emerge("net-wireless/iw wpa_supplicant", MOUNTPOINT)
|
57
|
+
end
|
58
|
+
|
59
|
+
def install_zfs
|
60
|
+
exec("./kernel.sh -b -a zfs -k #{@linux}")
|
61
|
+
only_make # a first make is necessary before emerge zfs
|
62
|
+
Helpers::emerge("zfs", MOUNTPOINT)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/getch/helpers.rb
CHANGED
@@ -29,4 +29,12 @@ module Helpers
|
|
29
29
|
def self.add_file(path, content = '')
|
30
30
|
File.write path, content if ! File.exist? path
|
31
31
|
end
|
32
|
+
|
33
|
+
def self.emerge(pkgs, path)
|
34
|
+
cmd = "chroot #{path} /bin/bash -c \"
|
35
|
+
source /etc/profile
|
36
|
+
emerge --changed-use #{pkgs}
|
37
|
+
\""
|
38
|
+
exec_or_die(cmd)
|
39
|
+
end
|
32
40
|
end
|
data/lib/getch/mount.rb
CHANGED
@@ -35,9 +35,39 @@ module Getch
|
|
35
35
|
if @user != nil then
|
36
36
|
FileUtils.mkdir_p @home, mode: 0700 if ! Dir.exist?(@home)
|
37
37
|
system("mount /dev/#{@disk}4 #{@home}")
|
38
|
-
FileUtils.chown @user, @user, @home
|
38
|
+
#FileUtils.chown @user, @user, @home
|
39
39
|
end
|
40
40
|
@state.mount
|
41
41
|
end
|
42
|
+
|
43
|
+
def gen_fstab
|
44
|
+
gen_uuid
|
45
|
+
datas = gen_data
|
46
|
+
File.write("#{MOUNTPOINT}/etc/fstab", datas.join("\n"), mode: "a")
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def gen_uuid
|
52
|
+
@hdd1_uuid = `lsblk -o "UUID" /dev/#{@disk}1 | tail -1`.chomp()
|
53
|
+
@hdd2_uuid = `lsblk -o "UUID" /dev/#{@disk}2 | tail -1`.chomp()
|
54
|
+
@hdd3_uuid = `lsblk -o "UUID" /dev/#{@disk}3 | tail -1`.chomp()
|
55
|
+
@hdd4_uuid = `lsblk -o "UUID" /dev/#{@disk}4 | tail -1`.chomp()
|
56
|
+
end
|
57
|
+
|
58
|
+
def gen_data
|
59
|
+
boot = Helpers::efi? ? "UUID=#{@hdd1_uuid} /boot/efi vfat noauto,defaults 0 2" : ''
|
60
|
+
swap = "UUID=#{@hdd2_uuid} none swap discard 0 0"
|
61
|
+
root = "UUID=#{@hdd3_uuid} / ext4 defaults 0 1"
|
62
|
+
home = @user != nil ? "UUID=#{@hdd4_uuid} /home/#{@user} ext4 defaults 0 2" : ''
|
63
|
+
|
64
|
+
datas = [
|
65
|
+
boot,
|
66
|
+
swap,
|
67
|
+
root,
|
68
|
+
home
|
69
|
+
]
|
70
|
+
return datas
|
71
|
+
end
|
42
72
|
end
|
43
73
|
end
|
data/lib/getch/states.rb
CHANGED
data/lib/getch/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: getch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- szorfein
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
J/zT/q2Ac7BWpSLbv6p9lChBiEnD9j24x463LR5QQjDNS5SsjzRQfFuprsa9Nqf2
|
36
36
|
Tw==
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2020-09-
|
38
|
+
date: 2020-09-16 00:00:00.000000000 Z
|
39
39
|
dependencies: []
|
40
40
|
description:
|
41
41
|
email:
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
|
+
- CHANGELOG.md
|
49
50
|
- README.md
|
50
51
|
- Rakefile
|
51
52
|
- bin/getch
|
@@ -54,8 +55,10 @@ files:
|
|
54
55
|
- lib/getch.rb
|
55
56
|
- lib/getch/disk.rb
|
56
57
|
- lib/getch/gentoo.rb
|
58
|
+
- lib/getch/gentoo/boot.rb
|
57
59
|
- lib/getch/gentoo/chroot.rb
|
58
60
|
- lib/getch/gentoo/config.rb
|
61
|
+
- lib/getch/gentoo/sources.rb
|
59
62
|
- lib/getch/gentoo/stage.rb
|
60
63
|
- lib/getch/helpers.rb
|
61
64
|
- lib/getch/mount.rb
|
@@ -65,7 +68,10 @@ files:
|
|
65
68
|
homepage: https://github.com/szorfein/getch
|
66
69
|
licenses:
|
67
70
|
- MIT
|
68
|
-
metadata:
|
71
|
+
metadata:
|
72
|
+
changelog_uri: https://github.com/szorfein/getch/blob/master/CHANGELOG.md
|
73
|
+
bug_tracker_uri: https://github.com/szorfein/getch/issues
|
74
|
+
wiki_uri: https://github.com/szorfein/getch
|
69
75
|
post_install_message:
|
70
76
|
rdoc_options: []
|
71
77
|
require_paths:
|
metadata.gz.sig
CHANGED
Binary file
|