]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tmpfiles: use common macro for a set of specifiers
authorMatthias Lisin <6209465+ml-@users.noreply.github.com>
Wed, 26 Jun 2024 02:12:42 +0000 (04:12 +0200)
committerMatthias Lisin <6209465+ml-@users.noreply.github.com>
Wed, 26 Jun 2024 02:18:14 +0000 (04:18 +0200)
This adds %q, %A and %M specifiers to tmpfiles:
- %A and %M were previously added to tmpfiles.d man page, but not to specifier_table
- %q is added via COMMON_SYSTEM_SPECIFIERS

man/tmpfiles.d.xml
src/tmpfiles/tmpfiles.c
test/units/TEST-22-TMPFILES.20.sh [new file with mode: 0755]

index c89706862f9ccc9703bcd27a2dc9204cd1657423..2b260da68be58b1fcf34a935985c704d01247c95 100644 (file)
@@ -764,6 +764,7 @@ d /tmp/foo/bar - - - bmA:1h -</programlisting></para>
             <xi:include href="standard-specifiers.xml" xpointer="m"/>
             <xi:include href="standard-specifiers.xml" xpointer="M"/>
             <xi:include href="standard-specifiers.xml" xpointer="o"/>
+            <xi:include href="standard-specifiers.xml" xpointer="q"/>
             <row>
               <entry><literal>%S</literal></entry>
               <entry>System or user state directory</entry>
index 5841db293e768ae53942b61719fbfc3ddc624a8a..59b48492ab74dafe7f795373fe2f3c1cfdf8ae7f 100644 (file)
@@ -3610,17 +3610,6 @@ static int parse_line(
         assert(buffer);
 
         const Specifier specifier_table[] = {
-                { 'a', specifier_architecture,    NULL },
-                { 'b', specifier_boot_id,         NULL },
-                { 'B', specifier_os_build_id,     NULL },
-                { 'H', specifier_hostname,        NULL },
-                { 'l', specifier_short_hostname,  NULL },
-                { 'm', specifier_machine_id,      NULL },
-                { 'o', specifier_os_id,           NULL },
-                { 'v', specifier_kernel_release,  NULL },
-                { 'w', specifier_os_version_id,   NULL },
-                { 'W', specifier_os_variant_id,   NULL },
-
                 { 'h', specifier_user_home,       NULL },
 
                 { 'C', specifier_directory,       UINT_TO_PTR(DIRECTORY_CACHE)   },
@@ -3628,6 +3617,7 @@ static int parse_line(
                 { 'S', specifier_directory,       UINT_TO_PTR(DIRECTORY_STATE)   },
                 { 't', specifier_directory,       UINT_TO_PTR(DIRECTORY_RUNTIME) },
 
+                COMMON_SYSTEM_SPECIFIERS,
                 COMMON_CREDS_SPECIFIERS(arg_runtime_scope),
                 COMMON_TMP_SPECIFIERS,
                 {}
diff --git a/test/units/TEST-22-TMPFILES.20.sh b/test/units/TEST-22-TMPFILES.20.sh
new file mode 100755 (executable)
index 0000000..65d2b33
--- /dev/null
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Test specifiers
+set -eux
+
+rm -rf /tmp/specifiers
+
+root='/tmp/specifiers/root'
+mkdir -p $root/etc
+cat >$root/etc/os-release <<EOF
+ID=the-id
+BUILD_ID=build-id
+VARIANT_ID=variant-id
+VERSION_ID=version-id
+IMAGE_ID=image-id
+IMAGE_VERSION=22
+EOF
+
+systemd-tmpfiles --create - --root=$root <<EOF
+f  /os-release2 - - - - ID=%o\n
+w+ /os-release2 - - - - BUILD_ID=%B\n
+w+ /os-release2 - - - - VARIANT_ID=%W\n
+w+ /os-release2 - - - - VERSION_ID=%w\n
+w+ /os-release2 - - - - IMAGE_ID=%M\n
+w+ /os-release2 - - - - IMAGE_VERSION=%A\n
+EOF
+
+diff $root/etc/os-release $root/os-release2