New function: set_locale(). Takes a format string of either a full locale-gen valid format such as 'en_US.UTF-8 UTF-8' or a shortened version 'US'. Currently only 'SE' is implemented tho.'

This commit is contained in:
Anton Hvornum 2020-03-16 10:31:42 +01:00
parent 2f283a4338
commit ef088bc624
1 changed files with 37 additions and 24 deletions

View File

@ -1014,7 +1014,22 @@ def strap_in_base(*positionals, **kwargs):
return True return True
return False return False
def set_locale(fmt):
if not '.' in fmt:
if fmt.lower() == 'se':
fmt = 'en_SE.UTF-8 UTF-8'
else:
fmt = 'en_US.UTF-8 UTF-8'
if not SAFETY_LOCK:
o = b''.join(sys_command(f"/usr/bin/arch-chroot /mnt sh -c \"echo '{fmt}' > /etc/locale.gen\""))
o = b''.join(sys_command(f"/usr/bin/arch-chroot /mnt sh -c \"echo 'LANG={fmt.split(' ')[0]}' > /etc/locale.conf\""))
o = b''.join(sys_command('/usr/bin/arch-chroot /mnt locale-gen'))
return True
def configure_base_system(*positionals, **kwargs): def configure_base_system(*positionals, **kwargs):
if not SAFETY_LOCK:
## TODO: Replace a lot of these syscalls with just python native operations. ## TODO: Replace a lot of these syscalls with just python native operations.
o = b''.join(sys_command('/usr/bin/genfstab -pU /mnt >> /mnt/etc/fstab')) o = b''.join(sys_command('/usr/bin/genfstab -pU /mnt >> /mnt/etc/fstab'))
if not os.path.isfile('/mnt/etc/fstab'): if not os.path.isfile('/mnt/etc/fstab'):
@ -1030,9 +1045,7 @@ def configure_base_system(*positionals, **kwargs):
#o = sys_command('arch-chroot /mnt echo "{hostname}" > /etc/hostname'.format(**args)) #o = sys_command('arch-chroot /mnt echo "{hostname}" > /etc/hostname'.format(**args))
#o = sys_command("arch-chroot /mnt sed -i 's/#\(en_US\.UTF-8\)/\1/' /etc/locale.gen") #o = sys_command("arch-chroot /mnt sed -i 's/#\(en_US\.UTF-8\)/\1/' /etc/locale.gen")
o = b''.join(sys_command("/usr/bin/arch-chroot /mnt sh -c \"echo '{hostname}' > /etc/hostname\"".format(**args))) o = b''.join(sys_command("/usr/bin/arch-chroot /mnt sh -c \"echo '{hostname}' > /etc/hostname\"".format(**args)))
o = b''.join(sys_command("/usr/bin/arch-chroot /mnt sh -c \"echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen\"")) set_locale('en_US.UTF-8 UTF-8')
o = b''.join(sys_command("/usr/bin/arch-chroot /mnt sh -c \"echo 'LANG=en_US.UTF-8' > /etc/locale.conf\""))
o = b''.join(sys_command('/usr/bin/arch-chroot /mnt locale-gen'))
o = b''.join(sys_command('/usr/bin/arch-chroot /mnt chmod 700 /root')) o = b''.join(sys_command('/usr/bin/arch-chroot /mnt chmod 700 /root'))
with open('/mnt/etc/mkinitcpio.conf', 'w') as mkinit: with open('/mnt/etc/mkinitcpio.conf', 'w') as mkinit: