Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/installer.py
diff options
context:
space:
mode:
authorDaniel Girtler <blackrabbit256@gmail.com>2023-06-05 18:02:49 +1000
committerGitHub <noreply@github.com>2023-06-05 10:02:49 +0200
commit06eadb31d4f0bca0c8cb95b6a9eb62ddd2d7cff2 (patch)
tree07a7ed675d125703346fa343f1aa9e5e4129dd5f /archinstall/lib/installer.py
parent5276d95339368210e75791e2b88c1bf5aca4517b (diff)
Move locales and cleanup menu (#1814)
* Cleanup imports and unused code * Cleanup imports and unused code * Update build check * Keep deprecation exception * Simplify logging * Move locale into new sub-menu --------- Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
Diffstat (limited to 'archinstall/lib/installer.py')
-rw-r--r--archinstall/lib/installer.py38
1 files changed, 19 insertions, 19 deletions
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
index 30442774..6eac85fc 100644
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -12,6 +12,7 @@ from . import disk
from .exceptions import DiskError, ServiceException, RequirementError, HardwareIncompatibilityError, SysCallError
from .general import SysCommand
from .hardware import SysInfo
+from .locale import LocaleConfiguration
from .locale import verify_keyboard_layout, verify_x11_keyboard_layout
from .luks import Luks2
from .mirrors import use_mirrors, MirrorConfiguration, add_custom_mirrors
@@ -457,37 +458,36 @@ class Installer:
with open(f'{self.target}/etc/hostname', 'w') as fh:
fh.write(hostname + '\n')
- def set_locale(self, locale :str, encoding :str = 'UTF-8', *args :str, **kwargs :str) -> bool:
- if not len(locale):
- return True
-
+ def set_locale(self, locale_config: LocaleConfiguration):
modifier = ''
+ lang = locale_config.sys_lang
+ encoding = locale_config.sys_enc
# This is a temporary patch to fix #1200
- if '.' in locale:
- locale, potential_encoding = locale.split('.', 1)
+ if '.' in locale_config.sys_lang:
+ lang, potential_encoding = locale_config.sys_lang.split('.', 1)
# Override encoding if encoding is set to the default parameter
# and the "found" encoding differs.
- if encoding == 'UTF-8' and encoding != potential_encoding:
+ if locale_config.sys_enc == 'UTF-8' and locale_config.sys_enc != potential_encoding:
encoding = potential_encoding
# Make sure we extract the modifier, that way we can put it in if needed.
- if '@' in locale:
- locale, modifier = locale.split('@', 1)
+ if '@' in locale_config.sys_lang:
+ lang, modifier = locale_config.sys_lang.split('@', 1)
modifier = f"@{modifier}"
# - End patch
with open(f'{self.target}/etc/locale.gen', 'a') as fh:
- fh.write(f'{locale}.{encoding}{modifier} {encoding}\n')
+ fh.write(f'{lang}.{encoding}{modifier} {encoding}\n')
+
with open(f'{self.target}/etc/locale.conf', 'w') as fh:
- fh.write(f'LANG={locale}.{encoding}{modifier}\n')
+ fh.write(f'LANG={lang}.{encoding}{modifier}\n')
try:
SysCommand(f'/usr/bin/arch-chroot {self.target} locale-gen')
- return True
- except SysCallError:
- return False
+ except SysCallError as e:
+ error(f'Failed to run locale-gen on target: {e}')
def set_timezone(self, zone :str, *args :str, **kwargs :str) -> bool:
if not zone:
@@ -620,7 +620,7 @@ class Installer:
return True
- def mkinitcpio(self, *flags :str) -> bool:
+ def mkinitcpio(self, flags: List[str], locale_config: LocaleConfiguration) -> bool:
for plugin in plugins.values():
if hasattr(plugin, 'on_mkinitcpio'):
# Allow plugins to override the usage of mkinitcpio altogether.
@@ -630,7 +630,7 @@ class Installer:
# mkinitcpio will error out if there's no vconsole.
if (vconsole := Path(f"{self.target}/etc/vconsole.conf")).exists() is False:
with vconsole.open('w') as fh:
- fh.write(f"KEYMAP={storage['arguments']['keyboard-layout']}\n")
+ fh.write(f"KEYMAP={locale_config.kb_layout}\n")
with open(f'{self.target}/etc/mkinitcpio.conf', 'w') as mkinit:
mkinit.write(f"MODULES=({' '.join(self.modules)})\n")
@@ -658,7 +658,7 @@ class Installer:
testing: bool = False,
multilib: bool = False,
hostname: str = 'archinstall',
- locales: List[str] = ['en_US.UTF-8 UTF-8']
+ locale_config: LocaleConfiguration = LocaleConfiguration.default()
):
for mod in self._disk_config.device_modifications:
for part in mod.partitions:
@@ -734,12 +734,12 @@ class Installer:
# sys_command(f'/usr/bin/arch-chroot {self.target} ln -s /usr/share/zoneinfo/{localtime} /etc/localtime')
# sys_command('/usr/bin/arch-chroot /mnt hwclock --hctosys --localtime')
self.set_hostname(hostname)
- self.set_locale(*locales[0].split())
+ self.set_locale(locale_config)
# TODO: Use python functions for this
SysCommand(f'/usr/bin/arch-chroot {self.target} chmod 700 /root')
- self.mkinitcpio('-P')
+ self.mkinitcpio(['-P'], locale_config)
self.helper_flags['base'] = True