admin/init-fs: Add a --modern switch

This skips creating the default stuff in the physical sysroot.
I don't recall why I did that to be honest; it originated with
the first commit of this file.  It might not have ever been
necessary.

In any case, it's not necessary now with Fedora CoreOS, so
prune it and let's have a clean `/`.

Keep the old behavior by default though to avoid breaking anyone.

Closes: #1894
Approved by: ajeddeloh
This commit is contained in:
Colin Walters 2019-08-06 01:59:38 +00:00 committed by Atomic Bot
parent 729254503c
commit ab73d9f525
2 changed files with 42 additions and 18 deletions

View File

@ -30,7 +30,10 @@
#include <glib/gi18n.h>
static gboolean opt_modern;
static GOptionEntry options[] = {
{ "modern", 0, 0, G_OPTION_ARG_NONE, &opt_modern, "Only create /boot and /ostree", NULL },
{ NULL }
};
@ -58,10 +61,21 @@ 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,
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;
}
@ -78,6 +92,8 @@ ot_admin_builtin_init_fs (int argc, char **argv, OstreeCommandInvocation *invoca
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))

View File

@ -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};