Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 45 additions & 8 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import re
import shlex
import shutil
import stat
import subprocess
import textwrap
import time
Expand Down Expand Up @@ -1329,14 +1330,6 @@ def _add_grub_bootloader(

self.pacman.strap('grub')

grub_default = self.target / 'etc/default/grub'
config = grub_default.read_text()

kernel_parameters = ' '.join(self._get_kernel_params(root, False, False))
config = re.sub(r'(GRUB_CMDLINE_LINUX=")("\n)', rf'\1{kernel_parameters}\2', config, count=1)

grub_default.write_text(config)

info(f'GRUB boot partition: {boot_partition.dev_path}')

boot_dir = Path('/boot')
Expand Down Expand Up @@ -1394,6 +1387,50 @@ def _add_grub_bootloader(
except SysCallError as err:
raise DiskError(f'Failed to install GRUB boot on {boot_partition.dev_path}: {err}')

if SysInfo.has_uefi() and uki_enabled:
grub_d = self.target / 'etc/grub.d'
linux_file = grub_d / '10_linux'
uki_file = grub_d / '15_uki'

raw_str_platform = r'\$grub_platform'
space_indent_cmd = ' uki'
content = textwrap.dedent(
f"""\
#! /bin/sh
set -e

cat << EOF
if [ "{raw_str_platform}" = "efi" ]; then
{space_indent_cmd}
fi
EOF
""",
)

try:
mode = linux_file.stat().st_mode
linux_file.chmod(mode & ~(stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH))
uki_file.write_text(content)
uki_file.chmod(mode)
except OSError:
error('Failed to enable UKI menu entries')
else:
grub_default = self.target / 'etc/default/grub'
config = grub_default.read_text()

kernel_parameters = ' '.join(
self._get_kernel_params(root, id_root=False, partuuid=False),
)
config = re.sub(
r'^(GRUB_CMDLINE_LINUX=")(")$',
rf'\1{kernel_parameters}\2',
config,
count=1,
flags=re.MULTILINE,
)

grub_default.write_text(config)

try:
self.arch_chroot(
f'grub-mkconfig -o {boot_dir}/grub/grub.cfg',
Expand Down