# $Id: PKGBUILD 82719 2010-06-16 04:44:35Z allan $
# Maintainer: Aaron Griffin <aaron@archlinux.org>

pkgname=bash
_patchlevel=007 #prepare for some patches
pkgver=4.1.$_patchlevel
pkgrel=2
pkgdesc="The GNU Bourne Again shell"
arch=('i686' 'x86_64')
license=('GPL')
url="http://www.gnu.org/software/bash/bash.html"
groups=('base')
backup=(etc/profile.bash etc/skel/.bashrc etc/skel/.bash_profile)
depends=('readline>=6.1' 'glibc')
makedepends=(gzip)
provides=('sh')
install=bash.install
source=(http://ftp.gnu.org/gnu/bash/bash-4.1.tar.gz
        profile.bash
        bashrc
        enable-system-config-files.patch
        system.bashrc)
if [ $_patchlevel -gt 000 ]; then
    for (( p=1; p<=$_patchlevel; p++ )); do
        source=(${source[@]} http://ftp.gnu.org/gnu/bash/bash-4.1-patches/bash41-$(printf "%03d" $p))
    done
fi

build() {
  cd ${srcdir}/${pkgname}-4.1
  for p in ../bash41-*; do
    [ -e "$p" ] || continue
    msg "applying patch ${p}"
    patch -Np0 -i ${p} || return 1
  done

  patch -Np0 -i $srcdir/enable-system-config-files.patch || return 1

  ./configure --prefix=/usr --with-curses --enable-readline \
    --without-bash-malloc --with-installed-readline \
    --bindir=/bin --mandir=/usr/share/man --infodir=/usr/share/info
  make || return 1
  make DESTDIR=${pkgdir} install

  install -D -m644 ${srcdir}/profile.bash ${pkgdir}/etc/profile.bash || return 1
  install -D -m644 ${srcdir}/system.bashrc ${pkgdir}/etc/bash.bashrc || return 1

  # for now, bash is our default /bin/sh
  cd ${pkgdir}/bin
  ln -s bash sh

  mkdir -p ${pkgdir}/etc/skel/
  install -D -m644 ${srcdir}/bashrc ${pkgdir}/etc/skel/.bashrc
  echo ". \$HOME/.bashrc" >${pkgdir}/etc/skel/.bash_profile
}

md5sums=('9800d8724815fd84994d9be65ab5e7b8'
         '17f20ec69535a2f50f2112a8c700630d'
         '3d2837e84645eac9bde399b58014bafa'
         '51725defa4c2dec49c1bc15883e0bee2'
         '196697769f1667a8a1aed608811129c6'
         '582dea5671b557f783e18629c2f77b68'
         '118d465095d4a4706eb1d34696a2666a'
         '120f7cf039a40d35fe375e59d6f17adc'
         '336ee037fc2cc1e2350b05097fbdc87c'
         '9471e666797f0b03eb2175ed752a9550'
         'fb80ccd58cb1e34940f3adf4ce6e4a1e'
         '192a8b161d419a1d0d211169f1d1046e')