#!/bin/bash set -x id export WORKSPACE=`pwd` debian_packaging_source_filename=${debian_packaging_source_url##*/} debian_dir=./debian : ${package_name:?"package_name must be set (i.e. package_name=libvirt)"} : ${code_checkout_dir:?"code_checkout_dir must be set (i.e. code_checkout_dir=./libvirt)"} : ${build_dist:?"build_dist must be set (i.e. build_dist=trusty)"} : ${debian_packaging_source_url:?"debian_packaging_source_url must be set (i.e. debian_packaging_source_url=http://archive.ubuntu.com/.../libvirt_xxx.debian.tar.gz)"} # # clean up previous build files # sudo apt-get update sudo apt-get install wget rm *.deb rm *.ddeb rm *.build rm *.changes rm *.dsc rm *.tar.gz* rm -rf ${debian_dir} rm -rf ${code_checkout_dir}/debian # # initialize submodules (like gnulib) # cd ${code_checkout_dir} git submodule init git submodule update cd ${WORKSPACE} # # retrieve debian packaging source # wget ${debian_packaging_source_url} tar xaf ${debian_packaging_source_filename} cp --recursive ${debian_dir} ${code_checkout_dir}/. # # update build dependencies in the control file # sed -i 's/quilt/native/' ${code_checkout_dir}/debian/source/format sed -i "s/Build-Depends:/Build-Depends:\n ${addl_builddep_package_list},/" ${code_checkout_dir}/debian/control # disable Sheepdog -- it's causing the build to fail for some reason sed -i "s/--with-storage-sheepdog/--without-storage-sheepdog/" ${code_checkout_dir}/debian/rules # don't enable apparmor sed -i "s/--with-apparmor/--with-apparmor=no --with-secdriver-apparmor=no/" ${code_checkout_dir}/debian/rules # enable libxl #sed -i 's/$(WITH_XEN)/$(WITH_XEN) --with-libxl/' ${code_checkout_dir}/debian/rules #sed -i "s/libxen-dev \[i386 amd64\]/libxen-dev/" ${code_checkout_dir}/debian/control # # since building from a git checkout, force bootstrap to run before the build starts # cat >> ${code_checkout_dir}/debian/rules << EOF makebuilddir/libvirt-bin:: if [ ! -f already_bootstrapped ]; then ./bootstrap --no-git --gnulib-srcdir=.gnulib; touch already_bootstrapped; fi EOF # # get the commit of the upstream code # cd ${code_checkout_dir} scm_commit=`git log -n1 --pretty=format:%h` if [ -z "${scm_commit}" ]; then echo "Invalid source git revision: ${scm_commit}" >&2 exit 1 fi cd ${WORKSPACE} # # construct version string using tag information from git # cd ${code_checkout_dir} pkg_version=`git describe --match='v*' |sed -e 's/^v//' -e 's/-rc/~rc/' -e 's/-\([0-9]*\)-/+git\1+/' ` if [ -z $pkg_version ]; then git fetch --tags pkg_version=`git describe --match='v*' |sed -e 's/^v//' -e 's/-rc/~rc/' -e 's/-\([0-9]*\)-/+git\1+/' ` fi cd ${WORKSPACE} echo "pkg_version: :${pkg_version}:" # # update changelog # currentdate=`date -R` cat > ${code_checkout_dir}/debian/changelog.new << EOF ${package_name} (${pkg_version}+${BUILD_NUMBER}linaro${build_dist}1) ${build_dist}; urgency=low * CI - ${package_name} build from upstream sources: - repository: ${GIT_URL} - commit: ${scm_commit} - build: ${BUILD_URL} - debian/ source: ${debian_packaging_source_url} -- Linaro Packagers ${currentdate} EOF cat ${code_checkout_dir}/debian/changelog >> ${code_checkout_dir}/debian/changelog.new mv --force ${code_checkout_dir}/debian/changelog.new ${code_checkout_dir}/debian/changelog #echo "changelog:" #cat ${code_checkout_dir}/debian/changelog # # start the build # (cd ${code_checkout_dir}; dpkg-buildpackage -S -nc -i.git) dsc=`echo *.dsc` export source="file:`pwd`/$dsc" builder_repo=http://git.linaro.org/git/ci/ubuntu-packaging-tools.git rm -rf ubuntu-packaging-tools git clone ${builder_repo} ./ubuntu-packaging-tools/dockerbuild ${source}