mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
An entry was run as its line was read, so the outcome followed the
order of the lines and of the files. With
f /var/run/app/file
L /var/run - - - - ../run
the f entry made /var/run a directory, and the link was never made.
An entry like z or w, placed before the one that makes its path, found
nothing to change.
tmpfiles.d(5) has a path created after the paths above it and removed
after those below it, and runs the entries that take a glob after the
others. Do the same. Every entry is now read before the first one is
run, which also means a line is parsed once, not once per pass, and
the pass that only gathered the x and X entries is gone.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
52 lines
1.4 KiB
Bash
Executable File
52 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
# Verify the order tmpfiles runs the entries in
|
|
set -eu
|
|
|
|
TEST_DIR=$(dirname "$0")
|
|
|
|
DIR=/tmp/order
|
|
CONF=/tmp/order.conf
|
|
|
|
test_teardown()
|
|
{
|
|
say "Running test teardown."
|
|
run "rm -rf $DIR $CONF"
|
|
}
|
|
|
|
# shellcheck source=/dev/null
|
|
. "$TEST_DIR/lib/setup.sh"
|
|
|
|
run "cat > $CONF" <<CONF
|
|
d $DIR
|
|
f $DIR/file - - - - new
|
|
r $DIR/file
|
|
CONF
|
|
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' ';')" = "clean d $DIR/sub, older than 1d;remove r $DIR/file;create f $DIR/dry text;create d $DIR/sub;"
|
|
assert "Nothing is done" "$(texec ls $DIR)" = "file"
|
|
|
|
sep
|
|
say 'A path is made after the one above it, wherever in the file they are'
|
|
run "cat > $CONF" <<CONF
|
|
w $DIR/real/file - - - - XY
|
|
d $DIR/real
|
|
f $DIR/link/file - - - - text
|
|
L $DIR/link - - - - real
|
|
CONF
|
|
run "/libexec/finit/tmpfiles --create $CONF"
|
|
assert "Link before the file below it" "$(texec readlink $DIR/link)" = "real"
|
|
say 'An entry that takes a glob, like w, is run after the others'
|
|
assert "File before it is written to" "$(texec cat $DIR/real/file)" = "XYxt"
|