diff options
author | Swati <swatix.sharma@intel.com> | 2016-06-27 17:53:53 +0530 |
---|---|---|
committer | swatisharma <swatix.sharma@intel.com> | 2016-08-11 15:47:22 +0530 |
commit | 7552c26370d38ef5dd182682a0d3bf096661fe0e (patch) | |
tree | 4b989be4c6250a1b3768b99c62004d465bc9d798 /ci/build_rpm | |
parent | 6ec128a4e6a1819881f8db6659d4024aac35ce38 (diff) |
OPNFV KVM4NFV CICD: Scripts for creating Rpms & Debians for Kernel, Qemu
This patch contains the files for generating rpms & debians for both kernel
& qemu changes, as part of kvmfornfv project development. The scripts will be
triggered to build kernel-rpm & qemu-rpm packages inside centos docker, and
kernel-debian & qemu-debian packages inside ubuntu docker, as part of the
CICD process.
After the new builds are ready, they will be deployed on the pharos testbed
for verification. Later, these will be consumed/triggered by verify/daily
Releng JJBs.
Reference: https://wiki.opnfv.org/display/kvm/KVM4NFV+CICD+Jobs
Change-Id: Ie8e8108566790a6c8db2fef1c9b5799a41732b44
Signed-off-by: Swati Sharma <swatix.sharma@intel.com>
Diffstat (limited to 'ci/build_rpm')
-rw-r--r-- | ci/build_rpm/Dockerfile | 14 | ||||
-rwxr-xr-x | ci/build_rpm/build_rpms.sh | 20 | ||||
-rwxr-xr-x | ci/build_rpm/build_rpms_docker.sh | 22 | ||||
-rwxr-xr-x | ci/build_rpm/kernel_rpm_build.sh | 53 | ||||
-rwxr-xr-x | ci/build_rpm/mkspec | 44 | ||||
-rwxr-xr-x | ci/build_rpm/mkversion | 10 | ||||
-rwxr-xr-x | ci/build_rpm/qemu_rpm_build.sh | 64 |
7 files changed, 227 insertions, 0 deletions
diff --git a/ci/build_rpm/Dockerfile b/ci/build_rpm/Dockerfile new file mode 100644 index 000000000..6d6d3ba35 --- /dev/null +++ b/ci/build_rpm/Dockerfile @@ -0,0 +1,14 @@ +#!/bin/bash + +FROM centos +RUN yum -y update && yum -y install \ + git \ + gcc \ + gcc-c++ \ + zlib-devel \ + gtk2-devel \ + make \ + gettext \ + bc \ + rpm \ + rpm-build diff --git a/ci/build_rpm/build_rpms.sh b/ci/build_rpm/build_rpms.sh new file mode 100755 index 000000000..40cae6ccf --- /dev/null +++ b/ci/build_rpm/build_rpms.sh @@ -0,0 +1,20 @@ +#!/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 new file mode 100755 index 000000000..2670163e4 --- /dev/null +++ b/ci/build_rpm/build_rpms_docker.sh @@ -0,0 +1,22 @@ +#!/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 +make +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 new file mode 100755 index 000000000..fa6383eb8 --- /dev/null +++ b/ci/build_rpm/kernel_rpm_build.sh @@ -0,0 +1,53 @@ +#!/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/mkspec b/ci/build_rpm/mkspec new file mode 100755 index 000000000..4aa542325 --- /dev/null +++ b/ci/build_rpm/mkspec @@ -0,0 +1,44 @@ +#!/bin/sh +# +# Output a simple RPM spec file. +# +# starting to output the spec + +QEMURELEASE=$1 + +__QEMURELEASE=`echo $QEMURELEASE | sed -e "s/-/_/g"` + +echo $srctree +echo "Name: qemu" +echo "Summary: The Linux qemu" +echo "Version: $__QEMURELEASE" +# we need to determine the NEXT version number +# rpm -q will agree +echo "Release: `sh mkversion`" +echo "License: GPLv2+ and LGPLv2+ and BSD" +echo "Group: Development/Tools" +echo "Vendor: The Linux Community" +echo "URL: http://www.qemu.org" +echo "Source: qemu-$__QEMURELEASE.tar.gz" +echo "%description" +echo "%prep" +echo " " +echo "%setup -q" +echo " " +echo "%build" +echo "%_configure" +echo "make" +echo "%install" +echo "rm -rf %{buildroot}" +echo "make install DESTDIR=%{buildroot}" +echo "%clean" +echo "rm -rf %{buildroot}" +echo "%files" +echo "%dir" +echo "/usr/local/share/qemu" +echo "/usr/local/share/locale/*" +echo "%doc" +echo "/usr/local/bin/ivshmem*" +echo "/usr/local/bin/qemu*" +echo "/usr/local/libexec/qemu-bridge-helper" +echo "%changelog" diff --git a/ci/build_rpm/mkversion b/ci/build_rpm/mkversion new file mode 100755 index 000000000..9668da7e0 --- /dev/null +++ b/ci/build_rpm/mkversion @@ -0,0 +1,10 @@ +if [ ! -f .version ] +then + touch .version + chmod 777 .version + echo 1 > .version + echo 1 +else + expr 0`cat .version` + 1 + expr 0`cat .version` + 1 > .version +fi diff --git a/ci/build_rpm/qemu_rpm_build.sh b/ci/build_rpm/qemu_rpm_build.sh new file mode 100755 index 000000000..1e87fbdd6 --- /dev/null +++ b/ci/build_rpm/qemu_rpm_build.sh @@ -0,0 +1,64 @@ +#!/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 + yum install rpm-build -y + mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} + mv rpmbuild $workspace +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 |