From 4502d5069e2b01b29f19b75335527edf91ee7f37 Mon Sep 17 00:00:00 2001 From: xuweibj Date: Wed, 7 Nov 2018 03:43:54 -0500 Subject: [PATCH 1/2] build script to build goconserver --- build.sh | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..8dd4b81 --- /dev/null +++ b/build.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +function check_linux_distro() +{ + local distro="$(source /etc/os-release >/dev/null 2>&1 && echo "${ID}")" + [[ -z "${distro}" && -f /etc/redhat-release ]] && distro="rhel" + [[ -z "${distro}" && -f /etc/SuSE-release ]] && distro="sles" + echo "${distro}" +} + +build_dir=/goconserver_build +if [ ${DEST} ]; then + build_dir=${DEST} +fi +mkdir -p $build_dir + +XCAT_BUILD_DISTRO="$(check_linux_distro)" +echo "[INFO] Start to build goconserver on $XCAT_BUILD_DISTRO" + +cur_path=$(cd "$(dirname "$0")"; pwd) +cd $cur_path + +case "${XCAT_BUILD_DISTRO}" in +"centos"|"fedora"|"rhel"|"sles") + pkgtype="rpm" + ;; +"ubuntu") + pkgtype="deb" + ;; +*) + echo "[ERROR] ${XCAT_BUILD_DISTRO}: unsupported Linux distribution to build goconserver" + exit 1 + ;; +esac + +make deps +if [ $? != 0 ]; then + echo "[ERROR] Failed to run make deps" + exit 1 +fi + +make $pkgtype |& tee /tmp/build.log +if [ $? != 0 ]; then + echo "[ERROR] Failed to run make $pkgtype" + exit 1 +fi + +buildpath=`find . -name "goconserver*.$pkgtype" | xargs ls -t | head -n 1` +if [ -z "$buildpath" ]; then + echo "[ERROR] Could not find build goconserver*.$pkgtype" + exit 1 +fi + +cp -f $buildpath $build_dir +if [ $? != 0 ]; then + echo "[ERROR] Failed to copy $buildpath to $build_dir" + exit 1 +fi + +cp -f /tmp/build.log $build_dir + +buildname=$(basename $buildpath) +echo "[INFO] Package path is $build_dir/$buildname" + +exit 0 From 6b24947d66219e35677ed97d13826ed2c9726687 Mon Sep 17 00:00:00 2001 From: xuweibj Date: Wed, 7 Nov 2018 22:16:27 -0500 Subject: [PATCH 2/2] modified depending on comments --- build.sh | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/build.sh b/build.sh index 8dd4b81..760811c 100755 --- a/build.sh +++ b/build.sh @@ -8,17 +8,15 @@ function check_linux_distro() echo "${distro}" } -build_dir=/goconserver_build -if [ ${DEST} ]; then - build_dir=${DEST} -fi +pkgname="goconserver" + +build_dir=${DEST:-/${pkgname}_build} mkdir -p $build_dir XCAT_BUILD_DISTRO="$(check_linux_distro)" -echo "[INFO] Start to build goconserver on $XCAT_BUILD_DISTRO" +echo "[INFO] Start to build $pkgname on $XCAT_BUILD_DISTRO" -cur_path=$(cd "$(dirname "$0")"; pwd) -cd $cur_path +cd "$(dirname "$0")" case "${XCAT_BUILD_DISTRO}" in "centos"|"fedora"|"rhel"|"sles") @@ -28,7 +26,7 @@ case "${XCAT_BUILD_DISTRO}" in pkgtype="deb" ;; *) - echo "[ERROR] ${XCAT_BUILD_DISTRO}: unsupported Linux distribution to build goconserver" + echo "[ERROR] ${XCAT_BUILD_DISTRO}: unsupported Linux distribution to build $pkgname" exit 1 ;; esac @@ -45,9 +43,9 @@ if [ $? != 0 ]; then exit 1 fi -buildpath=`find . -name "goconserver*.$pkgtype" | xargs ls -t | head -n 1` +buildpath=`find . -name "${pkgname}*.$pkgtype" | xargs ls -t | head -n 1` if [ -z "$buildpath" ]; then - echo "[ERROR] Could not find build goconserver*.$pkgtype" + echo "[ERROR] Could not find build ${pkgname}*.$pkgtype" exit 1 fi