optimize rpm building for CentOS

This commit is contained in:
shuxin   zheng 2022-07-13 18:57:58 +08:00
parent 0f8e3cd676
commit bbb9b6da29
2 changed files with 16 additions and 1 deletions

View File

@ -11,14 +11,17 @@ PKG_VERSION = $(shell grep '^Version:' $(PKG_NAME).spec | awk '{print $$2}')
PWD = $(shell pwd)
DEBUGINFO=$(shell ./control debuginfo )
all: libs
debuginfo:
tar:
@./control pack ${PKG_NAME}
libs: tar
@mkdir -p {BUILD,BUILDROOT,SRPMS,SPECS}
@rpmbuild --define "_topdir ${PWD}" --define "_sourcedir ${PWD}" --define "_rpmdir ${PWD}" --nodebuginfo -bb $(PKG_NAME).spec
@rpmbuild --define "_topdir ${PWD}" --define "_sourcedir ${PWD}" --define "_rpmdir ${PWD}" ${DEBUGINFO} -bb $(PKG_NAME).spec
@echo Binary PRM for $(PKG_NAME) has been created under ${PWD}/`rpm --eval '%{_arch}'`
clean cl:

12
packaging/control Executable file → Normal file
View File

@ -20,6 +20,16 @@ function help() {
echo "$0 build|pack"
}
# 检测rpmbuild是否可使用--nodebuginfo参数
function debuginfo() {
local exist_debuginfo=`rpmbuild --help |grep 'nodebuginfo' |wc -l`
if [ ${exist_debuginfo} -eq 1 ]; then
echo "--nodebuginfo"
else
echo ""
fi
}
function help() {
echo "$0 build|pack"
@ -29,6 +39,8 @@ if [ "$1" == "" ]; then
help
elif [ "$1" == "pack" ];then
pack $2
elif [ "$1" == "debuginfo" ];then
debuginfo
elif [ "$1" == "test" ];then
run_test
else