# $Id$
# Maintainer: Daniel Wallace <danielwallace at gtmanfred dot com>
# Contributor: Chris <seitz.christoph@gmail.com>
# Contributor: m0ikz <ndelatorre@moikz.com.ar>
# Contributor: atweiden <archbaum@gmail.com>

pkgname=ansible
pkgver=1.5
pkgrel=2
pkgdesc='Radically simple IT automation platform'
arch=('any')
url='http://www.ansible.com'
license=('GPL3')
depends=('python2' 'python2-yaml' 'python2-paramiko' 'python2-jinja')
makedepends=('asciidoc' 'fakeroot')
optdepends=('python2-pyasn1: needed for accelerated mode'
            'python2-crypto: needed for accelerated mode'
            'python2-keyczar: needed for accelerated mode')

backup=('etc/ansible/ansible.cfg')
source=(http://releases.ansible.com/ansible/$pkgname-$pkgver.tar.gz)
sha256sums=('37c46b84a5525ad027e3828cd862089a20783944603c504630d0c9c84e62df45')

build() {
  cd $pkgname-$pkgver

  python2 setup.py build
}

package() {
  cd $pkgname-$pkgver

  install -d "$pkgdir/usr/share/ansible"
  cp -dpr --no-preserve=ownership ./library/* "$pkgdir/usr/share/ansible/"
  cp -dpr --no-preserve=ownership ./examples "$pkgdir/usr/share/ansible"

  python2 setup.py install -O1 --root="$pkgdir"

  install -Dm644 examples/ansible.cfg "$pkgdir/etc/ansible/ansible.cfg"

  install -Dm644 README.md "$pkgdir/usr/share/doc/ansible/README.md"
  install -Dm644 COPYING "$pkgdir/usr/share/doc/ansible/COPYING"

  install -d "$pkgdir/usr/share/man/man1"
  cp -dpr --no-preserve=ownership docs/man/man1/*.1 "$pkgdir/usr/share/man/man1"

  #find "$pkgdir/usr/share/ansible/" -type f -exec sed -i '1s:python:&2:' {} +
  find "$pkgdir/usr/lib" -type f -name \*.py -exec sed -i '1s:python$:&2:' {} +
}

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