lib/getch/gentoo/config.rb in getch-0.0.8 vs lib/getch/gentoo/config.rb in getch-0.0.9

- old
+ new

@@ -22,22 +22,29 @@ grub_pc ] File.write(@make, data.join("\n"), mode: "a") end + # Write a repos.conf/gentoo.conf with the gpg verification def repo src = "#{MOUNTPOINT}/usr/share/portage/config/repos.conf" dest = "#{MOUNTPOINT}/etc/portage/repos.conf" FileUtils.mkdir dest, mode: 0644 if ! Dir.exist?(dest) + tmp = Tempfile.new('gentoo.conf') line_count = 0 - tmp_file = Tempfile.new('gentoo.conf') + File.open(src).each { |l| - File.write(tmp_file, "sync-allow-hardlinks = yes\n", mode: 'a') if line_count == 2 - File.write(tmp_file, l, mode: 'a') + File.write(tmp, "sync-allow-hardlinks = yes\n", mode: 'a') if line_count == 2 + if l.match(/^sync-type = rsync/) + File.write(tmp, "sync-type = webrsync\n", mode: 'a') + else + File.write(tmp, l, mode: 'a') + end line_count += 1 } - FileUtils.copy_file(tmp_file, "#{dest}/gentoo.conf", preserve = false) + + FileUtils.copy_file(tmp, "#{dest}/gentoo.conf", preserve = false) end def network src = '/etc/resolv.conf' dest = "#{MOUNTPOINT}/etc/resolv.conf" @@ -48,11 +55,11 @@ control_options(options) File.write("#{MOUNTPOINT}/etc/locale.gen", @utf8) File.write("#{MOUNTPOINT}/etc/locale.conf", "LANG=#{@lang}\n") File.write("#{MOUNTPOINT}/etc/locale.conf", 'LC_COLLATE=C', mode: 'a') File.write("#{MOUNTPOINT}/etc/timezone", "#{options.zoneinfo}") - File.write("#{MOUNTPOINT}/etc/vconsole.conf", "KEYMAP=#{options.keyboard}") + File.write("#{MOUNTPOINT}/etc/vconsole.conf", "KEYMAP=#{options.keymap}") end def hostname id = SecureRandom.hex(2) File.write("#{MOUNTPOINT}/etc/hostname", "gentoo-hatch-#{id}") @@ -72,10 +79,10 @@ private def control_options(options) search_zone(options.zoneinfo) search_utf8(options.language) - search_key(options.keyboard) + search_key(options.keymap) end def search_key(keys) @keymap = nil Dir.glob("#{MOUNTPOINT}/usr/share/keymaps/**/#{keys}.map.gz") { |f|