# SliTaz package receipt.

PACKED_SIZE="284.0K"
UNPACKED_SIZE="648.0K"
PACKAGE="bash"
VERSION="4.2"
CATEGORY="system-tools"
SHORT_DESC="The GNU bourne SHell."
MAINTAINER="pankso@slitaz.org"
TARBALL="$PACKAGE-$VERSION.tar.gz"
WEB_SITE="http://www.gnu.org/software/bash/"
WGET_URL="$GNU_MIRROR/$PACKAGE/$TARBALL"

DEPENDS="readline"
BUILD_DEPENDS="readline bison"

# Rules to compile & install the temporary toolchain.
cook_tmp_toolchain()
{
	cd $src
	./configure --without-bash-malloc &&
	make && make install
}

# Rules to configure and make the package.
compile_rules()
{
	# Patch and then build.
	cd $src
	# Skip tests that can not run while cross-compiling.
	cat > config.cache << "EOF"
ac_cv_func_mmap_fixed_mapped=yes
ac_cv_func_strcoll_works=yes
ac_cv_func_working_mktime=yes
bash_cv_func_sigsetjmp=present
bash_cv_getcwd_malloc=yes
bash_cv_job_control_missing=present
bash_cv_printf_a_format=yes
bash_cv_sys_named_pipes=present
bash_cv_ulimit_maxfds=yes
bash_cv_under_sys_siglist=yes
bash_cv_unusable_rtsigs=no
gt_cv_int_divbyzero_sigfpe=yes
EOF
	./configure \
		$CONFIGURE_ARGS \
		--cache-file=config.cache \
		--bindir=/bin \
		--enable-history --enable-alias  \
		--disable-nls --without-bash-malloc \
		--disable-help-builtin \
		--with-installed-readline &&
	make &&
	# Bash doesn't care about DESTDIR in environnment variable.
	make DESTDIR=$DESTDIR install
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	cp -a $_pkg/bin $fs
	# Config files.
	#
	mkdir $fs/etc
	cp $stuff/example.bashrc $fs/etc/bashrc
}

# Post install commands for Tazpkg.
# Check /bin/sh stat.
#
post_install()
{
	local root
	root=$1
	echo "Processing post-install commands..."
	sh=`readlink $root/bin/sh`
	if [ ! "$sh" = "/bin/bash" ]; then
		echo ""
		echo "**** Actual SH link : $sh"
		echo ""
		echo -n "Do you want Bash for /bin/sh (yes/No) ? : "
		read -t 30 anser
		if [ "$anser" == "yes" ]; then
			echo ""
			echo -n "Removing sh link to make a new one pointing on /bin/bash..."
			rm $root/bin/sh && ln -s /bin/bash $root/bin/sh
			status
		else
			echo ""
			echo "Leaving /bin/sh to : $sh"
		fi
	fi
}

# Restore a valid sh link if needed.
pre_remove()
{
	local root
	root=$1
	sh=`readlink $root/bin/sh`
	if [ ! "$sh" = "busybox" ]; then
		rm $root/bin/sh &&
		ln -s /bin/busybox $root/bin/sh
	fi
}
