# Maintainer: Carl Smedstad <carsme@archlinux.org>

pkgname=rebar3
pkgver=3.25.1
pkgrel=2
pkgdesc="Erlang build tool that makes it easy to compile and test Erlang applications and releases"
arch=('any')
url="https://github.com/erlang/rebar3"
license=('Apache-2.0')
depends=(
  erlang-common_test
  erlang-core
  erlang-dialyzer
  erlang-edoc
  erlang-erl_interface
  erlang-eunit
  erlang-parsetools
)
source=("$url/archive/$pkgver/$pkgname-$pkgver.tar.gz")
sha256sums=('458d6ceaf7822dd7682288354ab3ba74e14b3ed11cc5b551af9eb312de894106')

build() {
  cd $pkgname-$pkgver
  ./bootstrap
}

check() {
  cd $pkgname-$pkgver
  ./rebar3 ct
}

package() {
  cd $pkgname-$pkgver
  install -vDm755 -t "$pkgdir/usr/bin" rebar3
  install -vDm644 -t "$pkgdir/usr/lib/erlang/lib/rebar-$pkgver/ebin" \
    _build/bootstrap/lib/rebar/ebin/*.beam \
    _build/bootstrap/lib/rebar/ebin/rebar.app

  install -vDm644 -t "$pkgdir/usr/share/bash-completion/completions" \
    apps/rebar/priv/shell-completion/bash/rebar3
  install -vDm644 -t "$pkgdir/usr/share/zsh/site-functions" \
    apps/rebar/priv/shell-completion/zsh/_rebar3
  install -vDm644 -t "$pkgdir/usr/share/fish/vendor_completions.d" \
    apps/rebar/priv/shell-completion/fish/rebar3.fish

  install -vDm644 -t "$pkgdir/usr/share/man/man1" manpages/rebar3.1
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" \
    README.md rebar.config.sample THANKS
}
