Merge pull request #1080 from a-wai/fix-systemd-boot-install
[bootloader] Fix systemd-boot installation
This commit is contained in:
commit
7711cb0ad3
@ -87,17 +87,18 @@ def get_kernel_line(kernel_type):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def create_systemd_boot_conf(uuid, conf_path, kernel_line):
|
def create_systemd_boot_conf(install_path, efi_dir, uuid, entry, entry_name, kernel_type):
|
||||||
"""
|
"""
|
||||||
Creates systemd-boot configuration files based on given parameters.
|
Creates systemd-boot configuration files based on given parameters.
|
||||||
|
|
||||||
|
:param install_path:
|
||||||
|
:param efi_dir:
|
||||||
:param uuid:
|
:param uuid:
|
||||||
:param conf_path:
|
:param entry:
|
||||||
:param kernel_line:
|
:param entry_name:
|
||||||
|
:param kernel_type:
|
||||||
"""
|
"""
|
||||||
distribution = get_bootloader_entry_name()
|
|
||||||
kernel = libcalamares.job.configuration["kernel"]
|
kernel = libcalamares.job.configuration["kernel"]
|
||||||
img = libcalamares.job.configuration["img"]
|
|
||||||
kernel_params = ["quiet"]
|
kernel_params = ["quiet"]
|
||||||
|
|
||||||
partitions = libcalamares.globalstorage.value("partitions")
|
partitions = libcalamares.globalstorage.value("partitions")
|
||||||
@ -131,14 +132,40 @@ def create_systemd_boot_conf(uuid, conf_path, kernel_line):
|
|||||||
if swap_uuid:
|
if swap_uuid:
|
||||||
kernel_params.append("resume=UUID={!s}".format(swap_uuid))
|
kernel_params.append("resume=UUID={!s}".format(swap_uuid))
|
||||||
|
|
||||||
|
kernel_line = get_kernel_line(kernel_type)
|
||||||
|
libcalamares.utils.debug("Configure: \"{!s}\"".format(kernel_line))
|
||||||
|
|
||||||
|
if kernel_type == "fallback":
|
||||||
|
img = libcalamares.job.configuration["fallback"]
|
||||||
|
entry_name = entry_name + "-fallback"
|
||||||
|
else:
|
||||||
|
img = libcalamares.job.configuration["img"]
|
||||||
|
|
||||||
|
conf_path = os.path.join(install_path + efi_dir,
|
||||||
|
"loader",
|
||||||
|
"entries",
|
||||||
|
entry_name + ".conf")
|
||||||
|
|
||||||
|
# Copy kernel and initramfs to a subdirectory of /efi partition
|
||||||
|
files_dir = os.path.join(install_path + efi_dir, entry_name)
|
||||||
|
os.mkdir(files_dir)
|
||||||
|
|
||||||
|
kernel_path = install_path + kernel
|
||||||
|
kernel_name = os.path.basename(kernel_path)
|
||||||
|
shutil.copyfile(kernel_path, os.path.join(files_dir, kernel_name))
|
||||||
|
|
||||||
|
img_path = install_path + img
|
||||||
|
img_name = os.path.basename(img_path)
|
||||||
|
shutil.copyfile(img_path, os.path.join(files_dir, img_name))
|
||||||
|
|
||||||
lines = [
|
lines = [
|
||||||
'## This is just an example config file.\n',
|
'## This is just an example config file.\n',
|
||||||
'## Please edit the paths and kernel parameters according\n',
|
'## Please edit the paths and kernel parameters according\n',
|
||||||
'## to your system.\n',
|
'## to your system.\n',
|
||||||
'\n',
|
'\n',
|
||||||
"title {!s}{!s}\n".format(distribution, kernel_line),
|
"title {!s}{!s}\n".format(entry, kernel_line),
|
||||||
"linux {!s}\n".format(kernel),
|
"linux {!s}\n".format(os.path.join("/", entry_name, kernel_name)),
|
||||||
"initrd {!s}\n".format(img),
|
"initrd {!s}\n".format(os.path.join("/", entry_name, img_name)),
|
||||||
"options {!s} rw\n".format(" ".join(kernel_params)),
|
"options {!s} rw\n".format(" ".join(kernel_params)),
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -147,19 +174,17 @@ def create_systemd_boot_conf(uuid, conf_path, kernel_line):
|
|||||||
conf_file.write(line)
|
conf_file.write(line)
|
||||||
|
|
||||||
|
|
||||||
def create_loader(loader_path):
|
def create_loader(loader_path, entry):
|
||||||
"""
|
"""
|
||||||
Writes configuration for loader.
|
Writes configuration for loader.
|
||||||
|
|
||||||
:param loader_path:
|
:param loader_path:
|
||||||
|
:param entry:
|
||||||
"""
|
"""
|
||||||
distribution = get_bootloader_entry_name()
|
|
||||||
timeout = libcalamares.job.configuration["timeout"]
|
timeout = libcalamares.job.configuration["timeout"]
|
||||||
file_name_sanitizer = str.maketrans(" /", "_-")
|
|
||||||
distribution_translated = distribution.translate(file_name_sanitizer)
|
|
||||||
lines = [
|
lines = [
|
||||||
"timeout {!s}\n".format(timeout),
|
"timeout {!s}\n".format(timeout),
|
||||||
"default {!s}\n".format(distribution_translated),
|
"default {!s}\n".format(entry),
|
||||||
]
|
]
|
||||||
|
|
||||||
with open(loader_path, 'w') as loader_file:
|
with open(loader_path, 'w') as loader_file:
|
||||||
@ -204,27 +229,26 @@ def install_systemd_boot(efi_directory):
|
|||||||
distribution = get_bootloader_entry_name()
|
distribution = get_bootloader_entry_name()
|
||||||
file_name_sanitizer = str.maketrans(" /", "_-")
|
file_name_sanitizer = str.maketrans(" /", "_-")
|
||||||
distribution_translated = distribution.translate(file_name_sanitizer)
|
distribution_translated = distribution.translate(file_name_sanitizer)
|
||||||
conf_path = os.path.join(install_efi_directory,
|
|
||||||
"loader",
|
|
||||||
"entries",
|
|
||||||
distribution_translated + ".conf")
|
|
||||||
fallback_path = os.path.join(install_efi_directory,
|
|
||||||
"loader",
|
|
||||||
"entries",
|
|
||||||
distribution_translated + "-fallback.conf")
|
|
||||||
loader_path = os.path.join(install_efi_directory,
|
loader_path = os.path.join(install_efi_directory,
|
||||||
"loader",
|
"loader",
|
||||||
"loader.conf")
|
"loader.conf")
|
||||||
subprocess.call(["bootctl",
|
subprocess.call(["bootctl",
|
||||||
"--path={!s}".format(install_efi_directory),
|
"--path={!s}".format(install_efi_directory),
|
||||||
"install"])
|
"install"])
|
||||||
kernel_line = get_kernel_line("default")
|
create_systemd_boot_conf(install_path,
|
||||||
libcalamares.utils.debug("Configure: \"{!s}\"".format(kernel_line))
|
efi_directory,
|
||||||
create_systemd_boot_conf(uuid, conf_path, kernel_line)
|
uuid,
|
||||||
kernel_line = get_kernel_line("fallback")
|
distribution,
|
||||||
libcalamares.utils.debug("Configure: \"{!s}\"".format(kernel_line))
|
distribution_translated,
|
||||||
create_systemd_boot_conf(uuid, fallback_path, kernel_line)
|
"default")
|
||||||
create_loader(loader_path)
|
if "fallback" in libcalamares.job.configuration:
|
||||||
|
create_systemd_boot_conf(install_path,
|
||||||
|
efi_directory,
|
||||||
|
uuid,
|
||||||
|
distribution,
|
||||||
|
distribution_translated,
|
||||||
|
"fallback")
|
||||||
|
create_loader(loader_path, distribution_translated)
|
||||||
|
|
||||||
|
|
||||||
def install_grub(efi_directory, fw_type):
|
def install_grub(efi_directory, fw_type):
|
||||||
|
Loading…
Reference in New Issue
Block a user