OPNFV KVM4NFV CICD: Scripts for creating Rpms & Debians for Kernel, Qemu
[kvmfornfv.git] / ci / build_deb / qemu_deb_build.sh
1 #!/bin/bash
2
3 qemu_src_dir=qemu
4 workspace=/root
5 debbuild_dir=$workspace/debbuild
6 scripts_dir=ci/build_deb
7 output_dir="$1"
8 VERSION=`grep -m 1 "VERSION"  ${qemu_src_dir}/config-host.mak | cut -d= -f2-`
9
10 usage () {
11     echo "usage: ${0} output_dir"
12     exit 1
13 }
14
15 if [[ -z "$@" ]]; then
16     usage
17 fi
18
19 if [ ! -d ${output_dir} -o ! -w ${output_dir} ] ; then
20     echo "${0}: Output directory '${output_dir}' does not exist or cannot \
21           be written"
22     exit 1
23 fi
24
25 if [ ! -d ${qemu_src_dir} ] ; then
26     echo "${0}: Directory '${qemu_src_dir}' does not exist, run this script \
27           from the root of kvmfornfv source tree"
28     exit 1
29 fi
30
31 echo
32 echo "Build"
33 echo
34
35 qemu_deb_build() {
36     mkdir -p $debbuild_dir/qemu-$VERSION
37     cp -r $qemu_src_dir $debbuild_dir/qemu-$VERSION
38     mkdir -p $debbuild_dir/qemu-$VERSION/DEBIAN
39     touch control
40
41 #creating control file for debian build.
42     (cd ${scripts_dir}; ./mkcontrol.sh $VERSION > control)
43     mv $scripts_dir/control $debbuild_dir/qemu-$VERSION/DEBIAN/control
44
45 #building the qemu debian with control file developed.
46     dpkg-deb --build $debbuild_dir/qemu-$VERSION
47     if [ ${?} -ne 0 ] ; then
48         echo "${0}: qemu build failed"
49         exit 1
50     fi
51 }
52
53 if [ ! -d ${debbuild_dir} ] ; then
54     echo "creating debbuild directory"
55     mkdir -p $debbuild_dir
56 fi
57
58 qemu_deb_build
59 latest_qemu_build=`ls -rt $debbuild_dir | tail -1`
60 cp $debbuild_dir/$latest_qemu_build build_output