makepkg_power.sh 8.2 KB
Newer Older
H
Hui Li 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/bin/bash
#
# Generate tar.gz package for all os system

set -e
#set -x

curr_dir=$(pwd)
compile_dir=$1
version=$2
build_time=$3
cpuType=$4
osType=$5
verMode=$6
verType=$7
pagMode=$8
17
versionComp=$9
H
Hui Li 已提交
18 19 20 21 22 23 24 25 26 27 28

script_dir="$(dirname $(readlink -f $0))"
top_dir="$(readlink -f ${script_dir}/../..)"

# create compressed install file.
build_dir="${compile_dir}/build"
code_dir="${top_dir}/src"
release_dir="${top_dir}/release"

#package_name='linux'
if [ "$verMode" == "cluster" ]; then
H
Hui Li 已提交
29
    install_dir="${release_dir}/PowerDB-enterprise-server-${version}"
H
Hui Li 已提交
30
else
H
Hui Li 已提交
31
    install_dir="${release_dir}/PowerDB-server-${version}"
H
Hui Li 已提交
32 33 34 35
fi

# Directories and files.
#if [ "$pagMode" == "lite" ]; then
36
#  strip ${build_dir}/bin/taosd
H
Hui Li 已提交
37 38
#  strip ${build_dir}/bin/taos
#  bin_files="${build_dir}/bin/powerd ${build_dir}/bin/power ${script_dir}/remove_power.sh"
39
#else
40 41
#  bin_files="${build_dir}/bin/powerd ${build_dir}/bin/power ${build_dir}/bin/powerdemo ${build_dir}/bin/tarbitrator ${script_dir}/remove_power.sh\
#              ${script_dir}/set_core.sh ${script_dir}/startPre.sh  ${script_dir}/taosd-dump-cfg.gdb"
H
Hui Li 已提交
42 43 44 45
#fi

lib_files="${build_dir}/lib/libtaos.so.${version}"
header_files="${code_dir}/inc/taos.h ${code_dir}/inc/taoserror.h"
46 47 48 49 50
if [ "$verMode" == "cluster" ]; then
  cfg_dir="${top_dir}/../enterprise/packaging/cfg"
else
  cfg_dir="${top_dir}/packaging/cfg"
fi
H
Hui Li 已提交
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
install_files="${script_dir}/install_power.sh"
nginx_dir="${code_dir}/../../enterprise/src/plugins/web"

# Init file
#init_dir=${script_dir}/deb
#if [ $package_type = "centos" ]; then
#    init_dir=${script_dir}/rpm
#fi
#init_files=${init_dir}/powerd
# temp use rpm's powerd. TODO: later modify according to os type
init_file_deb=${script_dir}/../deb/powerd
init_file_rpm=${script_dir}/../rpm/powerd
init_file_tarbitrator_deb=${script_dir}/../deb/tarbitratord
init_file_tarbitrator_rpm=${script_dir}/../rpm/tarbitratord

# make directories.
mkdir -p ${install_dir}
mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc
mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/taos.cfg ${install_dir}/cfg/taos.cfg

#mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/* || :
mkdir -p ${install_dir}/bin
if [ "$pagMode" == "lite" ]; then
74
  strip ${build_dir}/bin/taosd
H
Hui Li 已提交
75 76 77 78 79
  strip ${build_dir}/bin/taos
#  bin_files="${build_dir}/bin/powerd ${build_dir}/bin/power ${script_dir}/remove_power.sh"
  cp ${build_dir}/bin/taos          ${install_dir}/bin/power
  cp ${build_dir}/bin/taosd         ${install_dir}/bin/powerd
  cp ${script_dir}/remove_power.sh  ${install_dir}/bin
80
else
H
Hui Li 已提交
81 82 83 84
#  bin_files="${build_dir}/bin/powerd ${build_dir}/bin/power ${build_dir}/bin/powerdemo ${build_dir}/bin/tarbitrator ${script_dir}/remove_power.sh ${script_dir}/set_core.sh"
  cp ${build_dir}/bin/taos          ${install_dir}/bin/power
  cp ${build_dir}/bin/taosd         ${install_dir}/bin/powerd
  cp ${script_dir}/remove_power.sh  ${install_dir}/bin
