# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Kasei Wang <cnsdwpc at gmail.com>

pkgname=brook
pkgver=20190401
pkgrel=2
pkgdesc="A cross-platform proxy/vpn software"
arch=('x86_64')
url="https://github.com/txthinking/brook"
license=('GPL')
depends=('glibc')
makedepends=('go-pie' 'git')
source=("$pkgname-$pkgver.tar.gz::https://github.com/txthinking/brook/archive/v$pkgver.tar.gz")
sha512sums=('83d9299666fef59820f1d7b672c93f0c71cd75fd6d6623b6d6784c16ba2a81dadb7288086d84469552db424fc09564436d21d3c064b1aaeb9f7e7912ba41f48d')

prepare() {
  cd brook-$pkgver

  mkdir build
  mkdir -p .gopath/src/github.com/txthinking
  ln -sf "$PWD" .gopath/src/github.com/txthinking/brook
  export GOPATH="$PWD/.gopath"

  go get github.com/mdp/qrterminal github.com/patrickmn/go-cache github.com/txthinking/ant \
         github.com/txthinking/socks5 golang.org/x/net/proxy \
         github.com/urfave/cli github.com/txthinking/gotun2socks
}

build() {
  cd brook-$pkgver/cli/brook
  go build -o brook
}

package() {
  cd brook-$pkgver/cli/brook
  install -Dm755 brook "$pkgdir"/usr/bin/brook
}
