getch 0.0.8 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CHANGELOG.md +44 -0
  5. data/README.md +57 -8
  6. data/bin/setup.sh +4 -2
  7. data/lib/getch.rb +43 -15
  8. data/lib/getch/command.rb +26 -5
  9. data/lib/getch/config.rb +58 -0
  10. data/lib/getch/filesystem.rb +6 -0
  11. data/lib/getch/filesystem/clean.rb +51 -0
  12. data/lib/getch/filesystem/device.rb +61 -0
  13. data/lib/getch/filesystem/ext4.rb +1 -0
  14. data/lib/getch/filesystem/ext4/config.rb +8 -9
  15. data/lib/getch/filesystem/ext4/device.rb +2 -7
  16. data/lib/getch/filesystem/ext4/encrypt/config.rb +69 -47
  17. data/lib/getch/filesystem/ext4/encrypt/deps.rb +21 -15
  18. data/lib/getch/filesystem/ext4/encrypt/device.rb +5 -9
  19. data/lib/getch/filesystem/ext4/encrypt/format.rb +10 -6
  20. data/lib/getch/filesystem/ext4/encrypt/mount.rb +6 -43
  21. data/lib/getch/filesystem/ext4/encrypt/partition.rb +57 -55
  22. data/lib/getch/filesystem/ext4/format.rb +3 -5
  23. data/lib/getch/filesystem/ext4/mount.rb +7 -46
  24. data/lib/getch/filesystem/ext4/partition.rb +16 -39
  25. data/lib/getch/filesystem/lvm.rb +1 -0
  26. data/lib/getch/filesystem/lvm/config.rb +12 -15
  27. data/lib/getch/filesystem/lvm/deps.rb +5 -20
  28. data/lib/getch/filesystem/lvm/device.rb +33 -9
  29. data/lib/getch/filesystem/lvm/encrypt.rb +15 -0
  30. data/lib/getch/filesystem/lvm/encrypt/config.rb +71 -0
  31. data/lib/getch/filesystem/lvm/encrypt/deps.rb +46 -0
  32. data/lib/getch/filesystem/lvm/encrypt/device.rb +46 -0
  33. data/lib/getch/filesystem/lvm/encrypt/format.rb +32 -0
  34. data/lib/getch/filesystem/lvm/encrypt/mount.rb +25 -0
  35. data/lib/getch/filesystem/lvm/encrypt/partition.rb +80 -0
  36. data/lib/getch/filesystem/lvm/format.rb +11 -7
  37. data/lib/getch/filesystem/lvm/mount.rb +7 -46
  38. data/lib/getch/filesystem/lvm/partition.rb +19 -31
  39. data/lib/getch/filesystem/mount.rb +56 -0
  40. data/lib/getch/filesystem/partition.rb +77 -0
  41. data/lib/getch/filesystem/zfs.rb +14 -0
  42. data/lib/getch/filesystem/zfs/config.rb +57 -0
  43. data/lib/getch/filesystem/zfs/deps.rb +95 -0
  44. data/lib/getch/filesystem/zfs/device.rb +58 -0
  45. data/lib/getch/filesystem/zfs/encrypt.rb +15 -0
  46. data/lib/getch/filesystem/zfs/encrypt/config.rb +67 -0
  47. data/lib/getch/filesystem/zfs/encrypt/deps.rb +97 -0
  48. data/lib/getch/filesystem/zfs/encrypt/device.rb +60 -0
  49. data/lib/getch/filesystem/zfs/encrypt/format.rb +105 -0
  50. data/lib/getch/filesystem/zfs/encrypt/mount.rb +51 -0
  51. data/lib/getch/filesystem/zfs/encrypt/partition.rb +65 -0
  52. data/lib/getch/filesystem/zfs/format.rb +114 -0
  53. data/lib/getch/filesystem/zfs/mount.rb +48 -0
  54. data/lib/getch/filesystem/zfs/partition.rb +64 -0
  55. data/lib/getch/gentoo.rb +8 -4
  56. data/lib/getch/gentoo/boot.rb +32 -17
  57. data/lib/getch/gentoo/chroot.rb +12 -26
  58. data/lib/getch/gentoo/config.rb +37 -12
  59. data/lib/getch/gentoo/sources.rb +26 -29
  60. data/lib/getch/gentoo/use.rb +43 -0
  61. data/lib/getch/gentoo/use_flag.rb +64 -0
  62. data/lib/getch/helpers.rb +35 -13
  63. data/lib/getch/options.rb +23 -8
  64. data/lib/getch/version.rb +1 -1
  65. metadata +46 -18
  66. metadata.gz.sig +0 -0
