# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: buckket <felix@buckket.org>

pkgname=redo-python
pkgver=0.42.d
pkgrel=6
pkgdesc='An implementation of the redo build system in Python'
arch=('any')
url='https://github.com/apenwarr/redo'
license=('GPL')
depends=('python')
makedepends=(
  'git'
  'python-beautifulsoup4'
  'python-markdown'
)
optdepends=('python-setproctitle: pretty output')
provides=('redo')
conflicts=('redo-sh' 'redo-c' 'redo-jdebp')
_commit='7f00abc36be15f398fa3ecf9f4e5283509c34a00' # redo-0.42d
source=("$pkgname::git+$url.git#commit=$_commit"
         fix-tests.patch)
b2sums=('9f302262bc49728a8e04a8bb5eee8e181da3f947115b63c9f5a0a2f6d1cb2bf2001681881d74627f42cbbc7ecb9ef6c22e9ffe1c06053295b4ef54c4211209f8'
        '48381fb55e577d2e06553a014dcb39c7b45c22eaa82242656e2ea7c596b56346f220662fcee7ed8c11168450ab54409f350e5c7d3c2568fb0e5127d91f7f6394')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed -e 's/^redo-//' -e  's/\([[:alpha:]]\)$/.\1/'
}

prepare() {
  cd $pkgname
  patch -p1 -i ../fix-tests.patch
}

check() {
  cd "$pkgname"

  # tests fail with make 4.4+
  rm -rf t/203-make

  # tests fail if C/CXX/LD FLAGS are set
  # there's probably a cleaner way around this
  local L_CFLAGS L_CXXFLAGS L_LDFLAGS
  L_CFLAGS=$CFLAGS
  L_CXXFLAGS=$CXXFLAGS
  L_LDFLAGS=$LDFLAGS

  unset CFLAGS CXXFLAGS LDFLAGS

  ./do test

  CFLAGS=$L_CFLAGS
  CXXFLAGS=$L_CXXFLAGS
  LDFLAGS=$L_LDFLAGS
}

package() {
  cd "$pkgname"

  DESTDIR="$pkgdir" ./do install
}
