# Contributor: Johannes Dewender <arch@JonnyJD.net>
# Contributor: trashstar
# Maintainer: Luke Shumaker <lukeshu@sbcglobal.net>

# parabola changes and rationale:
#  - upstream pkgbuild is gone, but we keep maintaining this.

_pkgname=addon-sdk
pkgname=mozilla-addon-sdk
pkgver=1.17
pkgdesc="SDK to build add-ons for Mozilla products (formerly jetpack)"
url="https://developer.mozilla.org/en-US/Add-ons/SDK"
license=('MPL2')

pkgrel=1
arch=('any')
depends=('python2')

source=("https://ftp.mozilla.org/pub/mozilla.org/labs/jetpack/${_pkgname}-${pkgver}.tar.gz")
md5sums=('33a9f9e6067f4e6ab8e0d798c16b53e9')

prepare() {
  cd "${srcdir}/${_pkgname}-${pkgver}"
  grep -rl python . | xargs sed -ri \
    -e 's/^(#!.*|\s*)python(\s|$)/\1python2\2/' \
    -e 's/(\$ |`)python /python2 /' \
    -e 's/python -m/python2 -m/'
}

package() {
  install -d "${pkgdir}/opt" "$pkgdir/usr/bin"
  cp -r "${srcdir}/${_pkgname}-${pkgver}" "${pkgdir}/opt/${pkgname}"
  ln -srT "$pkgdir/opt/${pkgname}/bin/cfx" "$pkgdir/usr/bin/cfx"
}

# vim:set ts=2 sw=2 et:
