From 02d419079d649f18a62ee64542b3f3f28ea14edb Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 24 Aug 2023 09:40:54 -0400 Subject: [PATCH] deploy: Add bootloader-naming-2 opt-init I've verified that this fixes compatibility with GRUB, which parses the filename: https://github.com/ostreedev/ostree/issues/2961 However, out of a large degree of conservatism I've made this an opt-in behavior for now. My plan is to test it out in the FCOS development streams first. --- src/libostree/ostree-sysroot-deploy.c | 11 +++++++++-- src/libostree/ostree-sysroot-private.h | 1 + src/libostree/ostree-sysroot.c | 1 + tests/inst/src/destructive.rs | 5 +++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c index 48a49e47f6..b756c76a37 100644 --- a/src/libostree/ostree-sysroot-deploy.c +++ b/src/libostree/ostree-sysroot-deploy.c @@ -1912,8 +1912,15 @@ install_deployment_kernel (OstreeSysroot *sysroot, int new_bootversion, const char *bootcsum = ostree_deployment_get_bootcsum (deployment); g_autofree char *bootcsumdir = g_strdup_printf ("ostree/%s-%s", osname, bootcsum); g_autofree char *bootconfdir = g_strdup_printf ("loader.%d/entries", new_bootversion); - g_autofree char *bootconf_name = g_strdup_printf ( - "ostree-%d-%s.conf", n_deployments - ostree_deployment_get_index (deployment), osname); + g_autofree char *bootconf_name = NULL; + guint index = n_deployments - ostree_deployment_get_index (deployment); + // Allow opt-in to dropping the stateroot, because grub2 parses the *filename* and ignores + // the version field. xref https://github.com/ostreedev/ostree/issues/2961 + bool use_new_naming = (sysroot->opt_flags & OSTREE_SYSROOT_GLOBAL_OPT_BOOTLOADER_NAMING_2) > 0; + if (use_new_naming) + bootconf_name = g_strdup_printf ("ostree-%d.conf", index); + else + bootconf_name = g_strdup_printf ("ostree-%d-%s.conf", index, osname); if (!glnx_shutil_mkdir_p_at (sysroot->boot_fd, bootcsumdir, 0775, cancellable, error)) return FALSE; diff --git a/src/libostree/ostree-sysroot-private.h b/src/libostree/ostree-sysroot-private.h index 63a294188c..a608a7a551 100644 --- a/src/libostree/ostree-sysroot-private.h +++ b/src/libostree/ostree-sysroot-private.h @@ -45,6 +45,7 @@ typedef enum OSTREE_SYSROOT_GLOBAL_OPT_SKIP_SYNC = 1 << 0, /* See https://github.com/ostreedev/ostree/pull/2847 */ OSTREE_SYSROOT_GLOBAL_OPT_EARLY_PRUNE = 1 << 1, + OSTREE_SYSROOT_GLOBAL_OPT_BOOTLOADER_NAMING_2 = 1 << 2, } OstreeSysrootGlobalOptFlags; typedef enum diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c index 8bcc2f733e..36dac18426 100644 --- a/src/libostree/ostree-sysroot.c +++ b/src/libostree/ostree-sysroot.c @@ -180,6 +180,7 @@ ostree_sysroot_init (OstreeSysroot *self) const GDebugKey globalopt_keys[] = { { "skip-sync", OSTREE_SYSROOT_GLOBAL_OPT_SKIP_SYNC }, { "early-prune", OSTREE_SYSROOT_GLOBAL_OPT_EARLY_PRUNE }, + { "bootloader-naming-2", OSTREE_SYSROOT_GLOBAL_OPT_BOOTLOADER_NAMING_2 }, }; const GDebugKey keys[] = { { "mutable-deployments", OSTREE_SYSROOT_DEBUG_MUTABLE_DEPLOYMENTS }, diff --git a/tests/inst/src/destructive.rs b/tests/inst/src/destructive.rs index c780f51cdf..aad92714a1 100644 --- a/tests/inst/src/destructive.rs +++ b/tests/inst/src/destructive.rs @@ -560,9 +560,10 @@ fn impl_transaction_test>( fn suppress_ostree_global_sync(sh: &xshell::Shell) -> Result<()> { let dropindir = "/etc/systemd/system/ostree-finalize-staged.service.d"; std::fs::create_dir_all(dropindir)?; + // Aslo opt-in to the new bootloader naming std::fs::write( - Path::new(dropindir).join("50-suppress-sync.conf"), - "[Service]\nEnvironment=OSTREE_SYSROOT_OPTS=skip-sync\n", + Path::new(dropindir).join("50-test-options.conf"), + "[Service]\nEnvironment=OSTREE_SYSROOT_OPTS=skip-sync,bootloader-naming-2\n", )?; cmd!(sh, "systemctl daemon-reload").run()?; Ok(())