# Contributor: Sergej Pupykin
# Maintainer: Tobias Powalowski <tpowa@archlinux.org>
pkgname=vde2
pkgver=2.3.2
pkgrel=16
pkgdesc="Virtual Distributed Ethernet for emulators like qemu"
url="https://sourceforge.net/projects/vde/"
license=("GPL" "LGPL" "CUSTOM")
arch=('x86_64')
depends=('bash' 'libpcap' 'openssl')
makedepends=('python')
source=(https://downloads.sourceforge.net/vde/$pkgname-$pkgver.tar.bz2
        vde_cryptcab-compile-against-openssl-1.1.0.patch
        dhcpd.conf.sample
        iptables.rules.sample
        vde-config.sample
        vde-connection.sample)
install=vde2.install
options=(!makeflags)
sha256sums=('cbea9b7e03097f87a6b5e98b07890d2275848f1fe4b9fcda77b8994148bc9542'
            '110370a5f48f1e241d43f8bb5e3ea6d2ca7d2c1949e1cf672d03bfc897f2e11f'
            'da0e2766dc63069da929c28126831ad5fdddcc4a04105a21217d78832c7ca1bc'
            '99076d7466cd99673dbe91ef83865187e7868177959b38e125df63eea957f83e'
            '5727c215646333c37b26388146cd3e6b3814b88d60d54051d7da99e00c0aef87'
            '5139110ed6d5d1174bf12971512dac5196d9d07df46dd393d7b1cd083118fe9b')

prepare() {
  cd $pkgname-$pkgver
  patch -Np1 -i ../vde_cryptcab-compile-against-openssl-1.1.0.patch
}

build() {
  cd $pkgname-$pkgver
  ./configure --prefix=/usr --sbindir=/usr/bin --sysconfdir=/etc --libexecdir=/usr/lib/vde2 \
             --enable-experimental
  make
}

package() {
  cd $pkgname-$pkgver 
  make prefix="$pkgdir/usr" sysconfdir="$pkgdir/etc" sbindir="$pkgdir/usr/bin" libexecdir="$pkgdir/usr/lib/vde2" install
  install -D -m 644 ../vde-config.sample "$pkgdir"/etc/vde/vde-config.sample
  install -D -m 644 ../vde-connection.sample "$pkgdir"/etc/vde/vde-connection.sample
  install -D -m 644 ../dhcpd.conf.sample "$pkgdir"/usr/share/vde2/dhcpd.conf.sample
  install -D -m 644 ../iptables.rules.sample "$pkgdir"/usr/share/vde2/iptables.rules.sample
  # install slirp license
  install -D -m 644 COPYING.slirpvde "$pkgdir"/usr/share/licenses/vde2/COPYING.slirpvde
}
