# Maintainer : Parabola GNU / Linux-libre Aurelien Desbrieres <aurelien@cwb.io>

_pkgname=rospkg
pkgname=(python{,2}-$_pkgname)
pkgver=1.1.7
pkgrel=1
pkgdesc="ROS package library"
arch=(any)
url="http://wiki.ros.org/rospkg"
license=('BSD3')

makedepends=(python{,2}-setuptools)
source=("https://files.pythonhosted.org/packages/source/r/rospkg/rospkg-${pkgver}.tar.gz")
sha256sums=('c6e918e13a6a51b362fd07b9a298f64e4cb066ee1e6168ac95b690c0b609b2ab')

prepare() {
  cp -r "$srcdir"/$_pkgname-$pkgver "$srcdir"/$_pkgname-$pkgver-python2
  mv    "$srcdir"/$_pkgname-$pkgver "$srcdir"/$_pkgname-$pkgver-python

  cd "$srcdir"/$_pkgname-$pkgver-python2
  find -type f -print0 | xargs -0 sed -i -e 's/#!\/usr\/bin\/env python/#!\/usr\/bin\/env python2/g'
}

_package() {
  depends=($1)
  cd "$srcdir"/$_pkgname-$pkgver-$1
  $1 setup.py install --root="$pkgdir"
}

for _pkg in "${pkgname[@]}"; do
  eval "package_$_pkg () { _package ${_pkg%%-*}; }"
done
