]> git.donarmstrong.com Git - debhelper.git/blob - dh_compress
r1: Initial revision
[debhelper.git] / dh_compress
1 #!/bin/sh -e
2 #
3 # Compresses files and makes sure that symlinks pointing to the 
4 # compressed files get fixed.
5
6 PATH=debian:$PATH:/usr/lib/debhelper
7 source dh_lib
8
9 # The config file is a sh script that outputs the files to be compressed
10 # (typically using find).
11 if [ -f debian/compress ]; then
12         files=`sh debian/compress 2>/dev/null`
13 else
14         # By default fall back on what the policy manual says to compress.
15         files=`
16                 find debian/tmp/usr/info debian/tmp/usr/man \
17                         debian/tmp/usr/X11*/man -type f 2>/dev/null ;
18                 find debian/tmp/usr/doc -type f -size +4k \
19                         ! -name "*.htm*" ! -name "*.gif" \
20                         ! -name "debian/tmp/usr/doc/*/copyright" 2>/dev/null
21         `
22 fi
23
24 if [ "$files" ]; then
25         # This is just a cosmetic fix.
26         files=`echo $files | tr "\n" " "`       
27
28         doit "gzip -9 $files" || true
29 fi
30
31 # Fix up symlinks that were pointing to the uncompressed files.
32 for file in `find debian/tmp -type l`; do
33         DIRECTORY=`expr $file : "\(.*\)/[^/]*"`
34         NAME=`expr $file : ".*/\([^/]*\)"`
35         LINKVAL=`ls -l $DIRECTORY/$NAME | awk '{ print $11;}'`
36         if [ ! -e $DIRECTORY/$LINKVAL -a -f $DIRECTORY/$LINKVAL.gz ]; then
37                 doit "rm $DIRECTORY/$NAME"
38                 doit "ln -s $LINKVAL.gz $DIRECTORY/$NAME.gz"
39         fi
40 done