summaryrefslogtreecommitdiffstats
path: root/ci/kernel_build.sh
blob: 91e8b7765e1d0665c47addefd543d2d7dc35bc60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash

source ./ci/kernelConfigValidate.sh

kernel_build_validate $@
kernel_build_prep

kernel_rpm_build() {
   rpmbuild_dir=/tmp/kvmfornfv_rpmbuild.$$
   artifact_dir=${rpmbuild_dir}/RPMS/x86_64
   mkdir -p $artifact_dir
   # Make timestamp part of version string for automated kernel boot verification
   date "+-%y%m%d%H%M" > "${kernel_src_dir}/localversion-zzz"

   (cd ${kernel_src_dir}; make RPMOPTS="--define '_topdir ${rpmbuild_dir}'" rpm-pkg)
   if [ ${?} -ne 0 ] ; then
      echo "${0}: Kernel build failed"
      rm -rf ${rpmbuild_dir}
      exit 1
   fi
   cp -f ${artifact_dir}/* ${output_dir}
   rm -rf ${rpmbuild_dir}
}

quirks(){
   #
   # Apply out of tree patches
   #
   SRC=/root
   for i in $SRC/kvmfornfv/patches/$1/*.patch
   do
      if [ -f "$i" ]
      then
         echo "Applying: $i"
         patch -p1 <$i
      fi
   done
}

kernel_deb_build(){
   VERSION="1.0.OPNFV"
   # Configure the kernel
   cd kernel

# Workaround build bug on Ubuntu 14.04
cat <<EOF > arch/x86/boot/install.sh
#!/bin/sh
cp -a -- "\$2" "\$4/vmlinuz-\$1"
EOF

# Build the kernel debs
make-kpkg clean
fakeroot make-kpkg --initrd --revision=$VERSION kernel_image kernel_headers
make
mv /root/kvmfornfv/linux-* /root/kvmfornfv/build_output
}

if [ $pkg_type == "centos" ];then
   kernel_rpm_build
elif [ $pkg_type == "ubuntu" ];then
   quirks kernel
   kernel_deb_build
fi