Combine the common code for kernel building on deb/rpm
[kvmfornfv.git] / ci / kernelConfigValidate.sh
1 #!/bin/bash
2
3 kernel_src_dir=kernel
4 kernel_config_file="${kernel_src_dir}/arch/x86/configs/opnfv.config"
5
6 function show_stage {
7     echo
8     echo $1
9     echo
10 }
11
12 function kernel_build_validate {
13     show_stage "validate"
14     if [[ -z "$@" ]]; then
15         echo "usage: ${0} output_dir"
16         echo "usage: ${1} pkg_type"
17         usage
18     fi
19     output_dir="$1"
20     pkg_type="$2"
21     if [ ! -d ${output_dir} -o ! -w ${output_dir} ] ; then
22         echo "${0}: Output directory '${output_dir}' does not exist or cannot be written"
23         exit 1
24     fi
25     if [ ! -d ${kernel_src_dir} ] ; then
26         echo "${0}: Directory '${kernel_src_dir}' does not exist, run this script from the root of kvmfornfv source tree"
27         exit 1
28     fi
29
30     if [ ! -f ${kernel_config_file} ] ; then
31         echo "${0}: ${kernel_config_file} does not exist"
32         exit 1
33     fi
34     echo
35     echo "Build"
36     echo
37 }
38
39 function kernel_build_prep {
40     show_stage "kernel tree prep"
41     cp -f ${kernel_config_file} "${kernel_src_dir}/.config"
42     make oldconfig
43 }