Changeset 4ee1c44


Ignore:
Timestamp:
01/12/2005 11:53:33 PM (17 years ago)
Author:
Randy McMurchy <randy@…>
Branches:
10.0, 10.1, 11.0, 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, nosym, perl-modules, qt5new, systemd-11177, systemd-13485, trunk, xry111/git-date, xry111/git-date-for-trunk, xry111/git-date-test
Children:
dd362e5
Parents:
68637f8c
Message:

Shortened line lengths in the compressdoc script

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

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • introduction/welcome/changelog.xml

    r68637f8c r4ee1c44  
    2727
    2828<listitem><para>January 12th, 2005 [randy]: Moved OpenSSL instructions from
    29 Chapter 8 to Chapter 4, suggested by Torsten Vollmann.</para></listitem>
     29Chapter 8 to Chapter 4, suggested by Torsten Vollmann; shortened line lengths
     30in the compressdoc script.</para></listitem>
    3031
    3132<listitem><para>January 11th, 2005 [randy]: Moved libgtkhtml, GNOME-Doc-Utils
  • postlfs/config/compressdoc.xml

    r68637f8c r4ee1c44  
    66]>
    77
    8 <sect1 id="postlfs-config-compressdoc" xreflabel="compressdoc">
     8<sect1 id="compressdoc" xreflabel="compressdoc">
    99<sect1info>
    1010<othername>$LastChangedBy$</othername>
     
    1313<?dbhtml filename="compressdoc.html"?>
    1414<title>Compressing man and info pages</title>
     15<indexterm zone="compressdoc">
     16<primary sortas="b-compressdoc">compressdoc</primary></indexterm>
    1517
    1618<para>Man and info reader programs can transparently process gzip'ed or
    1719bzip2'ed pages, a feature you can use to free some disk space while keeping
    1820your documentation available. However, things are not that simple; man
    19 directories tend to contain links&mdash;hard and symbolic&mdash;which defeat simple
    20 ideas like recursively calling <command>gzip</command> on them. A better way
    21 to go is to use the script below.
     21directories tend to contain links&mdash;hard and symbolic&mdash;which defeat
     22simple ideas like recursively calling <command>gzip</command> on them. A
     23better way to go is to use the script below.
    2224</para>
    2325
    2426<screen><userinput><command>cat &gt; /usr/sbin/compressdoc &lt;&lt; "EOF"</command>
    2527#!/bin/bash
    26 # VERSION: 20040320.0026
     28# VERSION: 20050112.0027
    2729#
    2830# Compress (with bzip2 or gzip) all man pages in a hierarchy and
    2931# update symlinks - By Marc Heerdink &lt;marc @ koelkast.net&gt;
     32#
    3033# Modified to be able to gzip or bzip2 files as an option and to deal
    3134# with all symlinks properly by Mark Hymers &lt;markh @ linuxfromscratch.org&gt;
     
    3639# compression level, to parse the man.conf for all occurrences of MANPATH,
    3740# to allow for a backup, to allow to keep the newest version of a page.
    38 # Modified 20040330 by Tushar Teredesai to replace $0 by the name of the script.
     41#
     42# Modified 20040330 by Tushar Teredesai to replace $0 by the name of the
     43# script.
    3944#   (Note: It is assumed that the script is in the user's PATH)
    4045#
     46# Modified 20050112 by Randy McMurchy to shorten line lengths and
     47# correct grammar errors.
     48#
    4149# TODO:
    42 #        - choose a default compress method to be based on the available
    43 #          tool : gzip or bzip2;
    44 #        - offer an option to automagically choose the best compression method
    45 #          on a per page basis (eg. check which ofgzip/bzip2/whatever is the
    46 #         most effective, page per page);
    47 #        - when a MANPATH env var exists, use this instead of /etc/man.conf
    48 #          (useful for users to (de)compress their man pages;
    49 #        - offer an option to restore a previous backup;
    50 #        - add other compression engines (compress, zip, etc?). Needed?
     50#     - choose a default compress method to be based on the available
     51#       tool : gzip or bzip2;
     52#     - offer an option to automagically choose the best compression
     53#       methed on a per page basis (eg. check which of
     54#       gzip/bzip2/whatever is the most effective, page per page);
     55#     - when a MANPATH env var exists, use this instead of /etc/man.conf
     56#       (useful for users to (de)compress their man pages;
     57#     - offer an option to restore a previous backup;
     58#     - add other compression engines (compress, zip, etc?). Needed?
    5159
    5260# Funny enough, this function prints some help.
     
    6674                Decompress the man pages.
    6775
    68   --backup      Specify a .tar backup shall be done for every directories.
    69                 In case a backup already exists, it is saved as .tar.old prior
    70                 to making the new backup. If an .tar.old backup exist, it is
    71                 removed prior to saving the backup.
     76  --backup      Specify a .tar backup shall be done for all directories.
     77                In case a backup already exists, it is saved as .tar.old
     78                prior to making the new backup. If a .tar.old backup
     79                exists, it is removed prior to saving the backup.
    7280                In backup mode, no other action is performed.
    7381
    7482And where options are :
    7583  -1 to -9, --fast, --best
    76                 The compression level, as accepted by gzip and bzip2. When not
    77                 specified, uses the default compression level for the given
    78                 method (-6 for gzip, and -9 for bzip2). Not used when in backup
    79                 or decompress modes.
    80 
    81   --force, -F   Force (re-)compression, even if the previous one was the same
    82                 method. Useful when changing the compression ratio. By default,
    83                 a page will not be re-compressed if it ends with the same suffix
    84                 as the method adds (.bz2 for bzip2, .gz for gzip).
    85 
    86   --soft, -S    Change hard-links into soft-links. Use with _caution_ as the
    87                 first encountered file will be used as a reference. Not used
    88                 when in backup mode.
    89 
    90   --hard, -H    Change soft-links into hard-links. Not used when in backup mode.
     84                The compression level, as accepted by gzip and bzip2.
     85                When not specified, uses the default compression level
     86                for the given method (-6 for gzip, and -9 for bzip2).
     87                Not used when in backup or decompress modes.
     88
     89  --force, -F   Force (re-)compression, even if the previous one was
     90                the same method. Useful when changing the compression
     91                ratio. By default, a page will not be re-compressed if
     92                it ends with the same suffix as the method adds
     93                (.bz2 for bzip2, .gz for gzip).
     94
     95  --soft, -S    Change hard-links into soft-links. Use with _caution_
     96                as the first encountered file will be used as a
     97                reference. Not used when in backup mode.
     98
     99  --hard, -H    Change soft-links into hard-links. Not used when in
     100                backup mode.
    91101
    92102  --conf=dir, --conf dir
    93103                Specify the location of man.conf. Defaults to /etc.
    94104
    95   --verbose, -v Verbose mode, print the name of the directory being processed.
    96                 Double the flag to turn it even more verbose, and to print the
    97                 name of the file being processed.
     105  --verbose, -v Verbose mode, print the name of the directory being
     106                processed. Double the flag to turn it even more verbose,
     107                and to print the name of the file being processed.
    98108
    99109  --fake, -f    Fakes it. Print the actual parameters compman will use.
    100110
    101   dirs          A list of space-separated _absolute_ pathname to the man
    102                 directories.
    103                 When empty, and only then, parse ${MAN_CONF}/man.conf for all
    104                 occurrences of MANPATH.
    105 
    106 Note about compression
     111  dirs          A list of space-separated _absolute_ pathnames to the
     112                man directories. When empty, and only then, parse
     113                ${MAN_CONF}/man.conf for all occurrences of MANPATH.
     114
     115Note about compression:
    107116  There has been a discussion on blfs-support about compression ratios of
    108117  both gzip and bzip2 on man pages, taking into account the hosting fs,
    109118  the architecture, etc... On the overall, the conclusion was that gzip
    110   was much efficient on 'small' files, and bzip2 on 'big' files, small and
    111   big being very dependent on the content of the files.
    112 
    113   See the original post from Mickael A. Peters, titled "Bootable Utility CD",
    114   and dated 20030409.1816(+0200), and subsequent posts:
     119  was much more efficient on 'small' files, and bzip2 on 'big' files,
     120  small and big being very dependent on the content of the files.
     121
     122  See the original post from Mickael A. Peters, titled
     123  "Bootable Utility CD", dated 20030409.1816(+0200), and subsequent posts:
    115124  http://linuxfromscratch.org/pipermail/blfs-support/2003-April/038817.html
    116125
    117   On my system (x86, ext3), man pages were 35564kiB before compression. gzip -9
    118   compressed them down to 20372kiB (57.28%), bzip2 -9 got down to 19812kiB
    119   (55.71%). That is a 1.57% gain in space. YMMV.
    120 
    121   What was not taken into consideration was the decompression speed. But does
    122   it make sense to? You gain fast access with uncompressed man pages, or you
    123   gain space at the expense of a slight overhead in time. Well, my P4-2.5GHz
    124   does not even let me notice this... :-)
     126  On my system (x86, ext3), man pages were 35564KB before compression.
     127  gzip -9 compressed them down to 20372KB (57.28%), bzip2 -9 got down to
     128  19812KB (55.71%). That is a 1.57% gain in space. YMMV.
     129
     130  What was not taken into consideration was the decompression speed. But
     131  does it make sense to? You gain fast access with uncompressed man
     132  pages, or you gain space at the expense of a slight overhead in time.
     133  Well, my P4-2.5GHz does not even let me notice this... :-)
     134
    125135EOT
    126136) | less
    127137}
    128138
    129 # This function checks that the man page is unique amongst bzip2'd, gzip'd and
    130 # uncompressed versions.
     139# This function checks that the man page is unique amongst bzip2'd,
     140# gzip'd and uncompressed versions.
    131141#  $1 the directory in which the file resides
    132142#  $2 the file name for the man page
    133 # Returns 0 (true) if the file is the latest and must be taken care of, and 1
    134 # (false) if the file is not the latest (and has therefore been deleted).
     143# Returns 0 (true) if the file is the latest and must be taken care of,
     144# and 1 (false) if the file is not the latest (and has therefore been
     145# deleted).
    135146function check_unique ()
    136147{
     
    148159
    149160  # Look for, and keep, the most recent one
    150   LATEST=`(cd "$DIR"; ls -1rt "${BASENAME}" "${GZ_FILE}" "${BZ_FILE}" 2&gt;/dev/null | tail -n 1)`
     161  LATEST=`(cd "$DIR"; ls -1rt "${BASENAME}" "${GZ_FILE}" "${BZ_FILE}" \
     162         2&gt;/dev/null | tail -n 1)`
    151163  for i in "${BASENAME}" "${GZ_FILE}" "${BZ_FILE}"; do
    152164    [ "$LATEST" != "$i" ] &amp;&amp; rm -f "$DIR"/"$i"
     
    162174MY_NAME=`basename $0`
    163175
    164 # OK, parse the command-line for arguments, and initialize to some sensible
    165 # state, that is : don't change links state, parse /etc/man.conf, be most
    166 # silent, search man.conf in /etc, and don't force (re-)compression.
     176# OK, parse the command-line for arguments, and initialize to some
     177# sensible state, that is: don't change links state, parse
     178# /etc/man.conf, be most silent, search man.conf in /etc, and don't
     179# force (re-)compression.
    167180COMP_METHOD=
    168181COMP_SUF=
     
    270283esac
    271284
    272 # Note: on my machine, 'man --path' gives /usr/share/man twice, once with a trailing '/', once without.
     285# Note: on my machine, 'man --path' gives /usr/share/man twice, once
     286# with a trailing '/', once without.
    273287if [ -z "$MAN_DIR" ]; then
    274288  MAN_DIR=`man --path -C "$MAN_CONF"/man.conf \
     
    302316  echo "man.conf is.......: ${MAN_CONF}/man.conf"
    303317  echo -n "Hard-links........: "
    304   [ "foo$LN_OPT" = "foo-S" ] &amp;&amp; echo "convert to soft-links" || echo "leave as is"
     318  [ "foo$LN_OPT" = "foo-S" ] &amp;&amp;
     319  echo "convert to soft-links" || echo "leave as is"
    305320  echo -n "Soft-links........: "
    306   [ "foo$LN_OPT" = "foo-H" ] &amp;&amp; echo "convert to hard-links" || echo "leave as is"
     321  [ "foo$LN_OPT" = "foo-H" ] &amp;&amp;
     322  echo "convert to hard-links" || echo "leave as is"
    307323  echo "Backup............: $BACKUP"
    308324  echo "Faking (yes!).....: $FAKE"
     
    325341    echo "Backing up $DIR..." &gt; $DEST_FD0
    326342    [ -f "${DIR_NAME}.tar.old" ] &amp;&amp; rm -f "${DIR_NAME}.tar.old"
    327     [ -f "${DIR_NAME}.tar" ] &amp;&amp; mv "${DIR_NAME}.tar" "${DIR_NAME}.tar.old"
     343    [ -f "${DIR_NAME}.tar" ] &amp;&amp;
     344    mv "${DIR_NAME}.tar" "${DIR_NAME}.tar.old"
    328345    tar cfv "${DIR_NAME}.tar" "${DIR_NAME}" &gt; $DEST_FD1
    329346  done
     
    341358
    342359    # Fixes the case when hard-links see their compression scheme change
    343     # (from not compressed to compressed, or from bz2 to gz, or from gz to bz2)
    344     # Also fixes the case when multiple version of the page are present, which
    345     # are either compressed or not.
     360    # (from not compressed to compressed, or from bz2 to gz, or from gz
     361    # to bz2)
     362    # Also fixes the case when multiple version of the page are present,
     363    # which are either compressed or not.
    346364    if [ ! -L "$FILE" -a ! -e "$FILE" ]; then continue; fi
    347365
     
    350368
    351369    if [ -d "$FILE" ]; then
    352       cd "${MEM_DIR}"  # Go back to where we ran "$0", in case "$0"=="./compressdoc" ...
     370      cd "${MEM_DIR}"  # Go back to where we ran "$0",
     371                       # in case "$0"=="./compressdoc" ...
    353372      # We are going recursive to that directory
    354373      echo "-&gt; Entering ${DIR}/${FILE}..." &gt; $DEST_FD0
    355374      # I need not pass --conf, as I specify the directory to work on
    356375      # But I need exit in case of error
    357       "$MY_NAME" ${COMP_METHOD} ${COMP_LVL} ${LN_OPT} ${VERBOSE_OPT} ${FORCE_OPT} "${DIR}/${FILE}" || exit 1
     376      "$MY_NAME" ${COMP_METHOD} ${COMP_LVL} ${LN_OPT} ${VERBOSE_OPT}
     377      ${FORCE_OPT} "${DIR}/${FILE}" || exit 1
    358378      echo "&lt;- Leaving ${DIR}/${FILE}." &gt; $DEST_FD1
    359379      cd "$DIR"  # Needed for the next iteration of the loop
     
    365385      BASE_FILE=`basename "$FILE" .gz`
    366386      BASE_FILE=`basename "$BASE_FILE" .bz2`
    367       if [ "${FILE}" = "${BASE_FILE}${COMP_SUF}" -a "foo${FORCE_OPT}" = "foo" ]; then continue; fi
     387      if [ "${FILE}" = "${BASE_FILE}${COMP_SUF}" \
     388         -a "foo${FORCE_OPT}" = "foo" ]; then continue; fi
    368389
    369390      # If we have a symlink
     
    379400
    380401        if [ ! "$EXT" = "none" ]; then
    381           LINK=`ls -l "$FILE" | cut -d "&gt;" -f2 | tr -d " " | sed s/\.$EXT$//`
     402          LINK=`ls -l "$FILE" | cut -d "&gt;" -f2 \
     403               | tr -d " " | sed s/\.$EXT$//`
    382404          NEWNAME=`echo "$FILE" | sed s/\.$EXT$//`
    383405          mv "$FILE" "$NEWNAME"
     
    401423        # Take care of hard-links: build the list of files hard-linked
    402424        # to the one we are {de,}compressing.
    403         # NB. This is not optimum has the file will eventually be compressed
    404         # as many times it has hard-links. But for now, that's the safe way.
     425        # NB. This is not optimum has the file will eventually be
     426        # compressed as many times it has hard-links. But for now,
     427        # that's the safe way.
    405428        inode=`ls -li "$FILE" | awk '{print $1}'`
    406429        HLINKS=`find . \! -name "$FILE" -inum $inode`
     
    451474              ln "${FILE}$COMP_SUF" "${NEWFILE}$COMP_SUF"
    452475            fi
    453             chmod 644 "${NEWFILE}$COMP_SUF" # Really work only for hard-links. Harmless for soft-links
     476            # Really work only for hard-links. Harmless for soft-links
     477            chmod 644 "${NEWFILE}$COMP_SUF"
    454478          done
    455479        fi
    456480
    457481      else
    458         # There is a problem when we get neither a symlink nor a plain file
    459         # Obviously, we shall never ever come here... :-(
    460         echo "Whaooo... \"${DIR}/${FILE}\" is neither a symlink nor a plain file. Please check:"
     482        # There is a problem when we get neither a symlink nor a plain
     483        # file. Obviously, we shall never ever come here... :-(
     484        echo -n "Whaooo... \"${DIR}/${FILE}\" is neither a symlink "
     485        echo "nor a plain file. Please check:"
    461486        ls -l "${DIR}/${FILE}"
    462487        exit 1
     
    465490  done # for FILE
    466491done # for DIR
     492
    467493<command>EOF
    468494chmod 755 /usr/sbin/compressdoc</command></userinput></screen>
     
    475501<para> Don't forget that a few programs, like the <application>X</application>
    476502Window System and <application>XEmacs</application> also install their
    477 documentation in non standard places (such as <filename class="directory">
    478 /usr/X11R6/man</filename>, etc...). Be sure to add these locations to the
    479 file <filename>/etc/man.conf</filename>, as a
    480 <envar>MANPATH</envar>=<replaceable>/path</replaceable> section.</para>
    481 <para> Example:</para><screen><userinput>
    482     ...
     503documentation in non standard places (such as
     504<filename class="directory">/usr/X11R6/man</filename>, etc...). Be sure to add
     505these locations to the file <filename>/etc/man.conf</filename>, as a
     506<envar>MANPATH</envar>=<replaceable>[/path]</replaceable> section.</para>
     507
     508<para> Example:</para>
     509
     510<screen><userinput>    ...
    483511    MANPATH=/usr/share/man
    484512    MANPATH=/usr/local/man
Note: See TracChangeset for help on using the changeset viewer.