mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-09 01:18:35 +03:00
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:
parent
729254503c
commit
ab73d9f525
@ -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,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))
|
||||
|
@ -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}"
|
||||
|
Loading…
Reference in New Issue
Block a user