mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
When a package is removed, the state its tmpfiles.d file made is left
behind, there was no way to ask for it to be removed.
systemd-tmpfiles has --purge for that, which removes what the entries
marked with a $ after the type make:
d$ /var/lib/app 0750 app app
tmpfiles --purge /usr/lib/tmpfiles.d/app.conf
Add the same. It only takes the entries of files on the command line,
never all of the tmpfiles.d files, and a path is removed before the
one above it. A $ was until now read and ignored.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
48 lines
1.4 KiB
Bash
Executable File
48 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
# Verify tmpfiles --purge, which removes what the entries marked with a
|
|
# $ make, for when a package is uninstalled
|
|
set -eu
|
|
|
|
TEST_DIR=$(dirname "$0")
|
|
|
|
DIR=/tmp/purge
|
|
CONF=/tmp/purge.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
|
|
d\$ $DIR/state
|
|
f\$ $DIR/state/file - - - - text
|
|
f\$ $DIR/file
|
|
L\$ $DIR/link - - - - file
|
|
e\$ $DIR/glob-*
|
|
d $DIR/kept
|
|
f $DIR/kept/file
|
|
r\$ $DIR/other
|
|
CONF
|
|
run "/libexec/finit/tmpfiles --create $CONF"
|
|
run "mkdir $DIR/glob-1 $DIR/glob-2 $DIR/state/more; touch $DIR/other"
|
|
|
|
say 'Only tells what it would do with --dry-run'
|
|
out=$(texec /libexec/finit/tmpfiles --dry-run --purge "$CONF")
|
|
assert "Entries with a \$, a path before the one above it" "$(echo "$out" | tr '\n' ';')" \
|
|
= "purge f\$ $DIR/state/file;purge d\$ $DIR/state;purge f\$ $DIR/file;purge L\$ $DIR/link;purge e\$ $DIR/glob-*;"
|
|
|
|
sep
|
|
say 'Removes what the entries with a $ make, and nothing else'
|
|
run "/libexec/finit/tmpfiles --purge $CONF"
|
|
assert "What is left" "$(texec ls $DIR | tr '\n' ' ')" = "kept other "
|
|
assert "And in it" "$(texec ls $DIR/kept)" = "file"
|
|
|
|
sep
|
|
say 'Needs a file, it is not for all of the tmpfiles.d files'
|
|
assert "Refused without one" "$(texec sh -c "/libexec/finit/tmpfiles --purge >/dev/null 2>&1; echo \$?")" = "1"
|