condition: introduce ConditionVersion=/AssertVersion=
Add a new condition wich checks against systemd version.
Change condition_test_kernel_version() into a generic condition_test_version()
so most of the code can be reused.
$ systemctl --version
systemd 258 (258~devel-g53ca5f6)
$ systemd-analyze condition 'ConditionVersion=systemd>255'
test.service: ConditionVersion=>255 succeeded.
$ systemd-analyze condition 'ConditionVersion=systemd>260'
test.service: ConditionVersion=>260 failed.
$ systemd-analyze condition 'ConditionVersion=systemd>=258'
test.service: ConditionVersion=>=258 succeeded.
$ systemd-analyze condition 'ConditionVersion=systemd>=257.1'
test.service: ConditionVersion=>=257.1 succeeded.
$ uname -r
6.12.13-200.fc41.aarch64
$ systemd-analyze condition 'ConditionVersion=kernel > 4.4'
test.service: ConditionVersion=kernel > 4.4 succeeded.
$ systemd-analyze condition 'ConditionVersion=kernel > 6.20'
test.service: ConditionVersion=kernel > 6.20 failed.
$ systemd-analyze condition 'ConditionVersion=kernel < 9.0'
test.service: ConditionVersion=kernel < 9.0 succeeded.
This commit is contained in:
committed by
Yu Watanabe
parent
f91273f4fc
commit
c154bb65ad
@@ -1481,6 +1481,24 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>ConditionVersion=</varname></term>
|
||||
|
||||
<listitem><para><varname>ConditionVersion=</varname> may be used to check whether a software
|
||||
version matches a certain expression, or if prefixed with the exclamation mark, does not match.
|
||||
The first argument is the software whose version has to be checked. Currently
|
||||
<literal>kernel</literal> and <literal>systemd</literal> are supported. If this argument is
|
||||
omitted, <literal>kernel</literal> is implied. The second argument must be a list
|
||||
of (potentially quoted) expressions. Each expression starts with one of <literal>=</literal> or
|
||||
<literal>!=</literal> for string comparisons, <literal><</literal>, <literal><=</literal>,
|
||||
<literal>==</literal>, <literal><></literal>, <literal>>=</literal>,
|
||||
<literal>></literal> for version comparisons, or <literal>$=</literal>, <literal>!$=</literal>
|
||||
for a shell-style glob match. If no operator is specified, <literal>$=</literal> is implied.</para>
|
||||
|
||||
<xi:include href="version-info.xml" xpointer="v258"/>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>ConditionCredential=</varname></term>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user