# $Id: PKGBUILD 145190 2015-10-28 12:15:28Z fyan $
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: alphazo <alphazo@gmail.com>

pkgname=sshuttle
pkgver=0.72
pkgrel=1
pkgdesc='Transparent proxy server that forwards all TCP packets over ssh'
arch=('any')
url="https://github.com/sshuttle/sshuttle"
license=('GPL2')
depends=('python2' 'iptables' 'openssh' 'net-tools')
makedepends=('git' 'pandoc')
backup=('etc/sshuttle/tunnel.conf' 'etc/sshuttle/prefixes.conf')
source=("git+https://github.com/sshuttle/$pkgname.git#tag=$pkgname-$pkgver"
        'sshuttle.service' 'arch-install.patch')
md5sums=('SKIP'
         'f2cd1660dcdb4e24b45b71e589da73f3'
         '15ed72e2b68dd07ef97abfdcb828d188')

prepare() {
  cd $pkgname/src
  patch -p1 -i "$srcdir/arch-install.patch"

  sed -i 's#/usr/bin/env python#/usr/bin/env python2#' stresstest.py
}

build() {
  cd $pkgname/src
  make
}

package() {
  cd $pkgname/src
  install -Dm755 sshuttle "$pkgdir/usr/bin/sshuttle"

  install -d "$pkgdir/usr/share/sshuttle"
  cp -r *.py compat "$pkgdir/usr/share/sshuttle"/

  install -Dm644 sshuttle.8 "$pkgdir/usr/share/man/man8/sshuttle.8"

  cd ..
  install -d "$pkgdir/etc/sshuttle"
  install -Dm644 packaging/{tunnel.conf,prefixes.conf} "$pkgdir/etc/sshuttle"
  install -Dm644 "$srcdir/sshuttle.service" "$pkgdir/usr/lib/systemd/system/sshuttle.service"
}
