getch 0.0.5 → 0.1.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.
Files changed (65) 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 +30 -0
  5. data/README.md +31 -6
  6. data/bin/setup.sh +29 -13
  7. data/lib/getch.rb +43 -30
  8. data/lib/getch/command.rb +163 -0
  9. data/lib/getch/filesystem.rb +8 -0
  10. data/lib/getch/filesystem/ext4.rb +14 -0
  11. data/lib/getch/filesystem/ext4/config.rb +59 -0
  12. data/lib/getch/filesystem/ext4/deps.rb +22 -0
  13. data/lib/getch/filesystem/ext4/device.rb +16 -0
  14. data/lib/getch/filesystem/ext4/encrypt.rb +15 -0
  15. data/lib/getch/filesystem/ext4/encrypt/config.rb +85 -0
  16. data/lib/getch/filesystem/ext4/encrypt/deps.rb +59 -0
  17. data/lib/getch/filesystem/ext4/encrypt/device.rb +21 -0
  18. data/lib/getch/filesystem/ext4/encrypt/format.rb +32 -0
  19. data/lib/getch/filesystem/ext4/encrypt/mount.rb +64 -0
  20. data/lib/getch/filesystem/ext4/encrypt/partition.rb +116 -0
  21. data/lib/getch/filesystem/ext4/format.rb +30 -0
  22. data/lib/getch/filesystem/ext4/mount.rb +62 -0
  23. data/lib/getch/filesystem/ext4/partition.rb +75 -0
  24. data/lib/getch/filesystem/lvm.rb +14 -0
  25. data/lib/getch/filesystem/lvm/config.rb +63 -0
  26. data/lib/getch/filesystem/lvm/deps.rb +57 -0
  27. data/lib/getch/filesystem/lvm/device.rb +19 -0
  28. data/lib/getch/filesystem/lvm/encrypt.rb +15 -0
  29. data/lib/getch/filesystem/lvm/encrypt/config.rb +74 -0
  30. data/lib/getch/filesystem/lvm/encrypt/deps.rb +63 -0
  31. data/lib/getch/filesystem/lvm/encrypt/device.rb +22 -0
  32. data/lib/getch/filesystem/lvm/encrypt/format.rb +32 -0
  33. data/lib/getch/filesystem/lvm/encrypt/mount.rb +64 -0
  34. data/lib/getch/filesystem/lvm/encrypt/partition.rb +92 -0
  35. data/lib/getch/filesystem/lvm/format.rb +25 -0
  36. data/lib/getch/filesystem/lvm/mount.rb +62 -0
  37. data/lib/getch/filesystem/lvm/partition.rb +81 -0
  38. data/lib/getch/filesystem/zfs.rb +14 -0
  39. data/lib/getch/filesystem/zfs/config.rb +58 -0
  40. data/lib/getch/filesystem/zfs/deps.rb +90 -0
  41. data/lib/getch/filesystem/zfs/device.rb +19 -0
  42. data/lib/getch/filesystem/zfs/encrypt.rb +15 -0
  43. data/lib/getch/filesystem/zfs/encrypt/config.rb +67 -0
  44. data/lib/getch/filesystem/zfs/encrypt/deps.rb +94 -0
  45. data/lib/getch/filesystem/zfs/encrypt/device.rb +21 -0
  46. data/lib/getch/filesystem/zfs/encrypt/format.rb +22 -0
  47. data/lib/getch/filesystem/zfs/encrypt/mount.rb +67 -0
  48. data/lib/getch/filesystem/zfs/encrypt/partition.rb +151 -0
  49. data/lib/getch/filesystem/zfs/format.rb +20 -0
  50. data/lib/getch/filesystem/zfs/mount.rb +67 -0
  51. data/lib/getch/filesystem/zfs/partition.rb +147 -0
  52. data/lib/getch/gentoo.rb +3 -2
  53. data/lib/getch/gentoo/boot.rb +29 -25
  54. data/lib/getch/gentoo/chroot.rb +18 -14
  55. data/lib/getch/gentoo/config.rb +18 -9
  56. data/lib/getch/gentoo/sources.rb +45 -31
  57. data/lib/getch/gentoo/stage.rb +2 -2
  58. data/lib/getch/helpers.rb +24 -6
  59. data/lib/getch/log.rb +54 -0
  60. data/lib/getch/options.rb +16 -7
  61. data/lib/getch/version.rb +1 -1
  62. metadata +48 -5
  63. metadata.gz.sig +0 -0
  64. data/lib/getch/disk.rb +0 -77
  65. data/lib/getch/mount.rb +0 -73
