PATH=debian:$PATH:/usr/lib/debhelper
. dh_lib
-# Pass this a list of files, one per line, it will return the list, with
-# any files that need to be excluded removed.
-filelist_excluded () {
- IFS="
-"
- if [ "$DH_EXCLUDE_GREP" ]; then
- # Use grep -F so we don't have to worry about regexp's.
- echo -n "$*" | grep -v -F \
- "`echo "$DH_EXCLUDE_GREP" | tr "|" "\n"`"
- else
- echo -n "$*"
- fi
- unset IFS
-}
-
for PACKAGE in $DH_DOPACKAGES; do
TMP=`tmpdir $PACKAGE`
# General permissions fixing.
- if [ ! "$DH_EXCLUDE_GREP" ]; then
+ if [ ! "$DH_EXCLUDE_FIND" ]; then
# It's much faster to do it this way, but we can only do
# this if there is nothing to exclude.
if [ -d $TMP ]; then
doit "chmod -R go=rX $TMP"
doit "chmod -R u+rw $TMP"
fi
+
+ FIND_OPTIONS=
else
# Do it the hard way.
- files=`filelist_excluded \`find $TMP 2>/dev/null\` | tr "\n" " "`
- if [ "$files" ]; then
- doit "chown root.root $files"
- doit "chmod go=rX $files"
- doit "chmod u+rw $files"
- fi
+ complex_doit "find $TMP ! \( $DH_EXCLUDE_FIND \) -print0 \
+ 2>/dev/null | xargs -0r chown root.root"
+ complex_doit "find $TMP ! \($DH_EXCLUDE_FIND \) -print0 \
+ 2>/dev/null | xargs -0r chmod go=rX"
+ complex_doit "find $TMP ! \( $DH_EXCLUDE_FIND \) -print0 \
+ 2>/dev/null | xargs -0r chmod u+rw"
+
+ FIND_OPTIONS="! \( $DH_EXCLUDE_FIND \)"
fi
# Fix up premissions in usr/doc, setting everything to not exectable
# by default, but leave examples directories alone.
- files=`filelist_excluded \`find $TMP/usr/doc -type f 2>/dev/null | grep -v /examples/\` | tr "\n" " "`
- if [ "$files" ]; then
- doit "chmod 644 $files"
- fi
- files=`filelist_excluded \`find $TMP/usr/doc -type d 2>/dev/null\` | tr "\n" " "`
- if [ "$files" ]; then
- doit "chmod 755 $files"
- fi
+ complex_doit "find $TMP/usr/doc -type f $FIND_OPTIONS -print0 \
+ 2>/dev/null | xargs -0r chmod 644"
+ complex_doit "find $TMP/usr/doc -type d $FIND_OPTIONS -print0 \
+ 2>/dev/null | xargs -0r chmod 755"
# Executable man pages are a bad thing..
- files=`filelist_excluded \`find $TMP/usr/man/ $TMP/usr/X11*/man/ -type f 2>/dev/null\` | tr "\n" " "`
- if [ "$files" ]; then
- doit "chmod 644 $files"
- fi
+ complex_doit "find $TMP/usr/man/ $TMP/usr/X11*/man/ -type f \
+ $FIND_OPTIONS -print0 2>/dev/null | xargs -0r chmod 644"
# ..and so are executable shared libraries (and .la files from libtool)
- files=`filelist_excluded \`find $TMP -perm -5 -type f \( -name "*.so*" -or -name "*.la" \)\` | tr "\n" " "`
- if [ "$files" ]; then
- doit "chmod a-X $files"
- fi
+ complex_doit "find $TMP -perm -5 -type f \
+ \( -name "*.so*" -or -name "*.la" \) $FIND_OPTIONS -print0 \
+ 2>/dev/null | xargs -0r chmod a-X"
done
$exclude=join ' ', @exclude;
$exclude_grep=join '|', @exclude;
+foreach (@exclude) {
+ $exclude_find.="-regex .*".quotemeta($_).".* -or ";
+}
+$exclude_find=~s/ -or $//;
# Now output everything, in a format suitable for a shell to eval it.
# Note the last line sets $@ in the shell to whatever arguements remain.
DH_INCLUDE_CONFFILES='$include'
DH_EXCLUDE='$exclude'
DH_EXCLUDE_GREP='$exclude_grep'
+DH_EXCLUDE_FIND='$exclude_find'
DH_D_FLAG='$d_flag'
DH_R_FLAG='$r_flag'
DH_K_FLAG='$k_flag'