3 AUTHOR: Mark Hymers <markh@linuxfromscratch.org>
5 SYNOPSIS: Formating and Compression issues for man pages
7 Note: This hint was previously maintained by
8 Rudolf Floers <r.floers@web.de>
9 and then by Gerard Beekmans <gerard@linuxfromscratch.org>.
10 Thanks to both of them. Any bugs, however, are still my responsibility!
14 (1) Compression of man pages
16 If you want to save a little diskspace, you can safely bzip2 or gzip all
17 manpages. We used to recommend just using gzip /usr/share/man/*/* (or
18 the bzip2 equivalent) but that breaks symlinks. Instead, you can use
21 (a copy is available from
22 http://www.linuxfromscratch.org/~markh/scripts/compman
23 if you want to avoid cutting and pasting it!)
25 ==========================================================================
28 # Compress (with bzip2 or gzip) all man pages in a hierarchy and
29 # update symlinks - By Marc Heerdink <marc@koelkast.net>.
30 # Modified to be able to gzip or bzip2 files as an option and to deal
31 # with all symlinks properly by Mark Hymers <markh@linuxfromscratch.org>
33 # WARNING: This script still can't cope with hard-links (suggestions are
34 # welcome on how to deal with this)
35 # The only time this should be a problem is if you have a symlink to a
36 # hardlink; but then, you're sick if you do that anyways :-)
39 if [ ! -d "$1" -o -z "$1" ] || [ "$2" != "bz2" -a "$2" != "gz" ]; then
40 echo "Usage: $0 <dir> <bz2/gz>"
44 for DIR in $1/man*; do
49 if [ -L "$FILE" ]; then
59 if [ "$EXT" != "none" ]; then
60 LINK=`ls -l $FILE |cut -d ">" -f2 |tr -d " " | sed s/.$EXT$//`
61 NEWNAME=`echo "$FILE" | sed s/\.$EXT$//`
65 LINK=`ls -l $FILE |cut -d ">" -f2 |tr -d " "`
68 rm -f "$FILE" && ln -s "${LINK}.$2" "${FILE}.$2"
71 elif [ -f "$FILE" ]; then
75 FILE=`echo $FILE | sed s/\.bz2$//`
79 FILE=`echo $FILE | sed s/\.gz$//`
85 bzip2 "$FILE" && chmod 644 "${FILE}.${2}";;
87 gzip "$FILE" && chmod 644 "${FILE}.${2}";;
90 echo "Compressed $FILE"
96 ==========================================================================
98 Don't forget to set the script to be executable and then run it using
100 ./compman /usr/share/man bz2
102 The first option is the tree of man pages to compress.
103 The second options is bz2 or gz; it tells the script which compression
108 TO BE ADDED - There's a slight problem; I can't get it to work at the
109 moment. Hopefully this'll get fixed soon!