From 9d5ccfeffff9dec81e8862fc1030670f80b6f3bc Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 17 Aug 2023 16:46:02 -0400 Subject: [PATCH 1/2] Add `ostree admin stateroot-init` as alias for `os-init` To further help deprecate the confusing "osname" terminology. --- Makefile-man.am | 2 +- man/ostree-admin-os-init.xml | 16 +----- man/ostree-admin-stateroot-init.xml | 75 +++++++++++++++++++++++++++ src/ostree/ot-admin-builtin-os-init.c | 6 +-- src/ostree/ot-builtin-admin.c | 2 + tests/libtest.sh | 2 +- 6 files changed, 84 insertions(+), 19 deletions(-) create mode 100644 man/ostree-admin-stateroot-init.xml diff --git a/Makefile-man.am b/Makefile-man.am index 03f16edc0c..da229bc7cb 100644 --- a/Makefile-man.am +++ b/Makefile-man.am @@ -26,7 +26,7 @@ if ENABLE_MAN # ostree.xml. man1_files = ostree.1 ostree-admin-cleanup.1 \ ostree-admin-config-diff.1 ostree-admin-deploy.1 \ -ostree-admin-init-fs.1 ostree-admin-instutil.1 ostree-admin-os-init.1 \ +ostree-admin-init-fs.1 ostree-admin-instutil.1 ostree-admin-stateroot-init.1 ostree-admin-os-init.1 \ ostree-admin-status.1 ostree-admin-set-origin.1 ostree-admin-switch.1 \ ostree-admin-undeploy.1 ostree-admin-upgrade.1 ostree-admin-unlock.1 \ ostree-admin-pin.1 ostree-admin-set-default.1 \ diff --git a/man/ostree-admin-os-init.xml b/man/ostree-admin-os-init.xml index fbe1ec7432..ea141ab81c 100644 --- a/man/ostree-admin-os-init.xml +++ b/man/ostree-admin-os-init.xml @@ -44,7 +44,7 @@ License along with this library. If not, see . ostree-admin-os-init - Initialize empty state for a given operating system + Soft-deprecated alias for stateroot-init @@ -57,19 +57,7 @@ License along with this library. If not, see . Description - Initializes an new stateroot (AKA "osname") for an operating system. - Ensures that the core subdirectories of /var (/tmp, /lib, /run, and - /lock) exist and initialize the given STATEROOT as OSTree stateroot. - Each deployment location is comprised of a single shared - var and a set of deployments (chroots). + This is a soft-deprecated alias for stateroot-init. Please see the documentation for that. - - - Example - $ ostree admin os-init exampleos - - ostree/deploy/exampleos initialized as OSTree root - - diff --git a/man/ostree-admin-stateroot-init.xml b/man/ostree-admin-stateroot-init.xml new file mode 100644 index 0000000000..c9e50ed9da --- /dev/null +++ b/man/ostree-admin-stateroot-init.xml @@ -0,0 +1,75 @@ + + + + + + + + + ostree admin stateroot-init + OSTree + + + + Developer + Colin + Walters + walters@verbum.org + + + + + + ostree admin stateroot-init + 1 + + + + ostree-admin-stateroot-init + Initialize empty state for a given operating system + + + + + ostree admin stateroot-init STATEROOT + + + + + Description + + + Initializes an new stateroot (AKA "osname") for an operating system. + Ensures that the core subdirectories of /var (/tmp, /lib, /run, and + /lock) exist and initialize the given STATEROOT as OSTree stateroot. + Each deployment location is comprised of a single shared + var and a set of deployments (chroots). + + + + + Example + $ ostree admin stateroot-init exampleos + + ostree/deploy/exampleos initialized as OSTree stateroot + + + diff --git a/src/ostree/ot-admin-builtin-os-init.c b/src/ostree/ot-admin-builtin-os-init.c index 607bf529ed..561d6cd442 100644 --- a/src/ostree/ot-admin-builtin-os-init.c +++ b/src/ostree/ot-admin-builtin-os-init.c @@ -34,7 +34,7 @@ gboolean ot_admin_builtin_os_init (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error) { - g_autoptr (GOptionContext) context = g_option_context_new ("OSNAME"); + g_autoptr (GOptionContext) context = g_option_context_new ("STATEROOT"); g_autoptr (OstreeSysroot) sysroot = NULL; if (!ostree_admin_option_context_parse (context, options, &argc, &argv, @@ -47,7 +47,7 @@ ot_admin_builtin_os_init (int argc, char **argv, OstreeCommandInvocation *invoca if (argc < 2) { - ot_util_usage_error (context, "OSNAME must be specified", error); + ot_util_usage_error (context, "STATEROOT must be specified", error); return FALSE; } @@ -56,7 +56,7 @@ ot_admin_builtin_os_init (int argc, char **argv, OstreeCommandInvocation *invoca if (!ostree_sysroot_init_osname (sysroot, osname, cancellable, error)) return FALSE; - g_print ("ostree/deploy/%s initialized as OSTree root\n", osname); + g_print ("ostree/deploy/%s initialized as OSTree stateroot\n", osname); return TRUE; } diff --git a/src/ostree/ot-builtin-admin.c b/src/ostree/ot-builtin-admin.c index 14f776c02e..0eeb3b2cb1 100644 --- a/src/ostree/ot-builtin-admin.c +++ b/src/ostree/ot-builtin-admin.c @@ -47,6 +47,8 @@ static OstreeCommand admin_subcommands[] = { "Deprecated commands intended for installer programs" }, { "os-init", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_os_init, "Initialize empty state for given operating system" }, + { "stateroot-init", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_os_init, + "Initialize empty state for given operating system" }, { "pin", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_pin, "Change the \"pinning\" state of a deployment" }, { "set-origin", OSTREE_BUILTIN_FLAG_NO_REPO, ot_admin_builtin_set_origin, diff --git a/tests/libtest.sh b/tests/libtest.sh index 1956f8036d..9d871aa430 100755 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -494,7 +494,7 @@ EOF if test -n "${OSTREE_NO_XATTRS:-}"; then echo -e 'disable-xattrs=true\n' >> sysroot/ostree/repo/config fi - ${CMD_PREFIX} ostree admin os-init testos + ${CMD_PREFIX} ostree admin stateroot-init testos case $bootmode in "syslinux") From f4e56b910ffe33389f2671d7ce9a3ced07bf61a1 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 17 Aug 2023 16:48:05 -0400 Subject: [PATCH 2/2] admin-deploy: Add `--stateroot` as alias for `--os` To further help deprecate the confusing "osname" terminology. --- man/ostree-admin-deploy.xml | 10 +++++++++- src/ostree/ot-admin-builtin-deploy.c | 2 ++ tests/admin-test.sh | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/man/ostree-admin-deploy.xml b/man/ostree-admin-deploy.xml index 0d73b8e10e..8915ad2c0b 100644 --- a/man/ostree-admin-deploy.xml +++ b/man/ostree-admin-deploy.xml @@ -65,11 +65,19 @@ License along with this library. If not, see . Options + + ="STATEROOT" + + + Use a different operating system stateroot than the current one. + + + ="STATEROOT" - Use a different operating system root than the current one. + Alias for --stateroot. diff --git a/src/ostree/ot-admin-builtin-deploy.c b/src/ostree/ot-admin-builtin-deploy.c index 00204ffdcb..bfeb81d905 100644 --- a/src/ostree/ot-admin-builtin-deploy.c +++ b/src/ostree/ot-admin-builtin-deploy.c @@ -51,6 +51,8 @@ static char **opt_overlay_initrds; static GOptionEntry options[] = { { "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Use a different operating system root than the current one", "OSNAME" }, + { "stateroot", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Target the provided stateroot", + "STATEROOT" }, { "origin-file", 0, 0, G_OPTION_ARG_FILENAME, &opt_origin_path, "Specify origin file", "FILENAME" }, { "no-prune", 0, 0, G_OPTION_ARG_NONE, &opt_no_prune, "Don't prune the repo when done", NULL }, diff --git a/tests/admin-test.sh b/tests/admin-test.sh index 9962e2edb2..e362162c5b 100644 --- a/tests/admin-test.sh +++ b/tests/admin-test.sh @@ -97,7 +97,7 @@ assert_file_has_content_literal err.txt "Cannot stage deployment: Not currently echo "ok staging does not work when not booted" orig_mtime=$(stat -c '%.Y' sysroot/ostree/deploy) -${CMD_PREFIX} ostree admin deploy --os=testos testos:testos/buildmain/x86_64-runtime +${CMD_PREFIX} ostree admin deploy --stateroot=testos testos:testos/buildmain/x86_64-runtime new_mtime=$(stat -c '%.Y' sysroot/ostree/deploy) assert_not_streq "${orig_mtime}" "${new_mtime}" # Need a new bootversion, sine we now have two deployments