# SliTaz package receipt.

PACKED_SIZE="44.0K"
UNPACKED_SIZE="92.0K"
PACKAGE="bzip2"
VERSION="1.0.6"
CATEGORY="utilities"
SHORT_DESC="High-quality data compressor."
MAINTAINER="pankso@slitaz.org"
LICENSE="BSD"
TARBALL="$PACKAGE-$VERSION.tar.gz"
WEB_SITE="http://www.bzip.org/"
WGET_URL="http://www.bzip.org/$VERSION/$TARBALL"
TAGS="compression archive"
HOST_ARCH="i486 arm"

DEPENDS="bzlib"
BUILD_DEPENDS=""

# Rules to configure and make the package.
compile_rules()
{
	cd $src
	# Disable the tests since they won't work on a multi-architecture build
	cp Makefile Makefile.orig
	sed -e "/^all:/s/ test//" Makefile.orig > Makefile
	# No configure script, we must used CC, AR and RANLIB set by cook.
	case "$ARCH" in
		arm)
			make -f Makefile-libbz2_so CC=${CC} AR=${AR} RANLIB=${RANLIB} &&
			make clean && make CC=${CC} AR=${AR} RANLIB=${RANLIB} ;;
		*)
			make -f Makefile-libbz2_so &&
			make clean && make ;;
	esac
}

# Just to be sure when cross-compiling.
testsuite()
{
	readelf -h $src/bzip2-shared
}

# 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()
{
	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
}
