# Maintainer: Alexandre Ferreira < alex.jorge.m [at] gmail.com >

pkgname=ansible
pkgver=2.9.21
pkgrel=1
pkgdesc='Radically simple IT automation platform'
arch=('i686' 'x86_64')
url='https://www.ansible.com'
license=('GPL3')
depends=('python' 'python-yaml' 'python-jinja')
provides=('python-ansible')
optdepends=('sshpass: for ssh connections with password')
makedepends=('tar' 'python-setuptools')
backup=('etc/ansible/ansible.cfg')
source=("https://releases.ansible.com/ansible/ansible-${pkgver}.tar.gz")
sha512sums=('572f04736bea590770db9b58e7fca8cf3b53b858a0cd2e16667e9d1935d173fa2a0a116d04e0ed976095fbd6b8cd878d21d3e5c4749046b39d121b9ac8b5c441')
noextract=("${pkgname}-${pkgver}.tar.gz")

prepare() {
  [[ -d ${pkgname}-${pkgver} ]] && rm -rf ${pkgname}-${pkgver}
  # Workaround an issue with symbolic links in the tarball.
  tar zxf "${srcdir}/${pkgname}-${pkgver}.tar.gz" || true
  MSYS=winsymlinks:lnk tar zxf "${srcdir}/${pkgname}-${pkgver}.tar.gz"
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  /usr/bin/python setup.py build
}

package() {
  cd ${pkgname}-${pkgver}
  /usr/bin/python setup.py install -O1 --root="${pkgdir}"
  install -Dm644 COPYING "${pkgdir}"/usr/share/doc/ansible/COPYING

  install -d "${pkgdir}"/usr/share/ansible/doc
  cp -dpr --no-preserve=ownership ./examples "${pkgdir}"/usr/share/ansible/doc/
  install -Dm644 examples/ansible.cfg "${pkgdir}"/etc/ansible/ansible.cfg

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