condition: for completenes sake at != comparator for ConditionKernelVersion=

This commit is contained in:
Lennart Poettering 2019-03-18 17:43:29 +01:00
parent 78d7652549
commit 2877d42870
2 changed files with 11 additions and 5 deletions

View File

@ -1117,11 +1117,12 @@
the exact assignment is looked for with right and left hand
side matching.</para>
<para><varname>ConditionKernelVersion=</varname> may be used to check whether the kernel version (as reported
by <command>uname -r</command>) matches a certain expression (or if prefixed with the exclamation mark does not
match it). The argument must be a single string. If the string starts with one of <literal>&lt;</literal>,
<literal>&lt;=</literal>, <literal>=</literal>, <literal>&gt;=</literal>, <literal>&gt;</literal> a relative
version comparison is done, otherwise the specified string is matched with shell-style globs.</para>
<para><varname>ConditionKernelVersion=</varname> may be used to check whether the kernel version (as
reported by <command>uname -r</command>) matches a certain expression (or if prefixed with the
exclamation mark does not match it). The argument must be a single string. If the string starts with
one of <literal>&lt;</literal>, <literal>&lt;=</literal>, <literal>=</literal>,
<literal>!=</literal>, <literal>&gt;=</literal>, <literal>&gt;</literal> a relative version
comparison is done, otherwise the specified string is matched with shell-style globs.</para>
<para>Note that using the kernel version string is an unreliable way to determine which features are supported
by a kernel, because of the widespread practice of backporting drivers, features, and fixes from newer upstream

View File

@ -138,6 +138,7 @@ typedef enum {
ORDER_LOWER,
ORDER_GREATER,
ORDER_EQUAL,
ORDER_UNEQUAL,
_ORDER_MAX,
_ORDER_INVALID = -1
} OrderOperator;
@ -150,6 +151,7 @@ static OrderOperator parse_order(const char **s) {
[ORDER_LOWER] = "<",
[ORDER_GREATER] = ">",
[ORDER_EQUAL] = "=",
[ORDER_UNEQUAL] = "!=",
};
OrderOperator i;
@ -180,6 +182,9 @@ static bool test_order(int k, OrderOperator p) {
case ORDER_EQUAL:
return k == 0;
case ORDER_UNEQUAL:
return k != 0;
case ORDER_GREATER_OR_EQUAL:
return k >= 0;