Ignore:
Timestamp:
10/03/2003 02:54:43 AM (21 years ago)
Author:
Larry Lawrence <larry@…>
Branches:
10.0, 10.1, 11.0, 11.1, 11.2, 11.3, 12.0, 12.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, kea, ken/TL2024, ken/inkscape-core-mods, ken/tuningfonts, krejzi/svn, lazarus, lxqt, nosym, perl-modules, plabs/newcss, plabs/python-mods, python3.11, qt5new, rahul/power-profiles-daemon, renodr/vulkan-addition, systemd-11177, systemd-13485, trunk, upgradedb, v5_0, v5_0-pre1, v5_1, v5_1-pre1, xry111/intltool, xry111/llvm18, xry111/soup3, xry111/test-20220226, xry111/xf86-video-removal
Children:
379f40a
Parents:
9491ec6b
Message:

applied compress patch

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • postlfs/config/compressdoc.xml

    r9491ec6b re6da9e5  
    4444  echo "Usage: $0 &lt;comp_method&gt; [options] [dirs]"
    4545  cat &lt;&lt; EOT
    46   Where comp_method is one of :
    47 
     46Where comp_method is one of :
    4847  --gzip, --gz, -g
    4948  --bzip2, --bz2, -b
     
    5958                In backup mode, no other action is performed.
    6059
    61   And where options are :
    62 
     60And where options are :
    6361  -1 to -9, --fast, --best
    6462                The compression level, as accepted by gzip and bzip2. When not
     
    6765                or decompress modes.
    6866
     67  --force, -F   Force (re-)compression, even if the previous one was the same
     68                method. Usefull when changing the compression ratio. By default,
     69                a page will not be re-compressed if it ends with the same suffix
     70                as the method adds (.bz2 for bzip2, .gz for gzip).
     71
    6972  -s            Change hard-links into soft-links. Use with _caution_ as the
    7073                first encountered file will be used as a reference. Not used
     
    7477                Specify the location of man.conf. Defaults to /etc.
    7578
    76   --quiet, -q   Quiet mode, only print the name of the directory being
    77                 processed. Add another -q flag to turn it absolutely silent.
     79  --verbose, -v Verbose mode, print the name of the directory being processed.
     80                Double the flag to turn it even more verbose, and to print the
     81                name of the file being processed.
    7882
    7983  --fake, -f    Fakes it. Print the actual parameters compman will use.
     
    9195  big being very dependent on the content of the files.
    9296
    93   See the original thread beginning at :
    94 http://archive.linuxfromscratch.org/mail-archives/blfs-support/2003/04/0424.html
     97  See the original post from Mickael A. Peters, titled "Bootable Utility CD",
     98  and dated 20030409.1816(+0200), and subsequent posts:
     99  http://linuxfromscratch.org/pipermail/blfs-support/2003-April/038817.html
    95100
    96101  On my system (x86, ext3), man pages were 35564kiB before compression. gzip -9
     
    105110}
    106111
    107 # This function checks that the path is absolute
    108 #  $1 : the path to check
    109 #  $2 : path to man.conf if $1 was extracted from it
    110 function check_path ()
    111 {
    112   echo checking path $1
    113   if [ -n "`echo $1 | cut -d '/' -f1`" ]; then
    114     echo "Path \"$1\" is not absolute."
    115     [ -n "$2" ] &amp;&amp; echo "Check your $2"
    116     exit 1
    117   fi
    118 }
    119 
    120112# This function checks that the man page is unique amongst bzip2'd, gzip'd and
    121 # the uncompressed versions.
     113# uncompressed versions.
    122114#  $1 the directory in which the file resides
    123115#  $2 the file name for the man page
     116# Returns 0 (true) if the file is the latest and must be taken care of, and 1
     117# (false) if the file is not the latest (and has therefore been deleted).
    124118function check_unique ()
    125119{
    126   # NB. When there are hardlink to this file, these are
    127   # _not_ deleted. In fact, if there are hardlinks, they
     120  # NB. When there are hard-links to this file, these are
     121  # _not_ deleted. In fact, if there are hard-links, they
    128122  # all have the same date/time, thus making them ready
    129123  # for deletion later on.
    130124
    131   # Build the list of all man page with the same name
     125  # Build the list of all man pages with the same name
     126  DIR=$1
    132127  BASENAME=`basename "${2}" .bz2`
    133128  BASENAME=`basename "${BASENAME}" .gz`
    134129  LIST=
    135   [ -f "$DIR"/"${BASENAME}" ] &amp;&amp; LIST="${LIST} ${BASENAME}"
    136   [ -f "$DIR"/"${BASENAME}".gz ] &amp;&amp; LIST="${LIST} ${BASENAME}.gz"
    137   [ -f "$DIR"/"${BASENAME}".bz2 ] &amp;&amp; LIST="${LIST} ${BASENAME}.bz2"
     130  [ -f "$DIR"/"${BASENAME}" -o -L "$DIR"/"${BASENAME}" ] &amp;&amp; LIST="${LIST} ${BASENAME}"
     131  [ -f "$DIR"/"${BASENAME}".gz -o -L "$DIR"/"${BASENAME}".gz ] &amp;&amp; LIST="${LIST} ${BASENAME}.gz"
     132  [ -f "$DIR"/"${BASENAME}".bz2 -o -L "$DIR"/"${BASENAME}".bz2 ] &amp;&amp; LIST="${LIST} ${BASENAME}.bz2"
    138133
    139134  # Look for, and keep, the most recent one
    140   LATEST=`(cd "$DIR"; ls -1rt $LIST)`
     135  LATEST=`(cd "$DIR"; ls -1rt $LIST | tail -1)`
    141136  for i in $LIST; do
    142     [ "$LATEST" != "$i" ] &amp;&amp; rm -f "$i"
     137    [ "$LATEST" != "$i" ] &amp;&amp; rm -f "$DIR"/"$i"
    143138  done
    144139
    145140  # In case the specified file was the latest, return 0
    146   [ "$LATEST" = "$1" ] &amp;&amp; return 0
     141  [ "$LATEST" = "$2" ] &amp;&amp; return 0
    147142  # If the file was not the latest, return 1
    148143  return 1
     
    150145
    151146# OK, parse the command line for arguments, and initialize to some sensible
    152 # state, that is keep hardlinks, parse /etc/man.conf, be most verbose, and
    153 # search man.conf in /etc
     147# state, that is keep hardlinks, parse /etc/man.conf, be most silent, search
     148# man.conf in /etc, and don't force (re-)compression.
    154149COMP_METHOD=
    155150COMP_SUF=
    156151COMP_LVL=
     152FORCE_COMP=no
    157153LN_OPT=
    158154MAN_DIR=
    159 QUIET_OPT=
    160 QUIET_LVL=0
     155VERBOSE_LVL=0
    161156BACKUP=no
    162157FAKE=no
     
    184179      shift
    185180      ;;
     181    --force|-F)
     182      FORCE_COMP=yes
     183      shift
     184      ;;
    186185    --soft|-s)
    187186      LN_OPT=-s
     
    196195      shift 2
    197196      ;;
    198     --quiet|-q)
    199       let QUIET_LVL++
    200       QUIET_OPT="$QUIET_OPT -q"
     197    --verbose|-v)
     198      let VERBOSE_LVL++
    201199      shift
    202200      ;;
     
    222220      ;;
    223221    *)
    224       check_path $1
    225       # We shall never return in that case! None the less, do exit
     222      echo "\"$1\" is not an absolute path name"
    226223      exit 1
    227224      ;;
     
    230227
    231228# Redirections
    232 case $QUIET_LVL in
     229case $VERBOSE_LVL in
    233230  0)
     231     # O, be silent
     232     DEST_FD0=/dev/null
     233     DEST_FD1=/dev/null
     234     VERBOSE_OPT=
     235     ;;
     236  1)
     237     # 1, be a bit verbose
     238     DEST_FD0=/dev/stdout
     239     DEST_FD1=/dev/null
     240     VERBOSE_OPT=-v
     241     ;;
     242  *)
     243     # 2 and above, be most verbose
    234244     DEST_FD0=/dev/stdout
    235245     DEST_FD1=/dev/stdout
    236      ;;
    237   1)
    238      DEST_FD0=/dev/stdout
    239      DEST_FD1=/dev/null
    240      ;;
    241   *)
    242      #2 and above, be silent
    243      DEST_FD0=/dev/null
    244      DEST_FD1=/dev/null
     246     VERBOSE_OPT="-v -v"
    245247     ;;
    246248esac
     
    257259# If no MANPATH in ${MAN_CONF}/man.conf, abort as well
    258260if [ -z "$MAN_DIR" ]; then
    259   echo "No directory specified, and no directory found in \"${MAN_CONF}/man.conf\""
     261  echo "No directory specified, and no directory found with \`man --path'"
    260262  exit 1
    261263fi
     
    274276  echo "Compression level.: $COMP_LVL"
    275277  echo "Compression suffix: $COMP_SUF"
     278  echo "Force compression.: $FORCE_COMP"
    276279  echo "man.conf is.......: ${MAN_CONF}/man.conf ($MAN_CONF)"
    277280  echo -n "Hard links........: "
     
    281284  echo "Faking (yes!).....: $FAKE"
    282285  echo "Directories.......: $MAN_DIR"
    283   echo "Silence level.....: $QUIET_LVL ($QUIET_OPT)"
     286  echo "Silence level.....: $VERBOSE_LVL ($VERBOSE_OPT)"
    284287  exit 0
    285288fi
     
    309312  cd "$DIR"
    310313  for FILE in *; do
     314    # Fixes the case were the directory is empty
    311315    if [ "foo$FILE" = "foo*" ]; then continue; fi
     316
     317    # Fixes the case when hard-links see their compression scheme change
     318    # (from not compressed to compressed, or from bz2 to gz, or from gz to bz2)
     319    # Also fixes the case when multiple version of the page are present, which
     320    # are either compressed or not.
     321    if [ ! -L "$FILE" -a ! -e "$FILE" ]; then continue; fi
     322
    312323    if [ -d "$FILE" ]; then
    313324      # We are going recursive to that directory
     
    315326      # I need not pass --conf, as I specify the directory to work on
    316327      # But I need exit in case of error
    317       "$0" ${COMP_METHOD} ${COMP_LVL} ${LN_OPT} ${QUIET_OPT} "${DIR}/${FILE}" || exit 1
     328      "$0" ${COMP_METHOD} ${COMP_LVL} ${LN_OPT} ${VERBOSE_OPT} "${DIR}/${FILE}" || exit 1
    318329      echo "&lt;- Leaving ${DIR}/${FILE}." &gt; $DEST_FD1
     330
    319331    else # !dir
    320       if check_unique "$DIR" "$FILE"; then continue; fi
     332      if ! check_unique "$DIR" "$FILE"; then continue; fi
     333
     334      # Check if the file is already compressed with the specified method
     335      BASE_FILE=`basename \`basename "$FILE" .bz2\` .gz`
     336      if [ "${FILE}" = "${BASE_FILE}${COMP_SUF}" -a "${FORCE_COMP}" = "no" ]; then continue; fi
    321337
    322338      # If we have a symlink
     
    331347        esac
    332348
    333         if [ "$EXT" != "none" ]; then
     349        if [ ! "$EXT" = "none" ]; then
    334350          LINK=`ls -l $FILE | cut -d "&gt;" -f2 | tr -d " " | sed s/\.$EXT$//`
    335351          NEWNAME=`echo "$FILE" | sed s/\.$EXT$//`
     
    363379          *.bz2)
    364380            bunzip2 $FILE
    365             FILE=`echo $FILE | sed s/\.bz2$//`
     381            FILE=`basename "$FILE" .bz2`
    366382          ;;
    367383          *.gz)
    368384            gunzip $FILE
    369             FILE=`echo $FILE | sed s/\.gz$//`
     385            FILE=`basename "$FILE" .gz`
    370386          ;;
    371387        esac
     
    405421  done # for FILE
    406422done # for DIR
    407 
    408423<command>EOF
    409424chmod 755 /usr/bin/compressdoc</command></userinput></screen>
     
    416431<para> Don't forget that a few programs, like the <application>X</application>
    417432Window system, <application>XEmacs</application>, also install their
    418 documentation in nonstandard places (such as <filename class="directory">
     433documentation in non standard places (such as <filename class="directory">
    419434/usr/X11R6/man</filename>, etc...). Don't forget to add those locations in the
    420435file <filename>/etc/man.conf</filename>, as a
Note: See TracChangeset for help on using the changeset viewer.