e4af1023e8c0bd8491d1c76057ab989cb7c7f6a9
[kvmfornfv.git] / fuel-plugin / build_kvm.sh
1 #!/bin/bash
2
3 quirks() {
4         # Workaround build bug on Ubuntu 14.04
5         cat <<EOF > arch/x86/boot/install.sh
6 #!/bin/sh
7 cp -a -- "\$2" "\$4/vmlinuz-\$1"
8 EOF
9
10         # Add deprecated XFS delaylog option back in
11         cat <<EOF | patch -p2
12 diff --git a/kernel/fs/xfs/xfs_super.c b/kernel/fs/xfs/xfs_super.c
13 index 65a4537..b73ca67 100644
14 --- a/kernel/fs/xfs/xfs_super.c
15 +++ b/kernel/fs/xfs/xfs_super.c
16 @@ -109,6 +109,7 @@ static struct xfs_kobj xfs_dbg_kobj;        /* global debug sysfs attrs */
17  #define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
18  #define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
19  #define MNTOPT_QUOTANOENF  "qnoenforce"        /* same as uqnoenforce */
20 +#define MNTOPT_DELAYLOG    "delaylog"  /* Delayed logging enabled */
21  #define MNTOPT_DISCARD    "discard"    /* Discard unused blocks */
22  #define MNTOPT_NODISCARD   "nodiscard" /* Do not discard unused blocks */
23  
24 @@ -359,6 +360,9 @@ xfs_parseargs(
25                 } else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
26                         mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
27                         mp->m_qflags &= ~XFS_GQUOTA_ENFD;
28 +               } else if (!strcmp(this_char, MNTOPT_DELAYLOG)) {
29 +                       xfs_warn(mp,
30 +               "delaylog is the default now, option is deprecated.");
31                 } else if (!strcmp(this_char, MNTOPT_DISCARD)) {
32                         mp->m_flags |= XFS_MOUNT_DISCARD;
33                 } else if (!strcmp(this_char, MNTOPT_NODISCARD)) {
34 -- 
35 1.9.1
36
37 EOF
38 }
39
40 KVM_COMMIT=""
41 OVS_COMMIT="4ff6642f3c1dd8949c2f42b3310ee2523ee970a6"
42 KEEP=no
43 for i
44 do
45         case $i in
46
47         -k)     KEEP=yes
48                 shift
49                 ;;
50
51         -c)     KVM_COMMIT=$2
52                 shift;shift
53                 ;;
54
55         -o)     OVS_COMMIT=$2
56                 shift;shift
57                 ;;
58
59         esac
60 done
61
62 SRC=${1:-/root}
63 CONFIG=${2:-arch/x86/configs/opnfv.config}
64 VERSION=${3:-1.0.OPNFV}
65
66 # Check for necessary build tools
67 if ! type git >/dev/null 2>/dev/null
68 then
69         echo "Build tools missing, run the command
70
71 apt-get install git fakeroot build-essential ncurses-dev xz-utils kernel-package automake
72
73 as root and try again"
74         exit 1
75 fi
76
77 # Make sure the source dir exists
78 if [ ! -d $SRC ]
79 then
80         echo "$SRC: no such directory"
81         exit 1
82 fi
83
84 (
85         cd $SRC
86
87         # Get the Open VSwitch sources
88         if [ ! -d ovs ]
89         then
90                 git clone https://github.com/openvswitch/ovs.git
91         fi
92
93         # Get the KVM for NFV kernel sources
94         if [ ! -d kvmfornfv ]
95         then
96                 git clone https://gerrit.opnfv.org/gerrit/kvmfornfv
97         fi
98         cd kvmfornfv
99         git pull
100         if [ x$KVM_COMMIT != x ]
101         then
102                 git checkout $KVM_COMMIT
103         else
104                 git reset --hard
105         fi
106         cd kernel
107
108         quirks
109
110         # Configure the kernel
111         cp $CONFIG .config
112
113         make oldconfig </dev/null
114
115         # Build the kernel debs
116         if [ $KEEP = no ]
117         then
118                 make-kpkg clean
119         fi
120         fakeroot make-kpkg --initrd --revision=$VERSION kernel_image kernel_headers
121         git checkout arch/x86/boot/install.sh
122         git checkout fs/xfs/xfs_super.c
123
124         # Build OVS kernel modules
125         cd ../../ovs
126         if [ x$OVS_COMMIT != x ]
127         then
128                 git checkout $OVS_COMMIT
129         else
130                 git reset --hard
131         fi
132
133         #
134         # Apply out of tree patches
135         #
136         for i in $SRC/kvmfornfv/patches/ovs/*.patch
137         do
138                 if [ -f "$i" ]
139                 then
140                         echo "Applying: $i"
141                         patch -p1 <$i
142                 fi
143         done
144
145         ./boot.sh
146         ./configure --with-linux=$SRC/kvmfornfv/kernel
147         make
148
149         # Add OVS kernel modules to kernel deb
150         dpkg-deb -x $SRC/kvmfornfv/linux-image*.deb ovs.$$
151         dpkg-deb --control $SRC/kvmfornfv/linux-image*.deb ovs.$$/DEBIAN
152         cp datapath/linux/*.ko ovs.$$/lib/modules/*/kernel/net/openvswitch
153         depmod -b ovs.$$ -a `ls ovs.$$/lib/modules`
154         dpkg-deb -b ovs.$$ $SRC/kvmfornfv/linux-image*.deb
155         rm -rf ovs.$$
156 )
157
158 mv $SRC/kvmfornfv/*.deb .