Skip to content

Commit

Permalink
Add ostree composefs-generate command
Browse files Browse the repository at this point in the history
This allows you to build a composefs based on a single commit, or
by unioning several commits on top of each others.
  • Loading branch information
alexlarsson committed Jun 22, 2022
1 parent 0ab8217 commit a0d8133
Show file tree
Hide file tree
Showing 6 changed files with 375 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile-ostree.am
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ostree_SOURCES = src/ostree/main.c \
src/ostree/ot-builtin-checkout.c \
src/ostree/ot-builtin-checksum.c \
src/ostree/ot-builtin-commit.c \
src/ostree/ot-builtin-composefs.c \
src/ostree/ot-builtin-create-usb.c \
src/ostree/ot-builtin-diff.c \
src/ostree/ot-builtin-export.c \
Expand Down
50 changes: 50 additions & 0 deletions bash/ostree
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,55 @@ _ostree_checkout() {
return 0
}

_ostree_composefs_generate() {
local boolean_options="
$main_boolean_options
--from-stdin
--union-add
--union-identical
--whiteouts
"

local options_with_args="
--from-file
--repo
--subpath
"

local options_with_args_glob=$( __ostree_to_extglob "$options_with_args" )

case "$prev" in
--from-file)
__ostree_compreply_all_files
return 0
;;
--repo|--subpath)
__ostree_compreply_dirs_only
return 0
;;
$options_with_args_glob )
return 0
;;
esac

case "$cur" in
-*)
local all_options="$boolean_options $options_with_args"
__ostree_compreply_all_options
;;
*)
local argpos=$( __ostree_pos_first_nonflag $( __ostree_to_alternatives "$options_with_args" ) )

if [ $cword -eq $argpos ]; then
__ostree_compreply_commits
elif [ $cword -eq $(($argpos + 1)) ]; then
__ostree_compreply_all_files
fi
esac

return 0
}

_ostree_checksum() {
local boolean_options="
$main_boolean_options
Expand Down Expand Up @@ -1852,6 +1901,7 @@ _ostree() {
checkout
checksum
commit
composefs-generate
config
create-usb
diff
Expand Down
125 changes: 125 additions & 0 deletions man/ostree-composefs-generate.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?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 <anne.loverso@students.olin.edu>
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 composefs-generate</title>
<productname>OSTree</productname>

<authorgroup>
<author>
<contrib>Developer</contrib>
<firstname>Colin</firstname>
<surname>Walters</surname>
<email>walters@verbum.org</email>
</author>
</authorgroup>
</refentryinfo>

<refmeta>
<refentrytitle>ostree composefs-generate</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>

<refnamediv>
<refname>ostree-composefs-generate</refname>
<refpurpose>Create a composefs image out of commits</refpurpose>
</refnamediv>

<refsynopsisdiv>
<cmdsynopsis>
<command>ostree composefs-generate</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg choice="req">COMMIT</arg> <arg choice="opt">DESTINATION</arg>
</cmdsynopsis>
</refsynopsisdiv>

<refsect1>
<title>Description</title>

<para>
Creates a composefs image out the given commit(s) into the filesystem under directory DESTINATION. If DESTINATION is not specified, the COMMIT will become the destination checkout target.
</para>
</refsect1>

<refsect1>
<title>Options</title>

<variablelist>

<varlistentry>
<term><option>--subpath</option>="PATH"</term>

<listitem><para>
Checkout sub-directory PATH.
</para></listitem>
</varlistentry>

<varlistentry>
<term><option>--union-add</option></term>

<listitem><para>
When combining multiple commits, keep existing files. The default is to overwrite existing files.
</para></listitem>
</varlistentry>

<varlistentry>
<term><option>--union-identical</option></term>

<listitem><para>When combining multiple commits, error out
if a file would be replaced with a different file. Add new files
and directories, ignore identical files, and keep existing
directories.
</varlistentry>

<varlistentry>
<term><option>--whiteouts</option></term>

<listitem><para>
Process whiteout files (Docker style).
</para></listitem>
</varlistentry>

<varlistentry>
<term><option>--from-stdin</option></term>

<listitem><para>
Process many checkouts from standard input.
</para></listitem>
</varlistentry>

<varlistentry>
<term><option>--from-file</option>="FILE"</term>

<listitem><para>
Process many checkouts from input file.
</para></listitem>
</varlistentry>

</variablelist>
</refsect1>

<refsect1>
<title>Example</title>
<para><command>$ ostree composefs-generate --repo=/my/repo my-branch image.cfs</command></para>
</refsect1>
</refentry>
3 changes: 3 additions & 0 deletions src/ostree/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ static OstreeCommand commands[] = {
{ "commit", OSTREE_BUILTIN_FLAG_NONE,
ostree_builtin_commit,
"Commit a new revision" },
{ "composefs-generate", OSTREE_BUILTIN_FLAG_NONE,
ostree_builtin_composefs_generate,
"Create a composefs image from a commit" },
{ "config", OSTREE_BUILTIN_FLAG_NONE,
ostree_builtin_config,
"Change repo configuration settings" },
Expand Down
Loading

0 comments on commit a0d8133

Please sign in to comment.