Changeset e6da9e5
- Timestamp:
- 10/03/2003 02:54:43 AM (20 years ago)
- Branches:
- 10.0, 10.1, 11.0, 11.1, 11.2, 11.3, 12.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, kea, ken/inkscape-core-mods, ken/tuningfonts, krejzi/svn, lazarus, lxqt, nosym, perl-modules, plabs/python-mods, qt5new, renodr/vulkan-addition, systemd-11177, systemd-13485, trunk, upgradedb, v5_0, v5_0-pre1, v5_1, v5_1-pre1, xry111/intltool, xry111/soup3, xry111/test-20220226, xry111/xf86-video-removal
- Children:
- 379f40a
- Parents:
- 9491ec6b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
postlfs/config/compressdoc.xml
r9491ec6b re6da9e5 44 44 echo "Usage: $0 <comp_method> [options] [dirs]" 45 45 cat << EOT 46 Where comp_method is one of : 47 46 Where comp_method is one of : 48 47 --gzip, --gz, -g 49 48 --bzip2, --bz2, -b … … 59 58 In backup mode, no other action is performed. 60 59 61 And where options are : 62 60 And where options are : 63 61 -1 to -9, --fast, --best 64 62 The compression level, as accepted by gzip and bzip2. When not … … 67 65 or decompress modes. 68 66 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 69 72 -s Change hard-links into soft-links. Use with _caution_ as the 70 73 first encountered file will be used as a reference. Not used … … 74 77 Specify the location of man.conf. Defaults to /etc. 75 78 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. 78 82 79 83 --fake, -f Fakes it. Print the actual parameters compman will use. … … 91 95 big being very dependent on the content of the files. 92 96 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 95 100 96 101 On my system (x86, ext3), man pages were 35564kiB before compression. gzip -9 … … 105 110 } 106 111 107 # This function checks that the path is absolute108 # $1 : the path to check109 # $2 : path to man.conf if $1 was extracted from it110 function check_path ()111 {112 echo checking path $1113 if [ -n "`echo $1 | cut -d '/' -f1`" ]; then114 echo "Path \"$1\" is not absolute."115 [ -n "$2" ] && echo "Check your $2"116 exit 1117 fi118 }119 120 112 # This function checks that the man page is unique amongst bzip2'd, gzip'd and 121 # theuncompressed versions.113 # uncompressed versions. 122 114 # $1 the directory in which the file resides 123 115 # $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). 124 118 function check_unique () 125 119 { 126 # NB. When there are hard linkto this file, these are127 # _not_ deleted. In fact, if there are hard links, they120 # NB. When there are hard-links to this file, these are 121 # _not_ deleted. In fact, if there are hard-links, they 128 122 # all have the same date/time, thus making them ready 129 123 # for deletion later on. 130 124 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 132 127 BASENAME=`basename "${2}" .bz2` 133 128 BASENAME=`basename "${BASENAME}" .gz` 134 129 LIST= 135 [ -f "$DIR"/"${BASENAME}" ] && LIST="${LIST} ${BASENAME}"136 [ -f "$DIR"/"${BASENAME}".gz ] && LIST="${LIST} ${BASENAME}.gz"137 [ -f "$DIR"/"${BASENAME}".bz2 ] && LIST="${LIST} ${BASENAME}.bz2"130 [ -f "$DIR"/"${BASENAME}" -o -L "$DIR"/"${BASENAME}" ] && LIST="${LIST} ${BASENAME}" 131 [ -f "$DIR"/"${BASENAME}".gz -o -L "$DIR"/"${BASENAME}".gz ] && LIST="${LIST} ${BASENAME}.gz" 132 [ -f "$DIR"/"${BASENAME}".bz2 -o -L "$DIR"/"${BASENAME}".bz2 ] && LIST="${LIST} ${BASENAME}.bz2" 138 133 139 134 # Look for, and keep, the most recent one 140 LATEST=`(cd "$DIR"; ls -1rt $LIST )`135 LATEST=`(cd "$DIR"; ls -1rt $LIST | tail -1)` 141 136 for i in $LIST; do 142 [ "$LATEST" != "$i" ] && rm -f "$ i"137 [ "$LATEST" != "$i" ] && rm -f "$DIR"/"$i" 143 138 done 144 139 145 140 # In case the specified file was the latest, return 0 146 [ "$LATEST" = "$ 1" ] && return 0141 [ "$LATEST" = "$2" ] && return 0 147 142 # If the file was not the latest, return 1 148 143 return 1 … … 150 145 151 146 # 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, and153 # search man.conf in /etc147 # state, that is keep hardlinks, parse /etc/man.conf, be most silent, search 148 # man.conf in /etc, and don't force (re-)compression. 154 149 COMP_METHOD= 155 150 COMP_SUF= 156 151 COMP_LVL= 152 FORCE_COMP=no 157 153 LN_OPT= 158 154 MAN_DIR= 159 QUIET_OPT= 160 QUIET_LVL=0 155 VERBOSE_LVL=0 161 156 BACKUP=no 162 157 FAKE=no … … 184 179 shift 185 180 ;; 181 --force|-F) 182 FORCE_COMP=yes 183 shift 184 ;; 186 185 --soft|-s) 187 186 LN_OPT=-s … … 196 195 shift 2 197 196 ;; 198 --quiet|-q) 199 let QUIET_LVL++ 200 QUIET_OPT="$QUIET_OPT -q" 197 --verbose|-v) 198 let VERBOSE_LVL++ 201 199 shift 202 200 ;; … … 222 220 ;; 223 221 *) 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" 226 223 exit 1 227 224 ;; … … 230 227 231 228 # Redirections 232 case $ QUIET_LVL in229 case $VERBOSE_LVL in 233 230 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 234 244 DEST_FD0=/dev/stdout 235 245 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" 245 247 ;; 246 248 esac … … 257 259 # If no MANPATH in ${MAN_CONF}/man.conf, abort as well 258 260 if [ -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'" 260 262 exit 1 261 263 fi … … 274 276 echo "Compression level.: $COMP_LVL" 275 277 echo "Compression suffix: $COMP_SUF" 278 echo "Force compression.: $FORCE_COMP" 276 279 echo "man.conf is.......: ${MAN_CONF}/man.conf ($MAN_CONF)" 277 280 echo -n "Hard links........: " … … 281 284 echo "Faking (yes!).....: $FAKE" 282 285 echo "Directories.......: $MAN_DIR" 283 echo "Silence level.....: $ QUIET_LVL ($QUIET_OPT)"286 echo "Silence level.....: $VERBOSE_LVL ($VERBOSE_OPT)" 284 287 exit 0 285 288 fi … … 309 312 cd "$DIR" 310 313 for FILE in *; do 314 # Fixes the case were the directory is empty 311 315 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 312 323 if [ -d "$FILE" ]; then 313 324 # We are going recursive to that directory … … 315 326 # I need not pass --conf, as I specify the directory to work on 316 327 # But I need exit in case of error 317 "$0" ${COMP_METHOD} ${COMP_LVL} ${LN_OPT} ${ QUIET_OPT} "${DIR}/${FILE}" || exit 1328 "$0" ${COMP_METHOD} ${COMP_LVL} ${LN_OPT} ${VERBOSE_OPT} "${DIR}/${FILE}" || exit 1 318 329 echo "<- Leaving ${DIR}/${FILE}." > $DEST_FD1 330 319 331 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 321 337 322 338 # If we have a symlink … … 331 347 esac 332 348 333 if [ "$EXT" != "none" ]; then349 if [ ! "$EXT" = "none" ]; then 334 350 LINK=`ls -l $FILE | cut -d ">" -f2 | tr -d " " | sed s/\.$EXT$//` 335 351 NEWNAME=`echo "$FILE" | sed s/\.$EXT$//` … … 363 379 *.bz2) 364 380 bunzip2 $FILE 365 FILE=` echo $FILE | sed s/\.bz2$//`381 FILE=`basename "$FILE" .bz2` 366 382 ;; 367 383 *.gz) 368 384 gunzip $FILE 369 FILE=` echo $FILE | sed s/\.gz$//`385 FILE=`basename "$FILE" .gz` 370 386 ;; 371 387 esac … … 405 421 done # for FILE 406 422 done # for DIR 407 408 423 <command>EOF 409 424 chmod 755 /usr/bin/compressdoc</command></userinput></screen> … … 416 431 <para> Don't forget that a few programs, like the <application>X</application> 417 432 Window system, <application>XEmacs</application>, also install their 418 documentation in non standard places (such as <filename class="directory">433 documentation in non standard places (such as <filename class="directory"> 419 434 /usr/X11R6/man</filename>, etc...). Don't forget to add those locations in the 420 435 file <filename>/etc/man.conf</filename>, as a
Note:
See TracChangeset
for help on using the changeset viewer.