From 917aaf3e922ecc0656663134be8365716e11f6f2 Mon Sep 17 00:00:00 2001 From: xuweibj Date: Wed, 7 Nov 2018 03:37:34 -0500 Subject: [PATCH 1/3] build scripts for ipmitool build --- build.sh | 11 ++++++++ ipmitool/build.sh | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100755 build.sh create mode 100755 ipmitool/build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..5b709ec --- /dev/null +++ b/build.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +pkgname=$1 +cur_path=$(cd "$(dirname "$0")"; pwd) +if [ "$pkgname" = "ipmitool" ]; then + $cur_path/ipmitool/build.sh + exit $? +elif [ -z $pkgname ]; then + echo "Please specify package want to build" + exit 1 +fi diff --git a/ipmitool/build.sh b/ipmitool/build.sh new file mode 100755 index 0000000..eb36e51 --- /dev/null +++ b/ipmitool/build.sh @@ -0,0 +1,67 @@ +#!/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=/ipmitool_build +if [ ${DEST} ]; then + build_dir=${DEST} +fi + +XCAT_BUILD_DISTRO="$(check_linux_distro)" +echo "[INFO] Start to build ipmitool on $XCAT_BUILD_DISTRO" + +cur_path=$(cd "$(dirname "$0")"; pwd) +cd $cur_path + +XCAT_BUILD_DISTRO="$(check_linux_distro)" +case "${XCAT_BUILD_DISTRO}" in +"centos"|"fedora"|"rhel"|"sles") + buildcmd="./bldipmi.pl" + dftpath="/tmp/build/" + pkgtype="rpm" + ;; +"ubuntu") + buildcmd="./make_deb.sh" + dftpath=$cur_path + pkgtype="deb" + ;; +*) + echo "${XCAT_BUILD_DISTRO}: unsupported Linux distribution to build goconserver" + exit 1 + ;; +esac + +$buildcmd |& tee /tmp/build.log +if [ $? != 0 ]; then + echo "[ERROR] Failed to build ipmitool by command $buildcmd" + exit 1 +fi + +buildpath=`find $dftpath -name ipmitool*.$pkgtype | xargs ls -t | head -n 1` +if [ -z "$buildpath" ]; then + echo "[ERROR] Could not find build ipmitool*.$pkgtype" + exit 1 +fi + +filepath=$(dirname $buildpath) +pathpre=${filepath:${#dftpath}} +build_dir=$build_dir/$pathpre +mkdir -p $build_dir + +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 c15b5275237dd1ca3a0c193518bd4a3c69357616 Mon Sep 17 00:00:00 2001 From: xuweibj Date: Wed, 7 Nov 2018 22:17:19 -0500 Subject: [PATCH 2/3] modified depending on comments --- build.sh | 2 +- ipmitool/build.sh | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/build.sh b/build.sh index 5b709ec..56f29f2 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,7 @@ #!/bin/bash pkgname=$1 -cur_path=$(cd "$(dirname "$0")"; pwd) +cur_path=$(dirname "$0") if [ "$pkgname" = "ipmitool" ]; then $cur_path/ipmitool/build.sh exit $? diff --git a/ipmitool/build.sh b/ipmitool/build.sh index eb36e51..61658d8 100755 --- a/ipmitool/build.sh +++ b/ipmitool/build.sh @@ -8,16 +8,14 @@ function check_linux_distro() echo "${distro}" } -build_dir=/ipmitool_build -if [ ${DEST} ]; then - build_dir=${DEST} -fi +pkgname="ipmitool" + +build_dir=${DEST:-/${pkgname}_build} XCAT_BUILD_DISTRO="$(check_linux_distro)" -echo "[INFO] Start to build ipmitool 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")" XCAT_BUILD_DISTRO="$(check_linux_distro)" case "${XCAT_BUILD_DISTRO}" in @@ -39,13 +37,13 @@ esac $buildcmd |& tee /tmp/build.log if [ $? != 0 ]; then - echo "[ERROR] Failed to build ipmitool by command $buildcmd" + echo "[ERROR] Failed to build $pkgname by command $buildcmd" exit 1 fi -buildpath=`find $dftpath -name ipmitool*.$pkgtype | xargs ls -t | head -n 1` +buildpath=`find $dftpath -name ${pkgname}*.$pkgtype | xargs ls -t | head -n 1` if [ -z "$buildpath" ]; then - echo "[ERROR] Could not find build ipmitool*.$pkgtype" + echo "[ERROR] Could not find build ${pkgname}*.$pkgtype" exit 1 fi From 682270f20dcd8ce610c0d4a6fe7c8b4f671437b1 Mon Sep 17 00:00:00 2001 From: xuweibj Date: Thu, 8 Nov 2018 00:40:02 -0500 Subject: [PATCH 3/3] modified depending on comments --- build.sh | 7 ++++--- ipmitool/build.sh | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index 56f29f2..de6927f 100755 --- a/build.sh +++ b/build.sh @@ -2,10 +2,11 @@ pkgname=$1 cur_path=$(dirname "$0") -if [ "$pkgname" = "ipmitool" ]; then - $cur_path/ipmitool/build.sh +if [ "$pkgname" ]; then + $cur_path/$pkgname/build.sh exit $? -elif [ -z $pkgname ]; then +else + # TODO: if not specify, build all packages for xcat-dep echo "Please specify package want to build" exit 1 fi diff --git a/ipmitool/build.sh b/ipmitool/build.sh index 61658d8..572e74e 100755 --- a/ipmitool/build.sh +++ b/ipmitool/build.sh @@ -15,7 +15,8 @@ build_dir=${DEST:-/${pkgname}_build} XCAT_BUILD_DISTRO="$(check_linux_distro)" echo "[INFO] Start to build $pkgname on $XCAT_BUILD_DISTRO" -cd "$(dirname "$0")" +cur_path=$(dirname "$0") +cd $cur_path XCAT_BUILD_DISTRO="$(check_linux_distro)" case "${XCAT_BUILD_DISTRO}" in