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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8949c8a35b78615d49e8a79daadbd70052adc9e84291bdc2832ecf58bbb185d
4
- data.tar.gz: e44e2466636fa47f72be581818f4648e19a7291ccdf435358b97241b1b12c77b
3
+ metadata.gz: 3632483fb40d3ce1ac81399c4e4d70c2391b99f80ecb38f8f9105a615d7f6def
4
+ data.tar.gz: 9481039af6ba7c062c0f0b4e6e1e0817cf7e7480c76a95e36558be8ea9961e56
5
5
  SHA512:
6
- metadata.gz: c4fd298a8d04ddabaf2e1bc53f27af50131479190a7df542840f2557ea227677b42bf7b2bfee25185d305e54b71a934c5723f36e4b0631b50eecba186b1b5e90
7
- data.tar.gz: 31b0a7f44918791c981b8f4af725d3be13565098dec21fd4948619e3edfa4c66f61fd93e4d646921d5df7be315e77c5ac0d4aeb3fb5ea1b26a9deab900520f32
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**: `BIOS`, `crypted disk` and `musl` will use `Grub2` and `systemd-boot` for `UEFI`.
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.5`.
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/sdc`
80
+ Install Gentoo on LVM and use a different root disk `/dev/vdc`
81
81
 
82
- # getch --format ext4 --lvm --disk sdc
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 vg0
110
+ # vgdisplay | grep vg
106
111
  # vgremove -f vg0
107
112
  # pvremove -f /dev/sdb
108
113
 
data/lib/fstab/root.rb CHANGED
@@ -37,7 +37,7 @@ module Fstab
37
37
  @efi || return
38
38
 
39
39
  uuid = gen_uuid @efi
40
- line = "UUID=#{uuid} /efi vfat defaults,nosuid,nodev 0 0"
40
+ line = "UUID=#{uuid} /efi vfat defaults,nosuid,nodev 0 2"
41
41
  echo_a @conf, line
42
42
  end
43
43
 
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
- line = "/dev/mapper/swap-luks none swap sw 0 0" :
19
- line = "UUID=#{uuid} swap swap rw,noatime,discard 0 0"
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 'Exec: ' + @cmd
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
- $?.success? && return
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' then "source /etc/profile && emerge --changed-use #{@cmd}"
143
- when 'void' then "/usr/bin/xbps-install -y #{@cmd}"
144
- end
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
@@ -70,7 +70,7 @@ module Getch
70
70
  @log.fatal('OPTIONS[:os] not supported yet.')
71
71
  end
72
72
 
73
- File.exist? "#{OPTIONS[:mountpoint]}#{@keymaps_dir}" ||
73
+ File.exist?("#{OPTIONS[:mountpoint]}#{@keymaps_dir}") ||
74
74
  @log.fatal("No dir keymaps #{@keymaps_dir} found.")
75
75
  end
76
76
  end
@@ -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 = 'COMMON_FLAGS="-march=native -O2 -pipe -fomit-frame-pointer"'
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/
@@ -44,7 +44,7 @@ module Getch
44
44
  return unless Helpers.systemd?
45
45
 
46
46
  src = "/usr/share/zoneinfo/#{OPTIONS[:timezone]}"
47
- dest = "/etc/localtime"
47
+ dest = '/etc/localtime'
48
48
  Getch::Chroot.new('ln', '-sf', src, dest)
49
49
  end
50
50
  end
data/lib/getch/device.rb CHANGED
@@ -52,6 +52,8 @@ module Getch
52
52
  private
53
53
 
54
54
  def load_devs
55
+ raise ArgumentError, 'No disk for root, use --disk DISK.' unless OPTIONS[:disk]
56
+
55
57
  if File.exist? @file
56
58
  DEVS.merge! YAML.load_file @file
57
59
  else
@@ -26,8 +26,12 @@ module Getch
26
26
  bootctl
27
27
  end
28
28
 
