# Maintainer: Developer <dev@opalos.org>
# Maintainer: Developer <dev@opalos.org>

pkgname=bash-completion
pkgver=%version%
pkgrel=%release%
pkgdesc='Programmable completion for the bash shell'
arch=(any)
url='https://github.com/scop/bash-completion'
license=(GPL2)
depends=(bash)
options=(!emptydirs !makeflags)
source=($url/releases/download/$pkgver/$pkgname-$pkgver.tar.xz
        $pkgname-drill.patch::https://github.com/scop/bash-completion/commit/cbec56cfd543.patch)
validpgpkeys=(A558062B6D5DA1347CD468D52B0AE2C1B09B07CB)
sha256sums=('73a8894bad94dee83ab468fa09f628daffd567e8bef1a24277f1e9a0daf911ac'
            '84563efa872e56b293a76abb2e5ec70e845f0fa1a22b8d33d2d4a6fa49b25b5a')

prepare() {
  cd $pkgname-$pkgver
  patch -Np1 -i ../$pkgname-drill.patch
}

build() {
  cd $pkgname-$pkgver
  ./configure --prefix=/usr --sysconfdir=/etc
  make
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install

  # bash-completion is sourced in /etc/bash.bashrc so that non-bash shell don't source it
  rm "$pkgdir/etc/profile.d/bash_completion.sh"

  # remove Slackware's makepkg completion
  rm "$pkgdir/usr/share/bash-completion/completions/makepkg"
}
