tmpfiles.sh: add support for + modifier

systemd added support for b+, c+, p+, and L+ in 2e78fa79 and 1554afae to
remove the target path if it already exists.
This commit is contained in:
Andrew Gregory 2014-08-25 15:37:45 -04:00 committed by William Hubbs
parent 4f4f00d612
commit 6f3f50d453

View File

@ -304,6 +304,7 @@ for FILE in $tmpfiles_d ; do
# But IS allowed when globs are expanded for the x/r/R/z/Z types.
while read cmd path mode uid gid age arg; do
LINENUM=$(( LINENUM+1 ))
FORCE=0
# Unless we have both command and path, skip this line.
if [ -z "$cmd" -o -z "$path" ]; then
@ -311,13 +312,20 @@ for FILE in $tmpfiles_d ; do
fi
case $cmd in
*!) [ "$BOOT" -eq "1" ] || continue; cmd=${cmd%!} ;;
\#*) continue ;;
esac
while [ ${#cmd} -gt 1 ]; do
case $cmd in
*!) cmd=${cmd%!}; [ "$BOOT" -eq "1" ] || continue 2 ;;
*+) cmd=${cmd%+}; FORCE=1; ;;
*) warninvalid ; continue 2 ;;
esac
done
# whine about invalid entries
case $cmd in
f|F|w|d|D|p|L|c|b|x|X|r|R|z|Z) ;;
\#*) continue ;;
*) warninvalid ; continue ;;
esac
@ -338,6 +346,13 @@ for FILE in $tmpfiles_d ; do
[ -n "$EXCLUDE" ] && checkprefix $path $EXCLUDE && continue
[ -n "$PREFIX" ] && ! checkprefix $path $PREFIX && continue
if [ $FORCE -gt 0 ]; then
case $cmd in
p|L|c|b) [ -f "$path" ] && dryrun_or_real rm -f "$path"
esac
fi
[ "$VERBOSE" -eq "1" ] && echo _$cmd "$@"
_$cmd "$@"
rc=$?