diff --git a/build-python-deb b/build-python-deb new file mode 100755 index 000000000..a6173d87a --- /dev/null +++ b/build-python-deb @@ -0,0 +1,107 @@ +#!/bin/bash +# +# Author: Yuan Bai (bybai@cn.ibm.com) +# +# +printusage() +{ + echo "Usage : build-python-deb xcat-openbmc-py" +} +# For the purpose of getting the distribution name +if [[ ! -f /etc/lsb-release ]]; then + echo "ERROR: Could not find /etc/lsb-release, is this script executed on a Ubuntu machine?" + exit 1 +fi +. /etc/lsb-release +# Check the necessary packages before starting the build +declare -a packages=( "reprepro" "devscripts" "debhelper" "quilt" ) + +for package in ${packages[@]}; do + RC=`dpkg -l | grep $package >> /dev/null 2>&1; echo $?` + if [[ ${RC} != 0 ]]; then + echo "ERROR: Could not find $package, install using 'apt-get install $package' to continue" + exit 1 + fi +done + +# Supported distributions +dists="saucy trusty utopic xenial" +pkg_name=$1 + +if [ -z "$pkg_name" ] || [ "$pkg_name" != "xcat-openbmc-py" ]; then + printusage + exit 1 +fi + +# Find where this script is located to set some build variables +old_pwd=`pwd` +cd `dirname $0` +curdir=`pwd` +export HOME=/root + +WGET_CMD="wget" +if [ ! -z ${LOG} ]; then + WGET_CMD="wget -o ${LOG}" +fi + +if [ -z "$REL" ]; then + t=${curdir%/src/xcat-core} + REL=`basename $t` +fi + +if [ "$PROMOTE" != 1 ]; then + code_change=1 + ver=`cat Version` + short_ver=`cat Version|cut -d. -f 1,2` + short_short_ver=`cat Version|cut -d. -f 1` + build_time=`date` + build_machine=`hostname` + commit_id=`git rev-parse --short HEAD` + commit_id_long=`git rev-parse HEAD` + + echo "###############################" + echo "# Building xcat-openbmc-py package #" + echo "###############################" + + #the package type: local | snap | alpha + #the build introduce string + build_string="Snap_Build" + xcat_release="snap$(date '+%Y%m%d%H%M')" + pkg_version="${ver}-${xcat_release}" + packages="xCAT-openbmc-py" + target_archs=(all) + for file in $packages + do + file_low=`echo $file | tr '[A-Z]' '[a-z]'` + target_archs="all" + for target_arch in $target_archs + do + cd $file + CURDIR=$(pwd) + dch -v $pkg_version -b -c debian/changelog $build_string + if [ "$target_arch" = "all" ]; then + CURDIR=$(pwd) + cp ${CURDIR}/debian/control ${CURDIR}/debian/control.save.998 + sed -i -e "s#>= 2.13-snap000000000000#= ${pkg_version}#g" ${CURDIR}/debian/control + dpkg-buildpackage -rfakeroot -uc -us + mv ${CURDIR}/debian/control.save.998 ${CURDIR}/debian/control + dh_testdir + dh_testroot + dh_clean -d + fi + rc=$? + if [ $rc -gt 0 ]; then + echo "Error: $file build package failed exit code $rc" + exit $rc + fi + rm -f debian/files + rm -f debian/xcat-openbmc-py.debhelper.log + rm -f debian/xcat-openbmc-py.substvars + sed -i -e "s/* Snap_Build//g" debian/changelog + cd - + rm -f ${file_low}_*.tar.gz + rm -f ${file_low}_*.changes + rm -f ${file_low}_*.dsc + done + done +fi