3 # Compresses files and makes sure that symlinks pointing to the
4 # compressed files get fixed.
6 PATH=debian:$PATH:/usr/lib/debhelper
9 # Returns a list of all the files that we want to compress,
10 # (ignoring any files we were asked to exclude on the command
11 # line). Assummes we are already in the temp directory.
13 if [ "$compress" ]; then
14 # The config file is a sh script that outputs the files to be compressed
15 # (typically using find).
16 sh $olddir/$compress 2>/dev/null
18 # By default fall back on what the policy manual says to compress.
19 find usr/info usr/man usr/X11*/man -type f ! -name "*.gz" 2>/dev/null || true
20 find usr/doc -type f \( -size +4k -or -name "changelog*" \) \
21 ! -name "*.htm*" ! -name "*.gif" ! -name "*.gz" \
22 ! -name "copyright" 2>/dev/null || true
26 # Returns a list of all the files we want to compress,
27 # after taking command line exclusions into account.
28 # Call only if DH_EXCLUDE_GREP is non-empty.
29 filelist_excluded () {
30 # Use grep -F so we don't have to worry about regexp's.
31 filelist | grep -v -F \
32 "`echo "$DH_EXCLUDE_GREP" | tr "|" "\n"`"
35 for PACKAGE in $DH_DOPACKAGES; do
37 compress=`pkgfile $PACKAGE compress`
39 # Run the file name gathering commands from within the directory
40 # structure that will be effected.
42 # Can't use doit here, that breaks --no-act mode.
43 verbose_echo "cd $TMP"
46 # Get the list of files to compress.
47 if [ "$DH_EXCLUDE_GREP" ]; then
48 files=`filelist_excluded`
54 # This is just a cosmetic fix.
55 files=`echo $files | tr "\n" " "`
57 doit "gzip -f9 $files" || true
60 # Change back to old pwd.
61 verbose_echo "cd $olddir"
64 # Fix up symlinks that were pointing to the uncompressed files.
65 for file in `find $TMP -type l`; do
66 DIRECTORY=`expr $file : "\(.*\)/[^/]*"`
67 NAME=`expr $file : ".*/\([^/]*\)"`
68 LINKVAL=`ls -l $DIRECTORY/$NAME | awk '{ print $11;}'`
69 if [ ! -e $DIRECTORY/$LINKVAL -a -f $DIRECTORY/$LINKVAL.gz ]; then
70 doit "rm $DIRECTORY/$NAME"
71 doit "ln -s $LINKVAL.gz $DIRECTORY/$NAME.gz"