summaryrefslogtreecommitdiffstats
path: root/man/systemd-vpick.xml
blob: 95f946a84cda26b290a11a0962eb952e31ba3f94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->

<refentry id="systemd-vpick"
    xmlns:xi="http://www.w3.org/2001/XInclude">

  <refentryinfo>
    <title>systemd-vpick</title>
    <productname>systemd</productname>
  </refentryinfo>

  <refmeta>
    <refentrytitle>systemd-vpick</refentrytitle>
    <manvolnum>1</manvolnum>
  </refmeta>

  <refnamediv>
    <refname>systemd-vpick</refname>
    <refpurpose>Resolve paths to <literal>.v/</literal> versioned directories</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <cmdsynopsis>
      <command>systemd-vpick <arg choice="opt" rep="repeat">OPTIONS</arg> <arg choice="opt" rep="repeat">PATH</arg></command>
    </cmdsynopsis>
  </refsynopsisdiv>

  <refsect1>
    <title>Description</title>

    <para><command>systemd-vpick</command> resolves a file system path referencing a <literal>.v/</literal>
    versioned directory to a path to the newest (by version) file contained therein. This tool provides a
    command line interface for the
    <citerefentry><refentrytitle>systemd.v</refentrytitle><manvolnum>7</manvolnum></citerefentry>
    logic.</para>

    <para>The tool expects a path to a <literal>.v/</literal> directory as argument (either directly, or with
    a triple underscore pattern as final component). It then determines the newest file contained in that
    directory, and writes its path to standard output.</para>

    <para>Unless the triple underscore pattern is passed as last component of the path, it is typically
    necessary to at least specify the <option>--suffix=</option> switch to configure the file suffix to look
    for.</para>

    <para>If the specified path does not reference a <literal>.v/</literal> path (i.e. neither the final
    component ends in <literal>.v</literal>, nor the penultimate does or the final one does contain a triple
    underscore) it specified path is written unmodified to standard output.</para>
  </refsect1>

  <refsect1>
    <title>Options</title>

    <para>The following options are understood:</para>

    <variablelist>
      <varlistentry>
        <term><option>--basename=</option></term>
        <term><option>-B</option></term>

        <listitem><para>Overrides the "basename" of the files to look for, i.e. the part to the left of the
        variable part of the filenames. Normally this is derived automatically from the filename of the
        <literal>.v</literal> component of the specified path, or from the triple underscore pattern in the
        last component of the specified path.</para>

        <xi:include href="version-info.xml" xpointer="v256"/></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>-V</option></term>

        <listitem><para>Explicitly configures the version to select. If specified, a filename with the
        specified version string will be looked for, instead of the newest version
        available.</para>

        <xi:include href="version-info.xml" xpointer="v256"/></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>-A</option></term>

        <listitem><para>Explicitly configures the architecture to select. If specified, a filename with the
        specified architecture identifier will be looked for. If not specified only filenames with a locally
        supported architecture are considered, or those without any architecture identifier.</para>

        <xi:include href="version-info.xml" xpointer="v256"/></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>--suffix=</option></term>
        <term><option>-S</option></term>

        <listitem><para>Configures the suffix of the filenames to consider. For the <literal>.v/</literal>
        logic it is necessary to specify the suffix to look for, and the <literal>.v/</literal> component
        must also carry the suffix immediately before <literal>.v</literal> in its name.</para>

        <xi:include href="version-info.xml" xpointer="v256"/></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>--type=</option></term>
        <term><option>-t</option></term>

        <listitem><para>Configures the inode type to look for in the <literal>.v/</literal> directory. Takes
        one of <literal>reg</literal>, <literal>dir</literal>, <literal>sock</literal>,
        <literal>fifo</literal>, <literal>blk</literal>, <literal>chr</literal>, <literal>lnk</literal> as
        argument, each identifying an inode type. See <citerefentry
        project='man-pages'><refentrytitle>inode</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
        details about inode types. If this option is used inodes not matching the specified type are filtered
        and not taken into consideration.</para>

        <xi:include href="version-info.xml" xpointer="v256"/></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>--print=</option></term>
        <term><option>-p</option></term>

        <listitem><para>Configures what precisely to write to standard output. If not specified prints the
        full, resolved path of the newest matching file in the <literal>.v/</literal> directory. This switch can be set to one of the following:</para>

        <itemizedlist>
          <listitem><para>If set to <literal>filename</literal>, will print only the filename instead of the full path of the resolved file.</para></listitem>
          <listitem><para>If set to <literal>version</literal>, will print only the version of the resolved file.</para></listitem>
          <listitem><para>If set to <literal>type</literal>, will print only the inode type of the resolved
          file (i.e. a string such as <literal>reg</literal> for regular files, or <literal>dir</literal> for
          directories).</para></listitem>
          <listitem><para>If set to <literal>arch</literal>, will print only the architecture of the resolved
          file.</para></listitem>
          <listitem><para>If set to <literal>tries</literal>, will print only the tries left/tries done of the
          resolved file.</para></listitem>
          <listitem><para>If set to <literal>all</literal>, will print all of the above in a simple tabular
          output.</para></listitem>
        </itemizedlist>

        <xi:include href="version-info.xml" xpointer="v256"/></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>--resolve=</option></term>

        <listitem><para>Takes a boolean argument. If true the path to the versioned file is fully
        canonicalized (i.e. symlinks resolved, and redundant path components removed) before it is shown. If
        false (the default) this is not done, and the path is shown without canonicalization.</para>

        <xi:include href="version-info.xml" xpointer="v256"/></listitem>
      </varlistentry>

      <xi:include href="standard-options.xml" xpointer="help" />
      <xi:include href="standard-options.xml" xpointer="version" />
    </variablelist>
  </refsect1>

  <refsect1>
    <title>Examples</title>

    <para>Use a command like the following to automatically pick the newest raw disk image from a
    <literal>.v/</literal> directory:</para>

    <programlisting>$ systemd-vpick --suffix=.raw --type=reg /var/lib/machines/quux.raw.v/</programlisting>

    <para>This will enumerate all regular files matching
    <filename>/var/lib/machines/quux.raw.v/quux*.raw</filename>, filter and sort them according to the rules
    described in
    <citerefentry><refentrytitle>systemd.v</refentrytitle><manvolnum>7</manvolnum></citerefentry>, and then
    write the path to the newest (by version) file to standard output.</para>

    <para>Use a command like the following to automatically pick the newest OS directory tree from a
    <literal>.v/</literal> directory:</para>

    <programlisting>$ systemd-vpick --type=dir /var/lib/machines/waldo.v/</programlisting>

    <para>This will enumerate all directory inodes matching
    <filename>/var/lib/machines/waldo.v/waldo*</filename>, filter and sort them according to the rules
    described in
    <citerefentry><refentrytitle>systemd.v</refentrytitle><manvolnum>7</manvolnum></citerefentry>, and then
    write the path to the newest (by version) directory to standard output.</para>

    <para>For further examples see
    <citerefentry><refentrytitle>systemd.v</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
  </refsect1>

  <refsect1>
    <title>Exit status</title>

    <para>On success, 0 is returned, a non-zero failure code
    otherwise.</para>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para><simplelist type="inline">
      <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
      <member><citerefentry><refentrytitle>systemd.v</refentrytitle><manvolnum>7</manvolnum></citerefentry></member>
    </simplelist></para>
  </refsect1>
</refentry>