Changeset 62b2fb0 for postlfs/config


Ignore:
Timestamp:
04/21/2008 10:39:09 PM (16 years ago)
Author:
Dan Nichilson <dnicholson@…>
Branches:
10.0, 10.1, 11.0, 11.1, 11.2, 11.3, 12.0, 12.1, 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, xry111/intltool, xry111/llvm18, xry111/soup3, xry111/test-20220226, xry111/xf86-video-removal
Children:
47aad0c8
Parents:
48e6b2a
Message:

compressdoc: Automatic compression by file size from Lars Bamberger

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • postlfs/config/compressdoc.xml

    r48e6b2a r62b2fb0  
    3333<screen role="root"><?dbfo keep-together="auto"?><userinput>cat &gt; /usr/sbin/compressdoc &lt;&lt; "EOF"
    3434<literal>#!/bin/bash
    35 # VERSION: 20080421.1121
     35# VERSION: 20080421.1320
    3636#
    3737# Compress (with bzip2 or gzip) all man pages in a hierarchy and
     
    6666# that don't exist or don't have sufficient permissions.
    6767#
     68# Modified 20080421 by Lars Bamberger to (sort of) automatically choose
     69# a compression method based on the size of the manpage. A couple bug
     70# fixes were added by Dan Nicholson.
     71#
    6872# TODO:
    6973#     - choose a default compress method to be based on the available
    7074#       tool : gzip or bzip2;
    71 #     - offer an option to automagically choose the best compression
    72 #       methed on a per page basis (eg. check which of
    73 #       gzip/bzip2/whatever is the most effective, page per page);
    7475#     - when a MANPATH env var exists, use this instead of /etc/man_db.conf
    7576#       (useful for users to (de)compress their man pages;
     
    8990  --bzip2, --bz2, -b
    9091                Compress using gzip or bzip2.
     92  --automatic
     93                Compress using either gzip or bzip2, depending on the
     94                size of the file to be compressed. Files larger than 5
     95                kB are bzipped, files larger than 1 kB are gzipped and
     96                files smaller than 1 kB are not compressed.
    9197
    9298  --decompress, -d
     
    217223    --bzip2|--bz2|-b)
    218224      COMP_SUF=.bz2
     225      COMP_METHOD=$1
     226      shift
     227      ;;
     228    --automatic)
     229      COMP_SUF=TBD
    219230      COMP_METHOD=$1
    220231      shift
     
    333344  case $COMP_METHOD in
    334345    --bzip2|--bz2|-b) echo -n "bzip2";;
    335     --gzip|__gz|-g) echo -n "gzip";;
     346    --gzip|--gz|-g) echo -n "gzip";;
     347    --automatic) echo -n "compressing";;
    336348    --decompress|-d) echo -n "decompressing";;
    337349    *) echo -n "unknown";;
     
    416428      if ! check_unique "$DIR" "$FILE"; then continue; fi
    417429
     430      # With automatic compression, get the uncompressed file size of
     431      # the file (dereferencing symlinks), and choose an appropriate
     432      # compression method.
     433      if [ "$COMP_METHOD" = "--automatic" ]; then
     434        declare -i SIZE
     435        case "$FILE" in
     436          *.bz2)
     437            SIZE=$(bzcat "$FILE" | wc -c) ;;
     438          *.gz)
     439            SIZE=$(zcat "$FILE" | wc -c) ;;
     440          *)
     441            SIZE=$(wc -c &lt; "$FILE") ;;
     442        esac
     443        if (( $SIZE &gt;= (5 * 2**10) )); then
     444          COMP_SUF=.bz2
     445        elif (( $SIZE &gt;= (1 * 2**10) )); then
     446          COMP_SUF=.gz
     447        else
     448          COMP_SUF=
     449        fi
     450      fi
     451
    418452      # Check if the file is already compressed with the specified method
    419453      BASE_FILE=`basename "$FILE" .gz`
Note: See TracChangeset for help on using the changeset viewer.