Build kernel in another directory and README.md update for fuel-plugin
[kvmfornfv.git] / fuel-plugin / build_kvm.sh
1 #!/bin/bash
2
3 SRC=/root
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 #
26 # Build kernel in another directory, so some files (which are root writeable only) generated during kernel
27 #   building wouldn't remain in the source directory mapped into Docker container
28 #
29 cp -r /kvmfornfv $SRC/.
30 cd $SRC
31
32 # Get the Open VSwitch sources
33 rm -rf ovs
34 git clone https://github.com/openvswitch/ovs.git
35 cd ovs; git checkout $OVS_COMMIT
36
37 cd $SRC/kvmfornfv/
38 quirks kernel
39
40 cd kernel
41
42 # Workaround build bug on Ubuntu 14.04
43 cat <<EOF > arch/x86/boot/install.sh
44 #!/bin/sh
45 cp -a -- "\$2" "\$4/vmlinuz-\$1"
46 EOF
47
48 # Configure the kernel
49 cp $CONFIG .config
50
51 make oldconfig </dev/null
52
53 # Build the kernel debs
54 make-kpkg clean
55
56 fakeroot make-kpkg --initrd --revision=$VERSION kernel_image kernel_headers
57
58 # Build OVS kernel modules
59 cd ../../ovs
60
61 quirks ovs
62 pip install six
63
64 ./boot.sh
65 ./configure --with-linux=$SRC/kvmfornfv/kernel
66 make
67
68 # Add OVS kernel modules to kernel deb
69 dpkg-deb -x $SRC/kvmfornfv/linux-image*.deb ovs.$$
70 dpkg-deb --control $SRC/kvmfornfv/linux-image*.deb ovs.$$/DEBIAN
71 cp datapath/linux/*.ko ovs.$$/lib/modules/*/kernel/net/openvswitch
72 depmod -b ovs.$$ -a `ls ovs.$$/lib/modules`
73 dpkg-deb -b ovs.$$ $SRC/kvmfornfv/linux-image*.deb
74 rm -rf ovs.$$
75
76 cp $SRC/kvmfornfv/linux-headers*.deb /kvmfornfv/.
77 cp $SRC/kvmfornfv/linux-image*.deb /kvmfornfv/.
78