getch 0.1.6 → 0.1.9

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.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.md +17 -26
  4. data/assets/system.conf +38 -0
  5. data/lib/cmdline.rb +128 -0
  6. data/lib/getch/command.rb +31 -21
  7. data/lib/getch/config/gentoo.rb +22 -23
  8. data/lib/getch/config/void.rb +8 -10
  9. data/lib/getch/config.rb +5 -2
  10. data/lib/getch/filesystem/clean.rb +15 -15
  11. data/lib/getch/filesystem/device.rb +3 -1
  12. data/lib/getch/filesystem/ext4/config.rb +8 -4
  13. data/lib/getch/filesystem/ext4/deps.rb +3 -1
  14. data/lib/getch/filesystem/ext4/device.rb +2 -3
  15. data/lib/getch/filesystem/ext4/encrypt/config.rb +12 -7
  16. data/lib/getch/filesystem/ext4/encrypt/deps.rb +4 -2
  17. data/lib/getch/filesystem/ext4/encrypt/device.rb +5 -3
  18. data/lib/getch/filesystem/ext4/encrypt/format.rb +4 -1
  19. data/lib/getch/filesystem/ext4/encrypt/mount.rb +3 -2
  20. data/lib/getch/filesystem/ext4/encrypt/partition.rb +21 -21
  21. data/lib/getch/filesystem/ext4/encrypt/void.rb +22 -21
  22. data/lib/getch/filesystem/ext4/encrypt.rb +2 -0
  23. data/lib/getch/filesystem/ext4/format.rb +3 -0
  24. data/lib/getch/filesystem/ext4/mount.rb +3 -0
  25. data/lib/getch/filesystem/ext4/partition.rb +9 -6
  26. data/lib/getch/filesystem/ext4/void.rb +8 -7
  27. data/lib/getch/filesystem/ext4.rb +2 -0
  28. data/lib/getch/filesystem/lvm/config.rb +7 -22
  29. data/lib/getch/filesystem/lvm/deps.rb +6 -4
  30. data/lib/getch/filesystem/lvm/device.rb +2 -0
  31. data/lib/getch/filesystem/lvm/encrypt/config.rb +12 -9
  32. data/lib/getch/filesystem/lvm/encrypt/deps.rb +6 -3
  33. data/lib/getch/filesystem/lvm/encrypt/device.rb +4 -2
  34. data/lib/getch/filesystem/lvm/encrypt/format.rb +4 -0
  35. data/lib/getch/filesystem/lvm/encrypt/mount.rb +3 -0
  36. data/lib/getch/filesystem/lvm/encrypt/partition.rb +7 -7
  37. data/lib/getch/filesystem/lvm/encrypt/void.rb +20 -19
  38. data/lib/getch/filesystem/lvm/encrypt.rb +2 -0
  39. data/lib/getch/filesystem/lvm/format.rb +3 -0
  40. data/lib/getch/filesystem/lvm/mount.rb +3 -0
  41. data/lib/getch/filesystem/lvm/partition.rb +8 -5
  42. data/lib/getch/filesystem/lvm/void.rb +7 -6
  43. data/lib/getch/filesystem/lvm.rb +2 -0
  44. data/lib/getch/filesystem/mount.rb +19 -12
  45. data/lib/getch/filesystem/partition.rb +16 -8
  46. data/lib/getch/filesystem/zfs/config.rb +9 -23
  47. data/lib/getch/filesystem/zfs/deps.rb +22 -57
  48. data/lib/getch/filesystem/zfs/device.rb +3 -1
  49. data/lib/getch/filesystem/zfs/encrypt/config.rb +10 -26
  50. data/lib/getch/filesystem/zfs/encrypt/deps.rb +25 -60
  51. data/lib/getch/filesystem/zfs/encrypt/device.rb +3 -1
  52. data/lib/getch/filesystem/zfs/encrypt/format.rb +12 -8
  53. data/lib/getch/filesystem/zfs/encrypt/mount.rb +13 -8
  54. data/lib/getch/filesystem/zfs/encrypt/partition.rb +18 -15
  55. data/lib/getch/filesystem/zfs/encrypt/void.rb +23 -22
  56. data/lib/getch/filesystem/zfs/encrypt.rb +2 -0
  57. data/lib/getch/filesystem/zfs/format.rb +9 -5
  58. data/lib/getch/filesystem/zfs/mount.rb +9 -7
  59. data/lib/getch/filesystem/zfs/partition.rb +15 -12
  60. data/lib/getch/filesystem/zfs/void.rb +20 -20
  61. data/lib/getch/filesystem/zfs.rb +2 -0
  62. data/lib/getch/filesystem.rb +2 -0
  63. data/lib/getch/gentoo/boot.rb +21 -72
  64. data/lib/getch/gentoo/bootloader.rb +68 -0
  65. data/lib/getch/gentoo/chroot.rb +26 -33
  66. data/lib/getch/gentoo/config.rb +30 -26
  67. data/lib/getch/gentoo/sources.rb +55 -66
  68. data/lib/getch/gentoo/stage.rb +12 -12
  69. data/lib/getch/gentoo/use.rb +3 -7
  70. data/lib/getch/gentoo/use_flag.rb +77 -51
  71. data/lib/getch/gentoo.rb +22 -8
  72. data/lib/getch/guard.rb +50 -43
  73. data/lib/getch/helpers.rb +155 -143
  74. data/lib/getch/log.rb +7 -5
  75. data/lib/getch/options.rb +16 -14
  76. data/lib/getch/states.rb +10 -3
  77. data/lib/getch/version.rb +1 -1
  78. data/lib/getch/void/boot.rb +18 -14
  79. data/lib/getch/void/chroot.rb +20 -19
  80. data/lib/getch/void/config.rb +20 -17
  81. data/lib/getch/void/stage.rb +13 -14
  82. data/lib/getch/void.rb +7 -1
  83. data/lib/getch.rb +13 -5
  84. data.tar.gz.sig +0 -0
  85. metadata +6 -5
  86. metadata.gz.sig +0 -0
  87. data/lib/getch/filesystem/.mount.rb.swp +0 -0
  88. data/lib/getch/filesystem/zfs/encrypt/.mount.rb.swp +0 -0
