From 677533f76521eeb9441301c4c0691270f872fe5b Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 1 Sep 2020 10:33:18 +0200 Subject: Added the option to set keyboard layout of installation. Not only on the live medium --- archinstall/lib/installer.py | 8 ++++++++ examples/guided.py | 11 ++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index a9470b7c..bd860186 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -242,6 +242,12 @@ class Installer(): o = b''.join(sys_command(f"/usr/bin/arch-chroot {self.mountpoint} sh -c \"echo '{user}:{password}' | chpasswd\"")) pass + def set_keyboard_language(language): + with open(f'{self.mountpoint}/etc/vconsole.conf', 'w') as vconsole: + vconsole.write(f'KEYMAP={language}\n') + vconsole.write(f'FONT=lat9w-16\n') + return True + def add_AUR_support(self): log(f'Building and installing yay support into {self.mountpoint}') self.add_additional_packages(['git', 'base-devel']) # TODO: Remove if not explicitly added at one point @@ -250,6 +256,8 @@ class Installer(): o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} sh -c "su - aibuilder -c \\"(cd /home/aibuilder; git clone https://aur.archlinux.org/yay.git)\\""')) o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} sh -c "chown -R aibuilder.aibuilder /home/aibuilder/yay"')) + + log(f'Building and installing yay.') o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} sh -c "su - aibuilder -c \\"(cd /home/aibuilder/yay; makepkg -si --noconfirm)\\" >/dev/null"')) o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} sh -c "userdel aibuilder; rm -rf /hoem/aibuilder"')) diff --git a/examples/guided.py b/examples/guided.py index 182a4fb0..a072a262 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -1,6 +1,6 @@ import archinstall, getpass, time -def perform_installation(device, boot_partition): +def perform_installation(device, boot_partition, language): """ Performs the installation steps on a block device. Only requirement is that the block devices are @@ -8,6 +8,7 @@ def perform_installation(device, boot_partition): """ with archinstall.Installer(device, boot_partition=boot_partition, hostname=hostname) as installation: if installation.minimal_installation(): + installation.set_keyboard_language(language) installation.add_bootloader() if len(packages) and packages[0] != '': @@ -26,7 +27,7 @@ def perform_installation(device, boot_partition): if root_pw: installation.user_set_pw('root', root_pw) - if len(aur.strip()): + if len(aur.strip()) and aur.strip().lower() != 'no': installation.add_AUR_support() # Unmount and close previous runs (in case the installer is restarted) @@ -82,7 +83,7 @@ while 1: break aur = input('Would you like AUR support? (leave blank for no): ') -if len(aur.strip()): +if len(aur.strip()) and aur.lower() != 'no': archinstall.log(' - AUR support provided by yay (https://aur.archlinux.org/packages/yay/)', bg='black', fg='white') profile = input('Any particular profile you want to install: ') @@ -125,7 +126,7 @@ with archinstall.Filesystem(harddrive, archinstall.GPT) as fs: with archinstall.luks2(harddrive.partition[1], 'luksloop', disk_password) as unlocked_device: unlocked_device.format('btrfs') - perform_installation(unlocked_device, harddrive.partition[0]) + perform_installation(unlocked_device, harddrive.partition[0], keyboard_language) else: harddrive.partition[1].format('ext4') - perform_installation(harddrive.partition[1], harddrive.partition[0]) \ No newline at end of file + perform_installation(harddrive.partition[1], harddrive.partition[0], keyboard_language) \ No newline at end of file -- cgit v1.2.3-70-g09d2