2017-06-06 19:16:58 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -x
|
|
|
|
set -euo pipefail
|
|
|
|
IFS=$'\n\t'
|
|
|
|
|
|
|
|
function pack() {
|
2020-06-05 23:25:57 +08:00
|
|
|
PKG_NAME=${1}
|
|
|
|
PKG_VERSION=$(grep '^Version:' ${PKG_NAME}.spec | awk '{print $2}')
|
2017-06-06 19:16:58 +08:00
|
|
|
cd ..
|
2020-06-05 23:25:57 +08:00
|
|
|
PROJECT_NAME="${PKG_NAME}-${PKG_VERSION}"
|
2022-07-13 19:02:44 +08:00
|
|
|
git archive --format=tar --prefix=$PROJECT_NAME/ HEAD | (tar xpf -)
|
2023-03-13 11:08:28 +08:00
|
|
|
tar zcpf ${PROJECT_NAME}.tar.gz ${PROJECT_NAME}
|
|
|
|
/bin/mv -f ${PROJECT_NAME}.tar.gz packaging/
|
2017-06-23 12:46:49 +08:00
|
|
|
rm -rf ${PKG_NAME}-${PKG_VERSION}
|
2017-06-06 19:16:58 +08:00
|
|
|
cd -
|
|
|
|
}
|
|
|
|
|
2020-06-05 23:25:57 +08:00
|
|
|
function help() {
|
|
|
|
echo "$0 build|pack"
|
|
|
|
}
|
|
|
|
|
2022-07-13 18:57:58 +08:00
|
|
|
# 检测rpmbuild是否可使用--nodebuginfo参数
|
|
|
|
function debuginfo() {
|
2023-03-13 11:08:28 +08:00
|
|
|
local exist_debuginfo=`rpmbuild --help | grep 'nodebuginfo' | wc -l`
|
|
|
|
if [ ${exist_debuginfo} -eq 1 ]; then
|
|
|
|
echo "--nodebuginfo"
|
|
|
|
else
|
|
|
|
echo ""
|
|
|
|
fi
|
2022-07-13 18:57:58 +08:00
|
|
|
}
|
|
|
|
|
2020-06-05 23:25:57 +08:00
|
|
|
|
2017-06-06 19:16:58 +08:00
|
|
|
function help() {
|
|
|
|
echo "$0 build|pack"
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$1" == "" ]; then
|
|
|
|
help
|
|
|
|
elif [ "$1" == "pack" ];then
|
2020-06-05 23:25:57 +08:00
|
|
|
pack $2
|
2022-07-13 18:57:58 +08:00
|
|
|
elif [ "$1" == "debuginfo" ];then
|
2023-03-13 11:08:28 +08:00
|
|
|
debuginfo
|
2017-06-06 19:16:58 +08:00
|
|
|
elif [ "$1" == "test" ];then
|
|
|
|
run_test
|
|
|
|
else
|
|
|
|
help
|
|
|
|
fi
|