home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 March / PCWELT_3_2006.ISO / base / 05_common.mo / usr / lib / rpm / brp-compress next >
Encoding:
Text File  |  2003-10-29  |  1.4 KB  |  57 lines

  1. #!/bin/sh
  2.  
  3. # If using normal root, avoid changing anything.
  4. if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
  5.     exit 0
  6. fi
  7.  
  8. cd $RPM_BUILD_ROOT
  9.  
  10. # Compress man pages
  11. COMPRESS="gzip -9"
  12. COMPRESS_EXT=.gz
  13.  
  14. for d in ./usr/man/man* ./usr/man/*/man* ./usr/info \
  15.     ./usr/share/man/man* ./usr/share/man/*/man* ./usr/share/info \
  16.     ./usr/kerberos/man ./usr/X11R6/man/man* ./usr/lib/perl5/man/man* \
  17.     ./usr/share/doc/*/man/man* ./usr/lib/*/man/man*
  18. do
  19.     [ -d $d ] || continue
  20.     for f in `find $d -type f`
  21.     do
  22.         [ -f "$f" ] || continue
  23.     [ "`basename $f`" = "dir" ] && continue
  24.  
  25.     case "$f" in
  26.      *.Z) gunzip $f; b=`echo $f | sed -e 's/\.Z$//'`;;
  27.      *.gz) gunzip $f; b=`echo $f | sed -e 's/\.gz$//'`;;
  28.      *.bz2) bunzip2 $f; b=`echo $f | sed -e 's/\.bz2$//'`;;
  29.      *) b=$f;;
  30.     esac
  31.  
  32.     $COMPRESS $b </dev/null 2>/dev/null || {
  33.         inode=`ls -i $b | awk '{ print $1 }'`
  34.         others=`find $d -type f -inum $inode`
  35.         if [ -n "$others" ]; then
  36.         for afile in $others ; do
  37.             [ "$afile" != "$b" ] && rm -f $afile
  38.         done
  39.         $COMPRESS -f $b
  40.         for afile in $others ; do
  41.             [ "$afile" != "$b" ] && ln $b$COMPRESS_EXT $afile$COMPRESS_EXT
  42.         done
  43.         else
  44.         $COMPRESS -f $b
  45.         fi
  46.     }
  47.     done
  48.  
  49.     for f in `find $d -type l`
  50.     do
  51.     l=`ls -l $f | sed -e 's/.* -> //' -e 's/\.gz$//' -e 's/\.bz2$//' -e 's/\.Z$//'`
  52.     rm -f $f
  53.     b=`echo $f | sed -e 's/\.gz$//' -e 's/\.bz2$//' -e 's/\.Z$//'`
  54.     ln -sf $l$COMPRESS_EXT $b$COMPRESS_EXT
  55.     done
  56. done
  57.