@@ -1,4 +1,4 @@
1
- require_relative '../helpers'
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Getch
4
4
  module Void
@@ -6,7 +6,7 @@ module Getch
6
6
  include Helpers::Void
7
7
 
8
8
  def initialize
9
- @state = Getch::States.new()
9
+ @state = Getch::States.new
10
10
  @pkgs = []
11
11
  mount
12
12
  end
@@ -14,39 +14,40 @@ module Getch
14
14
  # https://docs.voidlinux.org/installation/guides/chroot.html#install-base-system-rootfs-method-only
15
15
  def update
16
16
  return if STATES[:gentoo_update]
17
- command_output "/usr/bin/xbps-install -Suy xbps" # y to force (--yes)
18
- command_output "/usr/bin/xbps-install -uy"
19
- command_output "/usr/bin/xbps-install -y base-system"
20
- #command_output "/usr/bin/xbps-remove base-voidstrap"
17
+
18
+ command_output '/usr/bin/xbps-install -Suy xbps' # y to force (--yes)
19
+ command_output '/usr/bin/xbps-install -uy'
20
+ command_output '/usr/bin/xbps-install -y base-system'
21
+ #command_output '/usr/bin/xbps-remove base-voidstrap'
21
22
  @state.update
22
23
  end
23
24
 
24
25
  def extras
25
- @pkgs << "vim"
26
- @pkgs << "iptables"
27
- @pkgs << "iwd"
26
+ @pkgs << 'vim'
27
+ @pkgs << 'iptables'
28
+ @pkgs << 'iwd'
28
29
  end
29
30
 
30
31
  def fs
