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