tmpfiles: add the specifiers for the OS release and architecture

An entry with %a, or one of the specifiers that come from os-release,
was skipped as unsupported:

    d /var/lib/app/%o-%w 0755 - - -

Add %o, %w, %W, %B, %M, and %A, read from /etc/os-release with
/usr/lib/os-release as fallback, and %a with the names tmpfiles.d(5)
has for the architectures.  A field that os-release lacks gives an
empty string, as in tmpfiles.d(5).  An entry is still skipped when
the architecture is not one of those known.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-20 18:35:36 +01:00
1 parent bccd04d81d
commit fb3b13a245
6 files changed
+113 -22

No files matched your search

+13 -1
View File
@@ -10,14 +10,23 @@ CONF=/tmp/specifier.conf
test_teardown()
{
say "Running test teardown."
run "rm -rf $DIR $CONF"
run "rm -rf $DIR $CONF /etc/os-release"
}
# shellcheck source=/dev/null
. "$TEST_DIR/lib/setup.sh"
run "cat > /etc/os-release" <<OS
NAME="Finit Test"
ID=finit-test
VERSION_ID="1.2"
OS
run "cat > $CONF" <<CONF
d $DIR
f $DIR/os-%o-%w
f $DIR/arch-%a
f $DIR/variant-%W
f $DIR/host-%H
f $DIR/kernel-%v
f $DIR/machine-%m
@@ -38,3 +47,6 @@ assert "Boot ID" "$(texec ls $DIR/boot-"$boot")" = "$D
assert "Percent" "$(texec ls $DIR/100%)" = "$DIR/100%"
assert "In the argument" "$(texec cat $DIR/arg)" = "/tmp /var/tmp /run /var/lib /var/cache /var/log /root root 0 root 0 ${host%%.*}"
assert "Skipped: a lone % and an unknown specifier" "$(texec sh -c "ls $DIR | grep -c -e end -e unknown")" = "0"
assert "OS ID and version" "$(texec ls $DIR/os-finit-test-1.2)" = "$DIR/os-finit-test-1.2"
assert "Architecture" "$(texec sh -c "ls $DIR | grep -c '^arch-.'")" = "1"
assert "Empty when not in os-release" "$(texec ls $DIR/variant-)" = "$DIR/variant-"