]> git.donarmstrong.com Git - debhelper.git/blob - dh_fixperms
r104: Initial Import
[debhelper.git] / dh_fixperms
1 #!/bin/sh -e
2 #
3 # Do some general file permission fixups.
4
5 PATH=debian:$PATH:/usr/lib/debhelper
6 . dh_lib
7
8 for PACKAGE in $DH_DOPACKAGES; do
9         TMP=`tmpdir $PACKAGE`
10
11         # General permissions fixing.
12         if [ ! "$DH_EXCLUDE_FIND" ]; then
13                 # It's much faster to do it this way, but we can only do
14                 # this if there is nothing to exclude.
15                 if [ -d $TMP ]; then
16                         doit "chown -R root.root $TMP"
17                         doit "chmod -R go=rX $TMP"
18                         doit "chmod -R u+rw $TMP"
19                 fi
20
21                 FIND_OPTIONS=
22         else
23                 # Do it the hard way.
24                 complex_doit "find $TMP ! \( $DH_EXCLUDE_FIND \) -print0 \
25                         2>/dev/null | xargs -0r chown root.root"
26                 complex_doit "find $TMP ! \($DH_EXCLUDE_FIND \) -print0 \
27                         2>/dev/null | xargs -0r chmod go=rX"
28                 complex_doit "find $TMP ! \( $DH_EXCLUDE_FIND \) -print0 \
29                         2>/dev/null | xargs -0r chmod u+rw"
30
31                 FIND_OPTIONS="! \( $DH_EXCLUDE_FIND \)"
32         fi
33
34         # Fix up premissions in usr/doc, setting everything to not exectable
35         # by default, but leave examples directories alone.
36         complex_doit "find $TMP/usr/doc -type f $FIND_OPTIONS -print0 \
37                 2>/dev/null | xargs -0r chmod 644"
38         complex_doit "find $TMP/usr/doc -type d $FIND_OPTIONS -print0 \
39                 2>/dev/null | xargs -0r chmod 755"
40
41         # Executable man pages are a bad thing..
42         complex_doit "find $TMP/usr/man/ $TMP/usr/X11*/man/ -type f \
43                 $FIND_OPTIONS -print0 2>/dev/null | xargs -0r chmod 644"
44
45         # ..and so are executable shared libraries (and .la files from libtool)
46         complex_doit "find $TMP -perm -5 -type f \
47                 \( -name "*.so*" -or -name "*.la" \) $FIND_OPTIONS -print0 \
48                 2>/dev/null | xargs -0r chmod a-X"
49 done