Statistics
| Branch: | Tag: | Revision:

mininet / util / build-ovs-packages.sh @ master

History | View | Annotate | Download (2.86 KB)

1
#!/bin/bash
2

    
3
# Attempt to build debian packages for OVS
4

    
5
set -e  # exit on error
6
set -u  # exit on undefined variable
7

    
8
kvers=`uname -r`
9
ksrc=/lib/modules/$kvers/build
10
dist=`lsb_release -is | tr [A-Z] [a-z]`
11
release=`lsb_release -rs`
12
arch=`uname -m`
13
buildsuffix=-2
14
if [ "$arch" = "i686" ]; then arch=i386; fi
15
if [ "$arch" = "x86_64" ]; then arch=amd64; fi
16

    
17
overs=1.4.0
18
ovs=openvswitch-$overs
19
ovstgz=$ovs.tar.gz
20
ovsurl=http://openvswitch.org/releases/$ovstgz
21

    
22
install='sudo apt-get install -y'
23

    
24
echo "*** 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

    
29
echo "*** Installing OVS dependencies"
30
 $install pkg-config gcc make python-dev libssl-dev libtool
31
 $install dkms ipsec-tools
32

    
33
echo "*** Installing headers for $kvers"
34
 $install linux-headers-$kvers
35

    
36
echo "*** Retrieving OVS source"
37
 wget -c $ovsurl
38
 tar xzf $ovstgz
39
 cd $ovs
40

    
41
echo "*** 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

    
59
echo "*** 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

    
63
echo "*** 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

    
69
echo "*** Built the following packages:"
70
 cd ~
71
 ls -l *deb
72

    
73
archive=ovs-$overs-core-$dist-$release-$arch$buildsuffix.tar
74
ovsbase='common pki switch brcompat controller datapath-dkms'
75
echo "*** Packing up $ovsbase .debs into:"
76
echo "    $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

    
90
echo "*** Contents of archive $archive:"
91
 tar tf $archive
92

    
93
echo "*** Done (hopefully)"
94