# Maintainer: Luke Shumaker <lukeshu@sbcglobal.net>
# Maintainer (AUR:redo-git): Tim Diels <timdiels.m@gmail.com>

pkgname='apenwarr-redo'
pkgdesc="Avery Pennarun's implmentation of the redo build system"
url="https://github.com/apenwarr/redo"
pkgver=0.11
license=(LGPL2 custom:BSD2) # no, not 2.1, and not 'or any later version'
source=(redo-redo-$pkgver.tar.gz::https://github.com/apenwarr/redo/archive/redo-$pkgver.tar.gz)
md5sums=('1b6a07bdb00a74b2d166845f9520b67a')

pkgrel=1
arch=(any)
depends=(python2 sh)
makedepends=(python2-markdown python2-beautifulsoup3)
provides=('redo')
conflicts=('redo')

prepare() {
  cd "$srcdir/redo-redo-$pkgver"
  # Make everything use python2
  grep -rxFl '#!/usr/bin/env python' | xargs -d $'\n' sed -i 's@^#!/usr/bin/env python$@&2@'
  sed -i 's@python\b@python2@' install.do
  sed -rn 's|^# ?||p' < options.py > options.py.LICENSE.txt
}

build() {
  cd "$srcdir/redo-redo-$pkgver"
  make
}

check() {
  cd "$srcdir/redo-redo-$pkgver"
  make test
}

package() {
  cd "$srcdir/redo-redo-$pkgver"
  make DESTDIR="$pkgdir" install
  install -Dm644 LICENSE                "$pkgdir/usr/share/licenses/$pkgname/LGPL2.txt"
  install -Dm644 options.py.LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/options.py.LICENSE.txt"  
}