@@ -0,0 +1,20 @@
1
+ module Getch
2
+ module FileSystem
3
+ module Zfs
4
+ class Format < Getch::FileSystem::Zfs::Device
5
+ def initialize
6
+ super
7
+ @state = Getch::States.new()
8
+ format
9
+ end
10
+
11
+ def format
12
+ return if STATES[:format]
13
+ system("mkfs.fat -F32 #{@dev_boot_efi}") if @dev_boot_efi
14
+ system("mkswap -f #{@dev_swap}")
15
+ @state.format
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,67 @@
1
+ require 'fileutils'
2
+
3
+ module Getch
4
+ module FileSystem
5
+ module Zfs
6
+ class Mount < Getch::FileSystem::Zfs::Device
7
+ def initialize
8
+ super
9
+ @root_dir = MOUNTPOINT
10
+ @boot_dir = "#{@root_dir}/boot"
11
+ @boot_efi_dir = "#{@root_dir}/boot/efi"
12
+ @state = Getch::States.new()
13
+ @log = Getch::Log.new
14
+ end
15
+
16
+ def run
17
+ return if STATES[:mount]
18
+ exec("zpool export -a")
19
+ exec("rm -rf #{MOUNTPOINT}/*")
20
+ exec("zpool import -N -R #{MOUNTPOINT} #{@pool_name}")
21
+ exec("zpool import -N -R #{MOUNTPOINT} #{@boot_pool_name}") if @dev_boot
22
+ mount_swap
23
+ mount_root
24
+ mount_boot
25
+ mount_boot_efi
26
+ exec("zfs mount -a")
27
+ @state.mount
28
+ end
29
+
30
+ private
31
+
32
+ def mount_swap
33
+ if Helpers::grep?('/proc/swaps', /^\/dev/)
34
+ exec("swapoff #{@dev_swap}")
35
+ end
36
+
37
+ exec("swapon #{@dev_swap}")
38
+ end
39
+
40
+ def mount_root
41
+ Helpers::mkdir(@root_dir)
42
+ exec("zfs mount #{@pool_name}/ROOT/gentoo")
43
+ end
44
+
45
+ def mount_boot_efi
46
+ return if ! @dev_boot_efi
47
+ Helpers::mkdir(@boot_efi_dir)
48
+ exec("mount #{@dev_boot_efi} #{@boot_efi_dir}")
49
+ end
50
+
51
+ def mount_boot
52
+ return if ! @dev_boot
53
+ Helpers::mkdir(@boot_dir)
54
+ exec("zfs mount #{@boot_pool_name}/BOOT/gentoo")
55
+ end
56
+
57
+ def exec(cmd)
58
+ @log.info("==> #{cmd}")
59
+ system(cmd)
60
+ unless $?.success?
61
+ raise "Error with #{cmd}"
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,147 @@
1
+ module Getch
2
+ module FileSystem
3
+ module Zfs
4
+ class Partition < Getch::FileSystem::Zfs::Device
5
+ def initialize
6
+ super
7
+ @state = Getch::States.new()
8
+ @log = Getch::Log.new()
9
+ run_partition
10
+ end
11
+
12
+ def run_partition
13
+ return if STATES[:partition ]
14
+ clear_struct
15
+ cleaning
16
+ partition
17
+ zfs
18
+ @state.partition
19
+ end
20
+
21
+ private
22
+
23
+ def clear_struct
24
+ oldvg = `vgdisplay | grep #{@vg}`.chomp
25
+ oldzpool = `zpool status | grep pool:`.gsub(/pool: /, '').delete(' ').split("\n")
26
+ if oldzpool[0] != "" and $?.success?
27
+ oldzpool.each { |p| exec("zpool destroy #{p}") if p }
28
+ end
29
+ exec("vgremove -f #{@vg}") if oldvg != '' # remove older volume group
30
+ exec("pvremove -f #{@dev_root}") if oldvg != '' and File.exist? @dev_root # remove older volume group
31
+
32
+ exec("sgdisk -Z /dev/#{@disk}")
33
+ exec("wipefs -a /dev/#{@disk}")
34
+ end
35
+
36
+ # See https://wiki.archlinux.org/index.php/Solid_state_drive/Memory_cell_clearing
37
+ # for SSD
38
+ def cleaning
39
+ @bloc=`blockdev --getbsz /dev/#{@disk}`.chomp
40
+ puts
41
+ print "Cleaning data on #{@disk}, can be long, avoid this on Flash Memory (SSD,USB,...) ? (n,y) "
42
+ case gets.chomp
43
+ when /^y|^Y/
44
+ exec("dd if=/dev/urandom of=/dev/#{@disk} bs=#{@bloc} status=progress")
45
+ else
46
+ return
47
+ end
48
+ end
49
+
50
+ def partition
51
+ mem=`awk '/MemTotal/ {print $2}' /proc/meminfo`.chomp + 'K'
52
+ if Helpers::efi?
53
+ exec("sgdisk -n1:1M:+260M -t1:EF00 /dev/#{@disk}")
54
+ exec("sgdisk -n2:0:+#{mem} -t2:8200 /dev/#{@disk}")
55
+ exec("sgdisk -n3:0:+0 -t3:BF00 /dev/#{@disk}")
56
+ else
57
+ exec("sgdisk -n1:1MiB:+1MiB -t1:EF02 /dev/#{@disk}")
58
+ exec("sgdisk -n2:0:+2G -t2:BE00 /dev/#{@disk}") # boot pool GRUB
59
+ exec("sgdisk -n3:0:+#{mem} -t3:8200 /dev/#{@disk}")
60
+ exec("sgdisk -n4:0:+0 -t4:BF00 /dev/#{@disk}")
61
+ end
62
+ end
63
+
64
+ def zfs
65
+ ashift = case @bloc
66
+ when 8096
67
+ 13
68
+ when 4096
69
+ 12
70
+ else # 512
71
+ 9
72
+ end
73
+
74
+ Helpers::mkdir(MOUNTPOINT)
75
+
76
+ @log.debug("ashift found for #{@bloc} - #{ashift}")
77
+ if ! Helpers::efi?
78
+ # https://openzfs.github.io/openzfs-docs/Getting%20Started/Ubuntu/Ubuntu%2020.04%20Root%20on%20ZFS.html
79
+ @log.info("Creating boot pool on #{@pool_name}")
80
+ exec("zpool create -f \\
81
+ -o ashift=#{ashift} -d \\
82
+ -o feature@async_destroy=enabled \\
83
+ -o feature@bookmarks=enabled \\
84
+ -o feature@embedded_data=enabled \\
85
+ -o feature@empty_bpobj=enabled \\
86
+ -o feature@enabled_txg=enabled \\
87
+ -o feature@extensible_dataset=enabled \\
88
+ -o feature@filesystem_limits=enabled \\
89
+ -o feature@hole_birth=enabled \\
90
+ -o feature@large_blocks=enabled \\
91
+ -o feature@lz4_compress=enabled \\
92
+ -o feature@spacemap_histogram=enabled \\
93
+ -O acltype=posixacl -O canmount=off -O compression=lz4 \\
94
+ -O devices=off -O normalization=formD -O atime=off -O xattr=sa \\
95
+ -O mountpoint=/boot -R #{MOUNTPOINT} \\
96
+ #{@boot_pool_name} #{@dev_boot}
97
+ ")
98
+ end
99
+
100
+ exec("zpool create -f -o ashift=#{ashift} \\
101
+ -O acltype=posixacl -O canmount=off -O compression=lz4 \\
102
+ -O dnodesize=auto -O normalization=formD -O atime=off \\
103
+ -O xattr=sa -O mountpoint=/ -R #{MOUNTPOINT} \\
104
+ #{@pool_name} #{@dev_root}
105
+ ")
106
+
107
+ add_datasets
108
+ end
109
+
110
+ def add_datasets
111
+ exec("zfs create -o canmount=off -o mountpoint=none #{@pool_name}/ROOT")
112
+ exec("zfs create -o canmount=off -o mountpoint=none #{@boot_pool_name}/BOOT") if @dev_boot
113
+
114
+ exec("zfs create -o canmount=noauto -o mountpoint=/ #{@pool_name}/ROOT/gentoo")
115
+ # set bootfs
116
+ #exec("zpool set bootfs=#{@pool_name}/ROOT/gentoo #{@pool_name}")
117
+ exec("zfs create -o canmount=noauto -o mountpoint=/boot #{@boot_pool_name}/BOOT/gentoo") if @dev_boot
118
+
119
+ exec("zfs create -o canmount=off #{@pool_name}/ROOT/gentoo/usr")
120
+ exec("zfs create #{@pool_name}/ROOT/gentoo/usr/src")
121
+ exec("zfs create -o canmount=off #{@pool_name}/ROOT/gentoo/var")
122
+ exec("zfs create #{@pool_name}/ROOT/gentoo/var/log")
123
+ exec("zfs create #{@pool_name}/ROOT/gentoo/var/db")
124
+ exec("zfs create #{@pool_name}/ROOT/gentoo/var/tmp")
125
+
126
+ exec("zfs create -o canmount=off -o mountpoint=/ #{@pool_name}/USERDATA")
127
+ exec("zfs create -o canmount=on -o mountpoint=/root #{@pool_name}/USERDATA/root")
128
+ exec("zfs create -o canmount=on -o mountpoint=/home/#{@user} #{@pool_name}/USERDATA/#{@user}") if @user
129
+ end
130
+
131
+ # Follow https://wiki.archlinux.org/index.php/Partitioning
132
+ # Partition_efi
133
+ # /boot/efi - EFI system partition - 260MB
134
+ # / - Root
135
+
136
+ # Partition_bios
137
+ # None - Bios Boot Partition - 1MiB
138
+ # /boot - Boot - 8300
139
+ # / - Root
140
+
141
+ def exec(cmd)
142
+ Getch::Command.new(cmd).run!
143
+ end
144
+ end
145
+ end
146
+ end
147
+ end
@@ -39,12 +39,12 @@ module Getch
39
39
  def chroot
40
40
  chroot = Getch::Gentoo::Chroot.new()
41
41
  chroot.update
42
- chroot.world
43
42
  chroot.systemd
43
+ chroot.world
44
44
  return if STATES[:gentoo_kernel]
45
45
  chroot.kernel
46
46
  chroot.kernel_deps
47
- chroot.install_tools
47
+ chroot.install_pkgs
48
48
  end
49
49
 
50
50
  def kernel
@@ -52,6 +52,7 @@ module Getch
52
52
  source = Getch::Gentoo::Sources.new()
53
53
  new
54
54
  source.build_kspp
55
+ source.init_config
55
56
  source.build_others
56
57
  source.make
57
58
  @state.kernel
@@ -6,13 +6,15 @@ module Getch
6
6
  def initialize(opts)
7
7
  @disk = opts.disk
8
8
  @user = opts.username
9
+ @config = Getch.class_fs::Config.new()
9
10
  end
10
11
 
11
12
  def start
12
- gen_fstab
13
+ @config.fstab
13
14
  bootloader
14
15
  password
15
- umount
16
+ cleanup
17
+ the_end
16
18
  end
17
19
 
18
20
  def bootloader
@@ -29,38 +31,33 @@ module Getch
29
31
  puts "Configuring systemd-boot."
30
32
  # ref: https://forums.gentoo.org/viewtopic-p-8118822.html
31
33
  esp = '/boot/efi'
32
- #systemd = "#{MOUNTPOINT}/usr/lib/systemd"
33
- #FileUtils.mkdir_p "#{systemd}#{esp}", mode: 0700 if ! Dir.exist?("#{systemd}#{esp}")
34
34
  exec_chroot("bootctl --path #{esp} install")
35
-
36
- root = `lsblk -o "PARTUUID" /dev/#{@disk}3 | tail -1`.chomp()
37
- init = '/usr/lib/systemd/systemd'
38
- datas_gentoo = [
39
- 'title Gentoo Linux',
40
- 'linux /vmlinuz',
41
- "options root=PARTUUID=#{root} init=#{init} rw"
42
- ]
43
35
  datas_loader = [
44
36
  'default gentoo',
45
37
  'timeout 3',
46
38
  'editor 0'
47
39
  ]
48
- File.write("#{MOUNTPOINT}/#{esp}/loader/entries/gentoo.conf", datas_gentoo.join("\n"))
40
+ @config.systemd_boot
49
41
  File.write("#{MOUNTPOINT}/#{esp}/loader/loader.conf", datas_loader.join("\n"))
50
42
 
51
43
  FileUtils.cp("#{MOUNTPOINT}/usr/src/linux/arch/x86/boot/bzImage", "#{MOUNTPOINT}/#{esp}/vmlinuz", preserve: true)
44
+
45
+ initramfs = Dir.glob("#{MOUNTPOINT}/boot/initramfs-*.img")
46
+ FileUtils.cp("#{initramfs[0]}", "#{MOUNTPOINT}/#{esp}/initramfs", preserve: true) if initramfs != []
47
+
52
48
  exec_chroot("bootctl --path #{esp} update")
53
49
  end
54
50
 
55
51
  def bootctl_dep
56
52
  puts 'Installing systemd-boot...'
57
53
  exec_chroot("euse -p sys-apps/systemd -E gnuefi")
58
- Helpers::emerge("sys-apps/systemd efivar", MOUNTPOINT)
54
+ Getch::Emerge.new("sys-apps/systemd efivar").pkg!
59
55
  end
60
56
 
61
57
  def grub
62
58
  puts 'Installing GRUB...'
63
- Helpers::emerge("sys-boot/grub:2", MOUNTPOINT)
59
+ Getch::Emerge.new("sys-boot/grub:2").pkg!
60
+ @config.grub
64
61
  exec_chroot("grub-install /dev/#{@disk}")
65
62
  exec_chroot('grub-mkconfig -o /boot/grub/grub.cfg')
66
63
  end
@@ -78,17 +75,24 @@ module Getch
78
75
  end
79
76
  end
80
77
 
81
- def umount
82
- Helpers::exec_or_die("umount -l /mnt/gentoo/dev{/shm,/pts,}")
83
- Helpers::exec_or_die("umount -R #{MOUNTPOINT}")
84
- puts "Reboot when you have done"
85
- end
86
-
87
78
  private
88
79
 
89
- def gen_fstab
90
- mount = Getch::Mount.new(@disk, @user)
91
- mount.gen_fstab
80
+ def cleanup
81
+ Getch::Emerge.new("emerge --depclean").run!
82
+ end
83
+
84
+ def the_end
85
+ #Helpers::exec_or_die("umount -l /mnt/gentoo/dev{/shm,/pts,}")
86
+ #Helpers::exec_or_die("umount -R #{MOUNTPOINT}")
87
+ puts
88
+ puts "getch has finish, before reboot, you can:"
89
+ puts " + Chroot on your system with: chroot #{MOUNTPOINT} /bin/bash"
90
+ puts " + Install more packages like networkmanager or emacs"
91
+ puts
92
+ puts " + Add more modules for your kernel (graphic, wifi card) and recompile it with:"
93
+ puts " genkernel --kernel-config=/usr/src/linux/.config all "
94
+ puts
95
+ puts "Reboot the system when you have done !"
92
96
  end
93
97
 
94
98
  def exec_chroot(cmd)
@@ -96,7 +100,7 @@ module Getch
96
100
  source /etc/profile
97
101
  #{cmd}
98
102
  \""
99
- Helpers::exec_or_die(script)
103
+ Getch::Command.new(script).run!
100
104
  end
101
105
  end
102
106
  end
@@ -3,21 +3,22 @@ module Getch
3
3
  class Chroot
4
4
  def initialize
5
5
  @state = Getch::States.new()
6
+ @pkgs = []
6
7
  mount
7
8
  end
8
9
 
9
10
  def update
10
11
  return if STATES[:gentoo_update]
11
12
  puts "Downloading the last ebuilds for Gentoo..."
12
- cmd = "emerge-webrsync"
13
+ Helpers::create_dir("#{MOUNTPOINT}/var/db/repos/gentoo")
14
+ cmd = "emaint sync --auto"
13
15
  exec_chroot(cmd)
14
16
  end
15
17
 
16
18
  def world
17
19
  return if STATES[:gentoo_update]
18
- puts "Update Gentoo"
19
- cmd = "emerge --update --deep --newuse @world"
20
- exec_chroot(cmd)
20
+ puts "Update Gentoo world"
21
+ Getch::Emerge.new("emerge --update --deep --newuse @world").run!
21
22
  @state.update
22
23
  end
23
24
 
@@ -29,10 +30,10 @@ module Getch
29
30
 
30
31
  def kernel
31
32
  return if Dir.exist? "#{MOUNTPOINT}/usr/src/linux"
32
- puts "Installing kernel gentoo-sources..."
33
33
  license = "#{MOUNTPOINT}/etc/portage/package.license"
34
34
  File.write(license, "sys-kernel/linux-firmware linux-fw-redistributable no-source-code\n")
35
- Helpers::emerge("sys-kernel/gentoo-sources linux-firmware", MOUNTPOINT)
35
+ @pkgs << "sys-kernel/gentoo-sources"
36
+ @pkgs << "dev-util/dwarves"
36
37
  end
37
38
 
38
39
  def kernel_deps
@@ -41,8 +42,12 @@ module Getch
41
42
  garden_dep
42
43
  end
43
44
 
44
- def install_tools
45
- Helpers::emerge("dhcpcd", MOUNTPOINT)
45
+ def install_pkgs
46
+ @pkgs << "app-admin/sudo"
47
+ @pkgs << "app-editors/vim"
48
+ all_pkgs = @pkgs.join(" ")
49
+ puts "Installing #{all_pkgs}..."
50
+ Getch::Emerge.new(all_pkgs).pkg!
46
51
  end
47
52
 
48
53
  private
@@ -54,14 +59,13 @@ module Getch
54
59
 
55
60
  Dir.chdir("#{MOUNTPOINT}/root")
56
61
  Helpers::get_file_online(url, file)
57
- Helpers::exec_or_die("tar xzf #{file}") if ! Dir.exist? 'garden-master'
62
+ Getch::Command.new("tar xzf #{file}").run! if ! Dir.exist? 'garden-master'
58
63
  end
59
64
 
60
65
  def garden_dep
61
- Helpers::emerge("gentoolkit", MOUNTPOINT)
62
- cmd = "euse -p sys-apps/kmod -E lzma"
63
- Helpers::emerge("kmod", MOUNTPOINT)
64
- exec_chroot(cmd)
66
+ Getch::Emerge.new("gentoolkit").pkg!
67
+ exec_chroot("euse -p sys-apps/kmod -E lzma")
68
+ @pkgs << "sys-apps/kmod"
65
69
  end
66
70
 
67
71
  def mount
@@ -80,7 +84,7 @@ module Getch
80
84
  source /etc/profile
81
85
  #{cmd}
82
86
  \""
83
- Helpers::exec_or_die(script)
87
+ Getch::Command.new(script).run!
84
88
  end
85
89
  end
86
90
  end
@@ -11,29 +11,38 @@ module Getch
11
11
 
12
12
  def portage
13
13
  nproc = `nproc`.chomp()
14
- efi = Helpers::efi? ? 'GRUB_PLATFORMS="efi-64"' : ''
14
+ grub_pc = Helpers::efi? ? '' : 'GRUB_PLATFORMS="pc"'
15
+ quiet = DEFAULT_OPTIONS[:verbose] ? '' : "EMERGE_DEFAULT_OPTS=\"--jobs=#{nproc} --load-average=#{nproc}\""
15
16
  data = [
16
17
  '',
17
- 'ACCEPT_KEYWORD="amd64 ~amd64"',
18
+ 'ACCEPT_KEYWORDS="amd64"',
18
19
  "MAKEOPTS=\"-j#{nproc} -l#{nproc}\"",
20
+ quiet,
19
21
  'INPUT_DEVICES="libinput"',
20
- efi
22
+ grub_pc
21
23
  ]
22
24
  File.write(@make, data.join("\n"), mode: "a")
23
25
  end
24
26
 
27
+ # Write a repos.conf/gentoo.conf with the gpg verification
25
28
  def repo
26
29
  src = "#{MOUNTPOINT}/usr/share/portage/config/repos.conf"
27
30
  dest = "#{MOUNTPOINT}/etc/portage/repos.conf"
28
31
  FileUtils.mkdir dest, mode: 0644 if ! Dir.exist?(dest)
32
+ tmp = Tempfile.new('gentoo.conf')
29
33
  line_count = 0
30
- tmp_file = Tempfile.new('gentoo.conf')
34
+
31
35
  File.open(src).each { |l|
32
- File.write(tmp_file, "sync-allow-hardlinks = yes\n", mode: 'a') if line_count == 2
33
- File.write(tmp_file, l, mode: 'a')
36
+ File.write(tmp, "sync-allow-hardlinks = yes\n", mode: 'a') if line_count == 2
37
+ if l.match(/^sync-type = rsync/)
38
+ File.write(tmp, "sync-type = webrsync\n", mode: 'a')
39
+ else
40
+ File.write(tmp, l, mode: 'a')
41
+ end
34
42
  line_count += 1
35
43
  }
36
- FileUtils.copy_file(tmp_file, "#{dest}/gentoo.conf", preserve = false)
44
+
45
+ FileUtils.copy_file(tmp, "#{dest}/gentoo.conf", preserve = false)
37
46
  end
38
47
 
39
48
  def network
@@ -48,7 +57,7 @@ module Getch
48
57
  File.write("#{MOUNTPOINT}/etc/locale.conf", "LANG=#{@lang}\n")
49
58
  File.write("#{MOUNTPOINT}/etc/locale.conf", 'LC_COLLATE=C', mode: 'a')
50
59
  File.write("#{MOUNTPOINT}/etc/timezone", "#{options.zoneinfo}")
51
- File.write("#{MOUNTPOINT}/etc/vconsole.conf", "KEYMAP=#{options.keyboard}")
60
+ File.write("#{MOUNTPOINT}/etc/vconsole.conf", "KEYMAP=#{options.keymap}")
52
61
  end
53
62
 
54
63
  def hostname
@@ -72,7 +81,7 @@ module Getch
72
81
  def control_options(options)
73
82
  search_zone(options.zoneinfo)
74
83
  search_utf8(options.language)
75
- search_key(options.keyboard)
84
+ search_key(options.keymap)
76
85
  end
77
86
 
78
87
  def search_key(keys)