@@ -0,0 +1,64 @@
1
+ # lib/use_flag.rb
2
+
3
+ module Getch::Gentoo
4
+ class UseFlag
5
+ def initialize(options)
6
+ @efi = Helpers::efi?
7
+ @o = options
8
+ end
9
+
10
+ def apply
11
+ systemd
12
+ kmod
13
+ grub
14
+ zfs
15
+ lvm
16
+ cryptsetup
17
+ end
18
+
19
+ private
20
+
21
+ def systemd
22
+ flags = []
23
+ use = Getch::Gentoo::Use.new('sys-apps/systemd')
24
+ flags << 'dns-over-tls'
25
+ flags << 'gnuefi' if @efi
26
+ use.add(flags)
27
+ end
28
+
29
+ def kmod
30
+ use = Getch::Gentoo::Use.new('sys-apps/kmod')
31
+ use.add('zstd', 'lzma')
32
+ end
33
+
34
+ def grub
35
+ return if @efi
36
+ flags = []
37
+ use = Getch::Gentoo::Use.new('sys-boot/grub')
38
+ flags << '-grub_platforms_efi-64'
39
+ flags << 'libzfs' if @o.fs == 'zfs'
40
+ flags << 'device-mapper' if @o.fs == 'lvm'
41
+ use.add(flags)
42
+ end
43
+
44
+ def zfs
45
+ return unless @o.fs == 'zfs'
46
+ use = Getch::Gentoo::Use.new('sys-fs/zfs-kmod')
47
+ use.add('rootfs')
48
+ use = Getch::Gentoo::Use.new('sys-fs/zfs')
49
+ use.add('rootfs')
50
+ end
51
+
52
+ def lvm
53
+ return unless @o.fs == 'lvm'
54
+ use = Getch::Gentoo::Use.new
55
+ use.add_global('lvm', 'device-mapper')
56
+ end
57
+
58
+ def cryptsetup
59
+ return unless @o.encrypt
60
+ use = Getch::Gentoo::Use.new
61
+ use.add_global('cryptsetup')
62
+ end
63
+ end
64
+ end
data/lib/getch/helpers.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'open-uri'
2
2
  require 'open3'
3
3
  require 'fileutils'
4
- require_relative 'command'
5
4
 
6
5
  module Helpers
7
6
  def self.efi?
@@ -31,19 +30,42 @@ module Helpers
31
30
  File.write path, content if ! File.exist? path
32
31
  end
33
32
 
34
- def self.emerge(pkgs, path)
35
- cmd = "chroot #{path} /bin/bash -c \"
36
- source /etc/profile
37
- emerge --changed-use #{pkgs}
38
- \""
39
- Getch::Command.new(cmd).run!
33
+ def self.mkdir(dir)
34
+ FileUtils.mkdir_p dir if ! Dir.exist? dir
40
35
  end
41
36
 
42
- def self.run_chroot(cmd, path)
43
- script = "chroot #{path} /bin/bash -c \"
44
- source /etc/profile
45
- #{cmd}
46
- \""
47
- Getch::Command.new(script).run!
37
+ def self.touch(file)
38
+ File.write file, '' if ! File.exist? file
39
+ end
40
+
41
+ def self.grep?(file, regex)
42
+ is_found = false
43
+ return is_found if ! File.exist? file
44
+ File.open(file) do |f|
45
+ f.each do |line|
46
+ is_found = true if line.match(regex)
47
+ end
48
+ end
49
+ is_found
50
+ end
51
+
52
+ def self.sys(cmd)
53
+ system(cmd)
54
+ unless $?.success?
55
+ raise "Error with #{cmd}"
56
+ end
57
+ end
58
+
59
+ def self.partuuid(dev)
60
+ `lsblk -o PARTUUID #{dev}`.match(/[\w]+-[\w]+-[\w]+-[\w]+-[\w]+/)
61
+ end
62
+
63
+ def self.uuid(dev)
64
+ `lsblk -do UUID #{dev}`.match(/[\w]+-[\w]+-[\w]+-[\w]+-[\w]+/)
65
+ end
66
+
67
+ # Used with ZFS for the pool name
68
+ def self.pool_id(dev)
69
+ `lsblk -o PARTUUID #{dev}`.delete("\n").delete("PARTUUID").match(/[\w]{5}/)
48
70
  end
49
71
  end
data/lib/getch/options.rb CHANGED
@@ -2,15 +2,18 @@ require 'optparse'
2
2
 
3
3
  module Getch
4
4
  class Options
5
- attr_reader :language, :zoneinfo, :keyboard, :disk, :fs, :username, :encrypt, :verbose
5
+ attr_reader :language, :zoneinfo, :keymap, :disk, :fs, :username, :boot_disk, :cache_disk, :home_disk, :encrypt, :verbose
6
6
 
7
7
  def initialize(argv)
8
8
  @language = DEFAULT_OPTIONS[:language]
