OPNFV KVM4NFV CICD: Scripts for creating Rpms & Debians for Kernel, Qemu
[kvmfornfv.git] / ci / build_deb / kernel_deb_build.sh
1 #!/bin/bash
2
3 SRC=/root
4 kernel_src_dir=kernel
5 config_file="arch/x86/configs/opnfv.config"
6 VERSION="1.0.OPNFV"
7 output_dir="$1"
8
9 usage () {
10     echo "usage: ${0} output_dir"
11     exit 1
12 }
13
14 if [[ -z "$@" ]]; then
15     usage
16 fi
17
18 if [ ! -d ${output_dir} -o ! -w ${output_dir} ] ; then
19     echo "${0}: Output directory '${output_dir}' does not exist or cannot be written"
20     exit 1
21 fi
22
23 if [ ! -d ${kernel_src_dir} ] ; then
24     echo "${0}: Directory '${kernel_src_dir}' does not exist, run this script from the root of kvmfornfv source tree"
25     exit 1
26 fi
27
28 quirks() {
29 #
30 # Apply out of tree patches
31 #
32 for i in $SRC/kvmfornfv/patches/$1/*.patch
33 do
34     if [ -f "$i" ]
35     then
36         echo "Applying: $i"
37         patch -p1 <$i
38     fi
39 done
40 }
41
42 quirks kernel
43
44 cd kernel
45
46 if [ ! -f ${config_file} ] ; then
47     echo "${0}: ${config_file} does not exist"
48     exit 1
49 fi
50
51 # Workaround build bug on Ubuntu 14.04
52 cat <<EOF > arch/x86/boot/install.sh
53 #!/bin/sh
54 cp -a -- "\$2" "\$4/vmlinuz-\$1"
55 EOF
56
57 # Configure the kernel
58 cp $config_file .config
59
60 make oldconfig </dev/null
61
62 # Build the kernel debs
63 make-kpkg clean
64
65 fakeroot make-kpkg --initrd --revision=$VERSION kernel_image kernel_headers
66
67 make
68
69 mv /root/kvmfornfv/linux-* /root/kvmfornfv/build_output