makerpm.sh 994 字节
Newer Older
H
hzcheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#!/bin/bash
#
# Generate rpm package for centos 

#curr_dir=$(pwd)
compile_dir=$1
output_dir=$2
tdengine_ver=$3

script_dir="$(dirname $(readlink -f $0))"
top_dir="$(readlink -m ${script_dir}/../..)"
pkg_dir="${top_dir}/rpmworkroom"
spec_file="${script_dir}/tdengine.spec"

#echo "curr_dir: ${curr_dir}"
#echo "top_dir: ${top_dir}"
#echo "script_dir: ${script_dir}"
echo "compile_dir: ${compile_dir}"
echo "pkg_dir: ${pkg_dir}"
echo "spec_file: ${spec_file}"

P
plum-lihui 已提交
22 23 24 25 26
csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo"
fi

H
hzcheng 已提交
27
if [ -d ${pkg_dir} ]; then
P
plum-lihui 已提交
28
	 ${csudo} rm -rf ${pkg_dir}
H
hzcheng 已提交
29
fi
P
plum-lihui 已提交
30
${csudo} mkdir -p ${pkg_dir}
H
hzcheng 已提交
31 32
cd ${pkg_dir}

P
plum-lihui 已提交
33
${csudo} mkdir -p BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
H
hzcheng 已提交
34

P
plum-lihui 已提交
35
${csudo} rpmbuild --define="_version ${tdengine_ver}" --define="_topdir ${pkg_dir}" --define="_compiledir ${compile_dir}" -bb ${spec_file}
H
hzcheng 已提交
36 37 38

# copy rpm package to output_dir, then clean temp dir
#echo "rmpbuild end, cur_dir: $(pwd) "
P
plum-lihui 已提交
39
${csudo} cp -rf RPMS/* ${output_dir} 
H
hzcheng 已提交
40
cd ..
P
plum-lihui 已提交
41
${csudo} rm -rf ${pkg_dir}