31
- @pkgs << "lvm2" if OPTIONS[:fs] == 'lvm'
32
- @pkgs << "zfs" if OPTIONS[:fs] == 'zfs'
33
- @pkgs << "cryptsetup" if OPTIONS[:encrypt]
32
+ @pkgs << 'lvm2' if OPTIONS[:fs] == 'lvm'
33
+ @pkgs << 'zfs' if OPTIONS[:fs] == 'zfs'
34
+ @pkgs << 'cryptsetup' if OPTIONS[:encrypt]
34
35
  end
35
36
 
36
37
  def install_pkgs
37
- all_pkgs = @pkgs.join(" ")
38
+ all_pkgs = @pkgs.join(' ')
38
39
  command_output "/usr/bin/xbps-install -y #{all_pkgs}"
39
40
  end
40
41
 
41
42
  private
42
43
 
43
44
  def mount
44
- puts "Populate /proc, /sys and /dev."
45
- Helpers::exec_or_die("mount --types proc /proc \"#{MOUNTPOINT}/proc\"")
46
- Helpers::exec_or_die("mount --rbind /sys \"#{MOUNTPOINT}/sys\"")
47
- Helpers::exec_or_die("mount --make-rslave \"#{MOUNTPOINT}/sys\"")
48
- Helpers::exec_or_die("mount --rbind /dev \"#{MOUNTPOINT}/dev\"")
49
- Helpers::exec_or_die("mount --make-rslave \"#{MOUNTPOINT}/dev\"")
45
+ puts 'Populate /proc, /sys and /dev.'
46
+ Helpers.exec_or_die("mount --types proc /proc \"#{MOUNTPOINT}/proc\"")
47
+ Helpers.exec_or_die("mount --rbind /sys \"#{MOUNTPOINT}/sys\"")
48
+ Helpers.exec_or_die("mount --make-rslave \"#{MOUNTPOINT}/sys\"")
49
+ Helpers.exec_or_die("mount --rbind /dev \"#{MOUNTPOINT}/dev\"")
50
+ Helpers.exec_or_die("mount --make-rslave \"#{MOUNTPOINT}/dev\"")
50
51
  # Maybe add /dev/shm like describe here:
51
52
  # https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Base
52
53
  end
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fileutils'
2
4
  require 'securerandom'
3
- require_relative '../helpers'
4
5
 
5
6
  module Getch
6
7
  module Void
@@ -22,34 +23,34 @@ module Getch
22
23
  end
23
24
 
24
25
  def network
25
- print " => Copying /etc/resolv.conf..."
26
+ print ' => Copying /etc/resolv.conf...'
26
27
  src = '/etc/resolv.conf'
27
28
  dest = "#{@network_dir}/resolv.conf"
28
- FileUtils.copy_file(src, dest, preserve = true)
29
+ FileUtils.copy_file(src, dest)
29
30
  puts "\s[Ok]"
30
31
  end
31
32
 
32
33
  def system
33
- print " => Updating configs system..."
34
+ print ' => Updating configs system...'
34
35
  control_options
35
36
  rc = "#{MOUNTPOINT}/etc/rc.conf"
36
- add_line(rc, "HARDWARECLOCK=\"UTC\"") if !search(rc, /^HARDWARECLOCK/)
37
- add_line(rc, "KEYMAP=\"#{OPTIONS[:keymap]}\"") if !search(rc, /^KEYMAP/)
38
- add_line(rc, "TIMEZONE=\"#{OPTIONS[:zoneinfo]}\"") if !search(rc, /^TIMEZONE/)
39
- add_line(rc, "HOSTNAME=\"#{@hostname}\"") if !search(rc, /^HOSTNAME/)
37
+ add_line(rc, 'HARDWARECLOCK="UTC"') unless search(rc, /^HARDWARECLOCK/)
38
+ add_line(rc, "KEYMAP=\"#{OPTIONS[:keymap]}\"") unless search(rc, /^KEYMAP/)
39
+ add_line(rc, "TIMEZONE=\"#{OPTIONS[:zoneinfo]}\"") unless search(rc, /^TIMEZONE/)
40
+ add_line(rc, "HOSTNAME=\"#{@hostname}\"") unless search(rc, /^HOSTNAME/)
40
41
  puts "\s[OK]"
