Skip to content

Commit

Permalink
Merge pull request #2990 from cgwalters/init-is-stateroot
Browse files Browse the repository at this point in the history
Two s/osname/stateroot/ patches
  • Loading branch information
cgwalters authored Aug 18, 2023
2 parents 722fc2d + f4e56b9 commit f7786e7
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Makefile-man.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
10 changes: 9 additions & 1 deletion man/ostree-admin-deploy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,19 @@ License along with this library. If not, see <https://www.gnu.org/licenses/>.
<title>Options</title>

<variablelist>
<varlistentry>
<term><option>--stateroot</option>="STATEROOT"</term>

<listitem><para>
Use a different operating system stateroot than the current one.
</para></listitem>
</varlistentry>

<varlistentry>
<term><option>--os</option>="STATEROOT"</term>

<listitem><para>
Use a different operating system root than the current one.
Alias for <literal>--stateroot</literal>.
</para></listitem>
</varlistentry>

Expand Down
16 changes: 2 additions & 14 deletions man/ostree-admin-os-init.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ License along with this library. If not, see <https://www.gnu.org/licenses/>.

<refnamediv>
<refname>ostree-admin-os-init</refname>
<refpurpose>Initialize empty state for a given operating system</refpurpose>
<refpurpose>Soft-deprecated alias for stateroot-init</refpurpose>
</refnamediv>

<refsynopsisdiv>
Expand All @@ -57,19 +57,7 @@ License along with this library. If not, see <https://www.gnu.org/licenses/>.
<title>Description</title>

<para>
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
<filename>var</filename> and a set of deployments (chroots).
This is a soft-deprecated alias for stateroot-init. Please see the documentation for that.
</para>
</refsect1>

<refsect1>
<title>Example</title>
<para><command>$ ostree admin os-init exampleos</command></para>
<programlisting>
ostree/deploy/exampleos initialized as OSTree root
</programlisting>
</refsect1>
</refentry>
75 changes: 75 additions & 0 deletions man/ostree-admin-stateroot-init.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">

<!--
Copyright 2014 Anne LoVerso <[email protected]>
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/>.
-->

<refentry id="ostree">

<refentryinfo>
<title>ostree admin stateroot-init</title>
<productname>OSTree</productname>

<authorgroup>
<author>
<contrib>Developer</contrib>
<firstname>Colin</firstname>
<surname>Walters</surname>
<email>[email protected]</email>
</author>
</authorgroup>
</refentryinfo>

<refmeta>
<refentrytitle>ostree admin stateroot-init</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>

<refnamediv>
<refname>ostree-admin-stateroot-init</refname>
<refpurpose>Initialize empty state for a given operating system</refpurpose>
</refnamediv>

<refsynopsisdiv>
<cmdsynopsis>
<command>ostree admin stateroot-init</command> <arg choice="req">STATEROOT</arg>
</cmdsynopsis>
</refsynopsisdiv>

<refsect1>
<title>Description</title>

<para>
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
<filename>var</filename> and a set of deployments (chroots).
</para>
</refsect1>

<refsect1>
<title>Example</title>
<para><command>$ ostree admin stateroot-init exampleos</command></para>
<programlisting>
ostree/deploy/exampleos initialized as OSTree stateroot
</programlisting>
</refsect1>
</refentry>
2 changes: 2 additions & 0 deletions src/ostree/ot-admin-builtin-deploy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
6 changes: 3 additions & 3 deletions src/ostree/ot-admin-builtin-os-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}

Expand All @@ -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;
}
2 changes: 2 additions & 0 deletions src/ostree/ot-builtin-admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/admin-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/libtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit f7786e7

Please sign in to comment.