Typo
[linux_from_scratch_hints.git] / OLD / man.txt
blob337fffa122b2b3e3f7cd3429ec8f3971838d38c9
1 TITLE:          The Man Hint
2 LFS VERSION:    any
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!
12 HINT:
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
19 the following script. 
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 ==========================================================================
26 #!/bin/sh
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>"
41   exit 1
44 for DIR in $1/man*; do
45   cd $DIR
47   for FILE in *; do
49     if [ -L "$FILE" ]; then
50         case $FILE in
51         *.bz2)
52             EXT=bz2 ;;
53         *.gz)
54             EXT=gz ;;
55         *)
56             EXT=none ;;
57         esac
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$//`
62             mv "$FILE" "$NEWNAME"
63             FILE="$NEWNAME"
64         else
65             LINK=`ls -l $FILE |cut -d ">" -f2 |tr -d " "`
66         fi
68         rm -f "$FILE" && ln -s "${LINK}.$2" "${FILE}.$2"
69         echo "Relinked $FILE"
71     elif [ -f "$FILE" ]; then
72         case $FILE in
73         *.bz2)
74             bunzip2 $FILE
75             FILE=`echo $FILE | sed s/\.bz2$//`
76         ;;
77         *.gz)
78             gunzip $FILE
79             FILE=`echo $FILE | sed s/\.gz$//`
80         ;;
81         esac
83         case $2 in
84         bz2)
85             bzip2 "$FILE" && chmod 644 "${FILE}.${2}";;
86         gz)
87             gzip "$FILE" && chmod 644 "${FILE}.${2}";;
88         esac
90         echo "Compressed $FILE"
92     fi
94   done # for FILE
95 done # for DIR
96 ==========================================================================
98 Don't forget to set the script to be executable and then run it using 
99 something like:
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
104 you want to use.
106 (2)      cat pages
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!