]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Drop BIOS/grub support 1152/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 27 Aug 2022 09:33:09 +0000 (11:33 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 29 Aug 2022 09:15:54 +0000 (11:15 +0200)
As discussed in the last biweekly, there's no interest in maintaining
BIOS support in mkosi. Given the non-trivial amount of time that has to
be spent to keep BIOS/grub working as we develop new features, we'd rather
drop support than keep maintaining it.

Users that are still interested in BIOS support can fork mkosi at any point
before BIOS/grub support was removed.

.github/workflows/ci.yml
NEWS.md
mkosi.md
mkosi/__init__.py
mkosi/backend.py
mkosi/gentoo.py
tests/test_config_parser.py
tests/test_parse_load_args.py

index 9c5a7a02444573843a36b09c7529740666c3352f..65d6d3f62b6d357144abb5d67018484d2821bcc2 100644 (file)
@@ -196,9 +196,6 @@ jobs:
     - name: Build/Boot ${{ matrix.distro }}/${{ matrix.format }} UEFI UKI
       run: |
         tee mkosi.conf <<- EOF
-        [Output]
-        BootProtocols=uefi
-
         [Host]
         QemuBoot=uefi
         EOF
@@ -209,7 +206,6 @@ jobs:
       run: |
         tee mkosi.conf <<- EOF
         [Output]
-        BootProtocols=uefi
         WithUnifiedKernelImages=no
 
         [Host]
@@ -218,24 +214,10 @@ jobs:
 
         sudo MKOSI_TEST_DEFAULT_VERB=qemu python3 -m pytest --exitfirst -m integration -sv tests
 
-    - name: Build/Boot ${{ matrix.distro }}/${{ matrix.format }} BIOS
-      run: |
-        tee mkosi.conf <<- EOF
-        [Output]
-        BootProtocols=bios
-        WithUnifiedKernelImages=no
-
-        [Host]
-        QemuBoot=bios
-        EOF
-
-        sudo MKOSI_TEST_DEFAULT_VERB=qemu python3 -m pytest --exitfirst -m integration -sv tests
-
     - name: Build/Boot ${{ matrix.distro }}/${{ matrix.format}} QEMU Linux Boot
       run: |
         tee mkosi.conf <<- EOF
         [Output]
-        BootProtocols=linux
         WithUnifiedKernelImages=no
 
         [Host]
diff --git a/NEWS.md b/NEWS.md
index 2b4d6c55c073d64d7b3ed4b0398ce1029376ffb8..5bb7c85c19ee2d4013c02995ee4b0780298d8cf7 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -8,8 +8,6 @@ for more information.
 for more information.
 - The Arch kernel/bootloader pacman hooks were removed. For anyone that still
 wants to use them, they can be found [here](https://github.com/systemd/mkosi/tree/v13/mkosi/resources/arch).
-When building a bios image, /boot/vmlinuz-kver and /boot/initramfs-kver.img are
-now symlinks to the actual files as installed by kernel-install.
 - mkosi now creates distro~release subdirectories inside the build, cache and output
 directories for each distro~release combination that is built. This allows building
 for multiple distros without throwing away the results of a previous distro build every
@@ -23,6 +21,9 @@ been removed from the docs but are still supported for backwards compatibility.
 which is `SigLevel = Required DatabaseOptional`. If this results in keyring errors,
 you need to update the keyring by running `pacman-key --populate archlinux`.
 - Support for CentOS 7 was dropped.
+- Support for BIOS/grub was dropped. To allow users to configure grub themselves, the
+new `--bios-size` option can be used to add a BIOS boot partition of the specified size
+on which grub can be installed.
 
 ## v13
 
index c5c96fd97c89236892e1dd82b8d1e5f9f413cb80..66942022f39304a1bf49ff4a74a70ecff4e084cd 100644 (file)
--- a/mkosi.md
+++ b/mkosi.md
@@ -268,7 +268,7 @@ options are available:
 
 * A swap partition may be added in
 
-* The image may be made bootable on *EFI* and *BIOS* systems
+* The image may be made bootable on *EFI* systems
 
 * Separate partitions for `/srv` and `/home` may be added in
 
@@ -454,23 +454,7 @@ a boolean argument: either "1", "yes", or "true" to enable, or "0",
 
 `Bootable=`, `--bootable`, `-b`
 
-: Generate a bootable image. By default this will generate an image
-  bootable on UEFI systems. Use `BootProtocols=` to select support
-  for a different boot protocol.
-
-`BootProtocols=`, `--boot-protocols=`
-
-: Pick one or more boot protocols to support when generating a
-  bootable image, as enabled with `Bootable=`. Takes a comma-separated
-  list of `uefi`, `bios`, or `linux`. May be specified more than once in which
-  case the specified lists are merged. If `uefi` is specified the
-  `sd-boot` UEFI boot loader is used, if `bios` is specified the GNU
-  Grub boot loader is used. If `linux` is specified, the kernel image, initrd
-  and kernel cmdline are extracted from the image and stored in the output
-  directory. When running the `qemu` verb and setting the `--qemu-boot` option
-  to `linux`, qemu will be instructed to do a direct Linux kernel boot using
-  the previously extracted files. Use "!\*" to remove all previously added
-  protocols or "!protocol" to remove one protocol.
+: Generate a bootable image for UEFI systems.
 
 `KernelCommandLine=`, `--kernel-command-line=`
 
@@ -1148,10 +1132,9 @@ a machine ID.
 
 `QemuBoot=`, `--qemu-boot=`
 
-: When used with the `qemu` verb, this option sets the boot protocol to be used
-  by qemu. Can be set to either `uefi`, `bios`, or `linux`. Note that a boot
-  procotol needs to be included in `BootProtocols=` when building the image for
-  it to be usable with this option.
+: When used with the `qemu` verb, this option specifies how qemu should
+  boot the image. Can be set to either `uefi` to do a UEFI boot or `linux`
+  to do a qemu direct linux boot.
 
 `Netdev=`, `--netdev`
 
@@ -1344,8 +1327,8 @@ systemd-nspawn -bi image.raw
 ```
 
 Additionally, bootable *GPT* disk images (as created with the
-`--bootable` flag) work when booted directly by *EFI* and *BIOS*
-systems, for example in *KVM* via:
+`--bootable` flag) work when booted directly by *EFI* systems,
+for example in *KVM* via:
 
 ```bash
 qemu-kvm -m 512 -smp 2 -bios /usr/share/edk2/ovmf/OVMF_CODE.fd -drive format=raw,file=image.raw
index 1d3933ad015a7198b9ef8a19c9d946dd0c9d4d2e..5ccb21616e1f9513f12270b221f248b4b1168bdf 100644 (file)
@@ -81,13 +81,11 @@ from .backend import (
     SourceFileTransfer,
     Verb,
     die,
-    install_grub,
     is_centos_variant,
     is_epel_variant,
     is_rpm_distribution,
     nspawn_executable,
     nspawn_knows_arg,
-    nspawn_params_for_blockdev_access,
     nspawn_rlimit_params,
     nspawn_version,
     patch_file,
@@ -103,7 +101,6 @@ from .backend import (
     var_tmp,
     warn,
     workspace,
-    write_grub_config,
 )
 from .manifest import Manifest
 from .syscall import ioctl_partition_add, ioctl_partition_remove, reflink
@@ -772,10 +769,10 @@ def initialize_partition_table(args: MkosiArgs, force: bool = False) -> None:
     no_btrfs = args.output_format != OutputFormat.gpt_btrfs
 
     for condition, label, size, type_uuid, name, read_only in (
-            (args.bootable and "uefi" in args.boot_protocols,
+            (args.bootable,
              PartitionIdentifier.esp, args.esp_size, GPT_ESP, "ESP System Partition", False),
-            (args.bootable and "bios" in args.boot_protocols,
-             PartitionIdentifier.bios, BIOS_PARTITION_SIZE, GPT_BIOS, "BIOS Boot Partition", False),
+            (args.bios_size is not None,
+             PartitionIdentifier.bios, args.bios_size, GPT_BIOS, "BIOS Boot Partition", False),
             (args.xbootldr_size is not None,
              PartitionIdentifier.xbootldr, args.xbootldr_size, GPT_XBOOTLDR, "Boot Loader Partition", False),
             (args.swap_size is not None,
@@ -1804,12 +1801,6 @@ def make_rpm_list(args: MkosiArgs, packages: Set[str], do_run_build_script: bool
         if args.output_format == OutputFormat.gpt_btrfs:
             add_packages(args, packages, "btrfs-progs")
 
-        if args.get_partition(PartitionIdentifier.bios):
-            if args.distribution in (Distribution.mageia, Distribution.openmandriva):
-                add_packages(args, packages, "grub2")
-            else:
-                add_packages(args, packages, "grub2-pc")
-
     if not do_run_build_script and args.ssh:
         add_packages(args, packages, "openssh-server")
 
@@ -2495,9 +2486,6 @@ def install_debian_or_ubuntu(args: MkosiArgs, root: Path, *, do_run_build_script
             if not any(package.startswith("linux-image") for package in extra_packages):
                 add_packages(args, extra_packages, f"linux-image-{DEBIAN_KERNEL_ARCHITECTURES[args.architecture]}")
 
-        if args.get_partition(PartitionIdentifier.bios):
-            add_packages(args, extra_packages, "grub-pc")
-
         if args.output_format == OutputFormat.gpt_btrfs:
             add_packages(args, extra_packages, "btrfs-progs")
 
@@ -2584,13 +2572,6 @@ def install_debian_or_ubuntu(args: MkosiArgs, root: Path, *, do_run_build_script
         root.joinpath("etc/resolv.conf").symlink_to("../run/systemd/resolve/resolv.conf")
         run(["systemctl", "--root", root, "enable", "systemd-resolved"])
 
-    # Make sure kernel-install actually runs when needed by creating the machine-id subdirectory under /boot.
-    # In newer versions of systemd, this is already accomplished by running setting "layout=bls" in
-    # /etc/kernel/install.conf but for older Debian and Ubuntu we have to nudge kernel-install by creating
-    # this directory.
-    if "bios" in args.boot_protocols or ("linux" in args.boot_protocols and "uefi" not in args.boot_protocols):
-        root.joinpath("boot", args.machine_id).mkdir(mode=0o700)
-
     write_resource(root / "etc/kernel/install.d/50-mkosi-dpkg-reconfigure-dracut.install",
                    "mkosi.resources", "dpkg-reconfigure-dracut.install", executable=True)
 
@@ -2718,8 +2699,6 @@ def install_arch(args: MkosiArgs, root: Path, do_run_build_script: bool) -> None
             add_packages(args, packages, "xfsprogs")
         if args.encrypt:
             add_packages(args, packages, "cryptsetup", "device-mapper")
-        if args.get_partition(PartitionIdentifier.bios):
-            add_packages(args, packages, "grub")
 
         add_packages(args, packages, "dracut")
 
@@ -2750,14 +2729,6 @@ def install_arch(args: MkosiArgs, root: Path, do_run_build_script: bool) -> None
     # systemd-nspawn containers. See https://bugs.archlinux.org/task/45903.
     disable_pam_securetty(root)
 
-    # grub expects the kernel image and initramfs to be located in the /boot folder so let's create some
-    # symlinks in /boot that point to where kernel-install will store the kernel image and initramfs.
-    if "bios" in args.boot_protocols:
-        for kver, _ in gen_kernel_images(args, root):
-            boot_dir = Path("/") / boot_directory(args, kver)
-            root.joinpath(f"boot/vmlinuz-{kver}").symlink_to(boot_dir / "linux")
-            root.joinpath(f"boot/initramfs-{kver}.img").symlink_to(boot_dir / "initrd")
-
 
 @complete_step("Installing openSUSE…")
 def install_opensuse(args: MkosiArgs, root: Path, do_run_build_script: bool) -> None:
@@ -2804,9 +2775,6 @@ def install_opensuse(args: MkosiArgs, root: Path, do_run_build_script: bool) ->
     if not do_run_build_script and args.bootable:
         add_packages(args, packages, "kernel-default", "dracut")
 
-        if args.get_partition(PartitionIdentifier.bios):
-            add_packages(args, packages, "grub2")
-
     if not do_run_build_script and args.encrypt:
         add_packages(args, packages, "device-mapper")
 
@@ -3147,17 +3115,8 @@ def run_postinst_script(
 
         shutil.copy2(args.postinst_script, root_home(args, root) / "postinst")
 
-        nspawn_params = []
-        # in order to have full blockdev access, i.e. for making grub2 bootloader changes
-        # we need to have these bind mounts for a proper chroot setup
-        if args.bootable:
-            if loopdev is None:
-                raise ValueError("Parameter 'loopdev' required for bootable images.")
-            nspawn_params += nspawn_params_for_blockdev_access(args, loopdev)
-
         run_workspace_command(args, root, ["/root/postinst", verb],
                               network=(args.with_network is True),
-                              nspawn_params=nspawn_params,
                               env=args.environment)
         root_home(args, root).joinpath("postinst").unlink()
 
@@ -3196,9 +3155,6 @@ def install_boot_loader(
         if args.get_partition(PartitionIdentifier.esp):
             run_workspace_command(args, root, ["bootctl", "install"])
 
-        if args.get_partition(PartitionIdentifier.bios):
-            install_grub(args, root, loopdev)
-
 
 def install_extra_trees(args: MkosiArgs, root: Path, for_cache: bool) -> None:
     if not args.extra_trees:
@@ -4081,7 +4037,7 @@ def extract_kernel_image_initrd(
     for_cache: bool,
     mount: Callable[[], ContextManager[None]],
 ) -> Union[Tuple[BinaryIO, BinaryIO], Tuple[None, None]]:
-    if do_run_build_script or for_cache or "linux" not in args.boot_protocols:
+    if do_run_build_script or for_cache or not args.bootable:
         return None, None
 
     with mount():
@@ -4109,7 +4065,7 @@ def extract_kernel_cmdline(
     for_cache: bool,
     mount: Callable[[], ContextManager[None]],
 ) -> Optional[TextIO]:
-    if do_run_build_script or for_cache or "linux" not in args.boot_protocols:
+    if do_run_build_script or for_cache or not args.bootable:
         return None
 
     with mount():
@@ -5105,9 +5061,7 @@ def create_parser() -> ArgumentParserMkosi:
     group.add_argument(
         "--boot-protocols",
         action=CommaDelimitedListAction,
-        help="Boot protocols to use on a bootable image",
-        metavar="PROTOCOLS",
-        default=[],
+        help=argparse.SUPPRESS,
     )
     group.add_argument(
         "--kernel-command-line",
@@ -5532,16 +5486,19 @@ def create_parser() -> ArgumentParserMkosi:
         metavar="BYTES",
     )
     group.add_argument(
-        "--home-size", help="Set size of /home partition (only gpt_ext4, gpt_xfs, gpt_squashfs)", metavar="BYTES"
+        "--home-size", help="Set size of /home partition (only for GPT images)", metavar="BYTES"
     )
     group.add_argument(
-        "--srv-size", help="Set size of /srv partition (only gpt_ext4, gpt_xfs, gpt_squashfs)", metavar="BYTES"
+        "--srv-size", help="Set size of /srv partition (only for GPT images)", metavar="BYTES"
     )
     group.add_argument(
-        "--var-size", help="Set size of /var partition (only gpt_ext4, gpt_xfs, gpt_squashfs)", metavar="BYTES"
+        "--var-size", help="Set size of /var partition (only for GPT images)", metavar="BYTES"
     )
     group.add_argument(
-        "--tmp-size", help="Set size of /var/tmp partition (only gpt_ext4, gpt_xfs, gpt_squashfs)", metavar="BYTES"
+        "--tmp-size", help="Set size of /var/tmp partition (only for GPT images)", metavar="BYTES"
+    )
+    group.add_argument(
+        "--bios-size", help="Set size of BIOS boot partition (only for GPT images)", metavar="BYTES",
     )
     group.add_argument(
         "--usr-only",
@@ -5627,8 +5584,9 @@ def create_parser() -> ArgumentParserMkosi:
     group.add_argument(
         "--qemu-boot",
         help="Configure which qemu boot protocol to use",
-        choices=["uefi", "bios", "linux", None],
+        choices=["uefi", "linux", None],
         metavar="PROTOCOL",
+        default="uefi",
     )
     group.add_argument(
         "--network-veth",     # Compatibility option
@@ -6007,10 +5965,9 @@ def unlink_output(args: MkosiArgs) -> None:
                 unlink_try_hard(args.output_split_verity_sig)
                 unlink_try_hard(args.output_split_kernel)
 
-            if "linux" in args.boot_protocols:
-                unlink_try_hard(build_auxiliary_output_path(args, ".vmlinuz"))
-                unlink_try_hard(build_auxiliary_output_path(args, ".initrd"))
-                unlink_try_hard(build_auxiliary_output_path(args, ".cmdline"))
+            unlink_try_hard(build_auxiliary_output_path(args, ".vmlinuz"))
+            unlink_try_hard(build_auxiliary_output_path(args, ".initrd"))
+            unlink_try_hard(build_auxiliary_output_path(args, ".cmdline"))
 
             if args.nspawn_settings is not None:
                 unlink_try_hard(args.output_nspawn_settings)
@@ -6341,12 +6298,6 @@ def load_args(args: argparse.Namespace) -> MkosiArgs:
         ):
             die("Directory, subvolume, tar, cpio, and plain squashfs images cannot be booted.", MkosiNotSupportedException)
 
-        if not args.boot_protocols:
-            args.boot_protocols = ["uefi"]
-
-        if not {"uefi", "bios", "linux"}.issuperset(args.boot_protocols):
-            die("Not a valid boot protocol")
-
     if is_centos_variant(args.distribution):
         epel_release = parse_epel_release(args.release)
         if epel_release <= 9 and args.output_format == OutputFormat.gpt_btrfs:
@@ -6546,6 +6497,7 @@ def load_args(args: argparse.Namespace) -> MkosiArgs:
     args.esp_size = parse_bytes(args.esp_size)
     args.xbootldr_size = parse_bytes(args.xbootldr_size)
     args.swap_size = parse_bytes(args.swap_size)
+    args.bios_size = parse_bytes(args.bios_size)
 
     if args.root_size is None:
         args.root_size = 3 * 1024 * 1024 * 1024
@@ -6611,9 +6563,6 @@ def load_args(args: argparse.Namespace) -> MkosiArgs:
     if not args.read_only:
         args.kernel_command_line.append("rw")
 
-    if is_generated_root(args) and "bios" in args.boot_protocols:
-        die("Sorry, BIOS cannot be combined with --minimize or squashfs filesystems", MkosiNotSupportedException)
-
     if args.verity and not args.with_unified_kernel_images:
         die("Sorry, --verity can only be used with unified kernel images", MkosiNotSupportedException)
 
@@ -6668,6 +6617,10 @@ def load_args(args: argparse.Namespace) -> MkosiArgs:
     if args.qemu_kvm and not qemu_check_kvm_support():
         die("Sorry, the host machine does not support KVM acceleration.")
 
+    if args.boot_protocols is not None:
+        warn("The --boot-protocols is deprecated and has no effect anymore")
+    delattr(args, "boot_protocols")
+
     return MkosiArgs(**vars(args))
 
 
@@ -6812,7 +6765,6 @@ def print_summary(args: MkosiArgs) -> None:
             MkosiPrinter.info("       Kernel Command Line: " + " ".join(args.kernel_command_line))
             MkosiPrinter.info("           UEFI SecureBoot: " + yes_no(args.secure_boot))
 
-            MkosiPrinter.info("            Boot Protocols: " + line_join_list(args.boot_protocols))
             MkosiPrinter.info("     Unified Kernel Images: " + yes_no(args.with_unified_kernel_images))
             MkosiPrinter.info("             GPT First LBA: " + str(args.gpt_first_lba))
             MkosiPrinter.info("           Hostonly Initrd: " + yes_no(args.hostonly_initrd))
@@ -6874,15 +6826,13 @@ def print_summary(args: MkosiArgs) -> None:
         MkosiPrinter.info("\nPARTITIONS:")
         MkosiPrinter.info("            Root Partition: " + format_bytes_or_auto(args.root_size))
         MkosiPrinter.info("            Swap Partition: " + format_bytes_or_disabled(args.swap_size))
-        if "uefi" in args.boot_protocols:
-            MkosiPrinter.info("                       ESP: " + format_bytes_or_disabled(args.esp_size))
-        if "bios" in args.boot_protocols:
-            MkosiPrinter.info("                      BIOS: " + format_bytes_or_disabled(BIOS_PARTITION_SIZE))
+        MkosiPrinter.info("             EFI Partition: " + format_bytes_or_disabled(args.esp_size))
         MkosiPrinter.info("        XBOOTLDR Partition: " + format_bytes_or_disabled(args.xbootldr_size))
         MkosiPrinter.info("           /home Partition: " + format_bytes_or_disabled(args.home_size))
         MkosiPrinter.info("            /srv Partition: " + format_bytes_or_disabled(args.srv_size))
         MkosiPrinter.info("            /var Partition: " + format_bytes_or_disabled(args.var_size))
         MkosiPrinter.info("        /var/tmp Partition: " + format_bytes_or_disabled(args.tmp_size))
+        MkosiPrinter.info("            BIOS Partition: " + format_bytes_or_disabled(args.bios_size))
         MkosiPrinter.info("                 /usr only: " + yes_no(args.usr_only))
 
         MkosiPrinter.info("\nVALIDATION:")
@@ -7723,19 +7673,8 @@ def qemu_check_kvm_support() -> bool:
 def run_qemu_cmdline(args: MkosiArgs) -> Iterator[List[str]]:
     accel = "kvm" if args.qemu_kvm else "tcg"
 
-    if args.qemu_boot:
-        mode = args.qemu_boot
-    elif "uefi" in args.boot_protocols:
-        mode = "uefi"
-    elif "bios" in args.boot_protocols:
-        mode = "bios"
-    elif "linux" in args.boot_protocols:
-        mode = "linux"
-    else:
-        mode = "uefi"
-
     firmware, fw_supports_sb = find_qemu_firmware(args)
-    smm = "on" if fw_supports_sb and mode == "uefi" else "off"
+    smm = "on" if fw_supports_sb and args.qemu_boot == "uefi" else "off"
 
     cmdline = [
         find_qemu_binary(args),
@@ -7757,10 +7696,7 @@ def run_qemu_cmdline(args: MkosiArgs) -> Iterator[List[str]]:
         # -nodefaults removes the default CDROM device which avoids an error message during boot
         # -serial mon:stdio adds back the serial device removed by -nodefaults.
         cmdline += ["-nographic", "-nodefaults", "-serial", "mon:stdio"]
-        # Fix for https://github.com/systemd/mkosi/issues/559. QEMU gets stuck in a boot loop when using BIOS
-        # if there's no vga device.
-
-    if not args.qemu_headless or (args.qemu_headless and mode == "bios"):
+    else:
         cmdline += ["-vga", "virtio"]
 
     if args.netdev:
@@ -7779,10 +7715,10 @@ def run_qemu_cmdline(args: MkosiArgs) -> Iterator[List[str]]:
             # after it is created.
             cmdline += ["-nic", f"tap,script=no,downscript=no,ifname={ifname},model=virtio-net-pci"]
 
-    if mode == "uefi":
+    if args.qemu_boot == "uefi":
         cmdline += ["-drive", f"if=pflash,format=raw,readonly=on,file={firmware}"]
 
-    if mode == "linux":
+    if args.qemu_boot == "linux":
         cmdline += [
             "-kernel", str(build_auxiliary_output_path(args, ".vmlinuz")),
             "-initrd", str(build_auxiliary_output_path(args, ".initrd")),
@@ -7790,7 +7726,7 @@ def run_qemu_cmdline(args: MkosiArgs) -> Iterator[List[str]]:
         ]
 
     with contextlib.ExitStack() as stack:
-        if mode == "uefi" and fw_supports_sb:
+        if args.qemu_boot == "uefi" and fw_supports_sb:
             ovmf_vars = stack.enter_context(copy_file_temporary(src=find_ovmf_vars(args), dir=tmp_dir()))
             cmdline += [
                 "-global",
index 6ea3f8afac5144c3a4582c1ef9e3f22078bf7138..f3e34cbcc302021503fab8b055c653cbfda98cb8 100644 (file)
@@ -455,7 +455,6 @@ class MkosiArgs:
     output: Path
     output_dir: Optional[Path]
     bootable: bool
-    boot_protocols: List[str]
     kernel_command_line: List[str]
     secure_boot: bool
     secure_boot_key: Path
@@ -517,6 +516,7 @@ class MkosiArgs:
     srv_size: Optional[int]
     var_size: Optional[int]
     tmp_size: Optional[int]
+    bios_size: Optional[int]
     usr_only: bool
     split_artifacts: bool
     checksum: bool
@@ -632,29 +632,6 @@ def nspawn_knows_arg(arg: str) -> bool:
     return "unrecognized option" not in run([nspawn_executable(), arg], stderr=subprocess.PIPE, check=False, text=True).stderr
 
 
-def nspawn_params_for_blockdev_access(args: MkosiArgs, loopdev: Path) -> List[str]:
-    assert args.partition_table is not None
-
-    params = [
-        f"--bind-ro={loopdev}",
-        f"--property=DeviceAllow={loopdev}",
-        "--bind-ro=/dev/block",
-        "--bind-ro=/dev/disk",
-    ]
-
-    for ident in (PartitionIdentifier.esp,
-                  PartitionIdentifier.bios,
-                  PartitionIdentifier.root,
-                  PartitionIdentifier.xbootldr):
-        path = args.partition_table.partition_path(ident, loopdev)
-        if path and path.exists():
-            params += [f"--bind-ro={path}", f"--property=DeviceAllow={path}"]
-
-    params += [f"--setenv={env}={value}" for env, value in args.environment.items()]
-
-    return params
-
-
 def format_rlimit(rlimit: int) -> str:
         limits = resource.getrlimit(rlimit)
         soft = "infinity" if limits[0] == resource.RLIM_INFINITY else str(limits[0])
@@ -868,51 +845,6 @@ def path_relative_to_cwd(path: PathString) -> Path:
         return path
 
 
-def write_grub_config(args: MkosiArgs, root: Path) -> None:
-    kernel_cmd_line = " ".join(args.kernel_command_line)
-    grub_cmdline = f'GRUB_CMDLINE_LINUX="{kernel_cmd_line}"\n'
-    os.makedirs(root / "etc/default", exist_ok=True, mode=0o755)
-    grub_config = root / "etc/default/grub"
-    if not os.path.exists(grub_config):
-        grub_config.write_text(grub_cmdline)
-    else:
-
-        def jj(line: str) -> str:
-            if line.startswith(("GRUB_CMDLINE_LINUX=", "#GRUB_CMDLINE_LINUX=")):  # GENTOO:
-                return grub_cmdline
-            if args.qemu_headless:
-                if "GRUB_TERMINAL" in line:
-                    return line.strip('#').split('=')[0] + '="console serial"'
-            return line
-
-        patch_file(grub_config, jj)
-
-        if args.qemu_headless:
-            with open(grub_config, "a") as f:
-                f.write('GRUB_SERIAL_COMMAND="serial --unit=0 --speed 115200"\n')
-
-
-def install_grub(args: MkosiArgs, root: Path, loopdev: Path) -> None:
-    assert args.partition_table is not None
-
-    part = args.get_partition(PartitionIdentifier.bios)
-    if not part:
-        return
-
-    write_grub_config(args, root)
-
-    nspawn_params = nspawn_params_for_blockdev_access(args, loopdev)
-
-    grub = "/usr/sbin/grub" if root.joinpath("usr/sbin/grub-install").exists() else "/usr/sbin/grub2"
-
-    cmdline: Sequence[PathString] = [f"{grub}-install", "--modules=ext2 part_gpt", "--target=i386-pc", loopdev]
-    run_workspace_command(args, root, cmdline, nspawn_params=nspawn_params)
-
-    # TODO: Remove os.path.basename once https://github.com/systemd/systemd/pull/16645 is widely available.
-    cmdline = [f"{grub}-mkconfig", f"--output=/boot/{os.path.basename(grub)}/grub.cfg"]
-    run_workspace_command(args, root, cmdline, nspawn_params=nspawn_params)
-
-
 def die(message: str, exception: Type[MkosiException] = MkosiException) -> NoReturn:
     MkosiPrinter.warn(f"Error: {message}")
     raise exception(message)
index 435fb5d0b7e29b208aca5f3abdc56bf6f0a1fff9..efbd76f20283960375ec720ab5861bb47a678572 100644 (file)
@@ -53,7 +53,6 @@ class Gentoo:
     pkgs_sys: List[str]
     # filesystem packages (dosfstools, btrfs, squashfs, etc)
     pkgs_fs: List[str]
-    grub_platforms: List[str]
     UNINSTALL_IGNORE: List[str]
     root: Path
     portage_cfg_dir: Path
@@ -234,24 +233,18 @@ class Gentoo:
         if args.encrypt:
             self.pkgs_fs += ["cryptsetup", "device-mapper"]
 
-        self.grub_platforms = []
         if not do_run_build_script and args.bootable:
             if args.get_partition(PartitionIdentifier.esp):
                 self.pkgs_boot = ["sys-kernel/installkernel-systemd-boot"]
-            elif args.get_partition(PartitionIdentifier.bios):
-                self.pkgs_boot = ["sys-boot/grub"]
-                self.grub_platforms = ["coreboot", "qemu", "pc"]
             else:
                 self.pkgs_boot = []
 
             self.pkgs_boot += ["sys-kernel/gentoo-kernel-bin",
                                "sys-firmware/edk2-ovmf"]
 
-        # GENTOO_DONTMOVE: self.grub_platforms, for instance, must be set
         self.emerge_vars = {
             "BOOTSTRAP_USE": " ".join(self.portage_use_flags),
             "FEATURES": " ".join(self.portage_features),
-            "GRUB_PLATFORMS": " ".join(self.grub_platforms),
             "UNINSTALL_IGNORE": " ".join(self.UNINSTALL_IGNORE),
             "USE": " ".join(self.portage_use_flags),
         }
@@ -423,7 +416,6 @@ class Gentoo:
 
         self.baselayout_use = package_use.joinpath("baselayout")
         self.baselayout_use.write_text("sys-apps/baselayout build\n")
-        package_use.joinpath("grub").write_text("sys-boot/grub device-mapper truetype\n")
         package_use.joinpath("systemd").write_text(
             # repart for usronly
             dedent(
index 5bc986bd892142438ed63955a64d19bcd0e88046..d7ffeecc44bf347087683b9bb6f620d68a800151 100644 (file)
@@ -47,7 +47,7 @@ class MkosiConfig:
             "all_directory": None,
             "architecture": "x86_64",
             "bmap": False,
-            "boot_protocols": [],
+            "boot_protocols": None,
             "bootable": False,
             "build_dir": None,
             "build_packages": [],
@@ -124,6 +124,7 @@ class MkosiConfig:
             "tmp_size": None,
             "usr_only": False,
             "var_size": None,
+            "bios_size": None,
             "verb": Verb.build,
             "verity": False,
             "with_docs": False,
@@ -136,7 +137,7 @@ class MkosiConfig:
             "qemu_kvm": mkosi.qemu_check_kvm_support(),
             "qemu_args": [],
             "nspawn_keep_unit": False,
-            "qemu_boot": None,
+            "qemu_boot": "uefi",
             "netdev": False,
             "ephemeral": False,
             "with_unified_kernel_images": True,
@@ -248,8 +249,6 @@ class MkosiConfig:
                 self.reference_config[job_name]["force"] += 1
             if "Bootable" in mk_config_output:
                 self.reference_config[job_name]["bootable"] = mk_config_output["Bootable"]
-            if "BootProtocols" in mk_config_output:
-                self._append_list("boot_protocols", mk_config_output["BootProtocols"], job_name)
             if "KernelCommandLine" in mk_config_output:
                 self._append_list("kernel_command_line", mk_config_output["KernelCommandLine"], job_name, " ")
             if "SecureBoot" in mk_config_output:
@@ -555,7 +554,6 @@ class MkosiConfigManyParams(MkosiConfigOne):
                 "ManifestFormat": [mkosi.backend.ManifestFormat.json],
                 #                 # 'OutputDirectory': '',
                 "Bootable": False,
-                "BootProtocols": "uefi",
                 "KernelCommandLine": ["console=ttyS0"],
                 "SecureBoot": False,
                 "SecureBootKey": "/foo.pem",
@@ -624,7 +622,6 @@ class MkosiConfigManyParams(MkosiConfigOne):
                 "Output": "test_image.raw.xz",
                 #                 # 'OutputDirectory': '',
                 "Bootable": True,
-                "BootProtocols": "bios",
                 "KernelCommandLine": ["console=ttyS1"],
                 "SecureBoot": True,
                 "SecureBootKey": "/foo-ubu.pem",
@@ -691,7 +688,6 @@ class MkosiConfigManyParams(MkosiConfigOne):
                 "Output": "test_image.raw.xz",
                 #                 # 'OutputDirectory': '',
                 "Bootable": True,
-                "BootProtocols": "bios",
                 "KernelCommandLine": ["console=ttyS1"],
                 "SecureBoot": True,
                 "SecureBootKey": "/foo-debi.pem",
index 3abf9ed1278c8f81aba0e41f520ba7ce01ea0a01..9ff58aaeca0965ea42d5719acf9a472d51508140 100644 (file)
@@ -140,5 +140,3 @@ def test_compression() -> None:
     with pytest.raises(MkosiException, match=".*compression.*squashfs"):
         parse(["--format", "gpt_squashfs", "--compress", "False"])
 
-    with pytest.raises(MkosiException, match=".*BIOS.*squashfs"):
-        parse(["--format", "gpt_squashfs", "--boot-protocols", "bios"])