PR #534: Fixes hardcoded kernels in boot config for systemd
Fixing hardcoded kernel in boot-config
This commit is contained in:
commit
17c65a0abb
|
|
@ -40,6 +40,7 @@ class Installer:
|
||||||
base_packages = __packages__[:3]
|
base_packages = __packages__[:3]
|
||||||
if kernels is None:
|
if kernels is None:
|
||||||
kernels = ['linux']
|
kernels = ['linux']
|
||||||
|
self.kernels = kernels
|
||||||
self.target = target
|
self.target = target
|
||||||
self.init_time = time.strftime('%Y-%m-%d_%H-%M-%S')
|
self.init_time = time.strftime('%Y-%m-%d_%H-%M-%S')
|
||||||
self.milliseconds = int(str(time.time()).split('.')[1])
|
self.milliseconds = int(str(time.time()).split('.')[1])
|
||||||
|
|
@ -53,6 +54,7 @@ class Installer:
|
||||||
for kernel in kernels:
|
for kernel in kernels:
|
||||||
self.base_packages.append(kernel)
|
self.base_packages.append(kernel)
|
||||||
|
|
||||||
|
|
||||||
self.post_base_install = []
|
self.post_base_install = []
|
||||||
|
|
||||||
storage['session'] = self
|
storage['session'] = self
|
||||||
|
|
@ -453,45 +455,42 @@ class Installer:
|
||||||
with open(f'{self.target}/boot/loader/loader.conf', 'w') as loader:
|
with open(f'{self.target}/boot/loader/loader.conf', 'w') as loader:
|
||||||
for line in loader_data:
|
for line in loader_data:
|
||||||
if line[:8] == 'default ':
|
if line[:8] == 'default ':
|
||||||
loader.write(f'default {self.init_time}\n')
|
loader.write(f'default {self.init_time}_{self.kernels[0]}\n')
|
||||||
elif line[:8] == '#timeout' and 'timeout 5' not in loader_data:
|
elif line[:8] == '#timeout' and 'timeout 5' not in loader_data:
|
||||||
# We add in the default timeout to support dual-boot
|
# We add in the default timeout to support dual-boot
|
||||||
loader.write(f"{line[1:]}\n")
|
loader.write(f"{line[1:]}\n")
|
||||||
else:
|
else:
|
||||||
loader.write(f"{line}\n")
|
loader.write(f"{line}\n")
|
||||||
|
|
||||||
# For some reason, blkid and /dev/disk/by-uuid are not getting along well.
|
for kernel in self.kernels:
|
||||||
# And blkid is wrong in terms of LUKS.
|
# Setup the loader entry
|
||||||
# UUID = sys_command('blkid -s PARTUUID -o value {drive}{partition_2}'.format(**args)).decode('UTF-8').strip()
|
with open(f'{self.target}/boot/loader/entries/{self.init_time}_{kernel}.conf', 'w') as entry:
|
||||||
# Setup the loader entry
|
entry.write('# Created by: archinstall\n')
|
||||||
with open(f'{self.target}/boot/loader/entries/{self.init_time}.conf', 'w') as entry:
|
entry.write(f'# Created on: {self.init_time}\n')
|
||||||
entry.write('# Created by: archinstall\n')
|
entry.write('title Arch Linux\n')
|
||||||
entry.write(f'# Created on: {self.init_time}\n')
|
entry.write(f"linux /vmlinuz-{kernel}\n") # Issue: hardcoded
|
||||||
entry.write('title Arch Linux\n')
|
if not is_vm():
|
||||||
entry.write('linux /vmlinuz-linux\n')
|
vendor = cpu_vendor()
|
||||||
if not is_vm():
|
if vendor == "AuthenticAMD":
|
||||||
vendor = cpu_vendor()
|
entry.write("initrd /amd-ucode.img\n")
|
||||||
if vendor == "AuthenticAMD":
|
elif vendor == "GenuineIntel":
|
||||||
entry.write("initrd /amd-ucode.img\n")
|
entry.write("initrd /intel-ucode.img\n")
|
||||||
elif vendor == "GenuineIntel":
|
else:
|
||||||
entry.write("initrd /intel-ucode.img\n")
|
self.log("unknow cpu vendor, not adding ucode to systemd-boot config")
|
||||||
|
entry.write(f"initrd /initramfs-{kernel}.img\n")
|
||||||
|
# blkid doesn't trigger on loopback devices really well,
|
||||||
|
# so we'll use the old manual method until we get that sorted out.
|
||||||
|
|
||||||
|
if real_device := self.detect_encryption(root_partition):
|
||||||
|
# TODO: We need to detect if the encrypted device is a whole disk encryption,
|
||||||
|
# or simply a partition encryption. Right now we assume it's a partition (and we always have)
|
||||||
|
log(f"Identifying root partition by PART-UUID on {real_device}: '{real_device.uuid}'.", level=logging.DEBUG)
|
||||||
|
entry.write(f'options cryptdevice=PARTUUID={real_device.uuid}:luksdev root=/dev/mapper/luksdev rw intel_pstate=no_hwp {" ".join(self.KERNEL_PARAMS)}\n')
|
||||||
else:
|
else:
|
||||||
self.log("unknow cpu vendor, not adding ucode to systemd-boot config")
|
log(f"Identifying root partition by PART-UUID on {root_partition}, looking for '{root_partition.uuid}'.", level=logging.DEBUG)
|
||||||
entry.write('initrd /initramfs-linux.img\n')
|
entry.write(f'options root=PARTUUID={root_partition.uuid} rw intel_pstate=no_hwp {" ".join(self.KERNEL_PARAMS)}\n')
|
||||||
# blkid doesn't trigger on loopback devices really well,
|
|
||||||
# so we'll use the old manual method until we get that sorted out.
|
|
||||||
|
|
||||||
if real_device := self.detect_encryption(root_partition):
|
self.helper_flags['bootloader'] = bootloader
|
||||||
# TODO: We need to detect if the encrypted device is a whole disk encryption,
|
|
||||||
# or simply a partition encryption. Right now we assume it's a partition (and we always have)
|
|
||||||
log(f"Identifying root partition by PART-UUID on {real_device}: '{real_device.uuid}'.", level=logging.DEBUG)
|
|
||||||
entry.write(f'options cryptdevice=PARTUUID={real_device.uuid}:luksdev root=/dev/mapper/luksdev rw intel_pstate=no_hwp {" ".join(self.KERNEL_PARAMS)}\n')
|
|
||||||
else:
|
|
||||||
log(f"Identifying root partition by PART-UUID on {root_partition}, looking for '{root_partition.uuid}'.", level=logging.DEBUG)
|
|
||||||
entry.write(f'options root=PARTUUID={root_partition.uuid} rw intel_pstate=no_hwp {" ".join(self.KERNEL_PARAMS)}\n')
|
|
||||||
|
|
||||||
self.helper_flags['bootloader'] = bootloader
|
|
||||||
return True
|
|
||||||
|
|
||||||
elif bootloader == "grub-install":
|
elif bootloader == "grub-install":
|
||||||
self.pacstrap('grub')
|
self.pacstrap('grub')
|
||||||
|
|
@ -509,10 +508,11 @@ class Installer:
|
||||||
o = b''.join(SysCommand(f'/usr/bin/arch-chroot {self.target} grub-install --target=i386-pc /dev/{root_device}'))
|
o = b''.join(SysCommand(f'/usr/bin/arch-chroot {self.target} grub-install --target=i386-pc /dev/{root_device}'))
|
||||||
SysCommand('/usr/bin/arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg')
|
SysCommand('/usr/bin/arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg')
|
||||||
self.helper_flags['bootloader'] = True
|
self.helper_flags['bootloader'] = True
|
||||||
return True
|
|
||||||
else:
|
else:
|
||||||
raise RequirementError(f"Unknown (or not yet implemented) bootloader requested: {bootloader}")
|
raise RequirementError(f"Unknown (or not yet implemented) bootloader requested: {bootloader}")
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def add_additional_packages(self, *packages):
|
def add_additional_packages(self, *packages):
|
||||||
return self.pacstrap(*packages)
|
return self.pacstrap(*packages)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ plugins = {}
|
||||||
# 1: List archinstall.plugin definitions
|
# 1: List archinstall.plugin definitions
|
||||||
# 2: Load the plugin entrypoint
|
# 2: Load the plugin entrypoint
|
||||||
# 3: Initiate the plugin and store it as .name in plugins
|
# 3: Initiate the plugin and store it as .name in plugins
|
||||||
for plugin_definition in metadata.entry_points()['archinstall.plugin']:
|
for plugin_definition in metadata.entry_points().get('archinstall.plugin', []):
|
||||||
plugin_entrypoint = plugin_definition.load()
|
plugin_entrypoint = plugin_definition.load()
|
||||||
try:
|
try:
|
||||||
plugins[plugin_definition.name] = plugin_entrypoint()
|
plugins[plugin_definition.name] = plugin_entrypoint()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue