aboutsummaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2013-07-25 00:58:38 -0500
committerWilliam Hubbs <w.d.hubbs@gmail.com>2013-07-25 00:58:38 -0500
commite9189cd8a24b5614f3e82aec4a779e4d90656b1e (patch)
tree0a2c70fe8787524d66111d457b92cf9e5c4106c4 /sh
parent19579687fd6d4fb80ffbd83c010fab6777c3120c (diff)
tmpfiles: add --prefix and --exclude-prefix options
Diffstat (limited to 'sh')
-rwxr-xr-xsh/tmpfiles.sh.in19
1 files changed, 18 insertions, 1 deletions
diff --git a/sh/tmpfiles.sh.in b/sh/tmpfiles.sh.in
index 59fdcd76..22d5f1f5 100755
--- a/sh/tmpfiles.sh.in
+++ b/sh/tmpfiles.sh.in
@@ -15,6 +15,17 @@
DRYRUN=0
+checkprefix() {
+ n=$1
+ shift
+ for x in $@; do
+ case $n in
+ ${x}*) return 0 ;;
+ esac
+ done
+ return 1
+}
+
warninvalid() {
printf "tmpfiles: ignoring invalid entry on line %d of \`%s'\n" "$LINENUM" "$FILE"
error=$(( error+1 ))
@@ -202,6 +213,8 @@ _Z() {
}
CREATE=0 REMOVE=0 CLEAN=0 VERBOSE=0 DRYRUN=0 error=0 LINENO=0
+EXCLUDE=
+PREFIX=
FILE=
fragments=
# XXX: The harcoding of /usr/lib/ is an explicit choice by upstream
@@ -237,6 +250,8 @@ while [ $# -gt 0 ]; do
--clean) CLEAN=1 ;; # TODO: Not implemented
--verbose) VERBOSE=1 ;;
--dryrun|--dry-run) DRYRUN=1 ;;
+ --exclude-prefix=*) EXCLUDE="${EXCLUDE}${1##--exclude-prefix=} " ;;
+ --prefix=*) PREFIX="${PREFIX}${1##--prefix=} " ;;
esac
shift
done
@@ -247,7 +262,7 @@ if [ $(( CLEAN )) -eq 1 ] ; then
fi
if [ "$CREATE$REMOVE" = '00' ]; then
- printf 'usage: %s [--create] [--remove] [--clean] [--verbose] [--dry-run]\n' "${0##*/}"
+ printf 'usage: %s [--exclude-prefix=path] [--prefix=path] [--create] [--remove] [--clean] [--verbose] [--dry-run]\n' "${0##*/}"
exit 1
fi
@@ -297,6 +312,8 @@ for FILE in $tmpfiles_d ; do
[ "$arg" = '-' -o "$arg" = '' ] && arg=''
set -- "$path" "$mode" "$uid" "$gid" "$age" "$arg"
+ [ -n "$EXCLUDE" ] && checkprefix $path $EXCLUDE && continue
+ [ -n "$PREFIX" ] && ! checkprefix $path $PREFIX && continue
[ "$VERBOSE" -eq "1" ] && echo _$cmd "$@"
_$cmd "$@"
rc=$?