# $Id: PKGBUILD 116774 2014-08-03 03:53:55Z dwallace $
# Maintainer: Daniel Wallace <danielwallace at gtmanfred dot com>
# Contributor: Limao Luo <luolimao+AUR@gmail.com>

pkgbase=python-jsonpointer
_pkgname=jsonpointer
pkgname=(python2-jsonpointer python-jsonpointer)
pkgver=1.4
pkgrel=1
pkgdesc="Identify specific nodes in a JSON document (RFC 6901)"
arch=(any)
url=https://github.com/stefankoegl/python-json-pointer
license=(BSD)
makedepends=(python2-d2to1 python2-oslo-config python2-pbr python2-prettytable python2-requests
    python2-setuptools python2-simplejson python-d2to1 python-oslo-config python-pbr 
    python-prettytable python-requests python-setuptools python-simplejson)
source=(http://pypi.python.org/packages/source/j/${pkgname#*-}/${pkgname#*-}-$pkgver.tar.gz
    https://raw.github.com/stefankoegl/python-json-pointer/master/COPYING)
sha256sums=('cb9d357edc67fe41a929fbfd583e95a2a6c5fdc71e22522d88ab715c752905b4'
            'd8b24f15d472885f788a2d6e985850f264627b86012a17bb242c83f310d907e5')
sha512sums=('be1cf5b5df08bd42c25bded242afd4caf04baba8958cc8599859f80041f8db06e4d6aaadadd6cc6f35b2cc78a77a9d94ac45a9c809c21c61a691d7a6d9b5184f'
            '6a4c6b57a9cfe227175852c67ab7536fcc23646761cd10d25800edfccf408b139b1f589313f6cf6717c5764ca2e554cc16921118e01aebfbdf3ddfada82c6bac')

prepare(){
    cp -a $_pkgname-$pkgver $_pkgname-$pkgver-2
    find $_pkgname-$pkgver-2 -name \*.py -exec sed -i '1s/python$/&2/' {} +
}

build() {
    export LANG=en_US.UTF-8
    cd $srcdir/$_pkgname-$pkgver
    python setup.py build
    cd $srcdir/$_pkgname-$pkgver-2
    python2 setup.py build
}

package_python-jsonpointer() {
    cd $_pkgname-$pkgver
    depends=(python-d2to1 python-oslo-config python-pbr 
    python-prettytable python-requests python-simplejson)
    python setup.py install --prefix=/usr --root="$pkgdir"
    install -Dm644 $SRCDEST/COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
}
package_python2-jsonpointer() {
    cd $_pkgname-$pkgver-2
    depends=(python2-d2to1 python2-oslo-config python2-pbr python2-prettytable python2-requests
    python2-setuptools python2-simplejson python-d2to1)
    python2 setup.py install --prefix=/usr --root="$pkgdir"
    mv $pkgdir/usr/bin/jsonpointer $pkgdir/usr/bin/jsonpointer2 
    install -Dm644 $SRCDEST/COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
}
