tmpfiles: add --dry-run, to show what would be run

There was no way to see what the tmpfiles.d files on a system amount
to, short of running them:

    tmpfiles --dry-run --create --remove --boot

With -n or --dry-run each entry that would be run is printed, with
what would be done, remove, clean, or create, in the order it would
be.  Nothing is changed.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-20 19:10:04 +01:00
1 parent a27c0d40f3
commit ddb4f18fa9
5 files changed
+47 -5

No files matched your search

+11
View File
@@ -25,3 +25,14 @@ run "mkdir $DIR; echo old > $DIR/file"
run "/libexec/finit/tmpfiles --create --remove $CONF"
assert "The old file is removed, a new one created" "$(texec cat $DIR/file)" = "new"
sep
say 'With --dry-run it only tells what it would do, in that order'
run "cat > $CONF" <<CONF
f $DIR/dry - - - - text
r $DIR/file
d $DIR/sub - - - 1d
CONF
out=$(texec /libexec/finit/tmpfiles --dry-run --create --remove --clean "$CONF")
assert "What it would do" "$(echo "$out" | tr '\n' ';')" = "remove r $DIR/file;clean d $DIR/sub, older than 1d;create f $DIR/dry text;create d $DIR/sub;"
assert "Nothing is done" "$(texec ls $DIR)" = "file"