makerpm.sh 1.3 KB
Newer Older
H
hzcheng 已提交
1 2 3 4
#!/bin/bash
#
# Generate rpm package for centos 

L
lihui 已提交
5 6 7
#set -e
#set -x

H
hzcheng 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#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 已提交
25 26 27 28 29
csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo"
fi

L
lihui 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
function cp_rpm_package() {
local cur_dir
cd $1
cur_dir=$(pwd)

for dirlist in $(ls ${cur_dir}); do
  if test -d ${dirlist}; then
    cd ${dirlist}
    cp_rpm_package ${cur_dir}/${dirlist}
    cd ..
  fi
  if test -e ${dirlist}; then
    cp ${cur_dir}/${dirlist} ${output_dir}/TDengine-${tdengine_ver}.rpm
  fi
done
}

H
hzcheng 已提交
47
if [ -d ${pkg_dir} ]; then
L
lihui 已提交
48
  ${csudo} rm -rf ${pkg_dir}
H
hzcheng 已提交
49
fi
P
plum-lihui 已提交
50
${csudo} mkdir -p ${pkg_dir}
H
hzcheng 已提交
51 52
cd ${pkg_dir}

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

P
plum-lihui 已提交
55
${csudo} rpmbuild --define="_version ${tdengine_ver}" --define="_topdir ${pkg_dir}" --define="_compiledir ${compile_dir}" -bb ${spec_file}
H
hzcheng 已提交
56 57

# copy rpm package to output_dir, then clean temp dir
L
lihui 已提交
58 59 60
#${csudo} cp -rf RPMS/* ${output_dir}
cp_rpm_package ${pkg_dir}/RPMS 

H
hzcheng 已提交
61
cd ..
P
plum-lihui 已提交
62
${csudo} rm -rf ${pkg_dir}