# Template build file for 'bash'.
pkgname=bash
_bash_distver=4.3
_bash_patchlevel=046
version=${_bash_distver}.${_bash_patchlevel}
revision=1
wrksrc=${pkgname}-${_bash_distver}
build_style=gnu-configure
configure_args="--without-bash-malloc --with-curses --with-installed-readline"
hostmakedepends="bison"
makedepends="ncurses-devel readline-devel"
conflicts="chroot-bash>=0"
register_shell="/bin/bash"
short_desc="The GNU Bourne Again Shell"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
homepage="http://www.gnu.org/software/bash/bash.html"
license="GPL-3"
distfiles="${GNU_SITE}/$pkgname/$pkgname-${_bash_distver}.tar.gz"
CFLAGS="-DSYS_BASHRC='\"/etc/bash/bashrc\"'"
make_dirs="/etc/bash/bashrc.d 755 root root"
checksum=afc687a28e0e24dc21b988fa159ff9dbcf6b7caa92ade8645cc6d5605cd024d4

alternatives="
 sh:sh:/usr/bin/bash
 sh:sh.1:/usr/share/man/man1/bash.1"

pre_configure() {
	local url="${GNU_SITE}/$pkgname/$pkgname-${_bash_distver}-patches"
	local ver=$(echo ${_bash_distver}|sed "s|\.||g")

	if [ "${_bash_patchlevel}" -gt 000 ]; then
		for p in $(seq -w 001 ${_bash_patchlevel}); do
			if [ -f bash${ver}-${p} ]; then
				continue
			fi
			msg_normal " Fetching ${url}/bash${ver}-$p ...\n"
			$XBPS_FETCH_CMD ${url}/bash${ver}-$p
		done
	fi
	cd ${wrksrc}
	for p in $(seq -w 001 ${_bash_patchlevel}); do
		patch -sNp0 -i bash${ver}-${p}
		msg_normal " Applying patch bash${ver}-$p.\n"
	done
}
post_install() {
	rm -r ${DESTDIR}/usr/share/doc
	ln -s bash ${DESTDIR}/usr/bin/rbash
	vmkdir /etc/bash
	vinstall ${FILESDIR}/bashrc 644 etc/bash
	vinstall ${FILESDIR}/bash.sh 644 etc/profile.d
}