From 2a4cbe2f575c9ec4176ef8ef4d365259873e187e Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Mon, 13 Feb 2012 01:29:01 -0800 Subject: [PATCH] Fix OVS 1.4.0 switch and controller package build/remove/install. --- util/build-ovs-packages.sh | 20 ++++++---- util/install.sh | 75 +++++++++++++++++++++++++++++++++----- 2 files changed, 78 insertions(+), 17 deletions(-) diff --git a/util/build-ovs-packages.sh b/util/build-ovs-packages.sh index 6f1b02a..23c2757 100755 --- a/util/build-ovs-packages.sh +++ b/util/build-ovs-packages.sh @@ -10,6 +10,7 @@ ksrc=/lib/modules/$kvers/build dist=`lsb_release -is | tr [A-Z] [a-z]` release=`lsb_release -rs` arch=`uname -m` +buildsuffix=-1 if [ "$arch" = "i686" ]; then arch=i386; fi if [ "$arch" = "x86_64" ]; then arch=amd64; fi @@ -52,6 +53,8 @@ echo "*** Patching OVS source" $install python-pyside.qtcore pyqt4-dev-tools python-twisted python-twisted-bin \ python-twisted-core python-twisted-conch python-anyjson python-zope.interface fi + # init script was written to assume that commands complete + sed -i -e 's/^set -e/#set -e/' debian/openvswitch-controller.init echo "*** Building OVS user packages" opts=--with-linux=/lib/modules/`uname -r`/build @@ -67,15 +70,18 @@ echo "*** Built the following packages:" cd ~ ls -l *deb -archive=$ovs-core-$dist-$release-$arch.tar -ovsbase='common switch brcompat controller' -echo "*** Packing up dkml pki $ovsbase .debs into:" +archive=ovs-$overs-core-$dist-$release-$arch$buildsuffix.tar +ovsbase='common pki switch brcompat controller datapath-dkms' +echo "*** Packing up $ovsbase .debs into:" echo " $archive" - dppkg=openvswitch-datapath-dkms_$overs*all.deb - pkipkg=openvswitch-pki_$overs*all.deb - pkgs="$dppkg $pkipkg" + pkgs="" for component in $ovsbase; do - deb=(openvswitch-${component}_$overs*$arch.deb) + if echo $component | egrep 'dkms|pki'; then + # Architecture-independent packages + deb=(openvswitch-${component}_$overs*all.deb) + else + deb=(openvswitch-${component}_$overs*$arch.deb) + fi pkgs="$pkgs $deb" done rm -rf $archive diff --git a/util/install.sh b/util/install.sh index 1792909..9fd0927 100755 --- a/util/install.sh +++ b/util/install.sh @@ -18,13 +18,18 @@ DIST=Unknown RELEASE=Unknown CODENAME=Unknown ARCH=`uname -m` +if [ "$ARCH" = "x86_64" ]; then ARCH="amd64"; fi +if [ "$ARCH" = "686" ]; then ARCH="i386"; fi test -e /etc/debian_version && DIST="Debian" grep Ubuntu /etc/lsb-release &> /dev/null && DIST="Ubuntu" if [ "$DIST" = "Ubuntu" ] || [ "$DIST" = "Debian" ]; then install='sudo apt-get -y install' remove='sudo apt-get -y remove' - $install -y lsb-release + pkginst='sudo dpkg -i' + if ! which lsb_release &> /dev/null; then + $install -y lsb-release + fi fi if which lsb_release &> /dev/null; then DIST=`lsb_release -is` @@ -51,13 +56,20 @@ else exit 1 fi +# More distribution info +DIST_LC=`echo $DIST | tr [A-Z] [a-z]` # as lower case + # Kernel Deb pkg to be removed: KERNEL_IMAGE_OLD=linux-image-2.6.26-2-686 DRIVERS_DIR=/lib/modules/${KERNEL_NAME}/kernel/drivers/net -OVS_RELEASE=v1.2.2 +OVS_RELEASE=1.4.0 +OVS_PACKAGE_LOC=https://github.com/downloads/mininet/mininet +OVS_BUILDSUFFIX=-1 +OVS_PACKAGE_NAME=ovs-$OVS_RELEASE-core-$DIST_LC-$RELEASE-$ARCH$OVS_BUILDSUFFIX.tar OVS_SRC=~/openvswitch +OVS_TAG=v$OVS_RELEASE OVS_BUILD=$OVS_SRC/build-$KERNEL_NAME OVS_KMODS=($OVS_BUILD/datapath/linux/{openvswitch_mod.ko,brcompat_mod.ko}) @@ -66,14 +78,13 @@ function kernel { sudo apt-get update if [ "$DIST" = "Ubuntu" ] && [ "$RELEASE" = "10.04" ]; then $install linux-image-$KERNEL_NAME - fi elif [ "$DIST" = "Debian" ]; then # The easy approach: download pre-built linux-image and linux-headers packages: wget -c $KERNEL_LOC/$KERNEL_HEADERS wget -c $KERNEL_LOC/$KERNEL_IMAGE # Install custom linux headers and image: - sudo dpkg -i $KERNEL_IMAGE $KERNEL_HEADERS + $pkginst $KERNEL_IMAGE $KERNEL_HEADERS # The next two steps are to work around a bug in newer versions of # kernel-package, which fails to add initrd images with the latest kernels. @@ -185,11 +196,32 @@ function of { function ovs { echo "Installing Open vSwitch..." - if [ "$DIST" = "Ubuntu" ]; then - if [ `echo "$RELEASE >= 11.10" | bc` = 1 ]; then - # Use upstream OVS packages - $install openvswitch-switch openvswitch-controller + # First see if we have packages + # XXX wget -c seems to fail from github/amazon s3 + if wget $OVS_PACKAGE_LOC/$OVS_PACKAGE_NAME; then + # Install dkms dependencies + $install patch dkms fakeroot + tar xf $OVS_PACKAGE_NAME + orig=`tar tf $OVS_PACKAGE_NAME` + # Now install packages in reasonable dependency order + order='common pki openvswitch-switch brcompat controller dkms' + pkgs="" + for p in $order; do + pkg=`echo "$orig" | grep $p` + pkgs="$pkgs $pkg" + done + echo PKGS $pkgs + $pkginst $pkgs + sudo service openvswitch-controller stop + echo "Done (hopefully) installing packages" + return + fi + + # Otherwise try distribution's OVS packages + if [ "$DIST" = "Ubuntu" ] && [ `echo "$RELEASE >= 11.10" | bc` = 1 ]; then + if $install openvswitch-switch openvswitch-controller; then return + fi fi $install $KERNEL_HEADERS @@ -213,7 +245,7 @@ function ovs { cd ~/ git clone git://openvswitch.org/openvswitch $OVS_SRC cd $OVS_SRC - git checkout $OVS_RELEASE + git checkout $OVS_TAG ./boot.sh BUILDDIR=/lib/modules/${KERNEL_NAME}/build if [ ! -e $BUILDDIR ]; then @@ -228,6 +260,27 @@ function ovs { sudo make install } +function remove_ovs { + pkgs=`dpkg-query -l | grep openvswitch | awk '{ print $2;}'` + echo "Removing existing Open vSwitch packages:" + echo $pkgs + if ! $remove $pkgs; then + echo "Not all packages removed correctly" + fi + # For some reason this doesn't happen + if scripts=`ls /etc/init.d/*openvswitch* 2>/dev/null`; then + echo $scripts + for s in $scripts; do + s=$(basename $s) + echo SCRIPT $s + sudo service $s stop + sudo rm -f /etc/init.d/$s + sudo update-rc.d -f $s remove + done + fi + echo "Done removing OVS" +} + # Install NOX with tutorial files function nox { echo "Installing NOX w/tutorial files..." @@ -407,6 +460,7 @@ function usage { printf -- ' -k: install new (K)ernel\n' >&2 printf -- ' -m: install Open vSwitch kernel (M)odule\n' >&2 printf -- ' -n: install mini(N)et dependencies + core files\n' >&2 + printf -- ' -r: remove existing Open vSwitch packages\n' >&2 printf -- ' -t: install o(T)her stuff\n' >&2 printf -- ' -v: install open (V)switch\n' >&2 printf -- ' -x: install NO(X) OpenFlow controller\n' >&2 @@ -419,7 +473,7 @@ if [ $# -eq 0 ] then all else - while getopts 'abcdfhkmntvx' OPTION + while getopts 'abcdfhkmnrtvx' OPTION do case $OPTION in a) all;; @@ -431,6 +485,7 @@ else k) kernel;; m) modprobe;; n) mn_deps;; + r) remove_ovs;; t) other;; v) ovs;; x) nox;;