]> git.donarmstrong.com Git - debhelper.git/blob - dh_fixperms
r392: * DH_COMPAT=3 now enables the following new features which I can't just
[debhelper.git] / dh_fixperms
1 #!/usr/bin/perl -w
2 #
3 # Do some general file permission fixups.
4
5 use Debian::Debhelper::Dh_Lib;
6 init();
7
8 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
9         $TMP=tmpdir($PACKAGE);
10
11         if (! defined($dh{EXCLUDE_FIND}) || $dh{EXCLUDE_FIND} eq '') {
12                 $find_options="";
13         }
14         else {
15                 $find_options="! \\( $dh{EXCLUDE_FIND} \\)";
16         }
17
18         # General permissions fixing.
19         complex_doit("find $TMP $find_options -print0",
20                 "2>/dev/null | xargs -0r chown --no-dereference 0.0");
21         complex_doit("find $TMP ! -type l $find_options -print0",
22                 "2>/dev/null | xargs -0r chmod go=rX,u+rw,a-s");
23                 
24         # Fix up premissions in usr/share/doc, setting everything to not
25         # executable by default, but leave examples directories alone.
26         complex_doit("find $TMP/usr/share/doc $TMP/usr/doc -type f $find_options ! -regex '.*/examples/.*' -print0",
27                 "2>/dev/null | xargs -0r chmod 644");
28         complex_doit("find $TMP/usr/share/doc $TMP/usr/doc -type d $find_options -print0",
29                 "2>/dev/null | xargs -0r chmod 755");
30
31         # Executable man pages are a bad thing..
32         complex_doit("find $TMP/usr/share/man $TMP/usr/man/ $TMP/usr/X11*/man/ -type f",
33                 "$find_options -print0 2>/dev/null | xargs -0r chmod 644");
34
35         # ..and so are executable shared and static libraries 
36         # (and .la files from libtool)
37         complex_doit("find $TMP -perm -5 -type f",
38                 "\\( -name '*.so*' -or -name '*.la' -or -name '*.a' \\) $find_options -print0",
39                 "2>/dev/null | xargs -0r chmod a-X");
40 }