match glibc in ConditionVersion

Extend ConditionVersion= to allow matching against glibc version,
as proposed in https://github.com/systemd/systemd/pull/36468#issuecomment-2674600909
This commit is contained in:
Matteo Croce
2025-03-21 06:57:28 +09:00
committed by Yu Watanabe
parent 966f872880
commit dcde1e903a
4 changed files with 43 additions and 4 deletions
+4
View File
@@ -4,6 +4,7 @@
#include <errno.h>
#include <fcntl.h>
#include <fnmatch.h>
#include <gnu/libc-version.h>
#include <limits.h>
#include <stdlib.h>
#include <sys/stat.h>
@@ -258,6 +259,9 @@ static int condition_test_version(Condition *c, char **env) {
if (streq(word, "systemd"))
return condition_test_version_cmp(p, STRINGIFY(PROJECT_VERSION));
if (streq(word, "glibc"))
return condition_test_version_cmp(p, gnu_get_libc_version());
/* if no predicate has been set, default to "kernel" and use the whole parameter as condition */
if (!streq(word, "kernel"))
p = c->parameter;