9
9
  @zoneinfo = DEFAULT_OPTIONS[:zoneinfo]
10
- @keyboard = DEFAULT_OPTIONS[:keyboard]
10
+ @keymap = DEFAULT_OPTIONS[:keymap]
11
11
  @disk = DEFAULT_OPTIONS[:disk]
12
12
  @fs = DEFAULT_OPTIONS[:fs]
13
13
  @username = DEFAULT_OPTIONS[:username]
14
+ @boot_disk = DEFAULT_OPTIONS[:boot_disk]
15
+ @cache_disk = DEFAULT_OPTIONS[:cache_disk]
16
+ @home_disk = DEFAULT_OPTIONS[:home_disk]
14
17
  @encrypt = DEFAULT_OPTIONS[:encrypt]
15
18
  @verbose = DEFAULT_OPTIONS[:verbose]
16
19
  parse(argv)
@@ -26,20 +29,32 @@ module Getch
26
29
  opts.on("-z", "--zoneinfo ZONE", "Default is US/Eastern") do |zone|
27
30
  @zoneinfo = zone
28
31
  end
29
- opts.on("-k", "--keyboard KEY", "Default is us") do |key|
30
- @keyboard = key
32
+ opts.on("-k", "--keymap KEY", "Default is us") do |key|
33
+ @keymap = key
31
34
  end
32
- opts.on("-d", "--disk DISK", "Disk where install Gentoo (sda,sdb)") do |disk|
35
+ opts.on("-d", "--disk DISK", "Disk where install Gentoo (sda,sdb), default use #{@disk}") do |disk|
33
36
  @disk = disk
34
37
  end
35
- opts.on("-f", "--format FS", "Can be ext4, lvm. Default use ext4") do |fs|
38
+ opts.on("-f", "--format FS", "Can be ext4, lvm or zfs. Default use ext4") do |fs|
36
39
  @fs = fs
37
40
  DEFAULT_OPTIONS[:fs] = fs # dont known why, but it should be enforce
38
41
  end
39
- opts.on("-u", "--username USERNAME", "Initialize /home/username") do |user|
42
+ opts.on("-u", "--username USERNAME", "Create a new user /home/USERNAME with password.") do |user|
40
43
  @username = user
41
44
  end
42
- opts.on("--encrypt", "Encrypt your filesystem.!! NOT YET READY !!") do
45
+ opts.on("--separate-boot DISK", "Disk for the boot/efi partition, default use #{@disk}") do |boot|
46
+ @boot_disk = boot
47
+ DEFAULT_OPTIONS[:boot_disk] = boot
48
+ end
49
+ opts.on("--separate-cache DISK", "Disk for the swap partition, add ZIL/L2ARC for ZFS when set, default use #{@disk}") do |swap|
50
+ @cache_disk = swap
51
+ DEFAULT_OPTIONS[:cache_disk] = swap
52
+ end
53
+ opts.on("--separate-home DISK", "Disk for the /home partition, default is nil") do |home|
54
+ @home_disk = home
55
+ DEFAULT_OPTIONS[:home_disk] = home
56
+ end
57
+ opts.on("--encrypt", "Encrypt your system.") do
43
58
  @encrypt = true
44
59
  end
45
60
  opts.on("--verbose", "Write more messages to the standard output.") do
data/lib/getch/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Getch
2
- VERSION = '0.0.8'.freeze
2
+ VERSION = '0.1.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - szorfein
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIETTCCArWgAwIBAgIBATANBgkqhkiG9w0BAQsFADAoMSYwJAYDVQQDDB1zem9y
14
- ZmVpbi9EQz1wcm90b25tYWlsL0RDPWNvbTAeFw0yMDA0MzAxNzAxNDBaFw0yMTA0
15
- MzAxNzAxNDBaMCgxJjAkBgNVBAMMHXN6b3JmZWluL0RDPXByb3Rvbm1haWwvREM9
14
+ ZmVpbi9EQz1wcm90b25tYWlsL0RDPWNvbTAeFw0yMTA1MTEyMTAzNDZaFw0yMjA1
15
+ MTEyMTAzNDZaMCgxJjAkBgNVBAMMHXN6b3JmZWluL0RDPXByb3Rvbm1haWwvREM9
16
16
  Y29tMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAxCTYZRndCTRy18rE
17
17
  exr2wig/staa0G5kt99xqaBYD0dnIRBr/GO5dFntlBVwmefQlTrNbygVUIYTb8Vg
18
18
  B1oX3v/LLW9SRQcWaZwou0tARqanm5WhgV1ZYQTs22endTazsDHw0uhM3V+FgDh+
@@ -25,19 +25,19 @@ cert_chain:
25
25
  BgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUc8XWveAjxS5fVEOZeeZe
26
26
  uU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cVzZpIfOLvy03tn5
