#!/bin/bash # Function to compress man pages for the package # Based on the compressdoc script in BLFS. compressDoc() { if [ -z "$1" ] then return fi # First process the symlinks # Note that the links will be dangling for till the actual files are processed. for FILE in $(find "$1" -user $TT_PKG_USERNAME -type l -not -name "*.bz2" 2>/dev/null) do # Remove the .gz extension from the symlink case "$FILE" in *.gz) LINK=`ls -l "$FILE" | cut -d ">" -f2 | tr -d " " | sed s/\.gz$//` NEW_FILE=`echo "$FILE" | sed s/\.gz$//` rm -f $FILE ln -sf $LINK $NEW_FILE FILE=$NEWFILE ;; esac # Recreate symlink with bz2 extensions. LINK=`ls -l "$FILE" | cut -d ">" -f2 | tr -d " "` ln -sf $LINK.bz2 $FILE.bz2 rm -f $FILE done # Now process regular files and hardlinks for FILE in $(find "$1" -user $TT_PKG_USERNAME -not -name "*.bz2" 2>/dev/null) do # The file may not exist if it is a hardlinked file whose parent is already processed. if [ ! -f "$FILE" ] then continue fi # Figure out if the file is part of a hard linked conglomeration. INODE=`ls -li "$FILE" | awk '{print $1}'` H_LINKS=`find "$1" -not -name \`basename $FILE\` -inum "$INODE"` case "$FILE" in # If gz file, remove hardlinks, unzip. *.gz) NEW_H_LINKS="" for F in $(echo $H_LINKS ) do rm -f $F NEW_H_LINKS="$NEW_H_LINKS `echo $F | sed s/\.gz$//`" done H_LINKS="$NEW_HLINKS" gunzip -f $FILE if [ "$?" != "0" ] then rm -f $FILE continue fi FILE=`echo $FILE | sed s/\.gz$//` ;; # For a regular file, delete the hardlinks *) for F in $(echo $H_LINKS) do rm -f $F done ;; esac bzip2 -f $FILE if [ "$?" != "0" ] then rm -f $FILE continue fi for F in $(echo $H_LINKS) do ln -f $FILE.bz2 $F.bz2 done done }