# Maintainer: Christer Edwards <christer.edwards@gmail.com>
pkgname=salt-cloud-git
_gitname=salt-cloud
pkgver=0.0.0
pkgrel=3
pkgdesc="Salt Cloud is a generic cloud provisioning tool"
arch=('any')
url="https://github.com/saltstack/salt-cloud"
license=('APACHE')
groups=()
depends=('salt'
         'python2'
         'python2-yaml'
         'apache-libcloud'
         'python2-botocore')

makedepends=('git')
conflicts=('salt-cloud')
provides=('salt-cloud')

# makepkg 4.1 knows about git and will pull main branch
source=("git://github.com/saltstack/salt-cloud.git")

# makepkg knows it's a git repo because the url starts with 'git'
# it then knows to checkout the branch 'pacman41' upon cloning, expediating versioning.
# branch="develop"
# source=("git://github.com/saltstack/salt-cloud.git#branch=$branch")

# makepkg also knows about tags
#tags="v0.8.8"
#source=("git://github.com/saltstack/salt-cloud.git#tag=$tag")

# because the sources are not static, skip checksums
md5sums=('SKIP')

pkgver() {
  cd "$srcdir/$_gitname"
  echo $(git describe --always | sed 's/-/./g')
  # for git, if the repo has no tags, comment out the above and uncomment the next line:
  # echo "0.$(git rev-list --count $branch).$(git describe --always)"
  # This will give you a count of the total commits and the hash of the commit you are on.
  # Useful if you're making a repository with git packages so that they can have sequential
  # version numbers. (Else a pacman -Syu may not update the package)
}

#build() {
#  cd "${srcdir}/${_gitname}"
#  python2 setup.py build 
   # no need to build setup.py install will do this
#}

package() {
  cd "${srcdir}/${_gitname}"
  export BOOTSTRAP_SCRIPT_VERSION=develop
  python2 setup.py sdist
  python2 setup.py install --root=${pkgdir}/ --optimize=1
  
  # remove vcs leftovers
  find "$pkgdir" -type d -name .git -exec rm -r '{}' +
}