34
+ dAHfUn//hrBJAT9EXRHNUoLyEmFsCPabTCXjQH6EM2uBcsrjQN4SlgBNzsKc8bS4
35
+ F9Dl4EPzjBJOgQWf+NxzxNuNKI46Lp5Q8AI+xtDUHAPbSswHa40BA6ChFehP+j0L
36
+ fg==
37
37
  -----END CERTIFICATE-----
38
- date: 2020-09-30 00:00:00.000000000 Z
38
+ date: 2021-05-17 00:00:00.000000000 Z
39
39
  dependencies: []
40
- description:
40
+ description:
41
41
  email:
42
42
  - szorfein@protonmail.com
43
43
  executables:
@@ -54,7 +54,10 @@ files:
54
54
  - getch.gemspec
55
55
  - lib/getch.rb
56
56
  - lib/getch/command.rb
57
+ - lib/getch/config.rb
57
58
  - lib/getch/filesystem.rb
59
+ - lib/getch/filesystem/clean.rb
60
+ - lib/getch/filesystem/device.rb
58
61
  - lib/getch/filesystem/ext4.rb
59
62
  - lib/getch/filesystem/ext4/config.rb
60
63
  - lib/getch/filesystem/ext4/deps.rb
@@ -73,15 +76,40 @@ files:
73
76
  - lib/getch/filesystem/lvm/config.rb
74
77
  - lib/getch/filesystem/lvm/deps.rb
75
78
  - lib/getch/filesystem/lvm/device.rb
79
+ - lib/getch/filesystem/lvm/encrypt.rb
80
+ - lib/getch/filesystem/lvm/encrypt/config.rb
81
+ - lib/getch/filesystem/lvm/encrypt/deps.rb
82
+ - lib/getch/filesystem/lvm/encrypt/device.rb
83
+ - lib/getch/filesystem/lvm/encrypt/format.rb
84
+ - lib/getch/filesystem/lvm/encrypt/mount.rb
85
+ - lib/getch/filesystem/lvm/encrypt/partition.rb
76
86
  - lib/getch/filesystem/lvm/format.rb
77
87
  - lib/getch/filesystem/lvm/mount.rb
78
88
  - lib/getch/filesystem/lvm/partition.rb
89
+ - lib/getch/filesystem/mount.rb
90
+ - lib/getch/filesystem/partition.rb
91
+ - lib/getch/filesystem/zfs.rb
92
+ - lib/getch/filesystem/zfs/config.rb
93
+ - lib/getch/filesystem/zfs/deps.rb
94
+ - lib/getch/filesystem/zfs/device.rb
95
+ - lib/getch/filesystem/zfs/encrypt.rb
96
+ - lib/getch/filesystem/zfs/encrypt/config.rb
97
+ - lib/getch/filesystem/zfs/encrypt/deps.rb
98
+ - lib/getch/filesystem/zfs/encrypt/device.rb
99
+ - lib/getch/filesystem/zfs/encrypt/format.rb
100
+ - lib/getch/filesystem/zfs/encrypt/mount.rb
101
+ - lib/getch/filesystem/zfs/encrypt/partition.rb
102
+ - lib/getch/filesystem/zfs/format.rb
103
+ - lib/getch/filesystem/zfs/mount.rb
104
+ - lib/getch/filesystem/zfs/partition.rb
79
105
  - lib/getch/gentoo.rb
80
106
  - lib/getch/gentoo/boot.rb
81
107
  - lib/getch/gentoo/chroot.rb
82
108
  - lib/getch/gentoo/config.rb
83
109
  - lib/getch/gentoo/sources.rb
84
110
  - lib/getch/gentoo/stage.rb
111
+ - lib/getch/gentoo/use.rb
112
+ - lib/getch/gentoo/use_flag.rb
85
113
  - lib/getch/helpers.rb
86
114
  - lib/getch/log.rb
87
115
  - lib/getch/options.rb
@@ -94,7 +122,7 @@ metadata:
94
122
  changelog_uri: https://github.com/szorfein/getch/blob/master/CHANGELOG.md
95
123
  bug_tracker_uri: https://github.com/szorfein/getch/issues
96
124
  wiki_uri: https://github.com/szorfein/getch
97
- post_install_message:
125
+ post_install_message:
98
126
  rdoc_options: []
99
127
  require_paths:
100
128
  - lib
@@ -109,8 +137,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
137
  - !ruby/object:Gem::Version
110
138
  version: '0'
111
139
  requirements: []
112
- rubygems_version: 3.1.4
113
- signing_key:
140
+ rubygems_version: 3.0.9
141
+ signing_key:
114
142
  specification_version: 4
115
143
  summary: A CLI tool to install Gentoo
116
144
  test_files: []
metadata.gz.sig CHANGED
Binary file