tmpfiles: Implement L? to only create symlinks if source exists
This allows a single tmpfiles snippet with lines to symlink directories from /usr/share/factory to be shared across many different configurations while making sure symlinks only get created if the source actually exists.
This commit is contained in:
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
# shellcheck disable=SC2235
|
||||
set -eux
|
||||
|
||||
# Test L?
|
||||
|
||||
rm -rf /tmp/tmpfiles
|
||||
|
||||
root="/tmp/tmpfiles"
|
||||
mkdir "$root"
|
||||
touch "$root/abc"
|
||||
|
||||
SYSTEMD_LOG_LEVEL=debug systemd-tmpfiles --create - --root=$root <<EOF
|
||||
L? /i-dont-exist - - - - /def
|
||||
L? /i-do-exist - - - - /abc
|
||||
EOF
|
||||
|
||||
(! test -L "$root/i-dont-exist")
|
||||
test -L "$root/i-do-exist"
|
||||
Reference in New Issue
Block a user