5 rpmbuild_dir=$workspace/rpmbuild
6 artifact_rpms=$rpmbuild_dir/RPMS
7 artifact_dir=$artifact_rpms/x86_64
8 scripts_dir=ci/build_rpm
10 VERSION=`grep -m 1 "VERSION" ${qemu_src_dir}/config-host.mak | cut -d= -f2-`
13 echo "usage: ${0} output_dir"
17 if [[ -z "$@" ]]; then
21 if [ ! -d ${output_dir} -o ! -w ${output_dir} ] ; then
22 echo "${0}: Output directory '${output_dir}' does not exist or cannot \
27 if [ ! -d ${qemu_src_dir} ] ; then
28 echo "${0}: Directory '${qemu_src_dir}' does not exist, run this script \
29 from the root of kvmfornfv source tree"
38 cp -r ${qemu_src_dir} ${qemu_src_dir}-$VERSION
39 tar -zcvf ${qemu_src_dir}-$VERSION.tar.gz ${qemu_src_dir}-$VERSION
40 mv ${qemu_src_dir}-$VERSION.tar.gz ${rpmbuild_dir}/SOURCES/
42 #create a spec file for rpm creation.
43 (cd ${scripts_dir}; ./mkspec $VERSION > qemu.spec)
44 cp ${scripts_dir}/qemu.spec ${rpmbuild_dir}/SPECS/
46 #build the qemu rpm with spec file developed
47 rpmbuild -ba ${rpmbuild_dir}/SPECS/qemu.spec
48 if [ ${?} -ne 0 ] ; then
49 echo "${0}: qemu build failed"
52 rm -rf ${qemu_src_dir}-$VERSION
53 rm -rf ${rpmbuild_dir}/SOURCES/${qemu_src_dir}-$VERSION.tar.gz
56 if [ ! -d ${rpmbuild_dir} ] ; then
57 yum install rpm-build -y
58 mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
59 mv rpmbuild $workspace
63 latest_qemu_build=`ls -rt $artifact_dir | grep qemu-2.6* | tail -1`
64 cp $artifact_dir/$latest_qemu_build build_output