getch 0.7.3 → 0.11.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/CHANGELOG.md +8 -0
- data/README.md +18 -13
- data/lib/fstab/root.rb +1 -1
- data/lib/fstab/zfs.rb +8 -3
- data/lib/getch/command.rb +12 -5
- data/lib/getch/config/keymap.rb +1 -1
- data/lib/getch/config/portage.rb +13 -1
- data/lib/getch/config/timezone.rb +1 -1
- data/lib/getch/device.rb +2 -0
- data/lib/getch/gentoo/bootloader.rb +6 -2
- data/lib/getch/gentoo/finalize.rb +1 -0
- data/lib/getch/gentoo/pre_config.rb +2 -1
- data/lib/getch/gentoo/services.rb +1 -0
- data/lib/getch/gentoo/sources.rb +5 -2
- data/lib/getch/gentoo/tarball.rb +14 -9
- data/lib/getch/gentoo/terraform.rb +1 -0
- data/lib/getch/gentoo/update.rb +14 -3
- data/lib/getch/gentoo/use.rb +1 -0
- data/lib/getch/helpers.rb +2 -2
- data/lib/getch/options.rb +19 -0
- data/lib/getch/version.rb +1 -1
- data/lib/getch/void/bootloader.rb +2 -3
- data/lib/getch/void/finalize.rb +1 -0
- data/lib/getch/void/post_config.rb +1 -0
- data/lib/getch/void/pre_config.rb +1 -0
- data/lib/getch/void/services.rb +1 -0
- data/lib/getch/void/update.rb +1 -0
- data/lib/getch.rb +10 -5
- data/lib/lvm2.rb +13 -8
- data/lib/nito.rb +4 -0
- data/lib/sgdisk.rb +5 -5
- data.tar.gz.sig +0 -0
- metadata +2 -2
- 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: 3632483fb40d3ce1ac81399c4e4d70c2391b99f80ecb38f8f9105a615d7f6def
|
4
|
+
data.tar.gz: 9481039af6ba7c062c0f0b4e6e1e0817cf7e7480c76a95e36558be8ea9961e56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b30e3e62f01c8242a1dee3e43da7463ec2f4f4d779fe42068515eadff96384becfae42f32ddb97908722d2141f6c1adcc142941b45a1f73e85df1f12f4bc297
|
7
|
+
data.tar.gz: bfec1bb64102917cb894171e614741ef63e2ba39cf7ffd5e2aa694e76ea6c8fe50616d7f62b5ff045b873fd557f4ecb59a39defcdc19425ba5faf85b13147fa7
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 0.11.0, release 2024-10
|
2
|
+
* Add a new option `--boot-size SIZE`, like requested in
|
3
|
+
[#6](https://github.com/szorfein/getch/issues/6), actually, it's only used on a
|
4
|
+
/boot partition, not /efi.
|
5
|
+
* Add a new option `--root-size SIZE`.
|
6
|
+
* Add a new option `--swap-size SIZE`.
|
7
|
+
* Support [Gentoo binary](https://www.gentoo.org/news/2023/12/29/Gentoo-binary.html), use `--binary`, it make the install of Gentoo faster for small system.
|
8
|
+
|
1
9
|
## 0.7.3, release 2024-10
|
2
10
|
Add a Workflow to build gem on Github
|
3
11
|
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
</div>
|
12
12
|
|
13
|
-
A CLI tool to install Gentoo or Void Linux with default:
|
13
|
+
A CLI tool to install [Gentoo](https://www.gentoo.org/) (by compiling or in [binary](https://www.gentoo.org/news/2023/12/29/Gentoo-binary.html)) or [Void](https://voidlinux.org/) Linux with default:
|
14
14
|
+ DNS over HTTPS (with [Quad9](https://www.quad9.net/)).
|
15
15
|
+ Vim | Nano installed.
|
16
16
|
+ Iptables installed (not configured).
|
@@ -35,7 +35,7 @@ Filesystem supported (with or without encryption)
|
|
35
35
|
+ ZFS
|
36
36
|
|
37
37
|
Boot Manager:
|
38
|
-
+ **Gentoo**:
|
38
|
+
+ **Gentoo**: Grub2 except on systemd without encryption.
|
39
39
|
+ **Void**: use only Grub2.
|
40
40
|
|
41
41
|
The ISO images i was able to test and that works:
|
@@ -47,7 +47,7 @@ The ISO images i was able to test and that works:
|
|
47
47
|
You can also use your current `linux` host, just pay attention to the disk that will be used.
|
48
48
|
|
49
49
|
## Dependencies
|
50
|
-
Getch is build without external libs, so it only require `ruby >= 2.
|
50
|
+
Getch is build without external libs, so it only require `ruby >= 2.6`.
|
51
51
|
|
52
52
|
On a live image of Void, you need to install `xbps-install -S ruby xz gptfdisk
|
53
53
|
openssl`.
|
@@ -73,36 +73,41 @@ Just ensure than the script is run with a root account.
|
|
73
73
|
After an install by Getch, take a look on the [wiki](https://github.com/szorfein/getch/wiki).
|
74
74
|
|
75
75
|
## Examples
|
76
|
-
For a french user:
|
76
|
+
For a french user on Gentoo:
|
77
77
|
|
78
|
-
# getch --zoneinfo "Europe/Paris" --language fr_FR --keymap fr
|
78
|
+
# getch --disk sda --zoneinfo "Europe/Paris" --language fr_FR --keymap fr
|
79
79
|
|
80
|
-
Install Gentoo on LVM and use a different root disk `/dev/
|
80
|
+
Install Gentoo on LVM and use a different root disk `/dev/vdc`
|
81
81
|
|
82
|
-
# getch --format ext4 --lvm
|
82
|
+
# getch --disk vdc --format ext4 --lvm
|
83
83
|
|
84
|
-
Encrypt your disk with LVM with a french keymap
|
84
|
+
Encrypt your disk with LVM with a french keymap and in binary mode:
|
85
85
|
|
86
|
-
# getch --format ext4 --lvm --encrypt --keymap fr
|
86
|
+
# getch --disk sda --format ext4 --lvm --encrypt --keymap fr --binary
|
87
87
|
|
88
88
|
Encrypt with ext4 and create a new user `ninja`:
|
89
89
|
|
90
|
-
# getch --format ext4 --encrypt --username ninja
|
90
|
+
# getch --disk vda --format ext4 --encrypt --username ninja
|
91
|
+
|
92
|
+
Change size of root in Gb (default 16 on lvm), swap in Mb (default use your
|
93
|
+
current total ram) with lvm.
|
94
|
+
|
95
|
+
# getch --disk sda -o void --lvm --root-size 10 --swap-size 4096
|
91
96
|
|
92
97
|
With ZFS, if used with `--encrypt`, it use the native ZFS encryption:
|
93
98
|
|
94
|
-
# getch --format zfs
|
99
|
+
# getch --disk vda --format zfs
|
95
100
|
|
96
101
|
With `Void Linux` and `Musl` enable:
|
97
102
|
|
98
|
-
# getch --os void --encrypt -k fr --musl
|
103
|
+
# getch --disk sda --os void --encrypt -k fr --musl
|
99
104
|
|
100
105
|
## Troubleshooting
|
101
106
|
|
102
107
|
#### Old VG for LVM
|
103
108
|
If a old volume group exist, `getch` may fail to partition your disk. You have to clean up your device before proceed with `vgremove` and `pvremove`. An short example how doing this with a volume group named `vg0`:
|
104
109
|
|
105
|
-
# vgdisplay | grep
|
110
|
+
# vgdisplay | grep vg
|
106
111
|
# vgremove -f vg0
|
107
112
|
# pvremove -f /dev/sdb
|
108
113
|
|
data/lib/fstab/root.rb
CHANGED
data/lib/fstab/zfs.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Fstab
|
4
|
+
# Generating fstab for zfs filesystem
|
2
5
|
class Zfs < Root
|
3
6
|
def initialize(devs, options)
|
4
7
|
super
|
@@ -14,9 +17,11 @@ module Fstab
|
|
14
17
|
|
15
18
|
def write_swap
|
16
19
|
uuid = gen_uuid @swap
|
17
|
-
@encrypt
|
18
|
-
|
19
|
-
|
20
|
+
line = if @encrypt
|
21
|
+
'/dev/mapper/swap-luks none swap sw 0 0'
|
22
|
+
else
|
23
|
+
"UUID=#{uuid} swap swap rw,noatime,discard 0 0"
|
24
|
+
end
|
20
25
|
echo_a @conf, line
|
21
26
|
end
|
22
27
|
end
|
data/lib/getch/command.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'open3'
|
4
4
|
require 'nito'
|
5
|
+
require 'English'
|
5
6
|
|
6
7
|
module Getch
|
7
8
|
class Command
|
@@ -20,7 +21,7 @@ module Getch
|
|
20
21
|
protected
|
21
22
|
|
22
23
|
def x
|
23
|
-
@log.info
|
24
|
+
@log.info "Exec: #{@cmd}"
|
24
25
|
cmd = build_cmd
|
25
26
|
|
26
27
|
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
|
@@ -112,7 +113,7 @@ module Getch
|
|
112
113
|
def x
|
113
114
|
msg
|
114
115
|
system('chroot', OPTIONS[:mountpoint], '/bin/bash', '-c', other_args)
|
115
|
-
|
116
|
+
$CHILD_STATUS.success? && return
|
116
117
|
|
117
118
|
@log.fatal "Running #{@cmd}"
|
118
119
|
end
|
@@ -137,11 +138,17 @@ module Getch
|
|
137
138
|
@log.info "Installing #{@cmd}...\n"
|
138
139
|
end
|
139
140
|
|
141
|
+
# Gentoo binary should not use --changed-use
|
142
|
+
# https://wiki.gentoo.org/wiki/Binary_package_guide
|
140
143
|
def other_args
|
141
144
|
case OPTIONS[:os]
|
142
|
-
when 'gentoo'
|
143
|
-
|
144
|
-
|
145
|
+
when 'gentoo'
|
146
|
+
if OPTIONS[:binary]
|
147
|
+
"source /etc/profile && emerge #{@cmd}"
|
148
|
+
else
|
149
|
+
"source /etc/profile && emerge --changed-use #{@cmd}"
|
150
|
+
end
|
151
|
+
when 'void' then "/usr/bin/xbps-install -y #{@cmd}" end
|
145
152
|
end
|
146
153
|
end
|
147
154
|
end
|
data/lib/getch/config/keymap.rb
CHANGED
data/lib/getch/config/portage.rb
CHANGED
@@ -30,6 +30,7 @@ module Getch
|
|
30
30
|
mkdir "#{@dest}/package.accept_keywords", 0744
|
31
31
|
mkdir "#{@dest}/package.unmask", 0744
|
32
32
|
mkdir "#{@dest}/package.license", 0744
|
33
|
+
mkdir "#{@dest}/binrepos.conf", 0744 if OPTIONS[:binary]
|
33
34
|
|
34
35
|
touch "#{@dest}/package.use/zzz_via_autounmask"
|
35
36
|
touch "#{@dest}/package.accept_keywords/zzz_via_autounmask"
|
@@ -46,17 +47,28 @@ module Getch
|
|
46
47
|
# -fomit-frame-pointer reduce code compiled
|
47
48
|
# but have repercussions on the debugging of applications
|
48
49
|
def cpu_conf
|
49
|
-
change =
|
50
|
+
change = if OPTIONS[:binary]
|
51
|
+
'COMMON_FLAGS="-O2 -pipe -march=x86-64 -mtune=generic"'
|
52
|
+
else
|
53
|
+
'COMMON_FLAGS="-march=native -O2 -pipe -fomit-frame-pointer"'
|
54
|
+
end
|
50
55
|
sed "#{@dest}/make.conf", /^COMMON_FLAGS/, change
|
51
56
|
end
|
52
57
|
|
53
58
|
# https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Stage#MAKEOPTS
|
59
|
+
# Gentoo binary
|
60
|
+
# https://wiki.gentoo.org/wiki/Binary_package_guide
|
61
|
+
# https://wiki.gentoo.org/wiki/Gentoo_Binary_Host_Quickstart
|
54
62
|
def make_conf
|
55
63
|
nproc = `nproc`.chomp
|
56
64
|
|
57
65
|
echo_a "#{@dest}/make.conf", 'ACCEPT_KEYWORDS="amd64"'
|
58
66
|
echo_a "#{@dest}/make.conf", 'INPUT_DEVICES="libinput"'
|
59
67
|
echo_a "#{@dest}/make.conf", "MAKEOPTS=\"-j#{nproc} -l#{nproc}\""
|
68
|
+
return unless OPTIONS[:binary]
|
69
|
+
|
70
|
+
echo_a "#{@dest}/make.conf", 'EMERGE_DEFAULT_OPTS="${EMERGE_DEFAULT_OPTS} --getbinpkg --with-bdeps=y --binpkg-respect-use=y"'
|
71
|
+
echo_a "#{@dest}/make.conf", 'FEATURES="getbinpkg binpkg-request-signature"'
|
60
72
|
end
|
61
73
|
|
62
74
|
# https://www.gentoo.org/downloads/mirrors/
|
data/lib/getch/device.rb
CHANGED
@@ -26,8 +26,12 @@ module Getch
|
|
26
26
|
bootctl
|
27
27
|
end
|
28
28
|
|
29
|
-
#
|
30
|
-
|
29
|
+
# should also reload grub-mkconfig
|
30
|
+
if OPTIONS[:binary]
|
31
|
+
ChrootOutput.new('emerge --config sys-kernel/gentoo-kernel-bin')
|
32
|
+
else
|
33
|
+
ChrootOutput.new('emerge --config sys-kernel/gentoo-kernel')
|
34
|
+
end
|
31
35
|
end
|
32
36
|
|
33
37
|
def bootctl
|
@@ -4,6 +4,7 @@ require 'nito'
|
|
4
4
|
|
5
5
|
module Getch
|
6
6
|
module Gentoo
|
7
|
+
# configure before installting the system
|
7
8
|
class PreConfig
|
8
9
|
include NiTo
|
9
10
|
|
@@ -30,7 +31,7 @@ module Getch
|
|
30
31
|
|
31
32
|
def check_ip(host)
|
32
33
|
ip = `ping -c1 #{host}`.match(/\([0-9]*.[0-9]*.[0-9]*.[0-9]*\)/)
|
33
|
-
ip[0].tr('()','')
|
34
|
+
ip[0].tr('()', '')
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
data/lib/getch/gentoo/sources.rb
CHANGED
@@ -73,8 +73,11 @@ module Getch
|
|
73
73
|
def make
|
74
74
|
Install.new('sys-kernel/installkernel')
|
75
75
|
|
76
|
-
|
77
|
-
|
76
|
+
if OPTIONS[:binary]
|
77
|
+
Install.new 'sys-kernel/gentoo-kernel-bin'
|
78
|
+
else
|
79
|
+
Install.new 'sys-kernel/gentoo-kernel'
|
80
|
+
end
|
78
81
|
end
|
79
82
|
|
80
83
|
def load_modules
|
data/lib/getch/gentoo/tarball.rb
CHANGED
@@ -5,14 +5,17 @@ require 'open3'
|
|
5
5
|
|
6
6
|
module Getch
|
7
7
|
module Gentoo
|
8
|
+
# Download the last archive rootfs
|
8
9
|
class Tarball
|
9
10
|
def initialize
|
10
11
|
@log = Log.new
|
11
12
|
@mirror = 'https://mirror.rackspace.com/gentoo'
|
12
13
|
@release = release
|
13
|
-
@stage_file = OPTIONS[:musl]
|
14
|
-
|
15
|
-
|
14
|
+
@stage_file = if OPTIONS[:musl]
|
15
|
+
"stage3-amd64-musl-#{@release}.tar.xz"
|
16
|
+
else
|
17
|
+
"stage3-amd64-systemd-#{@release}.tar.xz"
|
18
|
+
end
|
16
19
|
end
|
17
20
|
|
18
21
|
def x
|
@@ -25,9 +28,11 @@ module Getch
|
|
25
28
|
protected
|
26
29
|
|
27
30
|
def stage3
|
28
|
-
OPTIONS[:musl]
|
29
|
-
@mirror
|
30
|
-
|
31
|
+
if OPTIONS[:musl]
|
32
|
+
"#{@mirror}/releases/amd64/autobuilds/latest-stage3-amd64-musl.txt"
|
33
|
+
else
|
34
|
+
"#{@mirror}/releases/amd64/autobuilds/latest-stage3-amd64-systemd.txt"
|
35
|
+
end
|
31
36
|
end
|
32
37
|
|
33
38
|
# release check line like bellow and return 20231126T163200Z:
|
@@ -51,11 +56,11 @@ module Getch
|
|
51
56
|
return if File.exist? @stage_file
|
52
57
|
|
53
58
|
@log.info "wget #{@stage_file}, please wait...\n"
|
54
|
-
Helpers.get_file_online(@mirror
|
59
|
+
Helpers.get_file_online("#{@mirror}/releases/amd64/autobuilds/#{file}", @stage_file)
|
55
60
|
end
|
56
61
|
|
57
62
|
def control_files
|
58
|
-
@log.info
|
63
|
+
@log.info 'Download other files...'
|
59
64
|
['DIGESTS', 'asc', 'CONTENTS.gz'].each do |f|
|
60
65
|
Helpers.get_file_online("#{@mirror}/releases/amd64/autobuilds/#{file}.#{f}", "#{@stage_file}.#{f}")
|
61
66
|
end
|
@@ -66,7 +71,7 @@ module Getch
|
|
66
71
|
@log.info 'Checking SHA512 checksum...'
|
67
72
|
command = "awk '/SHA512 HASH/{getline;print}' #{@stage_file}.DIGESTS | sha512sum --check"
|
68
73
|
_, stderr, status = Open3.capture3(command)
|
69
|
-
if status.success?
|
74
|
+
if status.success?
|
70
75
|
@log.result_ok
|
71
76
|
else
|
72
77
|
cleaning
|
data/lib/getch/gentoo/update.rb
CHANGED
@@ -4,11 +4,13 @@ require 'nito'
|
|
4
4
|
|
5
5
|
module Getch
|
6
6
|
module Gentoo
|
7
|
+
# update system gentoo
|
7
8
|
class Update
|
8
9
|
include NiTo
|
9
10
|
|
10
11
|
def initialize
|
11
12
|
@log = Log.new
|
13
|
+
@dest = "#{OPTIONS[:mountpoint]}/etc/portage"
|
12
14
|
x
|
13
15
|
end
|
14
16
|
|
@@ -18,12 +20,22 @@ module Getch
|
|
18
20
|
sync
|
19
21
|
add_musl_repo if OPTIONS[:musl]
|
20
22
|
update
|
23
|
+
gpg
|
21
24
|
end
|
22
25
|
|
23
26
|
private
|
24
27
|
|
28
|
+
# https://wiki.gentoo.org/wiki/Gentoo_Binary_Host_Quickstart#Package_signature_verification
|
29
|
+
# Fix permissions error on gnupg directory
|
30
|
+
def gpg
|
31
|
+
return unless OPTIONS[:binary]
|
32
|
+
|
33
|
+
mv "#{@dest}/gnupg", "#{@dest}/gnupg.bak"
|
34
|
+
ChrootOutput.new('getuto')
|
35
|
+
end
|
36
|
+
|
25
37
|
def sync
|
26
|
-
gentoo_conf = "#{
|
38
|
+
gentoo_conf = "#{@dest}/repos.conf/gentoo.conf"
|
27
39
|
@log.info "Synchronize index, please waiting...\n"
|
28
40
|
ChrootOutput.new('emaint sync --auto')
|
29
41
|
sed gentoo_conf, /^sync-type/, 'sync-type = rsync'
|
@@ -31,8 +43,7 @@ module Getch
|
|
31
43
|
|
32
44
|
def add_musl_repo
|
33
45
|
Install.new('dev-vcs/git')
|
34
|
-
|
35
|
-
file = "#{OPTIONS[:mountpoint]}/etc/portage/repos.conf/musl.conf"
|
46
|
+
file = "#{@dest}/repos.conf/musl.conf"
|
36
47
|
content = <<~CONF
|
37
48
|
[musl]
|
38
49
|
location = /var/db/repos/musl
|
data/lib/getch/gentoo/use.rb
CHANGED
data/lib/getch/helpers.rb
CHANGED
@@ -109,9 +109,9 @@ module Getch
|
|
109
109
|
t = l.split(' ') if l =~ /memtotal/i
|
110
110
|
t && mem = t[1]
|
111
111
|
end
|
112
|
-
mem || Log.new.fatal('get_memory - failed to get memory')
|
112
|
+
mem_to_mb = mem.to_i / 1024 || Log.new.fatal('get_memory - failed to get memory')
|
113
113
|
|
114
|
-
|
114
|
+
mem_to_mb.to_s
|
115
115
|
end
|
116
116
|
|
117
117
|
# get the sector size of a disk
|
data/lib/getch/options.rb
CHANGED
@@ -66,6 +66,21 @@ module Getch
|
|
66
66
|
OPTIONS[:home_disk] = Getch::Guard.disk(home)
|
67
67
|
end
|
68
68
|
|
69
|
+
opts.on('--boot-size SIZE', Numeric,
|
70
|
+
'Specifie the boot size in mebibyte (mib), default use 256.') do |size|
|
71
|
+
OPTIONS[:boot_size] = size
|
72
|
+
end
|
73
|
+
|
74
|
+
opts.on('--swap-size SIZE', Numeric,
|
75
|
+
"Specifie the swap size in megabyte (mb), default use your current memory #{Getch::OPTIONS[:swap_size]}.") do |size|
|
76
|
+
OPTIONS[:swap_size] = size
|
77
|
+
end
|
78
|
+
|
79
|
+
opts.on('--root-size SIZE', Numeric,
|
80
|
+
'Specifie the root size in gigabyte (G), default use 16 (used only on lvm when --separate-home was not specified.') do |size|
|
81
|
+
OPTIONS[:root_size] = size
|
82
|
+
end
|
83
|
+
|
69
84
|
opts.on('--lvm',
|
70
85
|
'System will use LVM, do not work with ZFS.') do
|
71
86
|
OPTIONS[:lvm] = true
|
@@ -80,6 +95,10 @@ module Getch
|
|
80
95
|
OPTIONS[:musl] = true
|
81
96
|
end
|
82
97
|
|
98
|
+
opts.on('--binary', 'Prefer to use binary packages instead of compile them (Gentoo).') do
|
99
|
+
OPTIONS[:binary] = true
|
100
|
+
end
|
101
|
+
|
83
102
|
opts.on('--verbose', 'Write more messages to the standard output.') do
|
84
103
|
OPTIONS[:verbose] = true
|
85
104
|
end
|
data/lib/getch/version.rb
CHANGED
@@ -2,11 +2,10 @@
|
|
2
2
|
|
3
3
|
module Getch
|
4
4
|
module Void
|
5
|
+
# install grub
|
5
6
|
class Bootloader
|
6
7
|
def dependencies
|
7
|
-
Helpers.efi? ?
|
8
|
-
Install.new('grub-x86_64-efi') :
|
9
|
-
Install.new('grub')
|
8
|
+
Helpers.efi? ? Install.new('grub-x86_64-efi') : Install.new('grub')
|
10
9
|
end
|
11
10
|
|
12
11
|
def install
|
data/lib/getch/void/finalize.rb
CHANGED
data/lib/getch/void/services.rb
CHANGED
data/lib/getch/void/update.rb
CHANGED
data/lib/getch.rb
CHANGED
@@ -16,7 +16,6 @@ require_relative 'getch/guard'
|
|
16
16
|
require_relative 'getch/version'
|
17
17
|
|
18
18
|
module Getch
|
19
|
-
|
20
19
|
OPTIONS = {
|
21
20
|
boot_disk: false,
|
22
21
|
disk: false,
|
@@ -34,8 +33,12 @@ module Getch
|
|
34
33
|
timezone: 'UTC',
|
35
34
|
username: false,
|
36
35
|
verbose: false,
|
37
|
-
vg_name: '
|
38
|
-
zfs_name: 'pool'
|
36
|
+
vg_name: 'vg0',
|
37
|
+
zfs_name: 'pool',
|
38
|
+
boot_size: 260,
|
39
|
+
swap_size: Getch::Helpers.get_memory,
|
40
|
+
root_size: 16,
|
41
|
+
binary: false
|
39
42
|
}
|
40
43
|
|
41
44
|
STATES = {
|
@@ -49,7 +52,7 @@ module Getch
|
|
49
52
|
terraform: false,
|
50
53
|
bootloader: false,
|
51
54
|
services: false,
|
52
|
-
finalize: false
|
55
|
+
finalize: false
|
53
56
|
}
|
54
57
|
|
55
58
|
MOUNTPOINT = '/mnt/getch'
|
@@ -66,8 +69,9 @@ module Getch
|
|
66
69
|
STATES[:partition] && return
|
67
70
|
|
68
71
|
@log.fatal 'No disk, use at least getch with -d DISK' unless OPTIONS[:disk]
|
72
|
+
os_cap = OPTIONS[:os].capitalize
|
69
73
|
|
70
|
-
puts "\nBuild
|
74
|
+
puts "\nBuild #{os_cap} Linux with the following args:\n"
|
71
75
|
puts
|
72
76
|
puts "\tLang: #{OPTIONS[:language]}"
|
73
77
|
puts "\tTimezone: #{OPTIONS[:timezone]}"
|
@@ -77,6 +81,7 @@ module Getch
|
|
77
81
|
puts "\tUsername: #{OPTIONS[:username]}"
|
78
82
|
puts "\tEncrypt: #{OPTIONS[:encrypt]}"
|
79
83
|
puts "\tMusl: #{OPTIONS[:musl]}"
|
84
|
+
puts "\tBinary mode: #{OPTIONS[:binary]}"
|
80
85
|
puts
|
81
86
|
puts "\tseparate-boot disk: #{OPTIONS[:boot_disk]}"
|
82
87
|
puts "\tseparate-cache disk: #{OPTIONS[:cache_disk]}"
|
data/lib/lvm2.rb
CHANGED
@@ -3,12 +3,13 @@
|
|
3
3
|
require 'getch/command'
|
4
4
|
|
5
5
|
module Lvm2
|
6
|
+
# Configure system with lvm
|
6
7
|
class Root
|
7
8
|
def initialize(devs, options)
|
8
9
|
@cache = options[:cache_disk] ||= nil
|
9
10
|
@root = devs[:root] ||= nil
|
10
11
|
@home = options[:home_disk] ||= nil
|
11
|
-
@vg = options[:vg_name] ||= '
|
12
|
+
@vg = options[:vg_name] ||= 'vg0'
|
12
13
|
end
|
13
14
|
|
14
15
|
def x
|
@@ -28,14 +29,14 @@ module Lvm2
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def pv_create
|
31
|
-
devs = [
|
32
|
+
devs = [@path_root]
|
32
33
|
@cache && devs << @path_cache
|
33
34
|
@home && devs << @path_home
|
34
35
|
devs.each { |d| d && add_pv(d) }
|
35
36
|
end
|
36
37
|
|
37
38
|
def vg_create
|
38
|
-
devs = [
|
39
|
+
devs = [@path_root]
|
39
40
|
@cache && devs << @path_cache
|
40
41
|
@home && devs << @path_home
|
41
42
|
add_vg devs
|
@@ -56,7 +57,7 @@ module Lvm2
|
|
56
57
|
private
|
57
58
|
|
58
59
|
def add_pv(dev)
|
59
|
-
File.exist?
|
60
|
+
File.exist?(dev) || @log.fatal("add_pv - no #{dev} exist.")
|
60
61
|
|
61
62
|
Getch::Command.new('pvcreate', '-f', dev)
|
62
63
|
end
|
@@ -66,15 +67,18 @@ module Lvm2
|
|
66
67
|
end
|
67
68
|
|
68
69
|
def add_swap(dev = nil)
|
69
|
-
mem = Getch::
|
70
|
+
mem = "#{Getch::OPTIONS[:swap_size]}M"
|
70
71
|
lvcreate('-L', mem, '-n', 'swap', @vg, dev)
|
71
72
|
end
|
72
73
|
|
73
74
|
# if home is available, we use the whole space.
|
74
75
|
def add_lv_root
|
75
|
-
|
76
|
-
|
77
|
-
@root.match?(/[0-9]/) ? add_root
|
76
|
+
size = "#{Getch::OPTIONS[:root_size]}G" # in gigabyte
|
77
|
+
if @home
|
78
|
+
@root.match?(/[0-9]/) ? add_root : add_root(nil, @path_root)
|
79
|
+
else
|
80
|
+
@root.match?(/[0-9]/) ? add_root(size) : add_root(size, @path_root)
|
81
|
+
end
|
78
82
|
end
|
79
83
|
|
80
84
|
def add_root(size = nil, dev = nil)
|
@@ -97,6 +101,7 @@ module Lvm2
|
|
97
101
|
end
|
98
102
|
end
|
99
103
|
|
104
|
+
# Configure hybrid system (encrypt + lvm)
|
100
105
|
class Hybrid < Root
|
101
106
|
def initialize(devs, options)
|
102
107
|
super
|
data/lib/nito.rb
CHANGED
data/lib/sgdisk.rb
CHANGED
@@ -42,13 +42,13 @@ module Sgdisk
|
|
42
42
|
def make_boot
|
43
43
|
@boot || return
|
44
44
|
|
45
|
-
partition @boot, @boot_code,
|
45
|
+
partition @boot, @boot_code, "0:+#{Getch::OPTIONS[:boot_size]}MiB"
|
46
46
|
end
|
47
47
|
|
48
48
|
def make_swap
|
49
49
|
@swap || return
|
50
50
|
|
51
|
-
mem = Getch::
|
51
|
+
mem = "#{Getch::OPTIONS[:swap_size]}M"
|
52
52
|
partition @swap, @swap_code, "0:+#{mem}"
|
53
53
|
end
|
54
54
|
|
@@ -98,7 +98,7 @@ module Sgdisk
|
|
98
98
|
disk = dev[/^[a-z]+/]
|
99
99
|
cmd = Getch::Command.new("sgdisk -E /dev/#{disk}")
|
100
100
|
end_position = cmd.res.to_i
|
101
|
-
(
|
101
|
+
(end_position - (end_position + 1) % 2048)
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
@@ -135,11 +135,11 @@ module Sgdisk
|
|
135
135
|
def make_boot
|
136
136
|
@boot || return
|
137
137
|
|
138
|
-
partition @boot, @boot_code,
|
138
|
+
partition @boot, @boot_code, "0:+#{Getch::OPTIONS[:boot_size]}MiB"
|
139
139
|
end
|
140
140
|
|
141
141
|
def make_swap
|
142
|
-
mem = Getch::
|
142
|
+
mem = "#{Getch::OPTIONS[:swap_size]}M"
|
143
143
|
partition @swap, @swap_code, "0:+#{mem}"
|
144
144
|
add_zlog
|
145
145
|
add_zcache
|
data.tar.gz.sig
CHANGED
Binary file
|
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.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- szorfein
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
urXgRIzALxd/xazPCnoLSXPzfJSI6Y77S1EBvhPd9RaSO8IyH9RhPDP9mnTvW2Kl
|
37
37
|
NAUnoL+txK5a
|
38
38
|
-----END CERTIFICATE-----
|
39
|
-
date: 2024-10-
|
39
|
+
date: 2024-10-15 00:00:00.000000000 Z
|
40
40
|
dependencies: []
|
41
41
|
description:
|
42
42
|
email:
|
metadata.gz.sig
CHANGED
Binary file
|