Changeset b94cd51


Ignore:
Timestamp:
09/20/2003 08:03:47 PM (19 years ago)
Author:
Larry Lawrence <larry@…>
Branches:
10.0, 10.1, 11.0, 11.1, 6.0, 6.1, 6.2, 6.2.0, 6.2.0-rc1, 6.2.0-rc2, 6.3, 6.3-rc1, 6.3-rc2, 6.3-rc3, 7.10, 7.4, 7.5, 7.6, 7.6-blfs, 7.6-systemd, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, basic, bdubbs/svn, elogind, gnome, kde5-13430, kde5-14269, kde5-14686, krejzi/svn, lazarus, nosym, perl-modules, qt5new, systemd-11177, systemd-13485, trunk, upgradedb, v5_0, v5_0-pre1, v5_1, v5_1-pre1, xry111/intltool, xry111/test-20220226
Children:
efe6586
Parents:
61cc896
Message:

compressdoc patch

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@1134 af4574ff-66df-0310-9fd7-8a98e5e911e0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • postlfs/config/compressdoc.xml

    r61cc896 rb94cd51  
    1111</para>
    1212
    13 <screen><userinput><command>cat &gt; /usr/bin/comprdoc &lt;&lt; "EOF"</command>
     13<screen><userinput><command>cat &gt; /usr/bin/compressdoc &lt;&lt; "EOF"</command>
    1414
    1515#!/bin/sh
     
    1717function changefileext
    1818{
    19  # prints the given filename with the new extension instead of
    20  # the old one. ! - always prints an absolute filename even if
    21  # the caller provides a relative one.
    22  # parameters : 1 - file name
    23  # 2 - old extension
    24  # 3 - new extension (may be empty)
     19    # prints the given filename with the new extension instead of
     20    # the old one. ! - always prints an absolute filename even if
     21    # the caller provides a relative one.
     22    # parameters : 1 - file name
     23    # 2 - old extension
     24    # 3 - new extension (may be empty)
    2525
    26  echo `dirname $1`\/`basename $1 $2`$3
     26    echo `dirname $1`\/`basename $1 $2`$3
    2727}
    2828
     
    3131if [ ! -d $1 -o -z $1 ] || [ "$2" != "gz" -a "$2" != "bz2" ]
    3232then
    33  echo "Usage : $0 /path/to/doc/dir gz/bz2"
    34  echo "e.g. $0 /usr/info gz to compress info pages in gzip format"
    35  echo "or   $0 /usr/X11R6/man bz2 to compact X man pages using bzip2."
    36  exit 1
     33   echo "Usage : $0 /path/to/doc/dir gz/bz2"
     34   echo "e.g. $0 /usr/info gz to compress info pages in gzip format"
     35   echo "or   $0 /usr/X11R6/man bz2 to compact X man pages using bzip2."
     36   exit 1
    3737fi
    3838
    3939# set up a few variables.
    4040
    41 NEWEXT=.$2 # NEWEXT = extension of newly compressed files
     41NEWEXT=.$2            # NEWEXT = extension of newly compressed files
    4242
    4343if [ "$NEWEXT" == ".bz2" ]
    4444then
    45  OLDEXT=".gz" # OLDEXT = extensions of files to recompress
    46  DECOMPRESS="gunzip -f" # DECOMPRESS = command to decompress a file
    47  COMPRESS="bzip2 -f9" # COMPRESS = command to compress a file
     45   OLDEXT=".gz" # OLDEXT = extensions of files to recompress
     46   DECOMPRESS="gunzip -f" # DECOMPRESS = command to decompress a file
     47   COMPRESS="bzip2 -f9" # COMPRESS = command to compress a file
    4848else
    49  OLDEXT=".bz2"
    50  DECOMPRESS="bunzip2 -f"
    51  COMPRESS="gzip -f9"
     49   OLDEXT=".bz2"
     50   DECOMPRESS="bunzip2 -f"
     51   COMPRESS="gzip -f9"
    5252fi
    5353
     
    6060for f in `find  . \! -name "*$NEWEXT"`
    6161do
    62  # the following test is needed because we have to update links ahead of
    63  # ourselves, so $f is sometimes a nonexistent file or a link to one.
     62   # the following test is needed because we have to update links ahead of
     63   # ourselves, so $f is sometimes a nonexistent file or a link to one.
    6464
    65  if [ -f $f -o -L $f ]
    66  then
    67  FILE=$f # the file being processed
    68  BASEFILE=`basename $FILE` # its basename (see HLINKS)
    69  INODE=`find $FILE -printf %i` # its inode number (see HLINKS)
    70  NEWFILE=`changefileext $FILE $OLDEXT $NEWEXT` # new file name
     65   if [ -f $f -o -L $f ]
     66   then
     67       FILE=$f # the file being processed
     68       BASEFILE=`basename $FILE` # its basename (see HLINKS)
     69       INODE=`find $FILE -printf %i` # its inode number (see HLINKS)
     70       NEWFILE=`changefileext $FILE $OLDEXT $NEWEXT` # new file name
    7171
    72  # HLINKS is the list of all hard links to the current file.
     72       # HLINKS is the list of all hard links to the current file.
    7373
    74  HLINKS=`find . \! -name $BASEFILE -inum $INODE`
     74       HLINKS=`find . \! -name $BASEFILE -inum $INODE`
    7575
    76  if [ -L $FILE ]
    77  then
    78  # the current file is a symbolic link, so we change
    79  # its name and the name of its target.
     76       if [ -L $FILE ]
     77       then
     78           # the current file is a symbolic link, so we change
     79           # its name and the name of its target.
    8080
    81  TARGET=`readlink $FILE`
    82  rm -f $FILE
    83  ln -sf `changefileext $TARGET $OLDEXT $NEWEXT` $NEWFILE
    84  elif [ -f $FILE ]
    85  then
    86  # the current file is a regular file.
     81           TARGET=`readlink $FILE`
     82           rm -f $FILE
     83           ln -sf `changefileext $TARGET $OLDEXT $NEWEXT` $NEWFILE
     84       elif [ -f $FILE ]
     85       then
     86           # the current file is a regular file.
    8787
    88  TEMPFILE=`changefileext $FILE $OLDEXT`
     88           TEMPFILE=`changefileext $FILE $OLDEXT`
    8989
    9090# if there are several versions of a page (at worst, there can be
     
    9393# it most likely means the user installed several versions of a package.
    9494
    95  # first, if we are dealing with an old-compressed file,
    96  # expand it if it is more recent than the uncompressed
    97  # file *and* the new-compressed file, else delete it.
    98  # (works even if TEMPFILE and/or NEWFILE do not exist)
     95           # first, if we are dealing with an old-compressed file,
     96           # expand it if it is more recent than the uncompressed
     97           # file *and* the new-compressed file, else delete it.
     98           # (works even if TEMPFILE and/or NEWFILE do not exist)
    9999
    100  if [ "$FILE" != "$TEMPFILE" ]
    101  then
    102  if [ $FILE -nt $TEMPFILE -a \
    103       $FILE -nt $NEWFILE ]
    104  then
    105  $DECOMPRESS $FILE
    106  else
    107  rm -f $FILE
    108  fi
    109  FILE=$TEMPFILE
    110  fi
     100           if [ "$FILE" != "$TEMPFILE" ]
     101           then
     102               if [ $FILE -nt $TEMPFILE -a $FILE -nt $NEWFILE ]
     103               then
     104                   $DECOMPRESS $FILE
     105               else
     106                   rm -f $FILE
     107               fi
     108               FILE=$TEMPFILE
     109           fi
    111110
    112  # now we are dealing with an uncompressed file that may
    113  # exist or not (because of the above). If it is newer
    114  # than both the new-compressed and the old-compressed
    115  # files then it is compressed, else it is deleted.
     111           # now we are dealing with an uncompressed file that may
     112           # exist or not (because of the above). If it is newer
     113           # than both the new-compressed and the old-compressed
     114           # files then it is compressed, else it is deleted.
    116115
    117  if [ -f $FILE ]
    118  then
    119  if [ $FILE -nt $NEWFILE -a \
    120       $FILE -nt $FILE$OLDEXT ]
    121  then
    122  $COMPRESS $FILE
    123  else
    124  rm -f $FILE
    125  fi
    126  fi
    127  fi
     116           if [ -f $FILE ]
     117           then
     118               if [ $FILE -nt $NEWFILE -a $FILE -nt $FILE$OLDEXT ]
     119               then
     120                   $COMPRESS $FILE
     121               else
     122                   rm -f $FILE
     123               fi
     124           fi
     125       fi
    128126
    129  # update the hard links to the current files,
    130  # as the new inode number is now known.
     127       # update the hard links to the current files,
     128       # as the new inode number is now known.
    131129
    132  for g in $HLINKS
    133  do
    134  rm -f $g
    135  ln -f $NEWFILE `changefileext $g $OLDEXT $NEWEXT`
    136  done
    137  fi
     130       for g in $HLINKS
     131       do
     132           rm -f $g
     133           ln -f $NEWFILE `changefileext $g $OLDEXT $NEWEXT`
     134       done
     135   fi
    138136done
    139137
     
    142140
    143141<para>Now, as root, you can issue a
    144 <userinput><command>/usr/bin/comprdoc /usr/man bz2</command></userinput>
     142<userinput><command>/usr/bin/compressdoc /usr/man bz2</command></userinput>
    145143to compress your system man pages. Similarly, you can run it on the
    146144<filename class="directory">/usr/info</filename> directory. Don't forget
     
    150148nonstandard places.</para>
    151149
    152 <para>Generally, package installation systems do not compress the man/info
    153 pages, which means you will need to run the script again if you want to keep
    154 the size of your documentation as small as possible. Also, note that upgrading
    155 a package is safe: when you have several versions of a page (for example, a
    156 compressed and an uncompressed file), the script always keeps the most recent
    157 and deletes the others.</para>
     150<para>Generally, package installation systems do not compress man/info pages,
     151which means you will need to run the script again if you want to keep the size
     152of your documentation as small as possible. Also, note that running the script
     153after upgrading a package is safe: when you have several versions of a page
     154(for example, one compressed and one uncompressed), the most recent one is kept
     155and the others deleted.</para>
    158156
    159157</sect1>
Note: See TracChangeset for help on using the changeset viewer.