Changeset 4ee1c44 for postlfs/config/compressdoc.xml
- Timestamp:
- 01/12/2005 11:53:33 PM (19 years ago)
- 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, xry111/intltool, xry111/llvm18, xry111/soup3, xry111/test-20220226, xry111/xf86-video-removal
- Children:
- dd362e5
- Parents:
- 68637f8c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
postlfs/config/compressdoc.xml
r68637f8c r4ee1c44 6 6 ]> 7 7 8 <sect1 id=" postlfs-config-compressdoc" xreflabel="compressdoc">8 <sect1 id="compressdoc" xreflabel="compressdoc"> 9 9 <sect1info> 10 10 <othername>$LastChangedBy$</othername> … … 13 13 <?dbhtml filename="compressdoc.html"?> 14 14 <title>Compressing man and info pages</title> 15 <indexterm zone="compressdoc"> 16 <primary sortas="b-compressdoc">compressdoc</primary></indexterm> 15 17 16 18 <para>Man and info reader programs can transparently process gzip'ed or 17 19 bzip2'ed pages, a feature you can use to free some disk space while keeping 18 20 your documentation available. However, things are not that simple; man 19 directories tend to contain links—hard and symbolic—which defeat simple20 ideas like recursively calling <command>gzip</command> on them. A better way21 to go is to use the script below.21 directories tend to contain links—hard and symbolic—which defeat 22 simple ideas like recursively calling <command>gzip</command> on them. A 23 better way to go is to use the script below. 22 24 </para> 23 25 24 26 <screen><userinput><command>cat > /usr/sbin/compressdoc << "EOF"</command> 25 27 #!/bin/bash 26 # VERSION: 200 40320.002628 # VERSION: 20050112.0027 27 29 # 28 30 # Compress (with bzip2 or gzip) all man pages in a hierarchy and 29 31 # update symlinks - By Marc Heerdink <marc @ koelkast.net> 32 # 30 33 # Modified to be able to gzip or bzip2 files as an option and to deal 31 34 # with all symlinks properly by Mark Hymers <markh @ linuxfromscratch.org> … … 36 39 # compression level, to parse the man.conf for all occurrences of MANPATH, 37 40 # 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. 39 44 # (Note: It is assumed that the script is in the user's PATH) 40 45 # 46 # Modified 20050112 by Randy McMurchy to shorten line lengths and 47 # correct grammar errors. 48 # 41 49 # TODO: 42 # 43 # 44 # - offer an option to automagically choose the best compression method45 # on a per page basis (eg. check which ofgzip/bzip2/whatever is the46 # 47 # 48 # 49 # 50 # 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? 51 59 52 60 # Funny enough, this function prints some help. … … 66 74 Decompress the man pages. 67 75 68 --backup Specify a .tar backup shall be done for everydirectories.69 In case a backup already exists, it is saved as .tar.old prior70 to making the new backup. If an .tar.old backup exist, it is71 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. 72 80 In backup mode, no other action is performed. 73 81 74 82 And where options are : 75 83 -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. 91 101 92 102 --conf=dir, --conf dir 93 103 Specify the location of man.conf. Defaults to /etc. 94 104 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 the97 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. 98 108 99 109 --fake, -f Fakes it. Print the actual parameters compman will use. 100 110 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 115 Note about compression: 107 116 There has been a discussion on blfs-support about compression ratios of 108 117 both gzip and bzip2 on man pages, taking into account the hosting fs, 109 118 the architecture, etc... On the overall, the conclusion was that gzip 110 was much efficient on 'small' files, and bzip2 on 'big' files, small and111 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 anddated 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: 115 124 http://linuxfromscratch.org/pipermail/blfs-support/2003-April/038817.html 116 125 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 125 135 EOT 126 136 ) | less 127 137 } 128 138 129 # This function checks that the man page is unique amongst bzip2'd, gzip'd and130 # uncompressed versions.139 # This function checks that the man page is unique amongst bzip2'd, 140 # gzip'd and uncompressed versions. 131 141 # $1 the directory in which the file resides 132 142 # $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). 135 146 function check_unique () 136 147 { … … 148 159 149 160 # Look for, and keep, the most recent one 150 LATEST=`(cd "$DIR"; ls -1rt "${BASENAME}" "${GZ_FILE}" "${BZ_FILE}" 2>/dev/null | tail -n 1)` 161 LATEST=`(cd "$DIR"; ls -1rt "${BASENAME}" "${GZ_FILE}" "${BZ_FILE}" \ 162 2>/dev/null | tail -n 1)` 151 163 for i in "${BASENAME}" "${GZ_FILE}" "${BZ_FILE}"; do 152 164 [ "$LATEST" != "$i" ] && rm -f "$DIR"/"$i" … … 162 174 MY_NAME=`basename $0` 163 175 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. 167 180 COMP_METHOD= 168 181 COMP_SUF= … … 270 283 esac 271 284 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. 273 287 if [ -z "$MAN_DIR" ]; then 274 288 MAN_DIR=`man --path -C "$MAN_CONF"/man.conf \ … … 302 316 echo "man.conf is.......: ${MAN_CONF}/man.conf" 303 317 echo -n "Hard-links........: " 304 [ "foo$LN_OPT" = "foo-S" ] && echo "convert to soft-links" || echo "leave as is" 318 [ "foo$LN_OPT" = "foo-S" ] && 319 echo "convert to soft-links" || echo "leave as is" 305 320 echo -n "Soft-links........: " 306 [ "foo$LN_OPT" = "foo-H" ] && echo "convert to hard-links" || echo "leave as is" 321 [ "foo$LN_OPT" = "foo-H" ] && 322 echo "convert to hard-links" || echo "leave as is" 307 323 echo "Backup............: $BACKUP" 308 324 echo "Faking (yes!).....: $FAKE" … … 325 341 echo "Backing up $DIR..." > $DEST_FD0 326 342 [ -f "${DIR_NAME}.tar.old" ] && rm -f "${DIR_NAME}.tar.old" 327 [ -f "${DIR_NAME}.tar" ] && mv "${DIR_NAME}.tar" "${DIR_NAME}.tar.old" 343 [ -f "${DIR_NAME}.tar" ] && 344 mv "${DIR_NAME}.tar" "${DIR_NAME}.tar.old" 328 345 tar cfv "${DIR_NAME}.tar" "${DIR_NAME}" > $DEST_FD1 329 346 done … … 341 358 342 359 # 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. 346 364 if [ ! -L "$FILE" -a ! -e "$FILE" ]; then continue; fi 347 365 … … 350 368 351 369 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" ... 353 372 # We are going recursive to that directory 354 373 echo "-> Entering ${DIR}/${FILE}..." > $DEST_FD0 355 374 # I need not pass --conf, as I specify the directory to work on 356 375 # 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 358 378 echo "<- Leaving ${DIR}/${FILE}." > $DEST_FD1 359 379 cd "$DIR" # Needed for the next iteration of the loop … … 365 385 BASE_FILE=`basename "$FILE" .gz` 366 386 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 368 389 369 390 # If we have a symlink … … 379 400 380 401 if [ ! "$EXT" = "none" ]; then 381 LINK=`ls -l "$FILE" | cut -d ">" -f2 | tr -d " " | sed s/\.$EXT$//` 402 LINK=`ls -l "$FILE" | cut -d ">" -f2 \ 403 | tr -d " " | sed s/\.$EXT$//` 382 404 NEWNAME=`echo "$FILE" | sed s/\.$EXT$//` 383 405 mv "$FILE" "$NEWNAME" … … 401 423 # Take care of hard-links: build the list of files hard-linked 402 424 # 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. 405 428 inode=`ls -li "$FILE" | awk '{print $1}'` 406 429 HLINKS=`find . \! -name "$FILE" -inum $inode` … … 451 474 ln "${FILE}$COMP_SUF" "${NEWFILE}$COMP_SUF" 452 475 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" 454 478 done 455 479 fi 456 480 457 481 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:" 461 486 ls -l "${DIR}/${FILE}" 462 487 exit 1 … … 465 490 done # for FILE 466 491 done # for DIR 492 467 493 <command>EOF 468 494 chmod 755 /usr/sbin/compressdoc</command></userinput></screen> … … 475 501 <para> Don't forget that a few programs, like the <application>X</application> 476 502 Window 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 ... 503 documentation in non standard places (such as 504 <filename class="directory">/usr/X11R6/man</filename>, etc...). Be sure to add 505 these 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> ... 483 511 MANPATH=/usr/share/man 484 512 MANPATH=/usr/local/man
Note:
See TracChangeset
for help on using the changeset viewer.