# SliTaz package receipt.

PACKAGE="bzip2"
VERSION="1.0.8"
CATEGORY="utilities"
SHORT_DESC="High-quality data compressor."
MAINTAINER="pankso@slitaz.org"
TARBALL="$PACKAGE-$VERSION.tar.gz"
WEB_SITE="http://www.bzip.org/"
WGET_URL="https://sourceware.org/pub/$PACKAGE/$TARBALL"
DEPENDS="bzlib"
BUILD_DEPENDS="gcc"
TAGS="compression archive"

# Rules to compile & install the temporary toolchain.
cook_tmp_toolchain()
{
	cd $src
	make &&	make PREFIX=/tools install
}

# Rules to configure and make the package.
compile_rules()
{
	cd $src
	make -f Makefile-libbz2_so &&
	make clean &&
	make
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/usr/bin
	cp -a $src/bzip2-shared $fs/usr/bin/bzip2
	# Da bunzip2, bzcat and lib symlink.
	cd $fs/usr/bin
	ln -s bzip2 bunzip2
	ln -s bzip2 bzcat
}

# Remove Busybox symlinks before installing
pre_install()
{
  local root
  root=$1
  echo "Processing post-install commands..."
  rm -f $root/usr/bin/bunzip2
  rm -f $root/usr/bin/bzcat
#  rm -f $root/usr/bin/bzip2
}

# Restore Busybox symlinks upon removal
post_remove()
{
	ln -s /bin/busybox /usr/bin/bunzip2
	ln -s /bin/busybox /usr/bin/bzcat
#	ln -s /bin/busybox /usr/bin/bzip2
}