Skip to content

Commit a59efc4

Browse files
committed
Added missing btrfs to mkinitcpio. Also added a bunch of locale stuff and genfstab which I forgot
1 parent 1fabd5c commit a59efc4

1 file changed

Lines changed: 42 additions & 2 deletions

File tree

archinstall/lib/installer.py

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,49 @@ def pacstrap(self, *packages, **kwargs):
4141
else:
4242
log(f'Could not sync mirrors: {sync_mirrors.exit_code}')
4343

44+
def genfstab(self, flags='-Pu'):
45+
o = b''.join(sys_command(f'/usr/bin/genfstab -pU {self.mountpoint} >> {self.mountpoint}/etc/fstab'))
46+
if not os.path.isfile(f'{self.mountpoint}/etc/fstab'):
47+
raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{o}')
48+
return True
49+
50+
def set_hostname(self, hostname=None):
51+
if not hostname: hostname = self.hostname
52+
with open(f'{self.mountpoint}/etc/hostname', 'w') as fh:
53+
fh.write(self.hostname + '\n')
54+
55+
def set_locale(self, locale, encoding='UTF-8'):
56+
with open(f'{self.mountpoint}/etc/locale.gen', 'a') as locale:
57+
locale.write(f'{locale} {encoding}\n')
58+
with open(f'{self.mountpoint}/etc/locale.conf', 'w') as locale:
59+
locale.write(f'LANG={locale}\n')
60+
sys_command(f'/usr/bin/arch-chroot {self.mountpoint} locale-gen')
61+
4462
def minimal_installation(self):
45-
if (x := self.pacstrap('base base-devel linux linux-firmware btrfs-progs efibootmgr nano wpa_supplicant dialog'.split(' '))):
46-
return x
63+
self.pacstrap('base base-devel linux linux-firmware btrfs-progs efibootmgr nano wpa_supplicant dialog'.split(' '))
64+
self.genfstab()
65+
66+
with open(f'{self.mountpoint}/etc/fstab', 'a') as fstab:
67+
fstab.write('\ntmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0\n') # Redundant \n at the start? who knoes?
68+
69+
## TODO: Support locale and timezone
70+
#os.remove(f'{self.mountpoint}/etc/localtime')
71+
#sys_command(f'/usr/bin/arch-chroot {self.mountpoint} ln -s /usr/share/zoneinfo/{localtime} /etc/localtime')
72+
#sys_command('/usr/bin/arch-chroot /mnt hwclock --hctosys --localtime')
73+
self.set_hostname()
74+
self.set_locale('en_US.UTF-8')
75+
76+
# TODO: Use python functions for this
77+
sys_command(f'/usr/bin/arch-chroot {self.mountpoint} chmod 700 /root')
78+
79+
if self.partition.filesystem == 'btrfs':
80+
with open(f'{self.mountpoint}/etc/mkinitcpio.conf', 'w') as mkinit:
81+
## TODO: Don't replace it, in case some update in the future actually adds something.
82+
mkinit.write('MODULES=(btrfs)\n')
83+
mkinit.write('BINARIES=(/usr/bin/btrfs)\n')
84+
mkinit.write('FILES=()\n')
85+
mkinit.write('HOOKS=(base udev autodetect modconf block encrypt filesystems keyboard fsck)\n')
86+
sys_command(f'/usr/bin/arch-chroot {self.mountpoint} mkinitcpio -p linux')
4787

4888
def add_bootloader(self):
4989
log(f'Adding bootloader to {self.boot_partition}')

0 commit comments

Comments
 (0)