summaryrefslogtreecommitdiff
path: root/dh_compress
diff options
context:
space:
mode:
authorjoey <joey>1999-08-17 04:12:54 +0000
committerjoey <joey>1999-08-17 04:12:54 +0000
commit938b66ee19e113785e6655b1c3e73e9003e6464c (patch)
treed06bd22faa3da8940bec71ba2e34e2028b6e7764 /dh_compress
downloaddebhelper-938b66ee19e113785e6655b1c3e73e9003e6464c.tar.gz
r1: Initial revision
Diffstat (limited to 'dh_compress')
-rwxr-xr-xdh_compress40
1 files changed, 40 insertions, 0 deletions
diff --git a/dh_compress b/dh_compress
new file mode 100755
index 00000000..e1f8ed64
--- /dev/null
+++ b/dh_compress
@@ -0,0 +1,40 @@
+#!/bin/sh -e
+#
+# Compresses files and makes sure that symlinks pointing to the
+# compressed files get fixed.
+
+PATH=debian:$PATH:/usr/lib/debhelper
+source dh_lib
+
+# The config file is a sh script that outputs the files to be compressed
+# (typically using find).
+if [ -f debian/compress ]; then
+ files=`sh debian/compress 2>/dev/null`
+else
+ # By default fall back on what the policy manual says to compress.
+ files=`
+ find debian/tmp/usr/info debian/tmp/usr/man \
+ debian/tmp/usr/X11*/man -type f 2>/dev/null ;
+ find debian/tmp/usr/doc -type f -size +4k \
+ ! -name "*.htm*" ! -name "*.gif" \
+ ! -name "debian/tmp/usr/doc/*/copyright" 2>/dev/null
+ `
+fi
+
+if [ "$files" ]; then
+ # This is just a cosmetic fix.
+ files=`echo $files | tr "\n" " "`
+
+ doit "gzip -9 $files" || true
+fi
+
+# Fix up symlinks that were pointing to the uncompressed files.
+for file in `find debian/tmp -type l`; do
+ DIRECTORY=`expr $file : "\(.*\)/[^/]*"`
+ NAME=`expr $file : ".*/\([^/]*\)"`
+ LINKVAL=`ls -l $DIRECTORY/$NAME | awk '{ print $11;}'`
+ if [ ! -e $DIRECTORY/$LINKVAL -a -f $DIRECTORY/$LINKVAL.gz ]; then
+ doit "rm $DIRECTORY/$NAME"
+ doit "ln -s $LINKVAL.gz $DIRECTORY/$NAME.gz"
+ fi
+done