getch 0.0.5 → 0.0.6

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: d947133437b5880e6880404a19c59e272ab01cf3c7acca7f4775d646c9a99597
4
- data.tar.gz: a910853539cd82f577ede94eab669ce323fc71a5986990f060dc54e96338f9b6
3
+ metadata.gz: 87ae271211f6081929b72327651ff6e4f18adeca452cf10294d75a114f26db38
4
+ data.tar.gz: eb0ea1a935578351133e4c13dd0ee7e13d1696d6fbcc58bbd441e59d1cacf7de
5
5
  SHA512:
6
- metadata.gz: c0e4a3c3ade0f4acc7793de34419248168bcce5211deaf48befbb85cf357519262157850b8c7524e178d9447e28b28c2bf5a89dcde0a1c887d46fd324656e96a
7
- data.tar.gz: cb41112758289ca2bf43fe433cb69177608b859c02a61cfa0af724a874a94f812d1231ee09e8ababc884c270160976be18c52b735ceca3d74ad694ee2eb11d50
6
+ metadata.gz: b32454448824fef83fab42ac34534125b0dc6d0655235f271c97b644105dba75eebf0ca56b1c32e6a8cab019fa638d4e9fc44f20744cafd7ca584a94e05a0f4d
7
+ data.tar.gz: 809fc8dd380821f9bc479b4efee45f7f83cafc3a0a14a441881a3abd1daaeb0da84b20a2f2ff0af9bdee31cc1f247a21a873ef2729144ec2483aec8f165b6adf
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,9 @@
1
+ ## 0.0.6, release 2020-09-19
2
+ * Add support for QEMU guest #2
3
+ * Kernel compilation, initialize a config file with `make localyesconfig`.
4
+ * More modular codes to start with encryption and other filesystems.
5
+ * Add the new option --verbose to display output of compilation, etc... #2
6
+
1
7
  ## 0.0.5, release 2020-09-17
2
8
  * Generate a hostname
3
9
  * Configure systemd-boot for UEFI system
data/README.md CHANGED
@@ -35,6 +35,8 @@ For a french user:
35
35
 
36
36
  # getch --username ninja --zoneinfo "Europe/Paris" --language fr_FR --keyboard fr
37
37
 
