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

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

H
hzcheng 已提交
8 9 10 11
#curr_dir=$(pwd)
compile_dir=$1
output_dir=$2
tdengine_ver=$3
L
lihui 已提交
12 13 14 15
cpuType=$4
osType=$5
verMode=$6
verType=$7
H
hzcheng 已提交
16 17

script_dir="$(dirname $(readlink -f $0))"
F
Frozen 已提交
18
top_dir="$(readlink -f ${script_dir}/../..)"
H
hzcheng 已提交
19 20 21 22 23 24 25 26 27 28
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 已提交
29 30 31 32 33
csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo"
fi

L
lihui 已提交
34
function cp_rpm_package() {
35 36 37 38 39 40 41 42 43 44 45 46 47 48
    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
L
lihui 已提交
49 50
}

H
hzcheng 已提交
51
if [ -d ${pkg_dir} ]; then
L
lihui 已提交
52
  ${csudo} rm -rf ${pkg_dir}
H
hzcheng 已提交
53
fi
P
plum-lihui 已提交
54
${csudo} mkdir -p ${pkg_dir}
H
hzcheng 已提交
55 56
cd ${pkg_dir}

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

59 60 61 62
if [ -f ${compile_dir}/build/lib/libavro.so.23.0.0 ]; then
    sed -i.bak 's/#Requires:/Requires: jansson snappy/g' ${spec_file}
fi

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

L
lihui 已提交
65
# copy rpm package to output_dir, and modify package name, then clean temp dir
L
lihui 已提交
66
#${csudo} cp -rf RPMS/* ${output_dir}
67
cp_rpm_package ${pkg_dir}/RPMS
L
lihui 已提交
68

L
lihui 已提交
69 70 71

if [ "$verMode" == "cluster" ]; then
  rpmname="TDengine-server-"${tdengine_ver}-${osType}-${cpuType}
L
lihui 已提交
72
elif [ "$verMode" == "edge" ]; then
L
lihui 已提交
73
  rpmname="TDengine-server"-${tdengine_ver}-${osType}-${cpuType}
L
lihui 已提交
74
else
L
lihui 已提交
75
  echo "unknow verMode, nor cluster or edge"
L
lihui 已提交
76 77 78 79
  exit 1
fi

if [ "$verType" == "beta" ]; then
80
  rpmname="TDengine-server-"${tdengine_ver}-${verType}-${osType}-${cpuType}".rpm"
81
elif [ "$verType" == "stable" ]; then
L
lihui 已提交
82 83 84 85
  rpmname=${rpmname}".rpm"
else
  echo "unknow verType, nor stabel or beta"
  exit 1
L
lihui 已提交
86 87
fi

L
lihui 已提交
88 89
mv ${output_dir}/TDengine-${tdengine_ver}.rpm ${output_dir}/${rpmname}

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