IGNOREPATH=/etc:/home:/var:/dev:/boot:/root:/usr/local:/sbin:/mnt:/tmp:/usr/src
STRIPLIB=y
STRIPBIN=y

VERSION=1.0.2
PROGNAME="bzip $VERSION"
DESC="\
bzip2 (a block-sorting file compressor)                                \n\
                                                                       \n\
Bzip2 compresses files using the Burrows-Wheeler block sorting text    \n\
compression algorithm, and Huffman coding.  Compression is generally   \n\
considerably better than that achieved by more conventional LZ77/LZ78- \n\
based compressors, and approaches the performance of the PPM family of \n\
statistical compressors.                                               \n\
                                                                       \n\
Julian Seward <jseward@acm.org> is the author of bzip2."

BUILD=1
MAINTAINER="Mark Post <mark.post@eds.com>"
SOURCE=http://sources.redhat.com/bzip2/
PKGNAME=bzip2-$VERSION-s390-$BUILD
TAG=ADD

compile() {
   tar -zxvf $CWD/bzip2-$VERSION.tar.gz
   cd bzip2-$VERSION/
   make -f Makefile-libbz2_so
   make
}

install() {
   make install PREFIX=/package-bzip/usr

   mkdir -p /package-bzip/usr/doc/bzip2-$VERSION
   cp -a CHANGES LICENSE README README.COMPILATION.PROBLEMS \
         Y2K_INFO bzip2.txt *.html \
       /package-bzip/usr/doc/bzip2-$VERSION

   mkdir -p /package-bzip/lib
   cp -a libbz2.so.$VERSION /package-bzip/lib/libbz2.so.$VERSION
   ( cd /package-bzip/lib/
     ln -sf libbz2.so.1.0.2 libbz2.so.1.0
   )

   ( cd /package-bzip/usr/lib
     rm -rf libbz2.so ; ln -sf ../../lib/libbz2.so.1.0 libbz2.so
   )

   mkdir -p /package-bzip/bin
   cp -p bzip2-shared /package-bzip/bin/bzip2
   ( cd /package-bzip/bin/
     rm -f bzcat ; ln -sf bzip2 bzcat
     ln -sf bzip2 bunzip2
   )
   mv /package-bzip/usr/bin/bzip2recover /package-bzip/bin/bzip2recover

   ( cd /package-bzip/usr/bin
     rm bzcmp bzegrep bzfgrep bzless
     rm -rf bzcat ; ln -sf ../../bin/bzip2 bzcat
     rm -rf bunzip2 ; ln -sf ../../bin/bzip2 bunzip2
     rm -rf bzip2 ; ln -sf ../../bin/bzip2 bzip2
   )

   ( cd /package-bzip/usr/man/man1
     rm -f bzcmp.1 bzegrep.1 bzfgrep.1 bzless.1 
     echo '.so man1/bzip2.1' > bzip2recover.1
     rm -f *.gz
     gzip -9 *.1
   )
}

attributes() {
   chown -R root.bin $PKG/package-bzip/bin \
                     $PKG/package-bzip/usr/bin
}

special() {
   cd $PKG
   mv package-bzip/* ./
   rmdir package-bzip

   cd $CTL
   cat $CWD/slack-desc > slack-desc

   sed -e 's%package-bzip/%%' doinst.sh > doinst.sh.new
   cat doinst.sh.new > doinst.sh
   rm doinst.sh.new
}

