condition: change ConditionKernelVersion= so that =/!= mean literal string comparison, and ==/<> version comparison

The only reason to do this is to ensure uniformity with the other
options, that work like this, i.e. ConditionOSRelease= or
ConditionSecurity=.

This is a compatibility break, but a minor one, given that string
comparison and version comparison is mostly the same for equality and
inequality.
This commit is contained in:
Lennart Poettering 2022-08-29 13:27:11 +02:00
parent 666d314a74
commit 06219747f5
2 changed files with 4 additions and 4 deletions

View file

@ -1334,9 +1334,9 @@
<listitem><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 list of (potentially quoted)
expressions. Each expression starts with one of <literal>&lt;</literal>, <literal>&lt;=</literal>,
<literal>=</literal> (or <literal>==</literal>), <literal>!=</literal> (or
<literal>&lt;&gt;</literal>), <literal>&gt;=</literal>, <literal>&gt;</literal> for a relative
expressions. Each expression starts with one of <literal>=</literal> or <literal>!=</literal> for
string comparisons, <literal>&lt;</literal>, <literal>&lt;=</literal>, <literal>==</literal>,
<literal>&lt;&gt;</literal>, <literal>&gt;=</literal>, <literal>&gt;</literal> for a relative
version comparison, or <literal>=$</literal>, <literal>!=$</literal> for a shell-style glob
match. If no operator is specified <literal>=$</literal> is implied.</para>

View file

@ -206,7 +206,7 @@ static int condition_test_kernel_version(Condition *c, char **env) {
break;
s = strstrip(word);
operator = parse_compare_operator(&s, COMPARE_ALLOW_FNMATCH);
operator = parse_compare_operator(&s, COMPARE_ALLOW_FNMATCH|COMPARE_EQUAL_BY_STRING);
if (operator < 0) /* No prefix? Then treat as glob string */
operator = COMPARE_FNMATCH_EQUAL;