Seeking Help: grub man pages not reproducible

kpcyrd kpcyrd at rxv.cc
Sun Jul 25 18:21:38 UTC 2021


Hello!

One of the rebuilderd based Arch Linux rebuilders flagged a design issue in
grub that likely affects all distros:

    │ ├── usr/share/man/man8/grub-install.8.gz
    │ │ ├── grub-install.8
    │ │ │ @@ -112,15 +112,15 @@
    │ │ │  is only available on EFI.
    │ │ │  .TP
    │ │ │  \fB\-s\fR, \fB\-\-skip\-fs\-probe\fR
    │ │ │  do not probe for filesystems in DEVICE
    │ │ │  .TP
    │ │ │  \fB\-\-target\fR=\fI\,TARGET\/\fR
    │ │ │  install GRUB for TARGET platform
    │ │ │ -[default=i386\-pc]; available targets:
    │ │ │ +[default=x86_64\-efi]; available targets:
    │ │ │  arm\-coreboot, arm\-efi, arm\-uboot, arm64\-efi,
    │ │ │  i386\-coreboot, i386\-efi, i386\-ieee1275,
    │ │ │  i386\-multiboot, i386\-pc, i386\-qemu, i386\-xen,
    │ │ │  i386\-xen_pvh, ia64\-efi, mips\-arc, mips\-qemu_mips,
    │ │ │  mipsel\-arc, mipsel\-loongson, mipsel\-qemu_mips,
    │ │ │  powerpc\-ieee1275, riscv32\-efi, riscv64\-efi,
    │ │ │  sparc64\-ieee1275, x86_64\-efi, x86_64\-xen

Note this is inside a man page, but not the binary. Searching the
previous line through the whole codebase leads to this location, in a C
file:

    % rg 'install GRUB for TARGET platform'
    util/grub-install.c
    258:   0, N_("install GRUB for TARGET platform [default=%s]; available targets: %s"), 2},

It seems the man page is generated from the --help text. The default is coming
from get_default_platform() which calls
grub_install_get_default_x86_platform():

    const char *
    grub_install_get_default_x86_platform (void)
    {
      if (is_efi_system())
        {
          if (read_platform_size() == 64)
        return "x86_64-efi";
          else
        return "i386-efi";
        }

      grub_util_info ("Looking for /proc/device-tree ..");
      if (is_not_empty_directory ("/proc/device-tree"))
        {
          grub_util_info ("...found");
          return "i386-ieee1275";
        }

      grub_util_info ("... not found");
      return "i386-pc";
    }

This effectively means `grub-install --help` tests for /sys/firmware/efi among
other things, I've confirmed this on two different systems:

    $ grub-install --help | rg 'available targets'
                     [default=i386-pc]; available targets:

and

    % grub-install --help | rg 'available targets'
                     [default=x86_64-efi]; available targets:

The problem now is that `grub-install.8` is a snapshot of that help-text from
the build-system, including the system specific defaults that might be
different on the users system.

I'm calling this a design issue because this means grub is shipping
incorrect man pages on some systems:

    % man grub-install | rg 'available  targets'
          install  GRUB  for  TARGET  platform  [default=i386-pc];  available  targets: arm-coreboot, arm-efi,
    % grub-install --help | rg 'available targets'
                     [default=x86_64-efi]; available targets:

Any ideas?

Thanks!


More information about the rb-general mailing list