]> git.donarmstrong.com Git - debhelper.git/blob - dh_fixperms
r338: * Patch from Jorgen `forcer' Schaefer <forcer at mindless.com> (much
[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 root.root");
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
25         # Fix up premissions in usr/share/doc, setting everything to not
26         # executable by default, but leave examples directories alone.
27         complex_doit("find $TMP/usr/share/doc $TMP/usr/doc -type f $find_options ! -regex '.*/examples/.*' -print0",
28                 "2>/dev/null | xargs -0r chmod 644");
29         complex_doit("find $TMP/usr/share/doc $TMP/usr/doc -type d $find_options -print0",
30                 "2>/dev/null | xargs -0r chmod 755");
31
32         # Executable man pages are a bad thing..
33         complex_doit("find $TMP/usr/share/man $TMP/usr/man/ $TMP/usr/X11*/man/ -type f",
34                 "$find_options -print0 2>/dev/null | xargs -0r chmod 644");
35
36         # ..and so are executable shared and static libraries 
37         # (and .la files from libtool)
38         complex_doit("find $TMP -perm -5 -type f",
39                 "\\( -name '*.so*' -or -name '*.la' -or -name '*.a' \\) $find_options -print0",
40                 "2>/dev/null | xargs -0r chmod a-X");
41 }