From 4a4f8c46515864b781fbe4f9c0d6e0bb61626efb Mon Sep 17 00:00:00 2001 From: Erik Flodin Date: Tue, 10 Dec 2024 21:23:50 +0100 Subject: [PATCH] Alt and default template comparsions are case-insensitive Also mention that distro and distro family can be overridden. --- _docs/060_alternates.md | 17 ++++++++--------- _docs/070_templates.md | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/_docs/060_alternates.md b/_docs/060_alternates.md index 8eafd1a..3b07dd1 100644 --- a/_docs/060_alternates.md +++ b/_docs/060_alternates.md @@ -23,15 +23,16 @@ commas. Each condition is an attribute/value pair, separated by a period. Some conditions do not require a "value", and in that case, the period and value can -be omitted. Most attributes can be abbreviated as a single letter. +be omitted. Most attributes can be abbreviated as a single letter. Values are +compared case-insensitive. | Attribute | Meaning | | - | - | | `arch`, `a` | Valid if the value matches the architecture. Architecture is calculated by running uname ‑m. | | `class`, `c` | Valid if the value matches the local.class configuration. Class must be manually set using yadm config local.class <class>. | | `default` | Valid when no other alternate is valid. | -| `distro`, `d` | Valid if the value matches the distro. Distro is calculated by running lsb_release ‑si or inspecting /etc/os-release | -| `distro_family`, `f` | Valid if the value matches the distro family. Distro family is calculated by inspecting the `ID_LIKE` line from /etc/os-release | +| `distro`, `d` | Valid if the value matches the distro. Distro is calculated by running lsb_release ‑si or inspecting `ID` from /etc/os-release | +| `distro_family`, `f` | Valid if the value matches the distro family. Distro family is calculated by inspecting `ID_LIKE` from /etc/os-release (or `ID` if `ID_LIKE` isn't found) | | `extension`, `e` | A special "condition" that doesn't affect the selection process. Its purpose is instead to allow the alternate file to end with a certain extension to e.g. make editors highlight the content properly. | | `hostname`, `h` | Valid if the value matches the short hostname. Hostname is calculated by running uname ‑n, and trimming off any domain. | | `os`, `o` | Valid if the value matches the OS. OS is calculated by running uname ‑s. * | @@ -43,9 +44,6 @@ The OS for "Windows Subsystem for Linux" is reported as "WSL", even though uname
* The OS for Linux-like runtimes for Windows (e.g. MinGW, Cygwin) is obtained by running `uname -o`. -
-* -If `lsb_release` is not available, "distro" will be the ID specified in `/etc/os-release`. You may use any number of conditions, in any order. An alternate will only be @@ -117,9 +115,10 @@ yadm configuration—with the `yadm config` command. The following sets the yadm config local.class Work -Similarly, the values of `arch`, `os`, `hostname`, and `user` can be manually -overridden using the configuration options `local.arch`, `local.os`, -`local.hostname`, and `local.user`. +Similarly, the values of `arch`, `os`, `hostname`, `user`, `distro`, and +`distro_family` can be manually overridden using the configuration options +`local.arch`, `local.os`, `local.hostname`, `local.user`, `local.distro`, and +`local.distro-family`. Additional local classes can be defined using the `--add` switch. diff --git a/_docs/070_templates.md b/_docs/070_templates.md index 3c8d8c7..90a80cf 100644 --- a/_docs/070_templates.md +++ b/_docs/070_templates.md @@ -100,7 +100,7 @@ variable. Only equality can be tested. These blocks must start with block can also be specified using the directive `{% else %}`. These directives must appear on lines by themselves. They may not appear on the same line. The "if" directive only supports testing a single variable, and there is no "elif" -directive as there is in Jinja. +directive as there is in Jinja. Comparisions are done case-insensitive.

If multiple classes are defined, `yadm.class=="someclass"` will be true if *any* of the defined classes are "someclass".