From 2f62f05d45b76d410ffdc91a6d3c1c413b7db759 Mon Sep 17 00:00:00 2001 From: Sean Donner Date: Tue, 11 May 2010 20:01:45 +0200 Subject: [PATCH] network/vde2: Added to 12.0 repository --- network/vde2/README | 45 ++++++++++++++++++ network/vde2/doinst.sh | 16 +++++++ network/vde2/rc.vde2 | 74 +++++++++++++++++++++++++++++ network/vde2/slack-desc | 19 ++++++++ network/vde2/vde2.SlackBuild | 92 ++++++++++++++++++++++++++++++++++++ network/vde2/vde2.info | 8 ++++ 6 files changed, 254 insertions(+) create mode 100644 network/vde2/README create mode 100644 network/vde2/doinst.sh create mode 100644 network/vde2/rc.vde2 create mode 100644 network/vde2/slack-desc create mode 100644 network/vde2/vde2.SlackBuild create mode 100644 network/vde2/vde2.info diff --git a/network/vde2/README b/network/vde2/README new file mode 100644 index 0000000000..d893cc50f0 --- /dev/null +++ b/network/vde2/README @@ -0,0 +1,45 @@ +VDE is an ethernet compliant virtual network which includes tools such +as 'vde_switch' and 'vdeqemu'. VDE switch has several virtual ports +where virtual machines, applications, virtual interfaces and +connectivity tools can be virtually plugged in. VDE qemu works as a +wrapper for running qemu virtual machines that connects transparently +to a specified vde_switch + +VDE is dependant upon TUN/TAP support in the Linux Kernel; this comes +enabled by default with Slackware 12's 'generic' kernel. To enable +TUN/TAP support manually, you must set the following entry in your +kernel's '.config' file and recompile: + CONFIG_TUN=m + +## Configuration +An init script has been provided in /etc/rc.d/rc.vde2 to use with +vde_switch. Edit this script and provide the TAP inteface name as +well as the subnet for your Virtual Switch to use. Do NOT choose +a subnet which is already in use. More than likely, the default +values will work fine. + +## VDE + Qemu +A common usage for vde_switch is to be able to have emulated OS's +via Qemu behave as if they were actually attached to a Local Network. +To enable this functionality with Qemu, replace any calls to 'qemu' +with the following command: + +vdeqemu -net vde,vlan=0 -net nic,vlan=0,macaddr=AA:BB:CC:DD:EE:FF + +Note that the 'macaddr' string is optional but can prove to be +quite useful when used in conjuction with a DHCP server (such as +dhcpd or dnsmasq) to assign IP's based upon MAC address. + +Do not forget to include the options which point vdeqemu to your +ISO image to boot along with any other options you may have used +with 'qemu' such as -localtime, -nographic etc. + +## Startup +To have this start upon each boot, add the following lines to +/etc/rc.d/rc.local and make sure rc.vde2 is executable. + + # Start vde_switch + if [ -x /etc/rc.d/rc.vde2 ]; then + /etc/rc.d/rc.vde2 start + fi + diff --git a/network/vde2/doinst.sh b/network/vde2/doinst.sh new file mode 100644 index 0000000000..d75f2a95fc --- /dev/null +++ b/network/vde2/doinst.sh @@ -0,0 +1,16 @@ +#!/bin/sh +config() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + # If there's no config file by that name, mv it over: + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then + # toss the redundant copy + rm $NEW + fi + # Otherwise, we leave the .new copy for the admin to consider... +} + +config etc/rc.d/rc.vde2.new + diff --git a/network/vde2/rc.vde2 b/network/vde2/rc.vde2 new file mode 100644 index 0000000000..9cc1beceb0 --- /dev/null +++ b/network/vde2/rc.vde2 @@ -0,0 +1,74 @@ +#!/bin/sh + +#=========================== EDIT THE FOLLOWING VARIABLES ========================== +# _________________________________________________________________________________ +# | | +# | Interface name to use for the TAP device | +# | | + TAP_IF="tap0" +# |_________________________________________________________________________________| +# | | +# | IP Address/Subnet in CIDR Notation for the Virtual Network | +# | | + TAP_NET="10.10.10.1/24" +# |_________________________________________________________________________________| +# +#=========================== DO NOT EDIT BELOW THIS LINE ============================ + +start(){ + echo -n "Starting VDE Switch..." + + # Load tun module + modprobe tun || { echo "Error, cannot load 'tun' module. Exiting..." ; exit 1 ; } + sleep 1 + + # Start tap switch + vde_switch -tap ${TAP_IF} -daemon || { echo "Error, cannot assign IP to ${TAP_IF}. Exiting..." ; exit 1 ; } + + # Bring tap interface up + ip addr add ${TAP_NET} dev ${TAP_IF} + ip link set ${TAP_IF} up + + #chmod 666 /tmp/vde.ctl + chmod -R a+rwx /var/run/vde.ctl + + # Apply workaround + echo 1024 > /proc/sys/dev/rtc/max-user-freq + echo +} + + +stop(){ + echo -n "Stopping VDE Switch..." + + # Bring tap interface down + ip addr flush dev ${TAP_IF} + ip link set ${TAP_IF} down + + # Kill VDE switch + kill $(pgrep vde_switch) + sleep 1 + + # Remove tun module + modprobe -r tun + echo +} + + +case "$1" in + start) + start + ;; + + stop) + stop + ;; + + restart) + stop + start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + ;; +esac diff --git a/network/vde2/slack-desc b/network/vde2/slack-desc new file mode 100644 index 0000000000..951972c6ea --- /dev/null +++ b/network/vde2/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. Line +# up the first '|' above the ':' following the base package name, and the '|' +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':'. + + |-----handy-ruler------------------------------------------------------| +vde2: Virtual Distributed Ethernet (VDE) +vde2: +vde2: VDE is an ethernet compliant virtual network which includes tools such +vde2: as 'vde_switch' and 'vdeqemu'. VDE switch has several virtual ports +vde2: where virtual machines, applications, virtual interfaces and +vde2: connectivity tools can be virtually plugged in. VDE qemu works as a +vde2: wrapper for running qemu virtual machines that connects transparently +vde2: to a specified vde_switch +vde2: +vde2: +vde2: diff --git a/network/vde2/vde2.SlackBuild b/network/vde2/vde2.SlackBuild new file mode 100644 index 0000000000..66e96e644d --- /dev/null +++ b/network/vde2/vde2.SlackBuild @@ -0,0 +1,92 @@ +#!/bin/sh + +# Slackware build script for VDE2 + +# Copyright 2007-2008 Sean Donner (sean.donner@sbcglobal.net) +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +PRGNAM=vde2 +VERSION=2.1.6 +ARCH=${ARCH:-i486} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} + +CWD=$(pwd) +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +if [ "$ARCH" = "i486" ]; then + SLKCFLAGS="-O2 -march=i486 -mtune=i686" +elif [ "$ARCH" = "i686" ]; then + SLKCFLAGS="-O2 -march=i686 -mtune=i686" +fi + +rm -rf $PKG +mkdir -p $TMP $PKG $OUTPUT +cd $TMP +rm -rf $PRGNAM-$VERSION +tar xvf $CWD/$PRGNAM-$VERSION.tar.bz2 || exit 1 +cd $PRGNAM-$VERSION +chown -R root:root . +chmod -R u+w,go+r-w,a-s . + +CFLAGS="$SLKCFLAGS" \ +CXXFLAGS="$SLKCFLAGS" \ +./configure \ + --prefix=/usr \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --datarootdir=/usr \ + --datadir=/usr/share + +make all || exit 1 +make install DESTDIR=$PKG || exit 1 + +( cd $PKG + find . -exec file {} + | sed -n '/ELF.*executable\|shared object/{ s/:.*//p }' | xargs strip --strip-unneeded + find . -exec file {} + | sed -n '/current ar archive/{ s/:.*//p }' | xargs strip --strip-debug +) + +( cd $PKG/usr/man + find . -type f -exec gzip -9 {} + +) + +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION + cp uml/README README.uml + cp qemu/README README.qemu + cp bochs/README README.bochs + cp slirpvde/README README.slirpvde + cp slirpvde/COPYRIGHT COPYRIGHT.slirpvde + cp libvdeplug/COPYING COPYING.libvdeplug + +cp -a COPYING* COPYRIGHT* LICENSE* README* \ + $PKG/usr/doc/$PRGNAM-$VERSION +cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild + +mkdir -p $PKG/etc/rc.d +install -m 0755 $CWD/rc.vde2 $PKG/etc/rc.d/rc.vde2.new + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc +cat $CWD/doinst.sh > $PKG/install/doinst.sh + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.tgz diff --git a/network/vde2/vde2.info b/network/vde2/vde2.info new file mode 100644 index 0000000000..26ee4d3382 --- /dev/null +++ b/network/vde2/vde2.info @@ -0,0 +1,8 @@ +PRGNAM="vde2" +VERSION="2.1.6" +HOMEPAGE="http://vde.sourceforge.net" +DOWNLOAD="http://downloads.sourceforge.net/vde/vde2-2.1.6.tar.bz2" +MD5SUM="68a9a5c4c8cf713bd4d97acc1eb341a6" +MAINTAINER="Sean Donner" +EMAIL="sean.donner@sbcglobal.net" +APPROVED="rworkman"