summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Marrero Corchado <jmarrero@users.noreply.github.com>2023-03-17 11:09:19 -0400
committerGitHub <noreply@github.com>2023-03-17 11:09:19 -0400
commit4f0c13fb8b5ef6c779c106d7c862833a0175c6ca (patch)
tree80fbd29b029db88ee2630a3842a1ea1fc5646682
parent7e93837e676979ada68f44d90ca7af129f610825 (diff)
parent10e465c3c41f54c773c2b7c21da69e52f0c1ce99 (diff)
downloadostree-4f0c13fb8b5ef6c779c106d7c862833a0175c6ca.tar.gz
Merge pull request #2705 from cgwalters/always-boot
Add `sysroot.bootprefix` option
-rw-r--r--Makefile-tests.am1
-rw-r--r--man/ostree.repo-config.xml9
-rw-r--r--src/libostree/ostree-repo-private.h1
-rw-r--r--src/libostree/ostree-repo.c5
-rw-r--r--src/libostree/ostree-sysroot-deploy.c12
-rwxr-xr-xtests/test-admin-deploy-bootprefix.sh35
6 files changed, 58 insertions, 5 deletions
diff --git a/Makefile-tests.am b/Makefile-tests.am
index 01ed0bd5..a30b86dd 100644
--- a/Makefile-tests.am
+++ b/Makefile-tests.am
@@ -99,6 +99,7 @@ _installed_or_uninstalled_test_scripts = \
tests/test-admin-upgrade-endoflife.sh \
tests/test-admin-upgrade-systemd-update.sh \
tests/test-admin-deploy-syslinux.sh \
+ tests/test-admin-deploy-bootprefix.sh \
tests/test-admin-deploy-2.sh \
tests/test-admin-deploy-karg.sh \
tests/test-admin-deploy-switch.sh \
diff --git a/man/ostree.repo-config.xml b/man/ostree.repo-config.xml
index 5afeac8a..5e6d9d89 100644
--- a/man/ostree.repo-config.xml
+++ b/man/ostree.repo-config.xml
@@ -415,6 +415,15 @@ License along with this library. If not, see <https://www.gnu.org/licenses/>.
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><varname>bootprefix</varname></term>
+ <listitem><para>A boolean value; defaults to false. If set to true, the bootloader entries
+ generated will include <literal>/boot</literal> as a prefix. This will likely be turned
+ on by default in the future.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</refsect1>
diff --git a/src/libostree/ostree-repo-private.h b/src/libostree/ostree-repo-private.h
index 17993574..5f21807e 100644
--- a/src/libostree/ostree-repo-private.h
+++ b/src/libostree/ostree-repo-private.h
@@ -228,6 +228,7 @@ struct OstreeRepo {
gchar **repo_finders;
OstreeCfgSysrootBootloaderOpt bootloader; /* Configure which bootloader to use. */
GHashTable *bls_append_values; /* Parsed key-values from bls-append-except-default key in config. */
+ gboolean enable_bootprefix; /* If true, prepend bootloader entries with /boot */
OstreeRepo *parent_repo;
};
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index 11175db4..515f51e5 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -3552,6 +3552,11 @@ reload_sysroot_config (OstreeRepo *self,
g_hash_table_replace (self->bls_append_values, key, value);
}
+ if (!ot_keyfile_get_boolean_with_default (self->config, "sysroot",
+ "bootprefix", FALSE,
+ &self->enable_bootprefix, error))
+ return FALSE;
+
return TRUE;
}
diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c
index 4d4f9bcb..b128136a 100644
--- a/src/libostree/ostree-sysroot-deploy.c
+++ b/src/libostree/ostree-sysroot-deploy.c
@@ -1875,6 +1875,8 @@ install_deployment_kernel (OstreeSysroot *sysroot,
OstreeRepo *repo = ostree_sysroot_repo (sysroot);
+ const char *bootprefix = repo->enable_bootprefix ? "/boot/" : "/";
+
/* Install (hardlink/copy) the kernel into /boot/ostree/osname-${bootcsum} if
* it doesn't exist already.
*/
@@ -1970,7 +1972,7 @@ install_deployment_kernel (OstreeSysroot *sysroot,
* /boot itself and drop the boocsum dir concept entirely. */
g_autofree char *destpath =
- g_strdup_printf ("/" _OSTREE_SYSROOT_BOOT_INITRAMFS_OVERLAYS "/%s.img", checksum);
+ g_strdup_printf ("%s%s/%s.img", bootprefix, _OSTREE_SYSROOT_BOOT_INITRAMFS_OVERLAYS, checksum);
const char *rel_destpath = destpath + 1;
/* lazily allocate array and create dir so we don't pollute /boot if not needed */
@@ -2066,7 +2068,7 @@ install_deployment_kernel (OstreeSysroot *sysroot,
g_autofree char *version_key = g_strdup_printf ("%d", n_deployments - ostree_deployment_get_index (deployment));
ostree_bootconfig_parser_set (bootconfig, OSTREE_COMMIT_META_KEY_VERSION, version_key);
- g_autofree char * boot_relpath = g_strconcat ("/", bootcsumdir, "/", kernel_layout->kernel_namever, NULL);
+ g_autofree char * boot_relpath = g_strconcat (bootprefix, bootcsumdir, "/", kernel_layout->kernel_namever, NULL);
ostree_bootconfig_parser_set (bootconfig, "linux", boot_relpath);
val = ostree_bootconfig_parser_get (bootconfig, "options");
@@ -2075,7 +2077,7 @@ install_deployment_kernel (OstreeSysroot *sysroot,
if (kernel_layout->initramfs_namever)
{
g_autofree char * initrd_boot_relpath =
- g_strconcat ("/", bootcsumdir, "/", kernel_layout->initramfs_namever, NULL);
+ g_strconcat (bootprefix, bootcsumdir, "/", kernel_layout->initramfs_namever, NULL);
ostree_bootconfig_parser_set (bootconfig, "initrd", initrd_boot_relpath);
if (overlay_initrds)
@@ -2119,7 +2121,7 @@ install_deployment_kernel (OstreeSysroot *sysroot,
if (kernel_layout->devicetree_namever)
{
- g_autofree char * dt_boot_relpath = g_strconcat ("/", bootcsumdir, "/", kernel_layout->devicetree_namever, NULL);
+ g_autofree char * dt_boot_relpath = g_strconcat (bootprefix, bootcsumdir, "/", kernel_layout->devicetree_namever, NULL);
ostree_bootconfig_parser_set (bootconfig, "devicetree", dt_boot_relpath);
}
else if (kernel_layout->devicetree_srcpath)
@@ -2128,7 +2130,7 @@ install_deployment_kernel (OstreeSysroot *sysroot,
* want to point to a whole directory of device trees.
* See: https://github.com/ostreedev/ostree/issues/1900
*/
- g_autofree char * dt_boot_relpath = g_strconcat ("/", bootcsumdir, "/", kernel_layout->devicetree_srcpath, NULL);
+ g_autofree char * dt_boot_relpath = g_strconcat (bootprefix, bootcsumdir, "/", kernel_layout->devicetree_srcpath, NULL);
ostree_bootconfig_parser_set (bootconfig, "fdtdir", dt_boot_relpath);
}
diff --git a/tests/test-admin-deploy-bootprefix.sh b/tests/test-admin-deploy-bootprefix.sh
new file mode 100755
index 00000000..d80c310b
--- /dev/null
+++ b/tests/test-admin-deploy-bootprefix.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 Colin Walters <walters@verbum.org>
+#
+# SPDX-License-Identifier: LGPL-2.0+
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see <https://www.gnu.org/licenses/>.
+
+set -euo pipefail
+
+. $(dirname $0)/libtest.sh
+
+# Exports OSTREE_SYSROOT so --sysroot not needed.
+setup_os_repository "archive" "syslinux"
+
+${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmain/x86_64-runtime
+${CMD_PREFIX} ostree --repo=sysroot/ostree/repo config set sysroot.bootprefix 'true'
+${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=root --os=testos testos:testos/buildmain/x86_64-runtime
+assert_file_has_content_literal sysroot/boot/loader/entries/ostree-1-testos.conf 'linux /boot/ostree/testos-'
+assert_file_has_content_literal sysroot/boot/loader/entries/ostree-1-testos.conf 'initrd /boot/ostree/testos-'
+
+tap_ok "bootprefix"
+
+tap_end