summaryrefslogtreecommitdiff
path: root/user/vde2
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2018-07-27 04:21:53 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2018-07-27 04:21:53 -0500
commitdde7c77d0c5af6b66a6ca69376135558b7c11e8c (patch)
tree65f6ee81e380d85337ad571d0cc44f65535dcadb /user/vde2
parent2d93668279aed9d04d659e1c353691e3ff19b58d (diff)
downloadpackages-dde7c77d0c5af6b66a6ca69376135558b7c11e8c.tar.gz
packages-dde7c77d0c5af6b66a6ca69376135558b7c11e8c.tar.bz2
packages-dde7c77d0c5af6b66a6ca69376135558b7c11e8c.tar.xz
packages-dde7c77d0c5af6b66a6ca69376135558b7c11e8c.zip
user/vde2: pull in, fix, modernise
Diffstat (limited to 'user/vde2')
-rw-r--r--user/vde2/APKBUILD58
-rw-r--r--user/vde2/musl-build-fix.patch15
-rw-r--r--user/vde2/vde2.post-down37
-rw-r--r--user/vde2/vde2.pre-install6
-rw-r--r--user/vde2/vde2.pre-up74
5 files changed, 190 insertions, 0 deletions
diff --git a/user/vde2/APKBUILD b/user/vde2/APKBUILD
new file mode 100644
index 000000000..f30051321
--- /dev/null
+++ b/user/vde2/APKBUILD
@@ -0,0 +1,58 @@
+# Maintainer:
+pkgname=vde2
+pkgver=2.3.2
+pkgrel=8
+pkgdesc="Virtual Distributed Ethernet - User mode networking for QEMU et al"
+url="http://vde.sourceforge.net/"
+arch="all"
+options="!check" # No test suite.
+license="GPL"
+depends="openssl"
+makedepends="linux-headers libpcap-dev openssl-dev python3-dev"
+subpackages="$pkgname-doc $pkgname-dev $pkgname-libs"
+install="vde2.pre-install"
+source="http://downloads.sourceforge.net/project/vde/vde2/$pkgver/vde2-$pkgver.tar.gz
+ musl-build-fix.patch
+ vde2.pre-up
+ vde2.post-down
+ "
+
+prepare() {
+ cd "$builddir"
+ default_prepare
+
+ update_config_sub
+}
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc
+ make -C src/common
+ make -j1 -C src/lib
+ make
+}
+
+package() {
+ cd "$builddir"
+ make -j1 DESTDIR="$pkgdir" install
+
+ install -Dm755 "$srcdir"/vde2.pre-up \
+ "$pkgdir"/etc/network/if-pre-up.d/vde2
+ install -Dm755 "$srcdir"/vde2.post-down \
+ "$pkgdir"/etc/network/if-post-down.d/vde2
+}
+
+libs() {
+ pkgdesc="Virtual Distributed Ethernet libraries"
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/lib*.so.* "$subpkgdir"/usr/lib/
+}
+
+sha512sums="b502ceac8eebd30694a25d913c1d321b58ec8ae97dec0b09acc40455f7a97c05040ff395242c144580a9d9d5cb19292055bc94133ea1bde66bfdab40844533a8 vde2-2.3.2.tar.gz
+52d02c3a5a4f5526ed2e653e5720f012501215c0440e26105c585ea0501423da04047f6bad13a71b7378397a9d9274b191007d839876b675e206ed5be0f25372 musl-build-fix.patch
+71b29d538bba80b881f239d683215279089c14e8feec05bf27c159ead51094cdfb168281900fa4527f588c624e8f7687df8d3f79377e07d13ad64de613177df3 vde2.pre-up
+d1cf18146145dbe608842c694b05d2906e36553b0ba3fa1ec2e53dbf06027b9e4937ea61aee77c1ccbb73b818f19d55787051eb6d5b09a38c7d18a1dad629190 vde2.post-down"
diff --git a/user/vde2/musl-build-fix.patch b/user/vde2/musl-build-fix.patch
new file mode 100644
index 000000000..c03459c6e
--- /dev/null
+++ b/user/vde2/musl-build-fix.patch
@@ -0,0 +1,15 @@
+diff --git a/src/vdetaplib/libvdetap.c b/src/vdetaplib/libvdetap.c
+index 00cd401..c70f290 100644
+--- a/src/vdetaplib/libvdetap.c
++++ b/src/vdetaplib/libvdetap.c
+@@ -121,6 +121,10 @@ int open(const char *path, int flags, ...)
+ return native_open(path, flags, data);
+ }
+
++/* musl apparently defines open64 as a macro */
++#ifdef open64
++#undef open64
++#endif
+ int open64(const char *path, int flags, ...)
+ {
+ va_list ap;
diff --git a/user/vde2/vde2.post-down b/user/vde2/vde2.post-down
new file mode 100644
index 000000000..be5f5b31d
--- /dev/null
+++ b/user/vde2/vde2.post-down
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+VDE_SWITCH=/usr/bin/vde_switch
+SLIRPVDE=/usr/bin/slirpvde
+
+# this is not an interesting stanza for us
+if [ -z "$IF_VDE2_SWITCH" -a -z "$IF_VDE2_PLUG" -a -z "$IF_VDE2_SLIRP" ]; then
+ exit 0
+fi
+
+PIDFILE="/var/run/vde2/$IFACE-plug.pid"
+CTLFILE="/var/run/vde2/$IFACE.ctl"
+if [ -f $PIDFILE ]; then
+ start-stop-daemon --stop --quiet --pidfile $PIDFILE
+ rm -f $PIDFILE
+fi
+
+PIDFILE="/var/run/vde2/$IFACE-slirp.pid"
+if [ -f $PIDFILE ]; then
+ start-stop-daemon --stop --quiet --pidfile $PIDFILE \
+ --exec $SLIRPVDE
+ rm -f $PIDFILE
+fi
+
+PIDFILE="/var/run/vde2/$IFACE.pid"
+CTLDIR="/var/run/vde2/$IFACE.ctl"
+if [ -f $PIDFILE ]; then
+ start-stop-daemon --stop --quiet --pidfile $PIDFILE \
+ --exec $VDE_SWITCH
+ rm -f $PIDFILE
+
+ # set the tap interface to non-persistant, see #568363
+ vde_tunctl -b -d $IFACE 1>/dev/null
+fi
+
+rm -rf $CTLDIR
+rm -f $CTLDIR.*
diff --git a/user/vde2/vde2.pre-install b/user/vde2/vde2.pre-install
new file mode 100644
index 000000000..3c3e08d47
--- /dev/null
+++ b/user/vde2/vde2.pre-install
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+addgroup -S vde2-net 2>/dev/null
+adduser -S -D -H -h /var/run/vde2 -s /sbin/nologin -G vde2-net -g vde2-net vde2-net 2>/dev/null
+
+exit 0
diff --git a/user/vde2/vde2.pre-up b/user/vde2/vde2.pre-up
new file mode 100644
index 000000000..991b38226
--- /dev/null
+++ b/user/vde2/vde2.pre-up
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+VDE_SWITCH=/usr/bin/vde_switch
+VDE_PLUG=/usr/bin/vde_plug
+SLIRPVDE=/usr/bin/slirpvde
+DPIPE=/usr/bin/dpipe
+RUNDIR=/var/run/vde2
+
+USER=vde2-net
+GROUP=vde2-net
+
+if [ ! -x $VDE_SWITCH ] || [ ! -x $SLIRPVDE ]; then
+ exit 0
+fi
+
+# this is not an interesting stanza for us
+if [ -z "$IF_VDE2_SWITCH" -a -z "$IF_VDE2_PLUG" -a -z "$IF_VDE2_SLIRP" ]; then
+ exit 0
+fi
+
+
+# Create directory if missing
+if [ ! -d $RUNDIR ]; then
+ mkdir -p $RUNDIR
+ chown vde2-net:vde2-net $RUNDIR
+ chmod 2770 $RUNDIR
+fi
+
+# vde2-switch [-|<args>]
+if [ -n "$IF_VDE2_SWITCH" ]; then
+ set -- $IF_VDE2_SWITCH
+ test "$1" = "-" && shift
+ PIDFILE="$RUNDIR/$IFACE.pid"
+ CTLDIR="$RUNDIR/$IFACE.ctl"
+ MGMTFILE="$RUNDIR/$IFACE.mgmt"
+
+ if [ "$METHOD" = "manual" ]; then
+ TAPOPTS=""
+ else
+ TAPOPTS="-t $IFACE"
+ fi
+
+ # block to make sure the interface exists, see #568363
+ vde_tunctl -b -t $IFACE 1>/dev/null
+
+ start-stop-daemon --start --quiet --pidfile $PIDFILE \
+ --exec $VDE_SWITCH -- \
+ -s $CTLDIR -m 660 -g $GROUP -p $PIDFILE $TAPOPTS \
+ -M $MGMTFILE --mgmtmode 660 -d "$@"
+fi
+
+# vde2-plug <dpipe_cmd2>
+if [ -n "$IF_VDE2_PLUG" ]; then
+ set -- $IF_VDE2_PLUG
+ PIDFILE="$RUNDIR/$IFACE-plug.pid"
+ CTLDIR="$RUNDIR/$IFACE.ctl"
+
+ start-stop-daemon --start --quiet --pidfile $PIDFILE \
+ --make-pidfile --background \
+ --exec $DPIPE -- $VDE_PLUG -g $GROUP -m 660 $CTLDIR = "$@"
+fi
+
+# vde2-slirp [-|<args>]
+if [ -n "$IF_VDE2_SLIRP" ]; then
+ set -- $IF_VDE2_SLIRP
+ test "$1" = "-" && shift
+ PIDFILE="$RUNDIR/$IFACE-slirp.pid"
+ CTLDIR="$RUNDIR/$IFACE.ctl"
+
+ start-stop-daemon --start --quiet --pidfile $PIDFILE \
+ --chuid $USER \
+ --exec $SLIRPVDE -- \
+ -s $CTLDIR -m 660 -p $PIDFILE -d "$@"
+fi