41
42
  end
42
43
 
43
44
  def locale
44
- print " => Updating locale system..."
45
+ print ' => Updating locale system...'
45
46
  control_options
46
47
  conf = "#{MOUNTPOINT}/etc/locale.conf"
47
48
  File.write(conf, "LANG=#{@lang}\n")
48
- add_line(conf, "LC_COLLATE=C")
49
+ add_line(conf, 'LC_COLLATE=C')
49
50
  conf = "#{MOUNTPOINT}/etc/default/libc-locales"
50
51
  add_line(conf, @utf8)
51
52
  puts "\s[OK]"
52
- command "xbps-reconfigure -f glibc-locales"
53
+ command 'xbps-reconfigure -f glibc-locales'
53
54
  end
54
55
 
55
56
  private
@@ -65,7 +66,7 @@ module Getch
65
66
  Dir.glob("#{MOUNTPOINT}/usr/share/kbd/keymaps/**/#{keys}.map.gz") { |f|
66
67
  @keymap = f
67
68
  }
68
- raise ArgumentError, "No keymap #{@keymap} found" if ! @keymap
69
+ raise ArgumentError, "No keymap #{@keymap} found" unless @keymap
69
70
  end
70
71
 
71
72
  def search_zone(zone)
@@ -76,11 +77,13 @@ module Getch
76
77
 
77
78
  def search_utf8(lang)
78
79
  @utf8, @lang = nil, nil
