diff options
author | Gatis Paeglis <gatis.paeglis@theqtcompany.com> | 2016-04-01 13:51:18 +0200 |
---|---|---|
committer | Colin Walters (automation) <walters+githubbot@verbum.org> | 2016-04-04 14:19:35 +0000 |
commit | 4e815484470fb22a1b0dc52af0193d5ce1a3caf7 (patch) | |
tree | 6c6c0262c3543ac90a2c441af5992f4e579f6b84 /src/libostree/ostree-bootloader-grub2.c | |
parent | 826c2149b8e1c7be7277d9e558680139e9fd0ab7 (diff) | |
download | ostree-4e815484470fb22a1b0dc52af0193d5ce1a3caf7.tar.gz |
Introducing ostree-grub-generator
ostree-grub-generator can be used to customize
the generated grub.cfg file. Compile time
decision ostree-grub-generator vs grub2-mkconfig
can be overwritten with the OSTREE_GRUB2_EXEC
envvar - useful for auto tests and OS installers.
Why this alternative approach:
1) The current approach is less flexible than using a
custom 'ostree-grub-generator' script. Each system can
adjust this script for its needs, instead of using the
hardcoded values from ostree-bootloader-grub2.c.
2) Too much overhead on embedded to generate grub.cfg
via /etc/grub.d/ configuration files. It is still
possible to do so, even with this patch applied.
No need to install grub2 package on a target device.
3) The grub2-mkconfig code path has other issues:
https://bugzilla.gnome.org/show_bug.cgi?id=761180
Task: https://bugzilla.gnome.org/show_bug.cgi?id=762220
Closes: #228
Approved by: cgwalters
Diffstat (limited to 'src/libostree/ostree-bootloader-grub2.c')
-rw-r--r-- | src/libostree/ostree-bootloader-grub2.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/libostree/ostree-bootloader-grub2.c b/src/libostree/ostree-bootloader-grub2.c index 11316e98..c970e662 100644 --- a/src/libostree/ostree-bootloader-grub2.c +++ b/src/libostree/ostree-bootloader-grub2.c @@ -299,8 +299,25 @@ _ostree_bootloader_grub2_write_config (OstreeBootloader *bootloader, g_autofree char *bootversion_str = g_strdup_printf ("%u", (guint)bootversion); g_autoptr(GFile) config_path_efi_dir = NULL; g_autofree char *grub2_mkconfig_chroot = NULL; + gboolean use_system_grub2_mkconfig = TRUE; + const gchar *grub_exec = NULL; + +#ifdef USE_BUILTIN_GRUB2_MKCONFIG + use_system_grub2_mkconfig = FALSE; +#endif + /* Autotests can set this envvar to select which code path to test, useful for OS installers as well */ + grub_exec = g_getenv ("OSTREE_GRUB2_EXEC"); + if (grub_exec) + { + if (g_str_has_suffix (grub_exec, GRUB2_MKCONFIG_PATH)) + use_system_grub2_mkconfig = TRUE; + else + use_system_grub2_mkconfig = FALSE; + } + else + grub_exec = use_system_grub2_mkconfig ? GRUB2_MKCONFIG_PATH : LIBEXECDIR "/ostree-grub-generator"; - if (ostree_sysroot_get_booted_deployment (self->sysroot) == NULL + if (use_system_grub2_mkconfig && ostree_sysroot_get_booted_deployment (self->sysroot) == NULL && g_file_has_parent (self->sysroot->path, NULL)) { g_autoptr(GPtrArray) deployments = NULL; @@ -318,6 +335,9 @@ _ostree_bootloader_grub2_write_config (OstreeBootloader *bootloader, * * In the case of an installer, use the first deployment root (which * will most likely be the only one. + * + * This all only applies if we're not using the builtin + * generator, which handles being run outside of the root. */ tool_deployment_root = ostree_sysroot_get_deployment_directory (self->sysroot, tool_deployment); grub2_mkconfig_chroot = g_file_get_path (tool_deployment_root); @@ -361,7 +381,7 @@ _ostree_bootloader_grub2_write_config (OstreeBootloader *bootloader, Upstream is fixed though. */ proc = g_subprocess_launcher_spawn (launcher, error, - "grub2-mkconfig", "-o", + grub_exec, "-o", gs_file_get_path_cached (new_config_path), NULL); |