2
0
mirror of https://github.com/xcat2/xcat-dep.git synced 2024-11-24 18:40:05 +00:00
xcat-dep/ipmitool/build.sh

67 lines
1.5 KiB
Bash
Raw Normal View History

2018-11-07 08:37:34 +00:00
#!/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}"
}
2018-11-08 03:17:19 +00:00
pkgname="ipmitool"
build_dir=${DEST:-/${pkgname}_build}
2018-11-07 08:37:34 +00:00
XCAT_BUILD_DISTRO="$(check_linux_distro)"
2018-11-08 03:17:19 +00:00
echo "[INFO] Start to build $pkgname on $XCAT_BUILD_DISTRO"
2018-11-07 08:37:34 +00:00
2018-11-08 05:40:02 +00:00
cur_path=$(dirname "$0")
cd $cur_path
2018-11-07 08:37:34 +00:00
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
2018-11-08 03:17:19 +00:00
echo "[ERROR] Failed to build $pkgname by command $buildcmd"
2018-11-07 08:37:34 +00:00
exit 1
fi
2018-11-08 03:17:19 +00:00
buildpath=`find $dftpath -name ${pkgname}*.$pkgtype | xargs ls -t | head -n 1`
2018-11-07 08:37:34 +00:00
if [ -z "$buildpath" ]; then
2018-11-08 03:17:19 +00:00
echo "[ERROR] Could not find build ${pkgname}*.$pkgtype"
2018-11-07 08:37:34 +00:00
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