Add support for explicitly requesting any specific bootloader type

...with the `sysroot.bootloader` configuration option.  This can be useful
when converting a system to use `ostree` which doesn't currently have a
bootloader configuration that `ostree` can automatically detect, and is
also useful in combination with the `--sysroot` option when provisioning a
rootfs for systems other than the one you're running `ostree admin deploy`
on.
This commit is contained in:
William Manley 2020-07-06 16:12:29 +01:00
parent 9482ecfe5a
commit 31acd2ef99
3 changed files with 23 additions and 1 deletions

View File

@ -373,7 +373,9 @@ Boston, MA 02111-1307, USA.
<term><varname>bootloader</varname></term>
<listitem><para>Configure the bootloader that OSTree uses when
deploying the sysroot. This may take the values
<literal>bootloader=none</literal> or <literal>bootloader=auto</literal>.
<literal>bootloader=none</literal>, <literal>bootloader=auto</literal>,
<literal>bootloader=grub2</literal>, <literal>bootloader=syslinux</literal>,
<literal>bootloader=uboot</literal> or <literal>bootloader=zipl</literal>.
Default is <literal>auto</literal>.
</para>
<para>
@ -388,6 +390,11 @@ Boston, MA 02111-1307, USA.
then OSTree will generate a config for the bootloader found. For
example, <literal>grub2-mkconfig</literal> is run for the grub2 case.
</para>
<para>
A specific bootloader type may also be explicitly requested by choosing
<literal>grub2</literal>, <literal>syslinux</literal>, <literal>uboot</literal> or
<literal>zipl</literal>.
</para>
</listitem>
</varlistentry>

View File

@ -114,6 +114,9 @@ typedef enum {
typedef enum {
CFG_SYSROOT_BOOTLOADER_OPT_AUTO = 0,
CFG_SYSROOT_BOOTLOADER_OPT_NONE,
CFG_SYSROOT_BOOTLOADER_OPT_GRUB2,
CFG_SYSROOT_BOOTLOADER_OPT_SYSLINUX,
CFG_SYSROOT_BOOTLOADER_OPT_UBOOT,
CFG_SYSROOT_BOOTLOADER_OPT_ZIPL,
/* Non-exhaustive */
} OstreeCfgSysrootBootloaderOpt;
@ -122,6 +125,9 @@ static const char* const CFG_SYSROOT_BOOTLOADER_OPTS_STR[] = {
/* This must be kept in the same order as the enum */
"auto",
"none",
"grub2",
"syslinux",
"uboot",
"zipl",
NULL,
};

View File

@ -1352,6 +1352,15 @@ _ostree_sysroot_query_bootloader (OstreeSysroot *sysroot,
/* No bootloader specified; do not query bootloaders to run. */
ret_loader = NULL;
break;
case CFG_SYSROOT_BOOTLOADER_OPT_GRUB2:
ret_loader = (OstreeBootloader*) _ostree_bootloader_grub2_new (sysroot);
break;
case CFG_SYSROOT_BOOTLOADER_OPT_SYSLINUX:
ret_loader = (OstreeBootloader*) _ostree_bootloader_syslinux_new (sysroot);
break;
case CFG_SYSROOT_BOOTLOADER_OPT_UBOOT:
ret_loader = (OstreeBootloader*) _ostree_bootloader_uboot_new (sysroot);
break;
case CFG_SYSROOT_BOOTLOADER_OPT_ZIPL:
/* We never consider zipl as active by default, so it can only be created
* if it's explicitly requested in the config */