# $Id: PKGBUILD 127935 2015-02-18 15:18:28Z 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.7
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=('46b2016b5e4f2b5cd2edf07c60ca8fe7dd91204ca848f98964be61b3c4760f5e'
            'd8b24f15d472885f788a2d6e985850f264627b86012a17bb242c83f310d907e5')
sha512sums=('26b25f31fb98fe7c7d926dcc492fe7889f2462430f959645e498fc47367d23243fb3b528da7af026827dffb30d7c5fe2ffb31843a8f2c9064647bebb313de9bb'
            '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
}
