diff --git a/src/ostree/ot-admin-builtin-init-fs.c b/src/ostree/ot-admin-builtin-init-fs.c index cca63a62..cb1e1b69 100644 --- a/src/ostree/ot-admin-builtin-init-fs.c +++ b/src/ostree/ot-admin-builtin-init-fs.c @@ -30,7 +30,10 @@ #include +static gboolean opt_modern; + static GOptionEntry options[] = { + { "modern", 0, 0, G_OPTION_ARG_NONE, &opt_modern, "Only create /boot and /ostree", NULL }, { NULL } }; @@ -58,26 +61,39 @@ ot_admin_builtin_init_fs (int argc, char **argv, OstreeCommandInvocation *invoca if (!glnx_opendirat (AT_FDCWD, sysroot_path, TRUE, &root_dfd, error)) return FALSE; - const char *normal_toplevels[] = {"boot", "dev", "home", "proc", "run", "sys"}; - for (guint i = 0; i < G_N_ELEMENTS (normal_toplevels); i++) + /* It's common to want to mount this outside of a deployment as well */ + if (!glnx_shutil_mkdir_p_at (root_dfd, "boot", 0755, cancellable, error)) + return FALSE; + + /* See https://github.com/coreos/coreos-assembler/pull/688 + * For Fedora CoreOS at least, we have this now to the point where we don't + * need this stuff in the physical sysroot. I'm not sure we ever really did, + * but to be conservative, make it opt-in to the new model of just boot/ and ostree/. + */ + if (!opt_modern) { - if (!glnx_shutil_mkdir_p_at (root_dfd, normal_toplevels[i], 0755, - cancellable, error)) + const char *traditional_toplevels[] = {"boot", "dev", "home", "proc", "run", "sys"}; + for (guint i = 0; i < G_N_ELEMENTS (traditional_toplevels); i++) + { + if (!glnx_shutil_mkdir_p_at (root_dfd, traditional_toplevels[i], 0755, + cancellable, error)) + return FALSE; + } + + if (!glnx_shutil_mkdir_p_at (root_dfd, "root", 0700, + cancellable, error)) return FALSE; + + if (!glnx_shutil_mkdir_p_at (root_dfd, "tmp", 01777, + cancellable, error)) + return FALSE; + if (fchmodat (root_dfd, "tmp", 01777, 0) == -1) + { + glnx_set_prefix_error_from_errno (error, "chmod: %s", "tmp"); + return FALSE; + } } - if (!glnx_shutil_mkdir_p_at (root_dfd, "root", 0700, - cancellable, error)) - return FALSE; - - if (!glnx_shutil_mkdir_p_at (root_dfd, "tmp", 01777, - cancellable, error)) - return FALSE; - if (fchmodat (root_dfd, "tmp", 01777, 0) == -1) - { - glnx_set_prefix_error_from_errno (error, "chmod: %s", "tmp"); - return FALSE; - } g_autoptr(GFile) dir = g_file_new_for_path (sysroot_path); g_autoptr(OstreeSysroot) sysroot = ostree_sysroot_new (dir); if (!ostree_sysroot_ensure_initialized (sysroot, cancellable, error)) diff --git a/tests/admin-test.sh b/tests/admin-test.sh index 31e969c2..0defebc0 100644 --- a/tests/admin-test.sh +++ b/tests/admin-test.sh @@ -21,7 +21,15 @@ set -euo pipefail -echo "1..$((26 + ${extra_admin_tests:-0}))" +echo "1..$((27 + ${extra_admin_tests:-0}))" + +mkdir sysrootmin +${CMD_PREFIX} ostree admin init-fs --modern sysrootmin +assert_has_dir sysrootmin/boot +assert_has_dir sysrootmin/ostree/repo +assert_not_has_dir sysrootmin/home +rm sysrootmin -rf +echo "ok init-fs --modern" function validate_bootloader() { cd ${test_tmpdir}; @@ -48,7 +56,7 @@ orig_mtime=$(stat -c '%.Y' sysroot/ostree/deploy) ${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime) export rev -# This initial deployment gets kicked off with some kernel arguments +# This initial deployment gets kicked off with some kernel arguments ${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime new_mtime=$(stat -c '%.Y' sysroot/ostree/deploy) assert_not_streq "${orig_mtime}" "${new_mtime}"