getch 0.0.2 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +41 -0
- data/README.md +20 -1
- data/bin/setup.sh +24 -10
- data/getch.gemspec +5 -0
- data/lib/getch.rb +42 -18
- data/lib/getch/command.rb +55 -0
- data/lib/getch/filesystem.rb +6 -0
- data/lib/getch/filesystem/ext4.rb +13 -0
- data/lib/getch/filesystem/ext4/config.rb +58 -0
- data/lib/getch/filesystem/ext4/deps.rb +22 -0
- data/lib/getch/filesystem/ext4/device.rb +16 -0
- data/lib/getch/filesystem/ext4/encrypt.rb +15 -0
- data/lib/getch/filesystem/ext4/encrypt/config.rb +62 -0
- data/lib/getch/filesystem/ext4/encrypt/deps.rb +37 -0
- data/lib/getch/filesystem/ext4/encrypt/device.rb +20 -0
- data/lib/getch/filesystem/ext4/encrypt/format.rb +26 -0
- data/lib/getch/filesystem/ext4/encrypt/mount.rb +64 -0
- data/lib/getch/filesystem/ext4/encrypt/partition.rb +95 -0
- data/lib/getch/filesystem/ext4/format.rb +24 -0
- data/lib/getch/filesystem/ext4/mount.rb +62 -0
- data/lib/getch/filesystem/ext4/partition.rb +75 -0
- data/lib/getch/gentoo.rb +67 -0
- data/lib/getch/gentoo/boot.rb +91 -0
- data/lib/getch/gentoo/chroot.rb +90 -0
- data/lib/getch/gentoo/config.rb +102 -0
- data/lib/getch/gentoo/sources.rb +82 -0
- data/lib/getch/gentoo/stage.rb +74 -0
- data/lib/getch/helpers.rb +49 -0
- data/lib/getch/options.rb +17 -9
- data/lib/getch/states.rb +26 -1
- data/lib/getch/version.rb +1 -1
- metadata +31 -5
- metadata.gz.sig +0 -0
- data/lib/getch/disk.rb +0 -83
data/lib/getch/options.rb
CHANGED
@@ -2,15 +2,17 @@ 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, :encrypt, :verbose
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@language =
|
9
|
-
@zoneinfo =
|
10
|
-
@keyboard =
|
11
|
-
@disk =
|
12
|
-
@fs =
|
13
|
-
@username =
|
7
|
+
def initialize(argv)
|
8
|
+
@language = DEFAULT_OPTIONS[:language]
|
9
|
+
@zoneinfo = DEFAULT_OPTIONS[:zoneinfo]
|
10
|
+
@keyboard = DEFAULT_OPTIONS[:keyboard]
|
11
|
+
@disk = DEFAULT_OPTIONS[:disk]
|
12
|
+
@fs = DEFAULT_OPTIONS[:fs]
|
13
|
+
@username = DEFAULT_OPTIONS[:username]
|
14
|
+
@encrypt = DEFAULT_OPTIONS[:encrypt]
|
15
|
+
@verbose = DEFAULT_OPTIONS[:verbose]
|
14
16
|
parse(argv)
|
15
17
|
end
|
16
18
|
|
@@ -36,11 +38,17 @@ module Getch
|
|
36
38
|
opts.on("-u", "--username USERNAME", "Initialize /home/username") do |user|
|
37
39
|
@username = user
|
38
40
|
end
|
41
|
+
opts.on("--encrypt", "Encrypt your filesystem.!! NOT YET READY !!") do
|
42
|
+
@encrypt = true
|
43
|
+
end
|
44
|
+
opts.on("--verbose", "Write more messages to the standard output.") do
|
45
|
+
@verbose = true
|
46
|
+
end
|
39
47
|
opts.on("-h", "--help", "Display this") do
|
40
48
|
puts opts
|
41
49
|
exit
|
42
50
|
end
|
43
|
-
end.parse!
|
51
|
+
end.parse!(into: DEFAULT_OPTIONS)
|
44
52
|
end
|
45
53
|
end
|
46
54
|
end
|
data/lib/getch/states.rb
CHANGED
@@ -17,6 +17,31 @@ module Getch
|
|
17
17
|
save
|
18
18
|
end
|
19
19
|
|
20
|
+
def mount
|
21
|
+
STATES[:mount] = true
|
22
|
+
save
|
23
|
+
end
|
24
|
+
|
25
|
+
def stage3
|
26
|
+
STATES[:gentoo_base] = true
|
27
|
+
save
|
28
|
+
end
|
29
|
+
|
30
|
+
def config
|
31
|
+
STATES[:gentoo_config] = true
|
32
|
+
save
|
33
|
+
end
|
34
|
+
|
35
|
+
def update
|
36
|
+
STATES[:gentoo_update] = true
|
37
|
+
save
|
38
|
+
end
|
39
|
+
|
40
|
+
def kernel
|
41
|
+
STATES[:gentoo_kernel] = true
|
42
|
+
save
|
43
|
+
end
|
44
|
+
|
20
45
|
private
|
21
46
|
|
22
47
|
def save
|
@@ -24,7 +49,7 @@ module Getch
|
|
24
49
|
end
|
25
50
|
|
26
51
|
def load_state()
|
27
|
-
if File.
|
52
|
+
if File.exist? @file
|
28
53
|
state_file = YAML.load_file(@file)
|
29
54
|
STATES.merge!(state_file)
|
30
55
|
else
|
data/lib/getch/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.7
|
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-
|
38
|
+
date: 2020-09-22 00:00:00.000000000 Z
|
39
39
|
dependencies: []
|
40
40
|
description:
|
41
41
|
email:
|
@@ -46,20 +46,46 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
|
+
- CHANGELOG.md
|
49
50
|
- README.md
|
50
51
|
- Rakefile
|
51
52
|
- bin/getch
|
52
53
|
- bin/setup.sh
|
53
54
|
- getch.gemspec
|
54
55
|
- lib/getch.rb
|
55
|
-
- lib/getch/
|
56
|
+
- lib/getch/command.rb
|
57
|
+
- lib/getch/filesystem.rb
|
58
|
+
- lib/getch/filesystem/ext4.rb
|
59
|
+
- lib/getch/filesystem/ext4/config.rb
|
60
|
+
- lib/getch/filesystem/ext4/deps.rb
|
61
|
+
- lib/getch/filesystem/ext4/device.rb
|
62
|
+
- lib/getch/filesystem/ext4/encrypt.rb
|
63
|
+
- lib/getch/filesystem/ext4/encrypt/config.rb
|
64
|
+
- lib/getch/filesystem/ext4/encrypt/deps.rb
|
65
|
+
- lib/getch/filesystem/ext4/encrypt/device.rb
|
66
|
+
- lib/getch/filesystem/ext4/encrypt/format.rb
|
67
|
+
- lib/getch/filesystem/ext4/encrypt/mount.rb
|
68
|
+
- lib/getch/filesystem/ext4/encrypt/partition.rb
|
69
|
+
- lib/getch/filesystem/ext4/format.rb
|
70
|
+
- lib/getch/filesystem/ext4/mount.rb
|
71
|
+
- lib/getch/filesystem/ext4/partition.rb
|
72
|
+
- lib/getch/gentoo.rb
|
73
|
+
- lib/getch/gentoo/boot.rb
|
74
|
+
- lib/getch/gentoo/chroot.rb
|
75
|
+
- lib/getch/gentoo/config.rb
|
76
|
+
- lib/getch/gentoo/sources.rb
|
77
|
+
- lib/getch/gentoo/stage.rb
|
78
|
+
- lib/getch/helpers.rb
|
56
79
|
- lib/getch/options.rb
|
57
80
|
- lib/getch/states.rb
|
58
81
|
- lib/getch/version.rb
|
59
82
|
homepage: https://github.com/szorfein/getch
|
60
83
|
licenses:
|
61
84
|
- MIT
|
62
|
-
metadata:
|
85
|
+
metadata:
|
86
|
+
changelog_uri: https://github.com/szorfein/getch/blob/master/CHANGELOG.md
|
87
|
+
bug_tracker_uri: https://github.com/szorfein/getch/issues
|
88
|
+
wiki_uri: https://github.com/szorfein/getch
|
63
89
|
post_install_message:
|
64
90
|
rdoc_options: []
|
65
91
|
require_paths:
|
@@ -75,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
101
|
- !ruby/object:Gem::Version
|
76
102
|
version: '0'
|
77
103
|
requirements: []
|
78
|
-
rubygems_version: 3.1.
|
104
|
+
rubygems_version: 3.1.4
|
79
105
|
signing_key:
|
80
106
|
specification_version: 4
|
81
107
|
summary: A CLI tool to install Gentoo
|
metadata.gz.sig
CHANGED
Binary file
|
data/lib/getch/disk.rb
DELETED
@@ -1,83 +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
|
-
def efi?
|
10
|
-
Dir.exist? '/sys/firmware/efi/efivars'
|
11
|
-
end
|
12
|
-
|
13
|
-
# https://wiki.archlinux.org/index.php/Securely_wipe_disk
|
14
|
-
def cleaning
|
15
|
-
return if STATES[:partition ]
|
16
|
-
puts
|
17
|
-
print "Cleaning data on #{@hdd}, can be long, avoid this on Flash Memory (SSD,USB,...) ? (n,y) "
|
18
|
-
case gets.chomp
|
19
|
-
when /^y|^Y/
|
20
|
-
system("dd if=/dev/urandom of=/dev/#{@hdd} bs=4M status=progress")
|
21
|
-
else
|
22
|
-
return
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def partition
|
27
|
-
return if STATES[:partition]
|
28
|
-
system("wipefs -a /dev/#{@hdd}")
|
29
|
-
system("sgdisk --zap-all /dev/#{@hdd}")
|
30
|
-
if efi? then
|
31
|
-
puts "Partition disk #{@hdd} for an EFI system"
|
32
|
-
partition_efi
|
33
|
-
else
|
34
|
-
puts "Partition disk #{@hdd} for a Bios system"
|
35
|
-
partition_bios
|
36
|
-
end
|
37
|
-
@state.partition
|
38
|
-
end
|
39
|
-
|
40
|
-
def format
|
41
|
-
return if STATES[:format]
|
42
|
-
puts "Format #{@hdd} with #{@fs}"
|
43
|
-
if efi? then
|
44
|
-
system("mkfs.vfat -F32 /dev/#{@hdd}1")
|
45
|
-
system("mkswap /dev/#{@hdd}2")
|
46
|
-
system("swapon /dev/#{@hdd}2")
|
47
|
-
system("mkfs.ext4 /dev/#{@hdd}3")
|
48
|
-
system("mkfs.ext4 /dev/#{@hdd}4")
|
49
|
-
else
|
50
|
-
system("mkswap /dev/#{@hdd}2")
|
51
|
-
system("swapon /dev/#{@hdd}2")
|
52
|
-
system("mkfs.ext4 /dev/#{@hdd}3")
|
53
|
-
system("mkfs.ext4 /dev/#{@hdd}4")
|
54
|
-
end
|
55
|
-
@state.format
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
# follow https://wiki.archlinux.org/index.php/Partitioning
|
61
|
-
def partition_efi
|
62
|
-
# /boot/efi - EFI system partition - 260MB
|
63
|
-
# swap - Linux Swap - size of the ram
|
64
|
-
# / - Root
|
65
|
-
# /home - Home
|
66
|
-
system("sgdisk -n1:1M:+260M -t1:EF00 /dev/#{@hdd}") # boot EFI
|
67
|
-
system("sgdisk -n2:0:+2G -t2:8200 /dev/#{@hdd}") # swap
|
68
|
-
system("sgdisk -n3:0:+15G -t3:8304 /dev/#{@hdd}") # root
|
69
|
-
system("sgdisk -n4:0:0 -t3:8302 /dev/#{@hdd}") # home
|
70
|
-
end
|
71
|
-
|
72
|
-
def partition_bios
|
73
|
-
# None - Bios Boot Partition - 1MiB
|
74
|
-
# swap - Linux Swap - size of the ram
|
75
|
-
# / - Root
|
76
|
-
# /home - Home
|
77
|
-
system("sgdisk -n1:1MiB:+1MiB -t1:EF02 /dev/#{@hdd}") # Bios boot
|
78
|
-
system("sgdisk -n2:0:+2G -t2:8200 /dev/#{@hdd}") # swap
|
79
|
-
system("sgdisk -n3:0:+15G -t3:8304 /dev/#{@hdd}") # root
|
80
|
-
system("sgdisk -n4:0:0 -t3:8302 /dev/#{@hdd}") # home
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|