Changeset 2fa79e3b
- Timestamp:
- 10/04/2003 01:47:13 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:
- 60e14d4
- Parents:
- b7d0bb4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
postlfs/config/compressdoc.xml
rb7d0bb4 r2fa79e3b 14 14 15 15 #!/bin/bash 16 # VERSION: 20031004.0245 16 17 # 17 18 # Compress (with bzip2 or gzip) all man pages in a hierarchy and 18 # update symlinks - By Marc Heerdink <marc @koelkast.net>.19 # update symlinks - By Marc Heerdink <marc @ koelkast.net> 19 20 # Modified to be able to gzip or bzip2 files as an option and to deal 20 # with all symlinks properly by Mark Hymers # <markh@linuxfromscratch.org>21 # with all symlinks properly by Mark Hymers <markh @ linuxfromscratch.org> 21 22 # 22 # Modified 200309 25 by Yann E. Morin <yann.morin.1998 @ #anciens.enib.fr>23 # Modified 20030930 by Yann E. Morin <yann.morin.1998 @ anciens.enib.fr> 23 24 # to accept compression/decompression, to correctly handle hard-links, 24 25 # to allow for changing hard-links into soft- ones, to specify the … … 27 28 # 28 29 # TODO: 29 # - inverse the quiet option into a verbose one, so as to be silent30 # by default;31 30 # - choose a default compress method to be based on the available 32 31 # tool : gzip or bzip2; … … 42 41 echo "Unknown option : $1" 43 42 fi 44 echo "Usage: $0 <comp_method> [options] [dirs]"43 ( echo "Usage: $0 <comp_method> [options] [dirs]" && \ 45 44 cat << EOT 46 45 Where comp_method is one of : … … 70 69 as the method adds (.bz2 for bzip2, .gz for gzip). 71 70 72 - sChange hard-links into soft-links. Use with _caution_ as the71 --soft, -S Change hard-links into soft-links. Use with _caution_ as the 73 72 first encountered file will be used as a reference. Not used 74 73 when in backup mode. 74 75 --hard, -H Change soft-links into hard-links. Not used when in backup mode. 75 76 76 77 --conf=dir, --conf dir … … 108 109 does not even let me notice this... :-) 109 110 EOT 111 ) | less 110 112 } 111 113 … … 145 147 146 148 # OK, parse the command-line for arguments, and initialize to some sensible 147 # state, that is keep hardlinks, parse /etc/man.conf, be most silent, search148 # man.conf in /etc, and don't force (re-)compression.149 # state, that is : don't change links state, parse /etc/man.conf, be most 150 # silent, search man.conf in /etc, and don't force (re-)compression. 149 151 COMP_METHOD= 150 152 COMP_SUF= 151 153 COMP_LVL= 152 FORCE_ COMP=no154 FORCE_OPT= 153 155 LN_OPT= 154 156 MAN_DIR= … … 180 182 ;; 181 183 --force|-F) 182 FORCE_COMP=yes 183 shift 184 ;; 185 --soft|-s) 186 LN_OPT=-s 184 FORCE_OPT=-F 185 shift 186 ;; 187 --soft|-S) 188 LN_OPT=-S 189 shift 190 ;; 191 --hard|-H) 192 LN_OPT=-H 187 193 shift 188 194 ;; … … 276 282 echo "Compression level.: $COMP_LVL" 277 283 echo "Compression suffix: $COMP_SUF" 278 echo "Force compression.: $FORCE_COMP" 279 echo "man.conf is.......: ${MAN_CONF}/man.conf ($MAN_CONF)" 280 echo -n "Hard links........: " 281 [ "$LN_OPT" = "-s" -o "$LN_OPT" = "--soft" ] && echo -n "Convert to symlinks" || echo -n "Keep hardlinks" 282 echo " ($LN_OPT)" 284 echo -n "Force compression.: " 285 [ "foo$FORCE_OPT" = "foo-F" ] && echo "yes" || echo "no" 286 echo "man.conf is.......: ${MAN_CONF}/man.conf" 287 echo -n "Hard-links........: " 288 [ "foo$LN_OPT" = "foo-S" ] && echo "convert to soft-links" || echo "leave as is" 289 echo -n "Soft-links........: " 290 [ "foo$LN_OPT" = "foo-H" ] && echo "convert to hard-links" || echo "leave as is" 283 291 echo "Backup............: $BACKUP" 284 292 echo "Faking (yes!).....: $FAKE" 285 293 echo "Directories.......: $MAN_DIR" 286 echo " Silence level.....: $VERBOSE_LVL ($VERBOSE_OPT)"294 echo "Verbosity level...: $VERBOSE_LVL" 287 295 exit 0 288 296 fi … … 310 318 # I need to take into account the localized man, so I'm going recursive 311 319 for DIR in $MAN_DIR; do 320 MEM_DIR=`pwd` 312 321 cd "$DIR" 313 322 for FILE in *; do … … 322 331 323 332 if [ -d "$FILE" ]; then 333 cd "${MEM_DIR}" # Go back to where we ran "$0", in case "$0"=="./compressdoc" ... 324 334 # We are going recursive to that directory 325 335 echo "-> Entering ${DIR}/${FILE}..." > $DEST_FD0 326 336 # I need not pass --conf, as I specify the directory to work on 327 337 # But I need exit in case of error 328 "$0" ${COMP_METHOD} ${COMP_LVL} ${LN_OPT} ${VERBOSE_OPT} "${DIR}/${FILE}" || exit 1338 "$0" ${COMP_METHOD} ${COMP_LVL} ${LN_OPT} ${VERBOSE_OPT} ${FORCE_OPT} "${DIR}/${FILE}" || exit 1 329 339 echo "<- Leaving ${DIR}/${FILE}." > $DEST_FD1 340 cd "$DIR" # Needed for the next iteration of the loop 330 341 331 342 else # !dir … … 334 345 # Check if the file is already compressed with the specified method 335 346 BASE_FILE=`basename \`basename "$FILE" .bz2\` .gz` 336 if [ "${FILE}" = "${BASE_FILE}${COMP_SUF}" -a " ${FORCE_COMP}" = "no" ]; then continue; fi347 if [ "${FILE}" = "${BASE_FILE}${COMP_SUF}" -a "foo${FORCE_OPT}" = "foo" ]; then continue; fi 337 348 338 349 # If we have a symlink … … 356 367 fi 357 368 358 rm -f "$FILE" && ln -s "${LINK}$COMP_SUF" "${FILE}$COMP_SUF" 369 if [ "$LN_OPT" = "-H" ]; then 370 # Change this soft-link into a hard- one 371 rm -f "$FILE" && ln "${LINK}$COMP_SUF" "${FILE}$COMP_SUF" 372 chmod --reference "${LINK}$COMP_SUF" "${FILE}$COMP_SUF" 373 else 374 # Keep this soft-link a soft- one. 375 rm -f "$FILE" && ln -s "${LINK}$COMP_SUF" "${FILE}$COMP_SUF" 376 fi 359 377 echo "Relinked $FILE" > $DEST_FD1 360 378 … … 387 405 esac 388 406 389 # Compress the file with the highestcompression ratio, if needed407 # Compress the file with the given compression ratio, if needed 390 408 case $COMP_SUF in 391 409 *bz2) … … 406 424 for i in $HLINKS; do 407 425 NEWFILE=`echo $i | sed s/\.gz$// | sed s/\.bz2$//` 408 ln ${LN_OPT} "${FILE}$COMP_SUF" "${NEWFILE}$COMP_SUF" 426 if [ "$LN_OPT" = "-S" ]; then 427 # Make this hard-link a soft- one 428 ln -s "${FILE}$COMP_SUF" "${NEWFILE}$COMP_SUF" 429 else 430 # Keep the hard-link a hard- one 431 ln "${FILE}$COMP_SUF" "${NEWFILE}$COMP_SUF" 432 fi 409 433 chmod 644 "${NEWFILE}$COMP_SUF" # Really work only for hard-links. Harmless for soft-links 410 434 done
Note:
See TracChangeset
for help on using the changeset viewer.