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