79
- File.open("#{MOUNTPOINT}/etc/default/libc-locales").each { |l|
80
- @utf8 = $~[0] if l.match(/#{lang}[. ]+[utf\-8 ]+/i)
81
- @lang = $~[0] if l.match(/#{lang}[. ]+utf\-8/i)
82
- }
83
- raise ArgumentError, "Lang #{lang} no found" if !@utf8
80
+ File.open("#{MOUNTPOINT}/etc/default/libc-locales").each do |l|
81
+ @utf8 = l.delete_prefix('#') if l.match(/#{lang}.UTF-8/)
82
+
83
+ found = l.split if l.match(/#{lang}.UTF-8/)
84
+ @lang = found[0].delete_prefix('#') if found
85
+ end
86
+ raise ArgumentError, "Lang #{lang} no found" unless @utf8
84
87
  end
85
88
  end
86
89
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'open-uri'
2
4
  require 'open3'
3
5
 
@@ -5,8 +7,8 @@ module Getch
5
7
  module Void
6
8
  class RootFS
7
9
  def initialize
8
- @url = "https://alpha.de.repo.voidlinux.org/live/current"
9
- @file = "sha256sum.sig"
10
+ @url = 'https://alpha.de.repo.voidlinux.org/live/current'
11
+ @file = 'sha256sum.txt'
10
12
  @xbps = false
11
13
  Dir.chdir(MOUNTPOINT)
12
14
  end
@@ -15,17 +17,18 @@ module Getch
15
17
  def search_archive
16
18
  yurl = "#{@url}/#{@file}"
17
19
  puts "Open #{yurl}"
18
- Helpers::get_file_online(yurl, @file)
19
- File.open(@file).each { |l|
20
- @xbps = l.tr('()', '').split(" ") if l.match(/void-x86_64-ROOTFS-[\d._]+.tar.xz/)
21
- }
20
+ Helpers.get_file_online(yurl, @file)
21
+ File.open(@file).each do |l|
22
+ @xbps = l.tr('()', '').split(' ') if l.match(/void-x86_64-ROOTFS-[\d._]+.tar.xz/)
23
+ end
22
24
  end
23
25
 
24
26
  def download
25
- raise StandardError, "No file found, retry later." if !@xbps
27
+ raise StandardError, 'No file found, retry later.' unless @xbps
26
28
  return if File.exist? @xbps[1]
29
+
27
30
  puts "Downloading #{@xbps[1]}..."
28
- Helpers::get_file_online("#{@url}/#{@xbps[1]}", @xbps[1])
31
+ Helpers.get_file_online("#{@url}/#{@xbps[1]}", @xbps[1])
29
32
  end
30
33
 
31
34
  def checksum
@@ -58,12 +61,8 @@ module Getch
58
61
  end
59
62
 
60
63
  def cleaning
61
- Dir.glob("void-x86_64*.tar.xz").each do |f|
62
- File.delete(f)
63
- end
64
- Dir.glob("sha256*").each do |f|
65
- File.delete(f)
66
- end
64
+ Dir.glob('void-x86_64*.tar.xz').each { |f| File.delete(f) }
65
+ Dir.glob('sha256*').each { |f| File.delete(f) }
67
66
  end
68
67
  end
69
68
  end
data/lib/getch/void.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'void/stage'
2
4
  require_relative 'void/config'
3
5
  require_relative 'void/chroot'
@@ -8,11 +10,12 @@ module Getch
8
10
  module Void
9
11
  class Main
10
12
  def initialize
11
- @state = Getch::States.new()
13
+ @state = Getch::States.new
12
14
  end
13
15
 
14
16
  def root_fs
15
17
  return if STATES[:gentoo_base]
18
+
16
19
  xbps = Getch::Void::RootFS.new
17
20
  xbps.search_archive
18
21
  xbps.download
@@ -22,6 +25,7 @@ module Getch
22
25
 
23
26
  def config
24
27
  return if STATES[:gentoo_config]
28
+
25
29
  config = Getch::Void::Config.new
26
30
  config.host
27
31
  config.network
@@ -32,6 +36,7 @@ module Getch
32
36
 
33
37
  def chroot
34
38
  return if STATES[:gentoo_kernel]
39
+
35
40
  chroot = Getch::Void::Chroot.new
36
41
  chroot.update
37
42
  chroot.fs
@@ -41,6 +46,7 @@ module Getch
41
46
 
42
47
  def kernel
43
48
  return if STATES[:gentoo_kernel]
49
+
44
50
  Getch::Void::Sources.new
45
51
  @state.kernel
46
52
  end
data/lib/getch.rb CHANGED
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'getch/helpers'
1
4
  require_relative 'getch/options'
2
5
  require_relative 'getch/states'
3
6
  require_relative 'getch/gentoo'
4
7
  require_relative 'getch/void'
5
8
  require_relative 'getch/filesystem'
6
9
  require_relative 'getch/command'
7
- require_relative 'getch/helpers'
8
10
  require_relative 'getch/log'
9
11
  require_relative 'getch/config'
10
12
  require_relative 'getch/guard'
@@ -34,10 +36,11 @@ module Getch
34
36
  :gentoo_base => false,
35
37
  :gentoo_config => false,
36
38
  :gentoo_update => false,
39
+ :gentoo_bootloader => false,
37
40
  :gentoo_kernel => false
38
41
  }
39
42
 
40
- MOUNTPOINT = "/mnt/gentoo"
43
+ MOUNTPOINT = '/mnt/gentoo'
41
44
 
42
45
  DEFAULT_FS = {
43
46
  true => {
@@ -67,7 +70,8 @@ module Getch
67
70
  end
68
71
 
69
72
  def resume
70
- raise "No disk, use at least getch with -d DISK" if !OPTIONS[:disk]
73
+ raise 'No disk, use at least getch with -d DISK' unless OPTIONS[:disk]
74
+
71
75
  puts "\nBuild " + OPTIONS[:os].capitalize + " Linux with the following args:\n"
72
76
  puts
73
77
  puts "\tLang: #{OPTIONS[:language]}"
@@ -82,7 +86,7 @@ module Getch
82
86
  puts "\tseparate-cache disk: #{OPTIONS[:cache_disk]}"
83
87
  puts "\tseparate-home disk: #{OPTIONS[:home_disk]}"
84
88
  puts
85
- print "Continue? (y,N) "
89
+ print 'Continue? (y,N) '
86
90
  case gets.chomp
87
91
  when /^y|^Y/
88
92
  return
@@ -93,11 +97,12 @@ module Getch
93
97
 
94
98
  def partition
95
99
  return if STATES[:partition]
100
+
96
101
  puts
97
102
  print "Partition and format disk #{OPTIONS[:disk]}, this will erase all data, continue? (y,N) "
98
103
  case gets.chomp
99
104
  when /^y|^Y/
100
- @log.info("Partition start")
105
+ @log.info('Partition start')
101
106
  @class_fs::Partition.new
102
107
  else
103
108
  exit
@@ -106,11 +111,13 @@ module Getch
106
111
 
107
112
  def format
108
113
  return if STATES[:format]
114
+
109
115
  @class_fs::Format.new
110
116
  end
111
117
 
112
118
  def mount
113
119
  return if STATES[:mount]
120
+
114
121
  @class_fs::Mount.new.run
115
122
  end
116
123
 
@@ -130,6 +137,7 @@ module Getch
130
137
  gentoo.stage3
131
138
  gentoo.config
132
139
  gentoo.chroot
140
+ gentoo.bootloader
133
141
  gentoo.kernel
134
142
  gentoo.boot
135
143
  end
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.1.6
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - szorfein
@@ -35,7 +35,7 @@ cert_chain:
35
35
  F9Dl4EPzjBJOgQWf+NxzxNuNKI46Lp5Q8AI+xtDUHAPbSswHa40BA6ChFehP+j0L
36
36
  fg==
37
37
  -----END CERTIFICATE-----
38
- date: 2021-06-30 00:00:00.000000000 Z
38
+ date: 2022-01-26 00:00:00.000000000 Z
39
39
  dependencies: []
40
40
  description:
41
41
  email:
@@ -48,14 +48,15 @@ extra_rdoc_files:
48
48
  files:
49
49
  - README.md
50
50
  - assets/network-stack.conf
51
+ - assets/system.conf
51
52
  - bin/getch
53
+ - lib/cmdline.rb
52
54
  - lib/getch.rb
53
55
  - lib/getch/command.rb
54
56
  - lib/getch/config.rb
55
57
  - lib/getch/config/gentoo.rb
56
58
  - lib/getch/config/void.rb
57
59
  - lib/getch/filesystem.rb
58
- - lib/getch/filesystem/.mount.rb.swp
59
60
  - lib/getch/filesystem/clean.rb
60
61
  - lib/getch/filesystem/device.rb
61
62
  - lib/getch/filesystem/ext4.rb
@@ -97,7 +98,6 @@ files:
97
98
  - lib/getch/filesystem/zfs/deps.rb
98
99
  - lib/getch/filesystem/zfs/device.rb
99
100
  - lib/getch/filesystem/zfs/encrypt.rb
100
- - lib/getch/filesystem/zfs/encrypt/.mount.rb.swp
101
101
  - lib/getch/filesystem/zfs/encrypt/config.rb
102
102
  - lib/getch/filesystem/zfs/encrypt/deps.rb
103
103
  - lib/getch/filesystem/zfs/encrypt/device.rb
@@ -111,6 +111,7 @@ files:
111
111
  - lib/getch/filesystem/zfs/void.rb
112
112
  - lib/getch/gentoo.rb
113
113
  - lib/getch/gentoo/boot.rb
114
+ - lib/getch/gentoo/bootloader.rb
114
115
  - lib/getch/gentoo/chroot.rb
115
116
  - lib/getch/gentoo/config.rb
116
117
  - lib/getch/gentoo/sources.rb
@@ -151,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
152
  - !ruby/object:Gem::Version
152
153
  version: '0'
153
154
  requirements: []
154
- rubygems_version: 3.0.9
155
+ rubygems_version: 3.2.32
155
156
  signing_key:
156
157
  specification_version: 4
157
158
  summary: A CLI tool to install Gentoo
metadata.gz.sig CHANGED
Binary file
Binary file