85 86
  cp ${build_dir}/bin/taosdemo      ${install_dir}/bin/powerdemo
  cp ${build_dir}/bin/taosdump      ${install_dir}/bin/powerdump
H
Hui Li 已提交
87 88
  cp ${build_dir}/bin/tarbitrator   ${install_dir}/bin
  cp ${script_dir}/set_core.sh      ${install_dir}/bin
89
  cp ${script_dir}/get_client.sh    ${install_dir}/bin
90 91
  cp ${script_dir}/startPre.sh      ${install_dir}/bin
  cp ${script_dir}/taosd-dump-cfg.gdb  ${install_dir}/bin
H
Hui Li 已提交
92 93 94 95 96 97 98 99 100 101 102
fi
chmod a+x ${install_dir}/bin/* || :

mkdir -p ${install_dir}/init.d && cp ${init_file_deb} ${install_dir}/init.d/powerd.deb
mkdir -p ${install_dir}/init.d && cp ${init_file_rpm} ${install_dir}/init.d/powerd.rpm
mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_deb} ${install_dir}/init.d/tarbitratord.deb || :
mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_rpm} ${install_dir}/init.d/tarbitratord.rpm || :

if [ "$verMode" == "cluster" ]; then
    sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/bin/remove_power.sh >> remove_power_temp.sh
    mv remove_power_temp.sh ${install_dir}/bin/remove_power.sh
103

H
Hui Li 已提交
104 105 106 107
    mkdir -p ${install_dir}/nginxd && cp -r ${nginx_dir}/* ${install_dir}/nginxd
    cp ${nginx_dir}/png/taos.png ${install_dir}/nginxd/admin/images/taos.png
    rm -rf ${install_dir}/nginxd/png

108
    sed -i "s/TDengine/PowerDB/g"   ${install_dir}/nginxd/admin/*.html
H
Hui Li 已提交
109
    sed -i "s/TDengine/PowerDB/g"   ${install_dir}/nginxd/admin/js/*.js
110

H
Hui Li 已提交
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
    sed -i '/dataDir/ {s/taos/power/g}'  ${install_dir}/cfg/taos.cfg
    sed -i '/logDir/  {s/taos/power/g}'  ${install_dir}/cfg/taos.cfg
    sed -i "s/TDengine/PowerDB/g"        ${install_dir}/cfg/taos.cfg

    if [ "$cpuType" == "aarch64" ]; then
        cp -f ${install_dir}/nginxd/sbin/arm/64bit/nginx ${install_dir}/nginxd/sbin/
    elif [ "$cpuType" == "aarch32" ]; then
        cp -f ${install_dir}/nginxd/sbin/arm/32bit/nginx ${install_dir}/nginxd/sbin/
    fi
    rm -rf ${install_dir}/nginxd/sbin/arm
fi

cd ${install_dir}
tar -zcv -f power.tar.gz * --remove-files  || :
exitcode=$?
if [ "$exitcode" != "0" ]; then
    echo "tar power.tar.gz error !!!"
    exit $exitcode
fi

cd ${curr_dir}
cp ${install_files} ${install_dir}
if [ "$verMode" == "cluster" ]; then
    sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/install_power.sh >> install_power_temp.sh
    mv install_power_temp.sh ${install_dir}/install_power.sh
fi
if [ "$pagMode" == "lite" ]; then
    sed 's/pagMode=full/pagMode=lite/g' ${install_dir}/install.sh >> install_power_temp.sh
    mv install_power_temp.sh ${install_dir}/install_power.sh
fi
chmod a+x ${install_dir}/install_power.sh

# Copy example code
mkdir -p ${install_dir}/examples
examples_dir="${top_dir}/tests/examples"
cp -r ${examples_dir}/c      ${install_dir}/examples
sed -i '/passwd/ {s/taosdata/powerdb/g}'  ${install_dir}/examples/c/*.c
sed -i '/root/   {s/taosdata/powerdb/g}'  ${install_dir}/examples/c/*.c

if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then
  cp -r ${examples_dir}/JDBC   ${install_dir}/examples
  cp -r ${examples_dir}/matlab ${install_dir}/examples
153
  sed -i '/password/ {s/taosdata/powerdb/g}'  ${install_dir}/examples/matlab/TDengineDemo.m
H
Hui Li 已提交
154
  cp -r ${examples_dir}/python ${install_dir}/examples
155
  sed -i '/password/ {s/taosdata/powerdb/g}'  ${install_dir}/examples/python/read_example.py
H
Hui Li 已提交
156
  cp -r ${examples_dir}/R      ${install_dir}/examples
157 158
  sed -i '/password/ {s/taosdata/powerdb/g}'  ${install_dir}/examples/R/command.txt
  cp -r ${examples_dir}/go     ${install_dir}/examples
H
Hui Li 已提交
159
  sed -i '/root/ {s/taosdata/powerdb/g}'  ${install_dir}/examples/go/taosdemo.go
H
Hui Li 已提交
160 161
fi
# Copy driver
162
mkdir -p ${install_dir}/driver && cp ${lib_files} ${install_dir}/driver && echo "${versionComp}" > ${install_dir}/driver/vercomp.txt
H
Hui Li 已提交
163 164 165 166 167

# Copy connector
connector_dir="${code_dir}/connector"
mkdir -p ${install_dir}/connector
if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then
P
plum-lihui 已提交
168
  cp ${build_dir}/lib/*.jar      ${install_dir}/connector ||:
Z
zyyang 已提交
169 170 171 172 173 174 175 176 177 178 179

  if [ -d "${connector_dir}/grafanaplugin/dist" ]; then
    cp -r ${connector_dir}/grafanaplugin/dist ${install_dir}/connector/grafanaplugin
  else
    echo "WARNING: grafanaplugin bundled dir not found, please check if want to use it!"
  fi
  if find ${connector_dir}/go -mindepth 1 -maxdepth 1 | read; then
    cp -r ${connector_dir}/go ${install_dir}/connector
  else
    echo "WARNING: go connector not found, please check if want to use it!"
  fi
H
Hui Li 已提交
180
  cp -r ${connector_dir}/python  ${install_dir}/connector/
181

182
  sed -i '/password/ {s/taosdata/powerdb/g}'  ${install_dir}/connector/python/taos/cinterface.py
183

184
  sed -i '/password/ {s/taosdata/powerdb/g}'  ${install_dir}/connector/python/taos/subscription.py
185

186
  sed -i '/self._password/ {s/taosdata/powerdb/g}'  ${install_dir}/connector/python/taos/connection.py
H
Hui Li 已提交
187 188 189 190 191 192
fi
# Copy release note
# cp ${script_dir}/release_note ${install_dir}

# exit 1

193
cd ${release_dir}
H
Hui Li 已提交
194 195

if [ "$verMode" == "cluster" ]; then
H
Hui Li 已提交
196
  pkg_name=${install_dir}-${osType}-${cpuType}
H
Hui Li 已提交
197
elif [ "$verMode" == "edge" ]; then
H
Hui Li 已提交
198
  pkg_name=${install_dir}-${osType}-${cpuType}
H
Hui Li 已提交
199 200 201 202 203 204 205 206 207 208 209
else
  echo "unknow verMode, nor cluster or edge"
  exit 1
fi

if [ "$pagMode" == "lite" ]; then
  pkg_name=${pkg_name}-Lite
fi

if [ "$verType" == "beta" ]; then
  pkg_name=${pkg_name}-${verType}
210 211
elif [ "$verType" == "stable" ]; then
  pkg_name=${pkg_name}
H
Hui Li 已提交
212 213 214 215 216 217 218 219 220 221 222 223 224
else
  echo "unknow verType, nor stabel or beta"
  exit 1
fi

tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || :
exitcode=$?
if [ "$exitcode" != "0" ]; then
    echo "tar ${pkg_name}.tar.gz error !!!"
    exit $exitcode
fi

cd ${curr_dir}