blob: 6a14659f477ebf9a9d70e2b9b7000acd4b7a370a [file] [log] [blame]
carlosmscabralf40ecd12013-02-01 18:15:58 -02001#!/bin/bash
2
3# Attempt to build debian packages for OVS
4
5set -e # exit on error
6set -u # exit on undefined variable
7
8kvers=`uname -r`
9ksrc=/lib/modules/$kvers/build
10dist=`lsb_release -is | tr [A-Z] [a-z]`
11release=`lsb_release -rs`
12arch=`uname -m`
13buildsuffix=-2
14if [ "$arch" = "i686" ]; then arch=i386; fi
15if [ "$arch" = "x86_64" ]; then arch=amd64; fi
16
17overs=1.4.0
18ovs=openvswitch-$overs
19ovstgz=$ovs.tar.gz
20ovsurl=http://openvswitch.org/releases/$ovstgz
21
22install='sudo apt-get install -y'
23
24echo "*** Installing debian/ubuntu build system"
25 $install build-essential devscripts ubuntu-dev-tools debhelper dh-make
26 $install diff patch cdbs quilt gnupg fakeroot lintian pbuilder piuparts
27 $install module-assistant
28
29echo "*** Installing OVS dependencies"
30 $install pkg-config gcc make python-dev libssl-dev libtool
31 $install dkms ipsec-tools
32
33echo "*** Installing headers for $kvers"
34 $install linux-headers-$kvers
35
36echo "*** Retrieving OVS source"
37 wget -c $ovsurl
38 tar xzf $ovstgz
39 cd $ovs
40
41echo "*** Patching OVS source"
42 # Not sure why this fails, but off it goes!
43 sed -i -e 's/dh_strip/# dh_strip/' debian/rules
44 if [ "$release" = "10.04" ]; then
45 # Lucid doesn't seem to have all the packages for ovsdbmonitor
46 echo "*** Patching debian/rules to remove dh_python2"
47 sed -i -e 's/dh_python2/dh_pysupport/' debian/rules
48 echo "*** Not building ovsdbmonitor since it's too hard on 10.04"
49 mv debian/ovsdbmonitor.install debian/ovsdbmonitor.install.backup
50 sed -i -e 's/ovsdbmonitor.install/ovsdbmonitor.install.backup/' Makefile.in
51 else
52 # Install a bag of hurt for ovsdbmonitor
53 $install python-pyside.qtcore pyqt4-dev-tools python-twisted python-twisted-bin \
54 python-twisted-core python-twisted-conch python-anyjson python-zope.interface
55 fi
56 # init script was written to assume that commands complete
57 sed -i -e 's/^set -e/#set -e/' debian/openvswitch-controller.init
58
59echo "*** Building OVS user packages"
60 opts=--with-linux=/lib/modules/`uname -r`/build
61 fakeroot make -f debian/rules DATAPATH_CONFIGURE_OPTS=$opts binary
62
63echo "*** Building OVS datapath kernel module package"
64 # Still looking for the "right" way to do this...
65 sudo mkdir -p /usr/src/linux
66 ln -sf _debian/openvswitch.tar.gz .
67 sudo make -f debian/rules.modules KSRC=$ksrc KVERS=$kvers binary-modules
68
69echo "*** Built the following packages:"
70 cd ~
71 ls -l *deb
72
73archive=ovs-$overs-core-$dist-$release-$arch$buildsuffix.tar
74ovsbase='common pki switch brcompat controller datapath-dkms'
75echo "*** Packing up $ovsbase .debs into:"
76echo " $archive"
77 pkgs=""
78 for component in $ovsbase; do
79 if echo $component | egrep 'dkms|pki'; then
80 # Architecture-independent packages
81 deb=(openvswitch-${component}_$overs*all.deb)
82 else
83 deb=(openvswitch-${component}_$overs*$arch.deb)
84 fi
85 pkgs="$pkgs $deb"
86 done
87 rm -rf $archive
88 tar cf $archive $pkgs
89
90echo "*** Contents of archive $archive:"
91 tar tf $archive
92
93echo "*** Done (hopefully)"
94