Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grub2: Generate config from pending deployment #1831

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/libostree/ostree-bootloader-grub2.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ grub2_child_setup (gpointer user_data)
static gboolean
_ostree_bootloader_grub2_write_config (OstreeBootloader *bootloader,
int bootversion,
GPtrArray *new_deployments,
GCancellable *cancellable,
GError **error)
{
Expand All @@ -357,15 +358,11 @@ _ostree_bootloader_grub2_write_config (OstreeBootloader *bootloader,
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;
OstreeDeployment *tool_deployment;
g_autoptr(GFile) tool_deployment_root = NULL;

deployments = ostree_sysroot_get_deployments (self->sysroot);

g_assert_cmpint (deployments->len, >, 0);

tool_deployment = deployments->pdata[0];
g_assert_cmpint (new_deployments->len, >, 0);
tool_deployment = new_deployments->pdata[0];

/* Sadly we have to execute code to generate the bootloader configuration.
* If we're in a booted deployment, we just don't chroot.
Expand All @@ -380,6 +377,8 @@ _ostree_bootloader_grub2_write_config (OstreeBootloader *bootloader,
grub2_mkconfig_chroot = g_file_get_path (tool_deployment_root);
}

g_debug ("Using grub2-mkconfig chroot: %s\n", grub2_mkconfig_chroot);

g_autoptr(GFile) new_config_path = NULL;
g_autoptr(GFile) config_path_efi_dir = NULL;
if (self->is_efi)
Expand Down
9 changes: 5 additions & 4 deletions src/libostree/ostree-bootloader-syslinux.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ append_config_from_loader_entries (OstreeBootloaderSyslinux *self,
}

static gboolean
_ostree_bootloader_syslinux_write_config (OstreeBootloader *bootloader,
int bootversion,
GCancellable *cancellable,
GError **error)
_ostree_bootloader_syslinux_write_config (OstreeBootloader *bootloader,
int bootversion,
GPtrArray *new_deployments,
GCancellable *cancellable,
GError **error)
{
OstreeBootloaderSyslinux *self = OSTREE_BOOTLOADER_SYSLINUX (bootloader);

Expand Down
9 changes: 5 additions & 4 deletions src/libostree/ostree-bootloader-uboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,11 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self,
}

static gboolean
_ostree_bootloader_uboot_write_config (OstreeBootloader *bootloader,
int bootversion,
GCancellable *cancellable,
GError **error)
_ostree_bootloader_uboot_write_config (OstreeBootloader *bootloader,
int bootversion,
GPtrArray *new_deployments,
GCancellable *cancellable,
GError **error)
{
OstreeBootloaderUboot *self = OSTREE_BOOTLOADER_UBOOT (bootloader);

Expand Down
6 changes: 4 additions & 2 deletions src/libostree/ostree-bootloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ _ostree_bootloader_get_name (OstreeBootloader *self)
gboolean
_ostree_bootloader_write_config (OstreeBootloader *self,
int bootversion,
GPtrArray *new_deployments,
GCancellable *cancellable,
GError **error)
{
g_return_val_if_fail (OSTREE_IS_BOOTLOADER (self), FALSE);

return OSTREE_BOOTLOADER_GET_IFACE (self)->write_config (self, bootversion,
cancellable, error);
return OSTREE_BOOTLOADER_GET_IFACE (self)->write_config (self, bootversion,
new_deployments,
cancellable, error);
}

gboolean
Expand Down
2 changes: 2 additions & 0 deletions src/libostree/ostree-bootloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct _OstreeBootloaderInterface
const char * (* get_name) (OstreeBootloader *self);
gboolean (* write_config) (OstreeBootloader *self,
int bootversion,
GPtrArray *new_deployments,
GCancellable *cancellable,
GError **error);
gboolean (* is_atomic) (OstreeBootloader *self);
Expand All @@ -61,6 +62,7 @@ const char *_ostree_bootloader_get_name (OstreeBootloader *self);

gboolean _ostree_bootloader_write_config (OstreeBootloader *self,
int bootversion,
GPtrArray *new_deployments,
GCancellable *cancellable,
GError **error);

Expand Down
3 changes: 2 additions & 1 deletion src/libostree/ostree-sysroot-deploy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2122,7 +2122,8 @@ write_deployments_bootswap (OstreeSysroot *self,
if (bootloader)
{
if (!_ostree_bootloader_write_config (bootloader, new_bootversion,
cancellable, error))
new_deployments, cancellable,
error))
return glnx_prefix_error (error, "Bootloader write config");
}

Expand Down
7 changes: 4 additions & 3 deletions tests/test-admin-deploy-none.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ cd ${test_tmpdir}
rm httpd osdata testos-repo sysroot -rf
setup_os_repository "archive" "sysroot.bootloader none"
${CMD_PREFIX} ostree pull-local --repo=sysroot/ostree/repo --remote testos testos-repo testos/buildmaster/x86_64-runtime
# Test grub2 does not get detected with bootloader configuration "none"
# (see https://github.com/ostreedev/ostree/issues/1774)
mkdir -p sysroot/boot/grub2 && touch sysroot/boot/grub2/grub.cfg
# Test that configuring sysroot.bootloader="none" is a workaround for previous
# grub2 bootloader issue (see https://github.com/ostreedev/ostree/issues/1774)
mkdir -p sysroot/boot/grub2
touch sysroot/boot/grub2/grub.cfg
${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os testos testos/buildmaster/x86_64-runtime > out.txt
assert_file_has_content out.txt "Bootloader updated.*"
assert_file_has_content sysroot/boot/loader/entries/ostree-1-testos.conf 'options.* root=LABEL=MOO'
Expand Down