# Compiling Time: 0.47 SBU
# Maintainer: James Buren <ryuo@frugalware.org>
# Contributor: Miklos Vajna <vmiklos@frugalware.org>

pkgname=bash
basever=4.3
patchver=042
if [ -z "$patchver" ]; then
	pkgver=$basever
else
	pkgver=${basever}_$patchver
fi
pkgrel=7
pkgdesc="The GNU Bourne Again shell"
url="http://tiswww.case.edu/php/chet/bash/bashtop.html"
#dlurl="ftp://ftp.cwru.edu/pub/$pkgname"
dlurl="ftp://ftp.gnu.org/gnu/$pkgname"
backup=(etc/{profile,shells,skel/.bashrc})
depends=('glibc>=2.22-7' 'readline>=6.3-7')
groups=('base' 'core')
archs=('i686' 'x86_64' 'arm')
up2date="echo \$(lynx -dump $url|grep current|sed -n -e 's/.*bash-\(.*\)\. .*$/\1/' -e '1 p')\$(lynx -dump "$dlurl/bash-$basever-patches"|grep 'bash${basever//.}-[0-9]\{3\}'|sed -n 's/.*bash${basever//.}-\([0-9]\{3\}\).*/_\1/;$ p')"
source=("$dlurl/$pkgname-$basever.tar.gz" profile shells bashrc system.bashrc revert-patch-043)
signatures=("${source[0]}.sig" '' '' '' '' '')

if [ -n "$patchver" ]; then
	for i in `seq -w $patchver`
	do
		source+=("$dlurl/bash-$basever-patches/bash${basever//.}-$i")
		signatures+=("$dlurl/bash-$basever-patches/bash${basever//.}-$i.sig")
	done
fi

options+=('force')

build()
{
	_bashconfig=(-DSYS_BASHRC=\'\"/etc/bashrc\"\')
	export CFLAGS="${CFLAGS} ${_bashconfig[@]}"
	Fcd $pkgname-$basever
	for i in `seq -w $patchver`
	do
		Fmessage "Using patch: bash${basever//.}-$i"
		patch -Np0 -i ../bash${basever//.}-$i || return 1
	done

	Fbuild --with-curses \
		--enable-readline \
		--without-bash-malloc
	Fmv /usr/bin /
	Ffile profile shells /etc/
	Ffile bashrc /etc/skel/.bashrc
	Ffile system.bashrc /etc/bashrc
	Fln bash /bin/sh
}

# optimization OK