38
+ After an install by Getch, take a look on the [wiki](https://github.com/szorfein/getch/wiki).
39
+
38
40
  ## Issues
39
41
  If need more support for your hardware (network, sound card, ...), you can submit a [new issue](https://github.com/szorfein/getch/issues/new) and post the output of the following command:
40
42
  + lspci
@@ -1,20 +1,22 @@
1
1
  require_relative 'getch/options'
2
- require_relative 'getch/disk'
3
2
  require_relative 'getch/states'
4
3
  require_relative 'getch/mount'
5
4
  require_relative 'getch/gentoo'
5
+ require_relative 'getch/filesystem'
6
+ require_relative 'getch/command'
6
7
  require_relative 'getch/helpers'
7
8
 
8
9
  module Getch
9
10
 
10
11
  DEFAULT_OPTIONS = {
11
12
  language: 'en_US',
12
- location: 'US/Eastern',
13
+ zoneinfo: 'US/Eastern',
13
14
  keyboard: 'us',
14
15
  disk: 'sda',
15
16
  fs: 'ext4',
16
- username: nil
17
- }.freeze
17
+ username: nil,
18
+ verbose: false
19
+ }
18
20
 
19
21
  STATES = {
20
22
  :partition => false,
@@ -27,16 +29,18 @@ module Getch
27
29
  }
28
30
 
29
31
  MOUNTPOINT = "/mnt/gentoo".freeze
30
- #MOUNTPOINT = "/home/daggoth/lol".freeze
32
+ OPTIONS_FS = {
33
+ 'ext4' => Getch::FileSystem::Ext4
34
+ }.freeze
31
35
 
32
36
  def self.resume_options(opts)
33
37
  puts "\nBuild Gentoo with the following args:\n"
34
- puts "lang: #{opts.language}"
35
- puts "zoneinfo: #{opts.zoneinfo}"
36
- puts "keyboard: #{opts.keyboard}"
37
- puts "disk: #{opts.disk}"
38
- puts "fs: #{opts.fs}"
39
- puts "username: #{opts.username}"
38
+ puts "lang: #{DEFAULT_OPTIONS[:language]}"
39
+ puts "zoneinfo: #{DEFAULT_OPTIONS[:zoneinfo]}"
40
+ puts "keyboard: #{DEFAULT_OPTIONS[:keyboard]}"
41
+ puts "disk: #{DEFAULT_OPTIONS[:disk]}"
42
+ puts "fs: #{DEFAULT_OPTIONS[:fs]}"
43
+ puts "username: #{DEFAULT_OPTIONS[:username]}"
40
44
  puts
41
45
  print "Continue? (n,y) "
42
46
  case gets.chomp
@@ -47,30 +51,22 @@ module Getch
47
51
  end
48
52
  end
49
53
 
50
- def self.format(disk, fs)
54
+ def self.format(disk, fs, user)
51
55
  return if STATES[:format] and STATES[:partition]
52
56
  puts
53
57
  print "Partition and format disk #{disk}, this will erase all data, continue? (n,y) "
54
58
  case gets.chomp
55
59
  when /^y|^Y/
56
- disk = Getch::Disk.new(disk, fs)
57
- disk.cleaning
58
- disk.partition
59
- disk.format
60
+ filesystem = OPTIONS_FS[fs].new(disk)
61
+ filesystem.cleaning
62
+ filesystem.partition
63
+ filesystem.format
64
+ OPTIONS_FS[fs]::Mount.new(disk, user).run
60
65
  else
61
66
  exit 1
62
67
  end
63
68
  end
64
69
 
65
- def self.mount(disk, user)
66
- return if STATES[:mount]
67
- mount = Getch::Mount.new(disk, user)
68
- mount.swap
69
- mount.root
70
- mount.boot
71
- mount.home
72
- end
73
-
74
70
  def self.init_gentoo(options)
75
71
  gentoo = Getch::Gentoo
76
72
  gentoo.stage3
@@ -82,10 +78,10 @@ module Getch
82
78
 
83
79
  def self.main(argv)
84
80
  options = Options.new(argv)
81
+ DEFAULT_OPTIONS.freeze
85
82
  resume_options(options)
86
83
  Getch::States.new() # Update States
87
- format(options.disk, options.fs)
88
- mount(options.disk, options.username)
84
+ format(options.disk, options.fs, options.username)
89
85
  init_gentoo(options)
90
86
  end
91
87
  end
@@ -0,0 +1,55 @@
1
+ require 'open3'
2
+
3
+ module Getch
4
+ class Command
5
+ def initialize(cmd)
6
+ @cmd = cmd
7
+ @block_size = 512
8
+ end
9
+
10
+ def run!
11
+ puts "Running command: " + @cmd.gsub(/\"/, '')
12
+
13
+ Open3.popen3(@cmd) do |stdin, stdout, stderr|
14
+ stdin.close_write
15
+
16
+ begin
17
+ files = [stdout, stderr]
18
+
19
+ until all_eof(files) do
20
+ ready = IO.select(files)
21
+
22
+ if ready
23
+ readable = ready[0]
24
+ # writable = ready[1]
25
+ # exceptions = ready[2]
26
+
27
+ readable.each do |f|
28
+ fileno = f.fileno
29
+
30
+ begin
31
+ data = f.read_nonblock(@block_size)
32
+
33
+ # Do something with the data...
34
+ puts "#{data}" if DEFAULT_OPTIONS[:verbose]
35
+ rescue EOFError
36
+ puts "fileno: #{fileno} EOF"
37
+ end
38
+ end
39
+ end
40
+ end
41
+ rescue IOError => e
42
+ puts "IOError: #{e}"
43
+ end
44
+ end
45
+ puts "Done"
46
+ end
47
+
48
+ private
49
+
50
+ # Returns true if all files are EOF
51
+ def all_eof(files)
52
+ files.find { |f| !f.eof }.nil?
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,7 @@
1
+ module Getch
2
+ module FileSystem
3
+ end
4
+ end
5
+
6
+ require_relative 'filesystem/root'
7
+ require_relative 'filesystem/ext4'
@@ -0,0 +1,75 @@
1
+ module Getch
2
+ module FileSystem
3
+ class Ext4 < Getch::FileSystem::Root
4
+ def initialize(disk)
5
+ @disk = disk
6
+ @fs = 'ext4'
7
+ super
8
+ end
9
+
10
+ class Mount < Getch::Mount
11
+ def initialize(disk, user)
12
+ @disk = disk
13
+ @user = user
14
+ super
15
+ end
16
+
17
+ private
18
+
19
+ def gen_vars
20
+ @dev_boot_efi = Helpers::efi? ? "/dev/#{@disk}1" : nil
21
+ @dev_swap = "/dev/#{@disk}2"
22
+ @dev_root = "/dev/#{@disk}3"
23
+ @dev_home = @user ? "/dev/#{@disk}4" : nil
24
+ end
25
+
26
+ def data_fstab
27
+ boot_efi = @dev_boot_efi ? "UUID=#{@uuid_boot_efi} /boot/efi vfat noauto,defaults 0 2" : ''
28
+ swap = @dev_swap ? "UUID=#{@uuid_swap} none swap discard 0 0" : ''
29
+ root = @dev_root ? "UUID=#{@uuid_root} / ext4 defaults 0 1" : ''
30
+ home = @dev_home ? "UUID=#{@uuid_home} /home/#{@user} ext4 defaults 0 2" : ''
31
+
32
+ return [ boot_efi, swap, root, home ]
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ # Follow https://wiki.archlinux.org/index.php/Partitioning
39
+ def partition_efi
40
+ # /boot/efi - EFI system partition - 260MB
41
+ # swap - Linux Swap - size of the ram
42
+ # / - Root
43
+ # /home - Home
44
+ system("sgdisk -n1:1M:+260M -t1:EF00 /dev/#{@disk}") # boot EFI
45
+ system("sgdisk -n2:0:+2G -t2:8200 /dev/#{@disk}") # swap
46
+ system("sgdisk -n3:0:+15G -t3:8304 /dev/#{@disk}") # root
47
+ system("sgdisk -n4:0:0 -t3:8302 /dev/#{@disk}") # home
48
+ end
49
+
50
+ def format_efi
51
+ system("mkfs.fat -F32 /dev/#{@disk}1")
52
+ system("mkswap /dev/#{@disk}2")
53
+ system("mkfs.#{@fs} /dev/#{@disk}3")
54
+ system("mkfs.#{@fs} /dev/#{@disk}4")
55
+ end
56
+
57
+ def partition_bios
58
+ # None - Bios Boot Partition - 1MiB
59
+ # swap - Linux Swap - size of the ram
60
+ # / - Root
61
+ # /home - Home
62
+ system("sgdisk -n1:1MiB:+1MiB -t1:EF02 /dev/#{@disk}")
63
+ system("sgdisk -n2:0:+2G -t2:8200 /dev/#{@disk}")
64
+ system("sgdisk -n3:0:+15G -t3:8304 /dev/#{@disk}")
65
+ system("sgdisk -n4:0:0 -t3:8302 /dev/#{@disk}")
66
+ end
67
+
68
+ def format_bios
69
+ system("mkswap /dev/#{@disk}2")
70
+ system("mkfs.#{@fs} /dev/#{@disk}3")
71
+ system("mkfs.#{@fs} /dev/#{@disk}4")
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,63 @@
1
+ module Getch
2
+ module FileSystem
3
+ class Root
4
+ def initialize(disk)
5
+ @disk = disk
6
+ @fs = nil
7
+ @state = Getch::States.new()
8
+ end
9
+
10
+ # https://wiki.archlinux.org/index.php/Securely_wipe_disk
11
+ def cleaning
12
+ return if STATES[:partition ]
13
+ puts
14
+ print "Cleaning data on #{@disk}, can be long, avoid this on Flash Memory (SSD,USB,...) ? (n,y) "
15
+ case gets.chomp
16
+ when /^y|^Y/
17
+ system("dd if=/dev/urandom of=/dev/#{@disk} bs=4M status=progress")
18
+ else
19
+ return
20
+ end
21
+ end
22
+
23
+ def partition
24
+ return if STATES[:partition]
25
+ Helpers::exec_or_die("sgdisk --zap-all /dev/#{@disk}")
26
+ Helpers::exec_or_die("wipefs -a /dev/#{@disk}")
27
+ if Helpers::efi? then
28
+ puts "Partition disk #{@disk} for an EFI system"
29
+ partition_efi
30
+ else
31
+ puts "Partition disk #{@disk} for a Bios system"
32
+ partition_bios
33
+ end
34
+ @state.partition
35
+ end
36
+
37
+ def format
38
+ return if STATES[:format]
39
+ puts "Format #{@disk} with #{@fs}"
40
+ if Helpers::efi? then
41
+ format_efi
42
+ else
43
+ format_bios
44
+ end
45
+ @state.format
46
+ end
47
+
48
+ private
49
+
50
+ def partition_efi
51
+ end
52
+
53
+ def partition_bios
54
+ end
55
+
56
+ def format_efi
57
+ end
58
+
59
+ def format_bios
60
+ end
61
+ end
62
+ end
63
+ end
@@ -51,6 +51,7 @@ module Getch
51
51
  return if STATES[:gentoo_kernel]
52
52
  source = Getch::Gentoo::Sources.new()
53
53
  new
54
+ source.init_config
54
55
  source.build_kspp
55
56
  source.build_others
56
57
  source.make
@@ -96,7 +96,7 @@ module Getch
96
96
  source /etc/profile
97
97
  #{cmd}
98
98
  \""
99
- Helpers::exec_or_die(script)
99
+ Getch::Command.new(script).run!
100
100
  end
101
101
  end
102
102
  end
@@ -54,7 +54,7 @@ module Getch
54
54
 
55
55
  Dir.chdir("#{MOUNTPOINT}/root")
56
56
  Helpers::get_file_online(url, file)
57
- Helpers::exec_or_die("tar xzf #{file}") if ! Dir.exist? 'garden-master'
57
+ Getch::Command.new("tar xzf #{file}").run! if ! Dir.exist? 'garden-master'
58
58
  end
59
59
 
60
60
  def garden_dep
@@ -80,7 +80,7 @@ module Getch
80
80
  source /etc/profile
81
81
  #{cmd}
82
82
  \""
83
- Helpers::exec_or_die(script)
83
+ Getch::Command.new(script).run!
84
84
  end
85
85
  end
86
86
  end
@@ -9,7 +9,8 @@ module Getch
9
9
  def build_others
10
10
  install_wifi if ismatch?('iwlwifi')
11
11
  install_zfs if ismatch?('zfs')
12
- exec("./kernel.sh -b -a virtualbox-guest -k #{@linux}") if ismatch?('vmwgfx')
12
+ virtualbox_guest
13
+ qemu_guest
13
14
  end
14
15
 
15
16
  def build_kspp
@@ -28,8 +29,22 @@ module Getch
28
29
  exec_chroot("cd #{@linux} && make -j$(nproc)")
29
30
  end
30
31
 
32
+ def init_config
33
+ exec_chroot("env-update && cd #{@linux} && make localyesconfig")
34
+ end
35
+
31
36
  private
32
37
 
38
+ def virtualbox_guest
39
+ exec("./kernel.sh -b -a virtualbox-guest -k #{@linux}") if ismatch?('vmwgfx')
40
+ Helpers::emerge("app-emulation/virtualbox-guest-additions", MOUNTPOINT)
41
+ end
42
+
43
+ def qemu_guest
44
+ exec("./kernel.sh -a qemu-guest -k #{@linux}") if ismatch?('virtio')
45
+ exec("./kernel.sh -a kvm -k #{@linux}") if ismatch?('kvm')
46
+ end
47
+
33
48
  def ismatch?(arg)
34
49
  @lsmod.match?(/#{arg}/)
35
50
  end
@@ -40,7 +55,7 @@ module Getch
40
55
  cd /root/garden-master
41
56
  #{cmd}
42
57
  \""
43
- Helpers::exec_or_die(script)
58
+ Getch::Command.new(script).run!
44
59
  end
45
60
 
46
61
  def exec_chroot(cmd)
@@ -48,7 +63,7 @@ module Getch
48
63
  source /etc/profile
49
64
  #{cmd}
50
65
  \""
51
- Helpers::exec_or_die(script)
66
+ Getch::Command.new(script).run!
52
67
  end
53
68
 
54
69
  def install_wifi
@@ -61,7 +61,7 @@ module Getch
61
61
  def decompress
62
62
  puts "Decompressing archive #{@stage_file}..."
63
63
  cmd = "tar xpvf #{@stage_file} --xattrs-include='*.*' --numeric-owner"
64
- Helpers::exec_or_die(cmd)
64
+ Getch::Command.new(cmd).run!
65
65
  end
66
66
 
67
67
  def cleaning
@@ -1,6 +1,7 @@
1
1
  require 'open-uri'
2
2
  require 'open3'
3
3
  require 'fileutils'
4
+ require_relative 'command'
4
5
 
5
6
  module Helpers
6
7
  def self.efi?
@@ -35,6 +36,6 @@ module Helpers
35
36
  source /etc/profile
36
37
  emerge --changed-use #{pkgs}
37
38
  \""
38
- exec_or_die(cmd)
39
+ Getch::Command.new(cmd).run!
39
40
  end
40
41
  end
@@ -5,69 +5,84 @@ module Getch
5
5
  def initialize(disk, user)
6
6
  @disk = disk
7
7
  @user = user
8
- @dest = MOUNTPOINT
9
- @boot_efi = MOUNTPOINT + '/boot/efi'
10
- @home = @user == nil ? MOUNTPOINT + '/home' : MOUNTPOINT + "/home/#{@user}"
8
+ @root_dir = MOUNTPOINT
9
+ @boot_dir = "#{@root_dir}/boot"
10
+ @boot_efi_dir = "#{@root_dir}/boot/efi"
11
+ @home_dir = @user ? "#{@root_dir}/home/#{@user}" : nil
11
12
  @state = Getch::States.new()
13
+ gen_vars
12
14
  end
13
15
 
14
- def swap
16
+ def run
15
17
  return if STATES[:mount]
16
- system("swapon /dev/#{@disk}2")
18
+ mount_swap
19
+ mount_root
20
+ mount_boot
21
+ mount_home
22
+ mount_boot_efi if Helpers::efi?
23
+ @state.mount
17
24
  end
18
25
 
19
- def root
20
- return if STATES[:mount]
21
- Dir.mkdir(@dest, 0700) if ! Dir.exist?(@dest)
22
- system("mount /dev/#{@disk}3 #{@dest}")
26
+ def gen_fstab
27
+ file = "#{@root_dir}/etc/fstab"
28
+ FileUtils.mkdir_p "#{@root_dir}/etc", mode: 0700 if ! Dir.exist?("#{@root_dir}/etc")
29
+ gen_uuid
30
+ datas = data_fstab
31
+ File.write(file, datas.join("\n"))
23
32
  end
24
33
 
25
- def boot
26
- return if STATES[:mount]
27
- if Helpers::efi? then
28
- FileUtils.mkdir_p @boot_efi, mode: 0700 if ! Dir.exist?(@boot_efi)
29
- system("mount /dev/#{@disk}1 #{@boot_efi}")
30
- end
34
+ private
35
+
36
+ def gen_vars
37
+ @dev_boot_efi = nil
38
+ @dev_boot = nil
39
+ @dev_root = nil
40
+ @dev_swap = nil
41
+ @dev_home = nil
31
42
  end
32
43
 
33
- def home
34
- return if STATES[:mount]
35
- if @user != nil then
36
- FileUtils.mkdir_p @home, mode: 0700 if ! Dir.exist?(@home)
37
- system("mount /dev/#{@disk}4 #{@home}")
38
- #FileUtils.chown @user, @user, @home
39
- end
40
- @state.mount
44
+ def mount_swap
45
+ return if ! @dev_swap
46
+ system("swapon #{@dev_swap}")
41
47
  end
42
48
 
43
- def gen_fstab
44
- gen_uuid
45
- datas = gen_data
46
- File.write("#{MOUNTPOINT}/etc/fstab", datas.join("\n"), mode: "a")
49
+ def mount_root
50
+ return if ! @dev_root
51
+ Dir.mkdir(@root_dir, 0700) if ! Dir.exist?(@root_dir)
52
+ system("mount #{@dev_root} #{@root_dir}")
47
53
  end
48
54
 
49
- private
55
+ def mount_boot_efi
56
+ return if ! @dev_boot_efi
57
+ FileUtils.mkdir_p @boot_efi_dir, mode: 0700 if ! Dir.exist?(@boot_efi_dir)
58
+ system("mount #{@dev_boot_efi} #{@boot_efi_dir}")
59
+ end
50
60
 
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()
61
+ def mount_boot
62
+ return if ! @dev_boot
63
+ FileUtils.mkdir_p @boot_dir, mode: 0700 if ! Dir.exist?(@boot_dir)
64
+ system("mount #{@dev_boot} #{@boot_dir}")
65
+ end
66
+
67
+ def mount_home
68
+ return if ! @dev_home
69
+ if @user != nil then
70
+ FileUtils.mkdir_p @home_dir, mode: 0700 if ! Dir.exist?(@home_dir)
71
+ system("mount #{@dev_home} #{@home_dir}")
72
+ end
73
+ @state.mount
56
74
  end
57
75
 
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" : ''
76
+ def gen_uuid
77
+ @uuid_swap = `lsblk -o "UUID" #{@dev_swap} | tail -1`.chomp() if @dev_swap
78
+ @uuid_root = `lsblk -o "UUID" #{@dev_root} | tail -1`.chomp() if @dev_root
79
+ @uuid_boot = `lsblk -o "UUID" #{@dev_boot} | tail -1`.chomp() if @dev_boot
80
+ @uuid_boot_efi = `lsblk -o "UUID" #{@dev_boot_efi} | tail -1`.chomp() if @dev_boot_efi
81
+ @uuid_home = `lsblk -o "UUID" #{@dev_home} | tail -1`.chomp() if @dev_home
82
+ end
63
83
 
64
- datas = [
65
- boot,
66
- swap,
67
- root,
68
- home
69
- ]
70
- return datas
84
+ def data_fstab
85
+ return []
71
86
  end
72
87
  end
73
88
  end
@@ -2,15 +2,16 @@ require 'optparse'
2
2
 
3
3
  module Getch
4
4
  class Options
5
- attr_reader :language, :zoneinfo, :keyboard, :disk, :fs, :username
5
+ attr_reader :language, :zoneinfo, :keyboard, :disk, :fs, :username, :verbose
6
6
 
7
7
  def initialize(argv)
8
8
  @language = DEFAULT_OPTIONS[:language]
9
- @zoneinfo = DEFAULT_OPTIONS[:location]
9
+ @zoneinfo = DEFAULT_OPTIONS[:zoneinfo]
10
10
  @keyboard = DEFAULT_OPTIONS[:keyboard]
11
11
  @disk = DEFAULT_OPTIONS[:disk]
12
12
  @fs = DEFAULT_OPTIONS[:fs]
13
13
  @username = DEFAULT_OPTIONS[:username]
14
+ @verbose = DEFAULT_OPTIONS[:verbose]
14
15
  parse(argv)
15
16
  end
16
17
 
@@ -36,11 +37,14 @@ module Getch
36
37
  opts.on("-u", "--username USERNAME", "Initialize /home/username") do |user|
37
38
  @username = user
38
39
  end
40
+ opts.on("-v", "--verbose", "Write more messages to the standard output.") do
41
+ @verbose = true
42
+ end
39
43
  opts.on("-h", "--help", "Display this") do
40
44
  puts opts
41
45
  exit
42
46
  end
43
- end.parse!
47
+ end.parse!(into: DEFAULT_OPTIONS)
44
48
  end
45
49
  end
46
50
  end
@@ -1,3 +1,3 @@
1
1
  module Getch
2
- VERSION = '0.0.5'.freeze
2
+ VERSION = '0.0.6'.freeze
3
3
  end
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.5
4
+ version: 0.0.6
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-17 00:00:00.000000000 Z
38
+ date: 2020-09-19 00:00:00.000000000 Z
39
39
  dependencies: []
40
40
  description:
41
41
  email:
@@ -53,7 +53,10 @@ files:
53
53
  - bin/setup.sh
54
54
  - getch.gemspec
55
55
  - lib/getch.rb
56
- - lib/getch/disk.rb
56
+ - lib/getch/command.rb
57
+ - lib/getch/filesystem.rb
58
+ - lib/getch/filesystem/ext4.rb
59
+ - lib/getch/filesystem/root.rb
57
60
  - lib/getch/gentoo.rb
58
61
  - lib/getch/gentoo/boot.rb
59
62
  - lib/getch/gentoo/chroot.rb
metadata.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- w�*j�&'�cDYΡ�\U�`��YR��㴼,�F�+D�mi9��Y�<��S�&f��$O�0�V
2
- a;��#�b��z���eb [ `�VLw;uF�ީ�T������������n���=���k��7 �K.B pehcNno��� ������vu��Di���V�|Î�R��2P:{qp&���\���S��UX��T��ߧp��pU4i2��'�g��_��b:L��[�ށ9��an�͚�� R\6f�H���5�ʮB��V1����S��E�����8 �e�����|
1
+ dHJ�`�M�D�X�>�[eh Y�58���}2
2
+ �h H�l�d�_��Ì�4��NR7V�Z7 �$��ۖ��`ZϹP���r���J���*������r/�Jٟ�I-d!(z:9�Yh��l ��gqX ��;��h �V������I��YŅ=���>[�!�o@_T��AoKq F|�kϣe%\�)�B$<�|�-�0�r��T�@�<�ܚh �gǙ/�l�%��(@���FE�D~�����}��j���$���D
@@ -1,77 +0,0 @@
1
- module Getch
2
- class Disk
3
- def initialize(disk, fs)
4
- @hdd = disk
5
- @fs = fs
6
- @state = Getch::States.new()
7
- end
8
-
9
- # https://wiki.archlinux.org/index.php/Securely_wipe_disk
10
- def cleaning
11
- return if STATES[:partition ]
12
- puts
13
- print "Cleaning data on #{@hdd}, can be long, avoid this on Flash Memory (SSD,USB,...) ? (n,y) "
14
- case gets.chomp
15
- when /^y|^Y/
16
- system("dd if=/dev/urandom of=/dev/#{@hdd} bs=4M status=progress")
17
- else
18
- return
19
- end
20
- end
21
-
22
- def partition
23
- return if STATES[:partition]
24
- system("sgdisk --zap-all /dev/#{@hdd}")
25
- system("wipefs -a /dev/#{@hdd}")
26
- if Helpers::efi? then
27
- puts "Partition disk #{@hdd} for an EFI system"
28
- partition_efi
29
- else
30
- puts "Partition disk #{@hdd} for a Bios system"
31
- partition_bios
32
- end
33
- @state.partition
34
- end
35
-
36
- def format
37
- return if STATES[:format]
38
- puts "Format #{@hdd} with #{@fs}"
39
- if Helpers::efi? then
40
- system("mkfs.fat -F32 /dev/#{@hdd}1")
41
- system("mkswap /dev/#{@hdd}2")
42
- system("mkfs.ext4 /dev/#{@hdd}3")
43
- system("mkfs.ext4 /dev/#{@hdd}4")
44
- else
45
- system("mkswap /dev/#{@hdd}2")
46
- system("mkfs.ext4 /dev/#{@hdd}3")
47
- system("mkfs.ext4 /dev/#{@hdd}4")
48
- end
49
- @state.format
50
- end
51
-
52
- private
53
-
54
- # follow https://wiki.archlinux.org/index.php/Partitioning
55
- def partition_efi
56
- # /boot/efi - EFI system partition - 260MB
57
- # swap - Linux Swap - size of the ram
58
- # / - Root
59
- # /home - Home
60
- system("sgdisk -n1:1M:+260M -t1:EF00 /dev/#{@hdd}") # boot EFI
61
- system("sgdisk -n2:0:+2G -t2:8200 /dev/#{@hdd}") # swap
62
- system("sgdisk -n3:0:+15G -t3:8304 /dev/#{@hdd}") # root
63
- system("sgdisk -n4:0:0 -t3:8302 /dev/#{@hdd}") # home
64
- end
65
-
66
- def partition_bios
67
- # None - Bios Boot Partition - 1MiB
68
- # swap - Linux Swap - size of the ram
69
- # / - Root
70
- # /home - Home
71
- system("sgdisk -n1:1MiB:+1MiB -t1:EF02 /dev/#{@hdd}") # Bios boot
72
- system("sgdisk -n2:0:+2G -t2:8200 /dev/#{@hdd}") # swap
73
- system("sgdisk -n3:0:+15G -t3:8304 /dev/#{@hdd}") # root
74
- system("sgdisk -n4:0:0 -t3:8302 /dev/#{@hdd}") # home
75
- end
76
- end
77
- end