29
- # ChrootOutput.new('emerge --config sys-kernel/gentoo-kernel')
30
- ChrootOutput.new('emerge --config sys-kernel/gentoo-kernel-bin') # should also reload grub-mkconfig
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
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Getch
4
4
  module Gentoo
5
+ # last steps
5
6
  class Finalize
6
7
  def initialize
7
8
  x
@@ -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
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Getch
4
4
  module Gentoo
5
+ # install|enable services for the next boot
5
6
  class Services
6
7
  def initialize
7
8
  x
@@ -73,8 +73,11 @@ module Getch
73
73
  def make
74
74
  Install.new('sys-kernel/installkernel')
75
75
 
76
- # Install.new 'sys-kernel/gentoo-kernel'
77
- Install.new 'sys-kernel/gentoo-kernel-bin'
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
@@ -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
- "stage3-amd64-musl-#{@release}.tar.xz" :
15
- "stage3-amd64-systemd-#{@release}.tar.xz"
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 + '/releases/amd64/autobuilds/latest-stage3-amd64-musl.txt' :
30
- @mirror + '/releases/amd64/autobuilds/latest-stage3-amd64-systemd.txt'
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 + '/releases/amd64/autobuilds/' + file, @stage_file)
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 "Download other files..."
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? then
74
+ if status.success?
70
75
  @log.result_ok
71
76
  else
72
77
  cleaning
@@ -1,5 +1,6 @@
1
1
  module Getch
2
2
  module Gentoo
3
+ # install required/usefull packages
3
4
  class Terraform
4
5
  def initialize
5
6
  x
@@ -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 = "#{OPTIONS[:mountpoint]}/etc/portage/repos.conf/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
@@ -4,6 +4,7 @@ require 'nito'
4
4
 
5
5
  module Getch
6
6
  module Gentoo
7
+ # Utility to configure use flag on Gentoo
7
8
  class Use
8
9
  include NiTo
9
10
 
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
- mem += 'K'
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Getch
4
- VERSION = '0.7.3'
4
+ VERSION = '0.11.0'
5
5
  end
@@ -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
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Getch
4
4
  module Void
5
+ # last steps
5
6
  class Finalize
6
7
  def initialize
7
8
  x
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Getch
4
4
  module Void
5
+ # config after installing the rootfs
5
6
  class PostConfig
6
7
  def initialize
7
8
  x
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Getch
4
4
  module Void
5
+ # config before installing the system
5
6
  class PreConfig
6
7
  def initialize
7
8
  x
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Getch
4
4
  module Void
5
+ # install/enable services
5
6
  class Services
6
7
  def initialize
7
8
  x
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Getch
4
4
  module Void
5
+ # system update
5
6
  class Update
6
7
  def initialize
7
8
  @log = Log.new
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: 'vg4',
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 " + OPTIONS[:os].capitalize + " Linux with the following args:\n"
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] ||= 'vg1'
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 = [ @path_root ]
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 = [ @path_root ]
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? dev || @log.fatal("add_pv - no #{dev} 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::Helpers.get_memory
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
- @home ?
76
- @root.match?(/[0-9]/) ? add_root : add_root(nil, @path_root) :
77
- @root.match?(/[0-9]/) ? add_root('16G') : add_root('16G', @path_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
@@ -67,6 +67,10 @@ module NiTo
67
67
  FileUtils.cp src, dest
68
68
  end
69
69
 
70
+ def mv(src, dest)
71
+ FileUtils.mv src, dest
72
+ end
73
+
70
74
  # create a void file
71
75
  def touch(file)
72
76
  File.write(file, '') unless File.exist? file
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, '0:+256MiB'
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::Helpers.get_memory
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
- ( end_position - ( end_position + 1 ) % 2048 )
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, '0:+2G'
138
+ partition @boot, @boot_code, "0:+#{Getch::OPTIONS[:boot_size]}MiB"
139
139
  end
140
140
 
141
141
  def make_swap
142
- mem = Getch::Helpers.get_memory
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.7.3
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-03 00:00:00.000000000 Z
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