9984f3babb0c023055816bcacd22c97c91e06f3c
[kvmfornfv.git] / fuel-plugin / build_kvm.sh
1 #!/bin/bash
2
3 SRC=/
4 CONFIG="arch/x86/configs/opnfv.config"
5 VERSION="1.0.OPNFV"
6 OVS_COMMIT="4ff6642f3c1dd8949c2f42b3310ee2523ee970a6"
7
8 quirks() {
9 #
10 # Apply out of tree patches
11 #
12 for i in $SRC/kvmfornfv/patches/$1/*.patch
13 do
14     if [ -f "$i" ]
15     then
16         echo "Applying: $i"
17         patch -p1 <$i
18     fi
19 done
20 }
21
22 apt-get update
23 apt-get install -y git fakeroot build-essential ncurses-dev xz-utils kernel-package bc autoconf automake libtool python python-pip
24
25 cd $SRC
26
27 # Get the Open VSwitch sources
28 rm -rf ovs
29 git clone https://github.com/openvswitch/ovs.git
30 cd ovs; git checkout $OVS_COMMIT
31
32 cd $SRC/kvmfornfv/
33 quirks kernel
34
35 cd kernel
36
37 # Workaround build bug on Ubuntu 14.04
38 cat <<EOF > arch/x86/boot/install.sh
39 #!/bin/sh
40 cp -a -- "\$2" "\$4/vmlinuz-\$1"
41 EOF
42
43 # Configure the kernel
44 cp $CONFIG .config
45
46 make oldconfig </dev/null
47
48 # Build the kernel debs
49 make-kpkg clean
50
51 fakeroot make-kpkg --initrd --revision=$VERSION kernel_image kernel_headers
52
53 # Build OVS kernel modules
54 cd ../../ovs
55
56 quirks ovs
57 pip install six
58
59 ./boot.sh
60 ./configure --with-linux=$SRC/kvmfornfv/kernel
61 make
62
63 # Add OVS kernel modules to kernel deb
64 dpkg-deb -x $SRC/kvmfornfv/linux-image*.deb ovs.$$
65 dpkg-deb --control $SRC/kvmfornfv/linux-image*.deb ovs.$$/DEBIAN
66 cp datapath/linux/*.ko ovs.$$/lib/modules/*/kernel/net/openvswitch
67 depmod -b ovs.$$ -a `ls ovs.$$/lib/modules`
68 dpkg-deb -b ovs.$$ $SRC/kvmfornfv/linux-image*.deb
69 rm -rf ovs.$$
70