summaryrefslogtreecommitdiffstats
path: root/ci
diff options
context:
space:
mode:
authorshravani <shravani.p@tcs.com>2016-12-20 15:09:34 +0530
committerShravani Paladugula <shravani.p@tcs.com>2017-02-09 04:34:34 +0000
commit843dfef73c86a8ad71afe36e2db9e711dddc199a (patch)
tree52c15baf57c751cf91bf35b3dbc027adacfa7a1d /ci
parent881aa3fcf152088440444d6f4296eaac3783801c (diff)
Combine the common code for kernel building on deb/rpm
This patch removes the duplication of code in rpm/debian build scripts. Change-Id: I88edc93df488bd01a43cd98e4f69f35e09f8f61c Signed-off-by: Shravani <shravani.p@tcs.com>
Diffstat (limited to 'ci')
-rw-r--r--ci/README44
-rwxr-xr-xci/build.sh41
-rwxr-xr-xci/build_deb/build_debs.sh20
-rwxr-xr-xci/build_deb/build_debs_docker.sh22
-rwxr-xr-xci/build_deb/kernel_deb_build.sh69
-rwxr-xr-xci/build_deb/qemu_deb_build.sh60
-rwxr-xr-xci/build_interface.sh30
-rwxr-xr-xci/build_rpm/build_rpms.sh20
-rwxr-xr-xci/build_rpm/build_rpms_docker.sh21
-rwxr-xr-xci/build_rpm/kernel_rpm_build.sh53
-rwxr-xr-xci/build_rpm/qemu_rpm_build.sh62
-rwxr-xr-xci/kernelConfigValidate.sh43
-rwxr-xr-xci/kernel_build.sh64
-rwxr-xr-xci/qemuConfigValidate.sh34
-rwxr-xr-xci/qemu_build.sh65
15 files changed, 285 insertions, 363 deletions
diff --git a/ci/README b/ci/README
index d4da16561..01dbbea80 100644
--- a/ci/README
+++ b/ci/README
@@ -1,16 +1,19 @@
The "ci" folder consists of-
build.sh --> builds rpm packages (if -p package option is passed as "centos"
-or in default case) by calling build_rpm subfolder files ; builds debian
-packages (if -p package option is passed as "ubuntu") by calling build_deb
-subfolder files; builds both debian and rpm packages (if -p package option is
+or in default case) by calling build_interface.sh and build_rpm subfolder
+files ; builds debian packages (if -p package option is passed as "ubuntu")
+by calling build_interface.sh and build_deb subfolder files;
+builds both debian and rpm packages (if -p package option is
passed as "both").
-build_deb --> contains the files required to build debian backages for kernel
-and qemu, inside ubuntu docker.
+build_interface.sh --> triggers qemu_build.sh and kernel_build.sh
-build_rpm --> contains the files required to build rpm backages for kernel and
-qemu, inside centos docker.
+build_deb --> contains the Dockerfile required to build debian backages for
+kernel and qemu, inside ubuntu docker.
+
+build_rpm --> contains the Dockerfile required to build rpm backages for
+kernel and qemu, inside centos docker.
envs --> contains the host and guest setup+configuration files.
@@ -18,23 +21,18 @@ envs --> contains the host and guest setup+configuration files.
The actual Tree structure is as below-
|-- build_deb
-| |-- build_debs_docker.sh
-| |-- build_debs.sh
| |-- Dockerfile
-| |-- kernel_deb_build.sh
-| |-- mkcontrol.sh
-| `-- qemu_deb_build.sh
+| `-- mkcontrol.sh
+|-- build_interface.sh
|-- build_rpm
-| |-- build_rpms_docker.sh
-| |-- build_rpms.sh
| |-- Dockerfile
-| |-- kernel_rpm_build.sh
| |-- mkspec
-| |-- mkversion
-| |-- qemu_rpm_build.sh
+| `-- mkversion
|-- build.sh
+|-- cyclicTestTrigger.sh
|-- envs
| |-- create-rt-tests-rpm.sh
+| |-- cyclictest.sh
| |-- guest-cmd.sh
| |-- guest-modify.sh
| |-- guest-setup0.sh
@@ -43,5 +41,13 @@ The actual Tree structure is as below-
| |-- host-run-qemu.sh
| |-- host-setup0.sh
| |-- host-setup1.sh
-| `-- rt-tests.patch
-`-- README
+| |-- rt-tests.patch
+| |-- stress_daily.sh
+| |-- stress_scripts.sh
+| `-- utils.sh
+|-- kernel_build.sh
+|-- kernelConfigValidate.sh
+|-- qemu_build.sh
+|-- qemuConfigValidate.sh
+|-- README
+`-- test_kvmfornfv.sh
diff --git a/ci/build.sh b/ci/build.sh
index 064c48a8b..918e3cab7 100755
--- a/ci/build.sh
+++ b/ci/build.sh
@@ -2,6 +2,7 @@
#
# Common parameter parsing for kvmfornfv scripts
#
+
function usage() {
echo ""
echo "Usage --> $0 [-p package_type] [-o output_dir] [-h]"
@@ -14,29 +15,35 @@ function usage() {
output_dir=""
type=""
+function run() {
+ case $1 in
+ centos)
+ cd $WORKSPACE/ci/build_rpm
+ sudo docker build -t kvm_rpm .
+ sudo docker run --privileged=true -v $WORKSPACE:/opt/kvmfornfv -t kvm_rpm \
+ /opt/kvmfornfv/ci/build_interface.sh $1
+ ;;
+ ubuntu)
+ cd $WORKSPACE/ci/build_deb
+ sudo docker build -t kvm_deb .
+ sudo docker run -v $WORKSPACE:/opt/kvmfornfv -t kvm_deb \
+ /opt/kvmfornfv/ci/build_interface.sh $1
+ ;;
+ *) echo "Not supported system"; exit 1;;
+ esac
+}
+
function build_package() {
choice=$1
-
case "$choice" in
- "centos")
- echo "Build $choice Rpms"
- cd ci/build_rpm
- ./build_rpms.sh
- cd $WORKSPACE
- ;;
- "ubuntu")
- echo "Build $choice Debians"
- cd ci/build_deb
- ./build_debs.sh
- cd $WORKSPACE
+ "centos"|"ubuntu")
+ echo "Build $choice Rpms/Debians"
+ run $choice
;;
"both")
echo "Build $choice Debians and Rpms"
- cd ci/build_deb
- ./build_debs.sh
- cd ../build_rpm
- ./build_rpms.sh
- cd $WORKSPACE
+ run "centos"
+ run "ubuntu"
;;
*)
echo "Invalid package option"
diff --git a/ci/build_deb/build_debs.sh b/ci/build_deb/build_debs.sh
deleted file mode 100755
index 2fcd3629b..000000000
--- a/ci/build_deb/build_debs.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-
-set -eux
-BUILD_FOR=${BUILD_FOR:-ubuntu}
-
-function build_deb_pkg {
- case $1 in
- ubuntu)
- sudo docker build -t kvm_deb .
- sudo docker run -v $WORKSPACE:/opt/kvmfornfv -t kvm_deb \
- /opt/kvmfornfv/ci/build_deb/build_debs_docker.sh
- ;;
- *) echo "Not supported system"; exit 1;;
- esac
-}
-
-for system in $BUILD_FOR
-do
- build_deb_pkg $system
-done
diff --git a/ci/build_deb/build_debs_docker.sh b/ci/build_deb/build_debs_docker.sh
deleted file mode 100755
index 3fd35ff54..000000000
--- a/ci/build_deb/build_debs_docker.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/bash
-
-tmp_deb_build_dir=/root/kvmfornfv
-deb_build_dir=/opt/kvmfornfv
-tmp_deb_output_dir=$tmp_deb_build_dir/build_output
-deb_output_dir=$deb_build_dir/build_output
-cp -r $deb_build_dir $tmp_deb_build_dir
-
-# Build qemu debian packages
-cd $tmp_deb_build_dir/qemu
-make clean
-./configure
-make
-cd $tmp_deb_build_dir
-./ci/build_deb/qemu_deb_build.sh build_output
-
-# Build kernel debian packages
-./ci/build_deb/kernel_deb_build.sh build_output
-
-# Move Kernel and Qemu Debian builds from tmp_output_dir to output_dir
-mv $tmp_deb_output_dir/qemu-* $deb_output_dir
-mv $tmp_deb_output_dir/linux-* $deb_output_dir
diff --git a/ci/build_deb/kernel_deb_build.sh b/ci/build_deb/kernel_deb_build.sh
deleted file mode 100755
index 824960e7f..000000000
--- a/ci/build_deb/kernel_deb_build.sh
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/bin/bash
-
-SRC=/root
-kernel_src_dir=kernel
-config_file="arch/x86/configs/opnfv.config"
-VERSION="1.0.OPNFV"
-output_dir="$1"
-
-usage () {
- echo "usage: ${0} output_dir"
- exit 1
-}
-
-if [[ -z "$@" ]]; then
- usage
-fi
-
-if [ ! -d ${output_dir} -o ! -w ${output_dir} ] ; then
- echo "${0}: Output directory '${output_dir}' does not exist or cannot be written"
- exit 1
-fi
-
-if [ ! -d ${kernel_src_dir} ] ; then
- echo "${0}: Directory '${kernel_src_dir}' does not exist, run this script from the root of kvmfornfv source tree"
- exit 1
-fi
-
-quirks() {
-#
-# Apply out of tree patches
-#
-for i in $SRC/kvmfornfv/patches/$1/*.patch
-do
- if [ -f "$i" ]
- then
- echo "Applying: $i"
- patch -p1 <$i
- fi
-done
-}
-
-quirks kernel
-
-cd kernel
-
-if [ ! -f ${config_file} ] ; then
- echo "${0}: ${config_file} does not exist"
- exit 1
-fi
-
-# Workaround build bug on Ubuntu 14.04
-cat <<EOF > arch/x86/boot/install.sh
-#!/bin/sh
-cp -a -- "\$2" "\$4/vmlinuz-\$1"
-EOF
-
-# Configure the kernel
-cp $config_file .config
-
-make oldconfig </dev/null
-
-# 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
diff --git a/ci/build_deb/qemu_deb_build.sh b/ci/build_deb/qemu_deb_build.sh
deleted file mode 100755
index f6d398a36..000000000
--- a/ci/build_deb/qemu_deb_build.sh
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/bash
-
-qemu_src_dir=qemu
-workspace=/root
-debbuild_dir=$workspace/debbuild
-scripts_dir=ci/build_deb
-output_dir="$1"
-VERSION=`grep -m 1 "VERSION" ${qemu_src_dir}/config-host.mak | cut -d= -f2-`
-
-usage () {
- echo "usage: ${0} output_dir"
- exit 1
-}
-
-if [[ -z "$@" ]]; then
- usage
-fi
-
-if [ ! -d ${output_dir} -o ! -w ${output_dir} ] ; then
- echo "${0}: Output directory '${output_dir}' does not exist or cannot \
- be written"
- exit 1
-fi
-
-if [ ! -d ${qemu_src_dir} ] ; then
- echo "${0}: Directory '${qemu_src_dir}' does not exist, run this script \
- from the root of kvmfornfv source tree"
- exit 1
-fi
-
-echo
-echo "Build"
-echo
-
-qemu_deb_build() {
- mkdir -p $debbuild_dir/qemu-$VERSION
- cp -r $qemu_src_dir $debbuild_dir/qemu-$VERSION
- mkdir -p $debbuild_dir/qemu-$VERSION/DEBIAN
- touch control
-
-#creating control file for debian build.
- (cd ${scripts_dir}; ./mkcontrol.sh $VERSION > control)
- mv $scripts_dir/control $debbuild_dir/qemu-$VERSION/DEBIAN/control
-
-#building the qemu debian with control file developed.
- dpkg-deb --build $debbuild_dir/qemu-$VERSION
- if [ ${?} -ne 0 ] ; then
- echo "${0}: qemu build failed"
- exit 1
- fi
-}
-
-if [ ! -d ${debbuild_dir} ] ; then
- echo "creating debbuild directory"
- mkdir -p $debbuild_dir
-fi
-
-qemu_deb_build
-latest_qemu_build=`ls -rt $debbuild_dir | tail -1`
-cp $debbuild_dir/$latest_qemu_build build_output
diff --git a/ci/build_interface.sh b/ci/build_interface.sh
new file mode 100755
index 000000000..6f5fadc28
--- /dev/null
+++ b/ci/build_interface.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+type=$1
+
+tmp_build_dir=/root/kvmfornfv
+build_dir=/opt/kvmfornfv
+tmp_output_dir=$tmp_build_dir/build_output
+output_dir=$build_dir/build_output
+cp -r $build_dir $tmp_build_dir
+
+# Build qemu rpm packages
+cd $tmp_build_dir/qemu
+make clean
+./configure
+
+cd $tmp_build_dir
+#Build qemu package
+./ci/qemu_build.sh build_output $type
+# Build kernel packages
+./ci/kernel_build.sh build_output $type
+
+if [ $type == "centos" ];then
+ # Move Kernel and Qemu Rpm builds from tmp_output_dir to output_dir
+ mv $tmp_output_dir/qemu-* $output_dir
+ mv $tmp_output_dir/kernel-* $output_dir
+elif [ $type == "ubuntu" ];then
+ # Move Kernel and Qemu Debian builds from tmp_output_dir to output_dir
+ mv $tmp_output_dir/qemu-* $output_dir
+ mv $tmp_output_dir/linux-* $output_dir
+fi
diff --git a/ci/build_rpm/build_rpms.sh b/ci/build_rpm/build_rpms.sh
deleted file mode 100755
index 40cae6ccf..000000000
--- a/ci/build_rpm/build_rpms.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-
-set -eux
-BUILD_FOR=${BUILD_FOR:-centos}
-
-function build_rpm_pkg {
- case $1 in
- centos)
- sudo docker build -t kvm_rpm .
- sudo docker run -v $WORKSPACE:/opt/kvmfornfv -t kvm_rpm \
- /opt/kvmfornfv/ci/build_rpm/build_rpms_docker.sh
- ;;
- *) echo "Not supported system"; exit 1;;
- esac
-}
-
-for system in $BUILD_FOR
-do
- build_rpm_pkg $system
-done
diff --git a/ci/build_rpm/build_rpms_docker.sh b/ci/build_rpm/build_rpms_docker.sh
deleted file mode 100755
index 708c8acbf..000000000
--- a/ci/build_rpm/build_rpms_docker.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-
-tmp_rpm_build_dir=/root/kvmfornfv
-rpm_build_dir=/opt/kvmfornfv
-tmp_rpm_output_dir=$tmp_rpm_build_dir/build_output
-rpm_output_dir=$rpm_build_dir/build_output
-cp -r $rpm_build_dir $tmp_rpm_build_dir
-
-# Build qemu rpm packages
-cd $tmp_rpm_build_dir/qemu
-make clean
-./configure
-cd $tmp_rpm_build_dir
-./ci/build_rpm/qemu_rpm_build.sh build_output
-
-# Build kernel rpm packages
-./ci/build_rpm/kernel_rpm_build.sh build_output
-
-# Move Kernel and Qemu Rpm builds from tmp_output_dir to output_dir
-mv $tmp_rpm_output_dir/qemu-* $rpm_output_dir
-mv $tmp_rpm_output_dir/kernel-* $rpm_output_dir
diff --git a/ci/build_rpm/kernel_rpm_build.sh b/ci/build_rpm/kernel_rpm_build.sh
deleted file mode 100755
index fa6383eb8..000000000
--- a/ci/build_rpm/kernel_rpm_build.sh
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/bash
-kernel_src_dir=kernel
-rpmbuild_dir=/tmp/kvmfornfv_rpmbuild.$$
-artifact_dir=${rpmbuild_dir}/RPMS/x86_64
-mkdir -p $artifact_dir
-config_file="${kernel_src_dir}/arch/x86/configs/opnfv.config"
-output_dir="$1"
-
-usage () {
- echo "usage: ${0} output_dir"
- exit 1
-}
-
-if [[ -z "$@" ]]; then
- usage
-fi
-
-if [ ! -d ${output_dir} -o ! -w ${output_dir} ] ; then
- echo "${0}: Output directory '${output_dir}' does not exist or cannot \
- be written"
- exit 1
-fi
-
-if [ ! -d ${kernel_src_dir} ] ; then
- echo "${0}: Directory '${kernel_src_dir}' does not exist, run this script \
- from the root of kvmfornfv source tree"
- exit 1
-fi
-
-if [ ! -f ${config_file} ] ; then
- echo "${0}: ${config_file} does not exist"
- exit 1
-fi
-
-echo
-echo "Build"
-echo
-
-cp -f ${config_file} "${kernel_src_dir}/.config"
-
-# 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}
diff --git a/ci/build_rpm/qemu_rpm_build.sh b/ci/build_rpm/qemu_rpm_build.sh
deleted file mode 100755
index 302d00354..000000000
--- a/ci/build_rpm/qemu_rpm_build.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/bash
-
-qemu_src_dir=qemu
-workspace=/root
-rpmbuild_dir=$workspace/rpmbuild
-artifact_rpms=$rpmbuild_dir/RPMS
-artifact_dir=$artifact_rpms/x86_64
-scripts_dir=ci/build_rpm
-output_dir="$1"
-VERSION=`grep -m 1 "VERSION" ${qemu_src_dir}/config-host.mak | cut -d= -f2-`
-
-usage () {
- echo "usage: ${0} output_dir"
- exit 1
-}
-
-if [[ -z "$@" ]]; then
- usage
-fi
-
-if [ ! -d ${output_dir} -o ! -w ${output_dir} ] ; then
- echo "${0}: Output directory '${output_dir}' does not exist or cannot \
- be written"
- exit 1
-fi
-
-if [ ! -d ${qemu_src_dir} ] ; then
- echo "${0}: Directory '${qemu_src_dir}' does not exist, run this script \
- from the root of kvmfornfv source tree"
- exit 1
-fi
-
-echo
-echo "Build"
-echo
-
-qemu_rpm_build() {
- cp -r ${qemu_src_dir} ${qemu_src_dir}-$VERSION
- tar -zcvf ${qemu_src_dir}-$VERSION.tar.gz ${qemu_src_dir}-$VERSION
- mv ${qemu_src_dir}-$VERSION.tar.gz ${rpmbuild_dir}/SOURCES/
-
- #create a spec file for rpm creation.
- (cd ${scripts_dir}; ./mkspec $VERSION > qemu.spec)
- cp ${scripts_dir}/qemu.spec ${rpmbuild_dir}/SPECS/
-
- #build the qemu rpm with spec file developed
- rpmbuild -ba ${rpmbuild_dir}/SPECS/qemu.spec
- if [ ${?} -ne 0 ] ; then
- echo "${0}: qemu build failed"
- exit 1
- fi
- rm -rf ${qemu_src_dir}-$VERSION
- rm -rf ${rpmbuild_dir}/SOURCES/${qemu_src_dir}-$VERSION.tar.gz
-}
-
-if [ ! -d ${rpmbuild_dir} ] ; then
- mkdir -p ${rpmbuild_dir}/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
-fi
-
-qemu_rpm_build
-latest_qemu_build=`ls -rt $artifact_dir | grep qemu-2.6* | tail -1`
-cp $artifact_dir/$latest_qemu_build build_output
diff --git a/ci/kernelConfigValidate.sh b/ci/kernelConfigValidate.sh
new file mode 100755
index 000000000..6d91d2699
--- /dev/null
+++ b/ci/kernelConfigValidate.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+kernel_src_dir=kernel
+kernel_config_file="${kernel_src_dir}/arch/x86/configs/opnfv.config"
+
+function show_stage {
+ echo
+ echo $1
+ echo
+}
+
+function kernel_build_validate {
+ show_stage "validate"
+ if [[ -z "$@" ]]; then
+ echo "usage: ${0} output_dir"
+ echo "usage: ${1} pkg_type"
+ usage
+ fi
+ output_dir="$1"
+ pkg_type="$2"
+ if [ ! -d ${output_dir} -o ! -w ${output_dir} ] ; then
+ echo "${0}: Output directory '${output_dir}' does not exist or cannot be written"
+ exit 1
+ fi
+ if [ ! -d ${kernel_src_dir} ] ; then
+ echo "${0}: Directory '${kernel_src_dir}' does not exist, run this script from the root of kvmfornfv source tree"
+ exit 1
+ fi
+
+ if [ ! -f ${kernel_config_file} ] ; then
+ echo "${0}: ${kernel_config_file} does not exist"
+ exit 1
+ fi
+ echo
+ echo "Build"
+ echo
+}
+
+function kernel_build_prep {
+ show_stage "kernel tree prep"
+ cp -f ${kernel_config_file} "${kernel_src_dir}/.config"
+ make oldconfig
+}
diff --git a/ci/kernel_build.sh b/ci/kernel_build.sh
new file mode 100755
index 000000000..91e8b7765
--- /dev/null
+++ b/ci/kernel_build.sh
@@ -0,0 +1,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
+
diff --git a/ci/qemuConfigValidate.sh b/ci/qemuConfigValidate.sh
new file mode 100755
index 000000000..f80526b60
--- /dev/null
+++ b/ci/qemuConfigValidate.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+qemu_src_dir=qemu
+workspace=/root
+#scripts_dir=ci/build_deb
+VERSION=`grep -m 1 "VERSION" ${qemu_src_dir}/config-host.mak | cut -d= -f2-`
+
+function show_stage {
+ echo
+ echo $1
+ echo
+}
+
+function qemu_build_validate {
+ show_stage "validate"
+ if [[ -z "$@" ]]; then
+ echo "usage: ${0} output_dir pkgtype"
+ exit 1
+ fi
+ output_dir="$1"
+ pkgtype="$2"
+ if [ ! -d ${output_dir} -o ! -w ${output_dir} ] ; then
+ echo "${0}: Output directory '${output_dir}' does not exist or cannot be written"
+ exit 1
+ fi
+ if [ ! -d ${qemu_src_dir} ] ; then
+ echo "${0}: Directory '${qemu_src_dir}' does not exist, run this script from the root of kvmfornfv source tree"
+ exit 1
+ fi
+ echo
+ echo "Build"
+ echo
+}
+
diff --git a/ci/qemu_build.sh b/ci/qemu_build.sh
new file mode 100755
index 000000000..e9eb4d2eb
--- /dev/null
+++ b/ci/qemu_build.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+source ./ci/qemuConfigValidate.sh
+rpmbuild_dir=$workspace/rpmbuild
+artifact_rpms=$rpmbuild_dir/RPMS
+artifact_dir=$artifact_rpms/x86_64
+debbuild_dir=$workspace/debbuild
+
+qemu_build_validate $@
+
+qemu_rpm_build() {
+ scripts_dir=ci/build_rpm
+ cp -r ${qemu_src_dir} ${qemu_src_dir}-$VERSION
+ tar -zcvf ${qemu_src_dir}-$VERSION.tar.gz ${qemu_src_dir}-$VERSION
+ mv ${qemu_src_dir}-$VERSION.tar.gz ${rpmbuild_dir}/SOURCES/
+
+ #create a spec file for rpm creation.
+ (cd ${scripts_dir}; ./mkspec $VERSION > qemu.spec)
+ cp ${scripts_dir}/qemu.spec ${rpmbuild_dir}/SPECS/
+
+ #build the qemu rpm with spec file developed
+ rpmbuild -ba ${rpmbuild_dir}/SPECS/qemu.spec
+ if [ ${?} -ne 0 ] ; then
+ echo "${0}: qemu build failed"
+ exit 1
+ fi
+ rm -rf ${qemu_src_dir}-$VERSION
+ rm -rf ${rpmbuild_dir}/SOURCES/${qemu_src_dir}-$VERSION.tar.gz
+}
+
+qemu_deb_build() {
+ scripts_dir=ci/build_deb
+ mkdir -p $debbuild_dir/qemu-$VERSION
+ cp -r $qemu_src_dir $debbuild_dir/qemu-$VERSION
+ mkdir -p $debbuild_dir/qemu-$VERSION/DEBIAN
+ touch control
+
+#creating control file for debian build.
+ (cd ${scripts_dir}; ./mkcontrol.sh $VERSION > control)
+ mv $scripts_dir/control $debbuild_dir/qemu-$VERSION/DEBIAN/control
+
+#building the qemu debian with control file developed.
+ dpkg-deb --build $debbuild_dir/qemu-$VERSION
+ if [ ${?} -ne 0 ] ; then
+ echo "${0}: qemu build failed"
+ exit 1
+ fi
+}
+
+if [ $pkgtype == "centos" ];then
+ if [ ! -d ${rpmbuild_dir} ] ; then
+ mkdir -p ${rpmbuild_dir}/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
+ fi
+ qemu_rpm_build
+ latest_qemu_build=`ls -rt $artifact_dir | grep qemu-2.6* | tail -1`
+ cp $artifact_dir/$latest_qemu_build ${output_dir}
+elif [ $pkgtype == "ubuntu" ];then
+ if [ ! -d ${debbuild_dir} ] ; then
+ echo "creating debbuild directory"
+ mkdir -p $debbuild_dir
+ fi
+ qemu_deb_build
+ latest_qemu_build=`ls -rt $debbuild_dir | tail -1`
+ cp $debbuild_dir/$latest_qemu_build build_output
+fi