1
0
Fork 0
mirror of synced 2024-12-21 14:11:08 -05:00

Ignore case for yadm.distro and .distro_family in default template

Same as b2b0b14 but for if statements in default template processor.
This commit is contained in:
Erik Flodin 2024-12-09 22:54:41 +01:00
parent b2b0b143d6
commit 18d5f66542
No known key found for this signature in database
GPG key ID: 420A7C865EE3F85F
3 changed files with 8 additions and 4 deletions

View file

@ -86,7 +86,7 @@ wrong user 2
{{% if yadm.distro == "wrongdistro1" %}}
wrong distro 1
{{% endif %}}
{{% if yadm.distro == "{LOCAL_DISTRO}" %}}
{{% if yadm.distro == "{LOCAL_DISTRO.upper()}" %}}
Included section for distro = {{{{yadm.distro}}}} ({{{{yadm.distro}}}} again)
{{% endif %}}
{{% if yadm.distro == "wrongdistro2" %}}
@ -95,7 +95,7 @@ wrong distro 2
{{% if yadm.distro_family == "wrongfamily1" %}}
wrong family 1
{{% endif %}}
{{% if yadm.distro_family == "{LOCAL_DISTRO_FAMILY}" %}}
{{% if yadm.distro_family == "{LOCAL_DISTRO_FAMILY.upper()}" %}}
Included section for distro_family = \
{{{{yadm.distro_family}}}} ({{{{yadm.distro_family}}}} again)
{{% endif %}}

4
yadm
View file

@ -363,6 +363,10 @@ BEGIN {
if (rhs == cls_array[idx]) { lhs = rhs; break }
}
}
else if (lhs == "yadm.distro" || lhs == "yadm.distro_family") {
lhs = tolower(replace_vars("{{" lhs "}}"))
rhs = tolower(rhs)
}
else {
lhs = replace_vars("{{" lhs "}}")
}

4
yadm.1
View file

@ -502,14 +502,14 @@ See the CONFIGURATION section for more details about setting
.BR local.class .
.TP
.BR distro , " d
Valid if the value matches the distro.
Valid if the value matches the distro (ignoring case).
Distro is calculated by running
.B "lsb_release -si"
or by inspecting the ID from
.BR "/etc/os-release" .
.TP
.BR distro_family , " f
Valid if the value matches the distro family.
Valid if the value matches the distro family (ignoring case).
Distro family is calculated by inspecting the ID_LIKE line from
.BR "/etc/os-release" .
.TP