mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-30 02:45:37 -04:00
[bootloader] join grub module with bootloader
This commit is contained in:
parent
76bfc4d96f
commit
e3a7fca6f4
7 changed files with 69 additions and 136 deletions
|
@ -49,8 +49,7 @@ install:
|
||||||
#- dracut
|
#- dracut
|
||||||
#- initramfs
|
#- initramfs
|
||||||
- grubcfg
|
- grubcfg
|
||||||
- grub
|
- bootloader
|
||||||
#- bootloader
|
|
||||||
- umount
|
- umount
|
||||||
|
|
||||||
# Phase 3 - postinstall.
|
# Phase 3 - postinstall.
|
||||||
|
|
|
@ -16,3 +16,8 @@ timeout: "10"
|
||||||
grubInstall: "grub-install"
|
grubInstall: "grub-install"
|
||||||
grubMkconfig: "grub-mkconfig"
|
grubMkconfig: "grub-mkconfig"
|
||||||
grubCfg: "/boot/grub/grub.cfg"
|
grubCfg: "/boot/grub/grub.cfg"
|
||||||
|
# Optionally set the --bootloader-id to use for EFI. If not set, this defaults
|
||||||
|
# to the bootloaderEntryName from branding.desc with problematic characters
|
||||||
|
# replaced. If an efiBootloaderId is specified here, it is taken to already be a
|
||||||
|
# valid directory name, so no such postprocessing is done in this case.
|
||||||
|
# efiBootloaderId: "dirname"
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
# Copyright 2014, Anke Boersma <demm@kaosx.us>
|
# Copyright 2014, Anke Boersma <demm@kaosx.us>
|
||||||
# Copyright 2014, Daniel Hillenbrand <codeworkx@bbqlinux.org>
|
# Copyright 2014, Daniel Hillenbrand <codeworkx@bbqlinux.org>
|
||||||
# Copyright 2014, Benjamin Vaudour <benjamin.vaudour@yahoo.fr>
|
# Copyright 2014, Benjamin Vaudour <benjamin.vaudour@yahoo.fr>
|
||||||
|
# Copyright 2014, Kevin Kofler <kevin.kofler@chello.at>
|
||||||
# Copyright 2015, Philip Mueller <philm@manjaro.org>
|
# Copyright 2015, Philip Mueller <philm@manjaro.org>
|
||||||
#
|
#
|
||||||
# Calamares is free software: you can redistribute it and/or modify
|
# Calamares is free software: you can redistribute it and/or modify
|
||||||
|
@ -93,11 +94,11 @@ def create_loader(loader_path):
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
def install_bootloader(boot_loader, fw_type):
|
def install_gummiboot(efi_directory):
|
||||||
if fw_type == 'efi':
|
|
||||||
install_path = libcalamares.globalstorage.value("rootMountPoint")
|
install_path = libcalamares.globalstorage.value("rootMountPoint")
|
||||||
efi_directory = libcalamares.globalstorage.value("efiSystemPartition")
|
|
||||||
install_efi_directory = install_path + efi_directory
|
install_efi_directory = install_path + efi_directory
|
||||||
|
kernel_line = libcalamares.job.configuration["kernelLine"]
|
||||||
|
fallback_kernel_line = libcalamares.job.configuration["fallbackKernelLine"]
|
||||||
uuid = get_uuid()
|
uuid = get_uuid()
|
||||||
distribution = get_bootloader_entry_name()
|
distribution = get_bootloader_entry_name()
|
||||||
file_name_sanitizer = str.maketrans(" /", "_-")
|
file_name_sanitizer = str.maketrans(" /", "_-")
|
||||||
|
@ -110,9 +111,49 @@ def install_bootloader(boot_loader, fw_type):
|
||||||
"{!s}-fallback.conf".format(distribution_translated))
|
"{!s}-fallback.conf".format(distribution_translated))
|
||||||
loader_path = os.path.join(
|
loader_path = os.path.join(
|
||||||
install_efi_directory, "loader", "loader.conf")
|
install_efi_directory, "loader", "loader.conf")
|
||||||
|
subprocess.call(["gummiboot", "--path={!s}".format(install_efi_directory), "install"])
|
||||||
|
print("Configure: \"{!s}\"".format(kernel_line))
|
||||||
|
create_conf(uuid, conf_path, kernel_line)
|
||||||
|
print("Configure: \"{!s}\"".format(fallback_kernel_line))
|
||||||
|
create_conf(uuid, fallback_path, fallback_kernel_line)
|
||||||
|
create_loader(loader_path)
|
||||||
|
|
||||||
|
|
||||||
|
def install_grub(efi_directory, fw_type):
|
||||||
|
if fw_type == "efi":
|
||||||
|
efi_directory_firmware = efi_directory + "/EFI"
|
||||||
|
check_chroot_call(["mkdir", "-p", "{!s}".format(efi_directory)])
|
||||||
|
if "efiBootloaderId" in libcalamares.job.configuration:
|
||||||
|
efi_bootloader_id = libcalamares.job.configuration["efiBootloaderId"]
|
||||||
|
else:
|
||||||
|
branding = libcalamares.globalstorage.value("branding")
|
||||||
|
distribution = branding["bootloaderEntryName"]
|
||||||
|
file_name_sanitizer = str.maketrans(" /", "_-")
|
||||||
|
efi_bootloader_id = distribution.translate(file_name_sanitizer)
|
||||||
|
check_chroot_call(
|
||||||
|
[libcalamares.job.configuration["grubInstall"], "--target=x86_64-efi",
|
||||||
|
"--efi-directory={!s}".format(efi_directory),
|
||||||
|
"--bootloader-id={!s}".format(efi_bootloader_id)])
|
||||||
|
# Workaround for some UEFI firmwares
|
||||||
|
check_chroot_call(["mkdir", "-p", "{!s}/boot".format(efi_directory_firmware)])
|
||||||
|
check_chroot_call(["cp", "{!s}/{!s}/grubx64.efi".format(efi_directory_firmware,
|
||||||
|
efi_bootloader_id),
|
||||||
|
"{!s}/boot/bootx64.efi".format(efi_directory_firmware)])
|
||||||
|
else:
|
||||||
|
boot_loader = libcalamares.globalstorage.value("bootLoader")
|
||||||
|
check_chroot_call(
|
||||||
|
[libcalamares.job.configuration["grubInstall"], "--target=i386-pc",
|
||||||
|
boot_loader["installPath"]])
|
||||||
|
|
||||||
|
check_chroot_call([libcalamares.job.configuration["grubMkconfig"], "-o",
|
||||||
|
libcalamares.job.configuration["grubCfg"]])
|
||||||
|
|
||||||
|
|
||||||
|
def prepare_bootloader(fw_type):
|
||||||
|
if fw_type == "efi":
|
||||||
|
efi_boot_loader = libcalamares.job.configuration["efiBootLoader"]
|
||||||
|
efi_directory = libcalamares.globalstorage.value("efiSystemPartition")
|
||||||
partitions = libcalamares.globalstorage.value("partitions")
|
partitions = libcalamares.globalstorage.value("partitions")
|
||||||
kernel_line = libcalamares.job.configuration["kernelLine"]
|
|
||||||
fallback_kernel_line = libcalamares.job.configuration["fallbackKernelLine"]
|
|
||||||
boot_p = ""
|
boot_p = ""
|
||||||
device = ""
|
device = ""
|
||||||
for partition in partitions:
|
for partition in partitions:
|
||||||
|
@ -129,23 +170,13 @@ def install_bootloader(boot_loader, fw_type):
|
||||||
print("Boot partition: \"{!s}\"".format(boot_p))
|
print("Boot partition: \"{!s}\"".format(boot_p))
|
||||||
print("Boot device: \"{!s}\"".format(device))
|
print("Boot device: \"{!s}\"".format(device))
|
||||||
subprocess.call(["sgdisk", "--typecode={!s}:EF00".format(boot_p), "{!s}".format(device)])
|
subprocess.call(["sgdisk", "--typecode={!s}:EF00".format(boot_p), "{!s}".format(device)])
|
||||||
subprocess.call(["gummiboot", "--path={!s}".format(install_efi_directory), "install"])
|
if (efi_boot_loader == "gummiboot" and fw_type == "efi"):
|
||||||
print("Configure: \"{!s}\"".format(kernel_line))
|
install_gummiboot(efi_directory)
|
||||||
create_conf(uuid, conf_path, kernel_line)
|
|
||||||
print("Configure: \"{!s}\"".format(fallback_kernel_line))
|
|
||||||
create_conf(uuid, fallback_path, fallback_kernel_line)
|
|
||||||
create_loader(loader_path)
|
|
||||||
else:
|
else:
|
||||||
install_path = boot_loader["installPath"]
|
install_grub(efi_directory, fw_type)
|
||||||
check_chroot_call(
|
|
||||||
[libcalamares.job.configuration["grubInstall"], "--target=i386-pc",
|
|
||||||
install_path])
|
|
||||||
check_chroot_call([libcalamares.job.configuration["grubMkconfig"], "-o",
|
|
||||||
libcalamares.job.configuration["grubCfg"]])
|
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
boot_loader = libcalamares.globalstorage.value("bootLoader")
|
|
||||||
fw_type = libcalamares.globalstorage.value("firmwareType")
|
fw_type = libcalamares.globalstorage.value("firmwareType")
|
||||||
install_bootloader(boot_loader, fw_type)
|
prepare_bootloader(fw_type)
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
---
|
|
||||||
# GRUB 2 binary names and boot directory
|
|
||||||
# Some distributions (e.g. Fedora) use grub2-* (resp. /boot/grub2/) names.
|
|
||||||
grubInstall: "grub-install"
|
|
||||||
grubMkconfig: "grub-mkconfig"
|
|
||||||
grubCfg: "/boot/grub/grub.cfg"
|
|
||||||
# Optionally set the --bootloader-id to use for EFI. If not set, this defaults
|
|
||||||
# to the bootloaderEntryName from branding.desc with problematic characters
|
|
||||||
# replaced. If an efiBootloaderId is specified here, it is taken to already be a
|
|
||||||
# valid directory name, so no such postprocessing is done in this case.
|
|
||||||
# efiBootloaderId: "dirname"
|
|
|
@ -1,81 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# === This file is part of Calamares - <http://github.com/calamares> ===
|
|
||||||
#
|
|
||||||
# Copyright 2014, Aurélien Gâteau <agateau@kde.org>
|
|
||||||
# Copyright 2014, Daniel Hillenbrand <codeworkx@bbqlinux.org>
|
|
||||||
# Copyright 2014, Kevin Kofler <kevin.kofler@chello.at>
|
|
||||||
# Copyright 2015, Philip Mueller <philm@manjaro.org>
|
|
||||||
#
|
|
||||||
# Calamares is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Calamares is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import libcalamares
|
|
||||||
from libcalamares.utils import check_chroot_call
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
|
|
||||||
def install_grub(boot_loader, fw_type):
|
|
||||||
if fw_type == 'efi':
|
|
||||||
efi_directory = libcalamares.globalstorage.value("efiSystemPartition")
|
|
||||||
efi_directory_firmware = efi_directory + "/EFI"
|
|
||||||
check_chroot_call(["mkdir", "-p", "{!s}".format(efi_directory)])
|
|
||||||
if "efiBootloaderId" in libcalamares.job.configuration:
|
|
||||||
efi_bootloader_id = libcalamares.job.configuration["efiBootloaderId"]
|
|
||||||
else:
|
|
||||||
branding = libcalamares.globalstorage.value("branding")
|
|
||||||
distribution = branding["bootloaderEntryName"]
|
|
||||||
file_name_sanitizer = str.maketrans(" /", "_-")
|
|
||||||
efi_bootloader_id = distribution.translate(file_name_sanitizer)
|
|
||||||
partitions = libcalamares.globalstorage.value("partitions")
|
|
||||||
boot_p = ""
|
|
||||||
device = ""
|
|
||||||
for partition in partitions:
|
|
||||||
if partition["mountPoint"] == efi_directory:
|
|
||||||
boot_device = partition["device"]
|
|
||||||
boot_p = boot_device[-1:]
|
|
||||||
device = boot_device[:-1]
|
|
||||||
if (not boot_p or not device):
|
|
||||||
return ("EFI directory \"{!s}\" not found!",
|
|
||||||
"Boot partition: \"{!s}\"",
|
|
||||||
"Boot device: \"{!s}\"".format(efi_directory,boot_p,device))
|
|
||||||
else:
|
|
||||||
print("EFI directory: \"{!s}\"".format(efi_directory))
|
|
||||||
print("Boot partition: \"{!s}\"".format(boot_p))
|
|
||||||
print("Boot device: \"{!s}\"".format(device))
|
|
||||||
subprocess.call(["sgdisk", "--typecode={!s}:EF00".format(boot_p), "{!s}".format(device)])
|
|
||||||
check_chroot_call(
|
|
||||||
[libcalamares.job.configuration["grubInstall"], "--target=x86_64-efi",
|
|
||||||
"--efi-directory={!s}".format(efi_directory),
|
|
||||||
"--bootloader-id={!s}".format(efi_bootloader_id)])
|
|
||||||
# Workaround for some UEFI firmwares
|
|
||||||
check_chroot_call(["mkdir", "-p", "{!s}/boot".format(efi_directory_firmware)])
|
|
||||||
check_chroot_call(["cp", "{!s}/{!s}/grubx64.efi".format(efi_directory_firmware,
|
|
||||||
efi_bootloader_id),
|
|
||||||
"{!s}/boot/bootx64.efi".format(efi_directory_firmware)])
|
|
||||||
else:
|
|
||||||
install_path = boot_loader["installPath"]
|
|
||||||
check_chroot_call(
|
|
||||||
[libcalamares.job.configuration["grubInstall"], "--target=i386-pc",
|
|
||||||
install_path])
|
|
||||||
|
|
||||||
check_chroot_call([libcalamares.job.configuration["grubMkconfig"], "-o",
|
|
||||||
libcalamares.job.configuration["grubCfg"]])
|
|
||||||
|
|
||||||
|
|
||||||
def run():
|
|
||||||
boot_loader = libcalamares.globalstorage.value("bootLoader")
|
|
||||||
fw_type = libcalamares.globalstorage.value("firmwareType")
|
|
||||||
install_grub(boot_loader, fw_type)
|
|
||||||
return None
|
|
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
type: "job"
|
|
||||||
name: "grub"
|
|
||||||
interface: "python"
|
|
||||||
script: "main.py"
|
|
|
@ -1,5 +0,0 @@
|
||||||
rootMountPoint: /tmp/mount
|
|
||||||
bootLoader:
|
|
||||||
installPath: /dev/sdb
|
|
||||||
branding:
|
|
||||||
bootloaderEntryName: "Generic Distro"
|
|
Loading…
Add table
Add a link
Reference in a new issue