# $Id: PKGBUILD 127548 2015-02-11 09:38:54Z fyan $
# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=shadowsocks
pkgver=2.6.8
pkgrel=1
pkgdesc="A lightweight tunnel proxy"
license=('Apache')
url="http://pypi.python.org/pypi/shadowsocks"
arch=('any')
depends=('python' 'python-setuptools')
optdepends=('libsodium: For salsa20 and chacha20 support')
install=${pkgname}.install
source=("http://pypi.python.org/packages/source/s/shadowsocks/shadowsocks-${pkgver}.tar.gz"
        "shadowsocks@.service"
        "shadowsocks-server@.service")
sha512sums=('5b674c3d101766261c891a01bff11f40d9e54fcd31f1f52e64ab9c3af4bee69447ee727af4a54f57dcb4f5b73f1051cd7c17a8199a9d74709b2b56f5da610d61'
            '96ecb174a476f64dec3ec086732d93a76d27e9a1cc56b1dc3fa87bf8e00d4b3c44076a01a0d525e42174cacc58fd5c16d5c8af5d4636dae13df549dec8204f7d'
            'f2f8240c18a4483bf3e03b3a5ac8822c3deae713224f732bf28f7fddfcc5d0b02aa91652665ff93f05731e162a9407109c18f43d732a3a9b19d9eacfc806a4df')

check() {
  cd shadowsocks-$pkgver

  # Tests not included
  return
  python tests/test.py -c tests/table.json
  python tests/test.py -c tests/aes.json
  python tests/test.py -c tests/rc4-md5.json
  python tests/test.py -c tests/salsa20.json
  python tests/test.py -c tests/server-multi-ports.json
  python tests/test.py -c tests/server-multi-passwd.json
  python tests/test.py -c tests/server-multi-passwd-table.json
  python tests/test.py -c tests/workers.json
}

package() {
  cd "$srcdir/shadowsocks-$pkgver"

  python setup.py install -O1 --root="$pkgdir"
  
  install -d "$pkgdir/etc/shadowsocks"
  install -Dm644 "$srcdir/shadowsocks@.service" "$pkgdir/usr/lib/systemd/system/shadowsocks@.service"
  install -Dm644 "$srcdir/shadowsocks-server@.service" "$pkgdir/usr/lib/systemd/system/shadowsocks-server@.service"
}
