release.sh 26.4 KB
Newer Older
H
hzcheng 已提交
1 2
#!/bin/bash
#
3
# Generate the deb package for ubuntu, or rpm package for centos, or tar.gz package for other linux os
H
hzcheng 已提交
4 5

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

8
# release.sh  -v [cluster | edge]
9
#             -c [aarch32 | aarch64 | x64 | x86 | mips64 ...]
H
Hui Li 已提交
10
#             -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...]
L
lihui 已提交
11 12
#             -V [stable | beta]
#             -l [full | lite]
H
Hui Li 已提交
13
#             -s [static | dynamic]
14
#             -d [taos | power | tq | pro | kh | jh]
H
Hui Li 已提交
15
#             -n [2.0.0.3]
H
Hui Li 已提交
16
#             -m [2.0.0.0]
17
#             -H [ false | true]
L
lihui 已提交
18 19

# set parameters by default value
L
lihui 已提交
20
verMode=edge     # [cluster, edge]
L
lihui 已提交
21 22
verType=stable   # [stable, beta]
cpuType=x64      # [aarch32 | aarch64 | x64 | x86 | mips64 ...]
H
Hui Li 已提交
23
osType=Linux     # [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...]
L
lihui 已提交
24
pagMode=full     # [full | lite]
H
Hui Li 已提交
25
soMode=dynamic   # [static | dynamic]
26
dbName=taos      # [taos | power | tq | pro | kh | jh]
27
allocator=glibc  # [glibc | jemalloc]
H
Hui Li 已提交
28
verNumber=""
29
verNumberComp="1.0.0.0"
30
httpdBuild=false
L
lihui 已提交
31

32
while getopts "hv:V:c:o:l:s:d:a:n:m:H:" arg
L
lihui 已提交
33 34 35 36 37 38 39 40 41 42 43 44 45 46
do
  case $arg in
    v)
      #echo "verMode=$OPTARG"
      verMode=$( echo $OPTARG )
      ;;
    V)
      #echo "verType=$OPTARG"
      verType=$(echo $OPTARG)
      ;;
    c)
      #echo "cpuType=$OPTARG"
      cpuType=$(echo $OPTARG)
      ;;
L
lihui 已提交
47 48 49 50
    l)
      #echo "pagMode=$OPTARG"
      pagMode=$(echo $OPTARG)
      ;;
H
Hui Li 已提交
51 52 53 54
    s)
      #echo "soMode=$OPTARG"
      soMode=$(echo $OPTARG)
      ;;
H
Hui Li 已提交
55 56 57 58
    d)
      #echo "dbName=$OPTARG"
      dbName=$(echo $OPTARG)
      ;;
59 60 61 62
    a)
      #echo "allocator=$OPTARG"
      allocator=$(echo $OPTARG)
      ;;
H
Hui Li 已提交
63 64 65 66
    n)
      #echo "verNumber=$OPTARG"
      verNumber=$(echo $OPTARG)
      ;;
H
Hui Li 已提交
67 68 69 70
    m)
      #echo "verNumberComp=$OPTARG"
      verNumberComp=$(echo $OPTARG)
      ;;
L
lihui 已提交
71 72 73 74
    o)
      #echo "osType=$OPTARG"
      osType=$(echo $OPTARG)
      ;;
75 76 77 78
    H)
      #echo "httpdBuild=$OPTARG"
      httpdBuild=$(echo $OPTARG)
      ;;
L
lihui 已提交
79
    h)
H
Hui Li 已提交
80 81
      echo "Usage: `basename $0` -v [cluster | edge] "
      echo "                  -c [aarch32 | aarch64 | x64 | x86 | mips64 ...] "
H
Hui Li 已提交
82
      echo "                  -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...] "
H
Hui Li 已提交
83 84
      echo "                  -V [stable | beta] "
      echo "                  -l [full | lite] "
85
      echo "                  -a [glibc | jemalloc] "
H
Hui Li 已提交
86
      echo "                  -s [static | dynamic] "
87
      echo "                  -d [taos | power | tq | pro | kh | jh] "
H
Hui Li 已提交
88
      echo "                  -n [version number] "
H
Hui Li 已提交
89
      echo "                  -m [compatible version number] "
90
      echo "                  -H [false | true] "
L
lihui 已提交
91 92
      exit 0
      ;;
93
    ?) #unknow option
L
lihui 已提交
94 95 96 97 98 99
      echo "unkonw argument"
      exit 1
      ;;
  esac
done

100
echo "verMode=${verMode} verType=${verType} cpuType=${cpuType} osType=${osType} pagMode=${pagMode} soMode=${soMode} dbName=${dbName} allocator=${allocator} verNumber=${verNumber} verNumberComp=${verNumberComp} httpdBuild=${httpdBuild}"
H
hzcheng 已提交
101 102

curr_dir=$(pwd)
S
slguan 已提交
103 104

if [ "$osType" != "Darwin" ]; then
H
Hui Li 已提交
105 106
  script_dir="$(dirname $(readlink -f $0))"
  top_dir="$(readlink -f ${script_dir}/..)"
S
slguan 已提交
107
else
H
Hui Li 已提交
108 109 110 111
  script_dir=`dirname $0`
  cd ${script_dir}
  script_dir="$(pwd)"
  top_dir=${script_dir}/..
S
slguan 已提交
112 113
fi

P
plum-lihui 已提交
114
csudo=""
H
Hui Li 已提交
115
#if command -v sudo > /dev/null; then
H
Hui Li 已提交
116
#  csudo="sudo"
H
Hui Li 已提交
117
#fi
P
plum-lihui 已提交
118

H
hzcheng 已提交
119
function is_valid_version() {
H
Hui Li 已提交
120
  [ -z $1 ] && return 1 || :
H
hzcheng 已提交
121

H
Hui Li 已提交
122 123 124 125 126
  rx='^([0-9]+\.){3}(\*|[0-9]+)$'
  if [[ $1 =~ $rx ]]; then
    return 0
  fi
  return 1
H
hzcheng 已提交
127 128 129
}

function vercomp () {
H
Hui Li 已提交
130
  if [[ $1 == $2 ]]; then
H
hzcheng 已提交
131
    echo 0
H
Hui Li 已提交
132 133
    exit 0
  fi
134

H
Hui Li 已提交
135 136 137 138 139 140 141
  local IFS=.
  local i ver1=($1) ver2=($2)

  # fill empty fields in ver1 with zeros
  for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do
    ver1[i]=0
  done
H
hzcheng 已提交
142

H
Hui Li 已提交
143 144 145 146 147 148 149 150 151 152 153 154
  for ((i=0; i<${#ver1[@]}; i++)); do
    if [[ -z ${ver2[i]} ]]; then
      # fill empty fields in ver2 with zeros
      ver2[i]=0
    fi
    if ((10#${ver1[i]} > 10#${ver2[i]})); then
      echo 1
      exit 0
    fi
    if ((10#${ver1[i]} < 10#${ver2[i]})); then
      echo 2
      exit 0
H
Hui Li 已提交
155 156
    fi
  done
H
Hui Li 已提交
157 158 159 160
  echo 0
}

# 1. check version information
161
if ( ( ! is_valid_version $verNumber ) || ( ! is_valid_version $verNumberComp ) || [[ "$(vercomp $verNumber $verNumberComp)" == '2' ]] ); then
H
Hui Li 已提交
162 163 164
  echo "please enter correct version"
  exit 0
fi
H
Hui Li 已提交
165

H
Hui Li 已提交
166
echo "=======================new version number: ${verNumber}, compatible version: ${verNumberComp}======================================"
H
hzcheng 已提交
167 168

build_time=$(date +"%F %R")
H
Hui Li 已提交
169 170 171

# get commint id from git
gitinfo=$(git rev-parse --verify HEAD)
P
plum-lihui 已提交
172 173 174 175 176 177 178 179

if [[ "$verMode" == "cluster" ]]; then
  enterprise_dir="${top_dir}/../enterprise"
  cd ${enterprise_dir}
  gitinfoOfInternal=$(git rev-parse --verify HEAD)
else
  gitinfoOfInternal=NULL
fi
180

H
Hui Li 已提交
181
cd ${curr_dir}
L
lihui 已提交
182

H
hzcheng 已提交
183
# 2. cmake executable file
L
lihui 已提交
184
compile_dir="${top_dir}/debug"
H
hzcheng 已提交
185
if [ -d ${compile_dir} ]; then
H
Hui Li 已提交
186
  ${csudo} rm -rf ${compile_dir}
H
hzcheng 已提交
187 188
fi

S
slguan 已提交
189
if [ "$osType" != "Darwin" ]; then
H
Hui Li 已提交
190
  ${csudo} mkdir -p ${compile_dir}
S
slguan 已提交
191
else
H
Hui Li 已提交
192
  mkdir -p ${compile_dir}
S
slguan 已提交
193
fi
H
hzcheng 已提交
194
cd ${compile_dir}
L
lihui 已提交
195

196 197 198 199 200 201
if [[ "$allocator" == "jemalloc" ]]; then
    allocator_macro="-DJEMALLOC_ENABLED=true"
else
    allocator_macro=""
fi

202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
# for powerdb
if [[ "$dbName" == "power" ]]; then
  # cmake/install.inc
  sed -i "s/C:\/TDengine/C:\/PowerDB/g" ${top_dir}/cmake/install.inc
  sed -i "s/taos\.exe/power\.exe/g" ${top_dir}/cmake/install.inc
  sed -i "s/taosdemo\.exe/powerdemo\.exe/g" ${top_dir}/cmake/install.inc
  # src/kit/shell/inc/shell.h
  sed -i "s/taos_history/power_history/g" ${top_dir}/src/kit/shell/inc/shell.h
  # src/inc/taosdef.h
  sed -i "s/\"taosdata\"/\"powerdb\"/g" ${top_dir}/src/inc/taosdef.h
  # src/util/src/tconfig.c
  sed -i "s/taos config/power config/g" ${top_dir}/src/util/src/tconfig.c
  sed -i "s/taos\.cfg/power\.cfg/g"   ${top_dir}/src/util/src/tconfig.c
  sed -i "s/etc\/taos/etc\/power/g"   ${top_dir}/src/util/src/tconfig.c
  # src/kit/taosdemo/taosdemo.c
  sed -i "s/\"taosdata\"/\"powerdb\"/g" ${top_dir}/src/kit/taosdemo/taosdemo.c
  # src/util/src/tlog.c
  sed -i "s/log\/taos/log\/power/g"   ${top_dir}/src/util/src/tlog.c
  # src/dnode/src/dnodeSystem.c
  sed -i "s/TDengine/Power/g" ${top_dir}/src/dnode/src/dnodeSystem.c
  sed -i "s/TDengine/Power/g"   ${top_dir}/src/dnode/src/dnodeMain.c
  sed -i "s/taosdlog/powerdlog/g"   ${top_dir}/src/dnode/src/dnodeMain.c
  # src/client/src/tscSystem.c
  sed -i "s/taoslog/powerlog/g"   ${top_dir}/src/client/src/tscSystem.c
  # src/util/src/tnote.c
  sed -i "s/taosinfo/powerinfo/g"   ${top_dir}/src/util/src/tnote.c
  # src/dnode/CMakeLists.txt
  sed -i "s/taos\.cfg/power\.cfg/g"   ${top_dir}/src/dnode/CMakeLists.txt
  # src/kit/taosdump/taosdump.c
  sed -i "s/TDengine/Power/g" ${top_dir}/src/kit/taosdump/taosdump.c
  sed -i "s/Default is taosdata/Default is power/g" ${top_dir}/src/kit/taosdump/taosdump.c
  sed -i "s/\"taosdata\"/\"powerdb\"/g" ${top_dir}/src/kit/taosdump/taosdump.c
  sed -i "s/taos\/taos\.cfg/power\/power\.cfg/g" ${top_dir}/src/kit/taosdump/taosdump.c
  # src/os/src/linux/linuxEnv.c
  sed -i "s/etc\/taos/etc\/power/g" ${top_dir}/src/os/src/linux/linuxEnv.c
  sed -i "s/lib\/taos/lib\/power/g" ${top_dir}/src/os/src/linux/linuxEnv.c
  sed -i "s/log\/taos/log\/power/g" ${top_dir}/src/os/src/linux/linuxEnv.c
  # src/os/src/windows/wEnv.c
  sed -i "s/TDengine/PowerDB/g" ${top_dir}/src/os/src/windows/wEnv.c
  # src/kit/shell/src/shellEngine.c
  sed -i "s/TDengine shell/PowerDB shell/g" ${top_dir}/src/kit/shell/src/shellEngine.c
  sed -i "s/2020 by TAOS Data, Inc/2020 by PowerDB, Inc/g" ${top_dir}/src/kit/shell/src/shellEngine.c
  sed -i "s/\"taos> \"/\"power> \"/g" ${top_dir}/src/kit/shell/src/shellEngine.c
  sed -i "s/\"   -> \"/\"    -> \"/g" ${top_dir}/src/kit/shell/src/shellEngine.c
  sed -i "s/prompt_size = 6/prompt_size = 7/g" ${top_dir}/src/kit/shell/src/shellEngine.c
fi

# for tq
if [[ "$dbName" == "tq" ]]; then
  # cmake/install.inc
  sed -i "s/C:\/TDengine/C:\/TQueue/g" ${top_dir}/cmake/install.inc
  sed -i "s/taos\.exe/tq\.exe/g" ${top_dir}/cmake/install.inc
  sed -i "s/taosdemo\.exe/tqdemo\.exe/g" ${top_dir}/cmake/install.inc
  # src/kit/shell/inc/shell.h
  sed -i "s/taos_history/tq_history/g" ${top_dir}/src/kit/shell/inc/shell.h
  # src/inc/taosdef.h
  sed -i "s/\"taosdata\"/\"tqueue\"/g" ${top_dir}/src/inc/taosdef.h
  # src/util/src/tconfig.c
  sed -i "s/taos config/tq config/g" ${top_dir}/src/util/src/tconfig.c
  sed -i "s/taos\.cfg/tq\.cfg/g"   ${top_dir}/src/util/src/tconfig.c
  sed -i "s/etc\/taos/etc\/tq/g"   ${top_dir}/src/util/src/tconfig.c
  # src/kit/taosdemo/taosdemo.c
  sed -i "s/\"taosdata\"/\"tqueue\"/g" ${top_dir}/src/kit/taosdemo/taosdemo.c
  # src/util/src/tlog.c
  sed -i "s/log\/taos/log\/tq/g"   ${top_dir}/src/util/src/tlog.c
  # src/dnode/src/dnodeSystem.c
  sed -i "s/TDengine/TQueue/g" ${top_dir}/src/dnode/src/dnodeSystem.c
  sed -i "s/TDengine/TQueue/g"   ${top_dir}/src/dnode/src/dnodeMain.c
  sed -i "s/taosdlog/tqdlog/g"   ${top_dir}/src/dnode/src/dnodeMain.c
  # src/client/src/tscSystem.c
  sed -i "s/taoslog/tqlog/g"   ${top_dir}/src/client/src/tscSystem.c
  # src/util/src/tnote.c
  sed -i "s/taosinfo/tqinfo/g"   ${top_dir}/src/util/src/tnote.c
  # src/dnode/CMakeLists.txt
  sed -i "s/taos\.cfg/tq\.cfg/g"   ${top_dir}/src/dnode/CMakeLists.txt
  # src/kit/taosdump/taosdump.c
  sed -i "s/TDengine/TQueue/g" ${top_dir}/src/kit/taosdump/taosdump.c
  sed -i "s/Default is taosdata/Default is tqueue/g" ${top_dir}/src/kit/taosdump/taosdump.c
  sed -i "s/\"taosdata\"/\"tqueue\"/g" ${top_dir}/src/kit/taosdump/taosdump.c
  sed -i "s/taos\/taos\.cfg/tq\/tq\.cfg/g" ${top_dir}/src/kit/taosdump/taosdump.c
  # src/os/src/linux/linuxEnv.c
  sed -i "s/etc\/taos/etc\/tq/g" ${top_dir}/src/os/src/linux/linuxEnv.c
  sed -i "s/lib\/taos/lib\/tq/g" ${top_dir}/src/os/src/linux/linuxEnv.c
  sed -i "s/log\/taos/log\/tq/g" ${top_dir}/src/os/src/linux/linuxEnv.c
  # src/os/src/windows/wEnv.c
  sed -i "s/TDengine/TQ/g" ${top_dir}/src/os/src/windows/wEnv.c
  # src/kit/shell/src/shellEngine.c
  sed -i "s/TDengine shell/TQ shell/g" ${top_dir}/src/kit/shell/src/shellEngine.c
  sed -i "s/2020 by TAOS Data, Inc/2020 by TQ, Inc/g" ${top_dir}/src/kit/shell/src/shellEngine.c
  sed -i "s/\"taos> \"/\"tq> \"/g" ${top_dir}/src/kit/shell/src/shellEngine.c
  sed -i "s/\"   -> \"/\" -> \"/g" ${top_dir}/src/kit/shell/src/shellEngine.c
  sed -i "s/prompt_size = 6/prompt_size = 4/g" ${top_dir}/src/kit/shell/src/shellEngine.c
fi

# for prodb
297
if [[ "$dbName" == "pro" ]]; then
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
  # cmake/install.inc
  sed -i "s/C:\/TDengine/C:\/ProDB/g" ${top_dir}/cmake/install.inc
  sed -i "s/taos\.exe/prodbc\.exe/g" ${top_dir}/cmake/install.inc
  sed -i "s/taosdemo\.exe/prodemo\.exe/g" ${top_dir}/cmake/install.inc
  # src/kit/shell/inc/shell.h
  sed -i "s/taos_history/prodb_history/g" ${top_dir}/src/kit/shell/inc/shell.h
  # src/inc/taosdef.h
  sed -i "s/\"taosdata\"/\"prodb\"/g" ${top_dir}/src/inc/taosdef.h
  # src/util/src/tconfig.c
  sed -i "s/taos config/prodb config/g" ${top_dir}/src/util/src/tconfig.c
  sed -i "s/taos\.cfg/prodb\.cfg/g"   ${top_dir}/src/util/src/tconfig.c
  sed -i "s/etc\/taos/etc\/ProDB/g"   ${top_dir}/src/util/src/tconfig.c
  # src/kit/taosdemo/taosdemo.c
  sed -i "s/\"taosdata\"/\"prodb\"/g" ${top_dir}/src/kit/taosdemo/taosdemo.c
  sed -i "s/support@taosdata.com/support@hanatech.com.cn/g" ${top_dir}/src/kit/taosdemo/taosdemo.c
  # src/util/src/tlog.c
  sed -i "s/log\/taos/log\/ProDB/g"   ${top_dir}/src/util/src/tlog.c
  # src/dnode/src/dnodeSystem.c
  sed -i "s/TDengine/ProDB/g" ${top_dir}/src/dnode/src/dnodeSystem.c
  sed -i "s/TDengine/ProDB/g"   ${top_dir}/src/dnode/src/dnodeMain.c
  sed -i "s/taosdlog/prodlog/g"   ${top_dir}/src/dnode/src/dnodeMain.c
  # src/client/src/tscSystem.c
  sed -i "s/taoslog/prolog/g"   ${top_dir}/src/client/src/tscSystem.c
  # src/util/src/tnote.c
  sed -i "s/taosinfo/proinfo/g"   ${top_dir}/src/util/src/tnote.c
  # src/dnode/CMakeLists.txt
  sed -i "s/taos\.cfg/prodb\.cfg/g"   ${top_dir}/src/dnode/CMakeLists.txt
  # src/kit/taosdump/taosdump.c
  sed -i "s/Default is taosdata/Default is prodb/g" ${top_dir}/src/kit/taosdump/taosdump.c
  sed -i "s/taos\/taos\.cfg/ProDB\/prodb\.cfg/g" ${top_dir}/src/kit/taosdump/taosdump.c
  sed -i "s/\"taosdata\"/\"prodb\"/g" ${top_dir}/src/kit/taosdump/taosdump.c
  sed -i "s/TDengine/ProDB/g" ${top_dir}/src/kit/taosdump/taosdump.c
  # src/os/src/linux/linuxEnv.c
  sed -i "s/etc\/taos/etc\/ProDB/g" ${top_dir}/src/os/src/linux/linuxEnv.c
  sed -i "s/lib\/taos/lib\/ProDB/g" ${top_dir}/src/os/src/linux/linuxEnv.c
  sed -i "s/log\/taos/log\/ProDB/g" ${top_dir}/src/os/src/linux/linuxEnv.c
  # src/os/src/windows/wEnv.c
  sed -i "s/TDengine/ProDB/g" ${top_dir}/src/os/src/windows/wEnv.c
  # src/kit/shell/src/shellEngine.c
  sed -i "s/TDengine shell/ProDB shell/g" ${top_dir}/src/kit/shell/src/shellEngine.c
  sed -i "s/2020 by TAOS Data, Inc/2020 by Hanatech, Inc/g" ${top_dir}/src/kit/shell/src/shellEngine.c
  sed -i "s/\"taos> \"/\"ProDB> \"/g" ${top_dir}/src/kit/shell/src/shellEngine.c
  sed -i "s/\"   -> \"/\"    -> \"/g" ${top_dir}/src/kit/shell/src/shellEngine.c
  sed -i "s/prompt_size = 6/prompt_size = 7/g" ${top_dir}/src/kit/shell/src/shellEngine.c
fi

# for KingHistorian
if [[ "$dbName" == "kh" ]]; then
  # cmake/install.inc
  sed -i "s/C:\/TDengine/C:\/KingHistorian/g" ${top_dir}/cmake/install.inc
  sed -i "s/taos\.exe/khclient\.exe/g" ${top_dir}/cmake/install.inc
  sed -i "s/taosdemo\.exe/khdemo\.exe/g" ${top_dir}/cmake/install.inc
  # src/kit/shell/inc/shell.h
  sed -i "s/taos_history/kh_history/g" ${top_dir}/src/kit/shell/inc/shell.h
  # src/inc/taosdef.h
  sed -i "s/\"taosdata\"/\"khroot\"/g" ${top_dir}/src/inc/taosdef.h
  # src/util/src/tconfig.c
  sed -i "s/taos config/kh config/g"  ${top_dir}/src/util/src/tconfig.c
  sed -i "s/taos\.cfg/kinghistorian\.cfg/g"  ${top_dir}/src/util/src/tconfig.c
  sed -i "s/etc\/taos/etc\/kinghistorian/g"   ${top_dir}/src/util/src/tconfig.c
  # src/kit/taosdemo/taosdemo.c
  sed -i "s/\"taosdata\"/\"khroot\"/g" ${top_dir}/src/kit/taosdemo/taosdemo.c
  sed -i "s/support@taosdata.com/support@wellintech.com/g" ${top_dir}/src/kit/taosdemo/taosdemo.c
  # src/util/src/tlog.c
  sed -i "s/log\/taos/log\/kinghistorian/g"   ${top_dir}/src/util/src/tlog.c
  # src/dnode/src/dnodeSystem.c
  sed -i "s/TDengine/KingHistorian/g"  ${top_dir}/src/dnode/src/dnodeSystem.c 
  sed -i "s/TDengine/KingHistorian/g"   ${top_dir}/src/dnode/src/dnodeMain.c
  sed -i "s/taosdlog/khserverlog/g"  ${top_dir}/src/dnode/src/dnodeMain.c
  # src/client/src/tscSystem.c
  sed -i "s/taoslog/khclientlog/g"  ${top_dir}/src/client/src/tscSystem.c
  # src/util/src/tnote.c
  sed -i "s/taosinfo/khinfo/g"  ${top_dir}/src/util/src/tnote.c
  # src/dnode/CMakeLists.txt
  sed -i "s/taos\.cfg/kinghistorian\.cfg/g"  ${top_dir}/src/dnode/CMakeLists.txt
  # src/dnode/CMakeLists.txt
  sed -i "s/Default is taosdata/Default is khroot/g" ${top_dir}/src/kit/taosdump/taosdump.c
  sed -i "s/\"taosdata\"/\"khroot\"/g" ${top_dir}/src/kit/taosdump/taosdump.c
  sed -i "s/TDengine/KingHistorian/g" ${top_dir}/src/kit/taosdump/taosdump.c
  sed -i "s/taos\/taos\.cfg/kinghistorian\/kinghistorian\.cfg/g" ${top_dir}/src/kit/taosdump/taosdump.c
  # src/os/src/linux/linuxEnv.c
  sed -i "s/etc\/taos/etc\/kinghistorian/g" ${top_dir}/src/os/src/linux/linuxEnv.c
  sed -i "s/lib\/taos/lib\/kinghistorian/g" ${top_dir}/src/os/src/linux/linuxEnv.c
  sed -i "s/log\/taos/log\/kinghistorian/g" ${top_dir}/src/os/src/linux/linuxEnv.c
  # src/os/src/windows/wEnv.c
  sed -i "s/TDengine/KingHistorian/g" ${top_dir}/src/os/src/windows/wEnv.c
  # src/kit/shell/src/shellEngine.c
  sed -i "s/TDengine shell/KingHistorian shell/g" ${top_dir}/src/kit/shell/src/shellEngine.c
  sed -i "s/2020 by TAOS Data, Inc/2021 by Wellintech, Inc/g" ${top_dir}/src/kit/shell/src/shellEngine.c
  sed -i "s/\"taos> \"/\"kh> \"/g" ${top_dir}/src/kit/shell/src/shellEngine.c
  sed -i "s/\"   -> \"/\" -> \"/g" ${top_dir}/src/kit/shell/src/shellEngine.c
  sed -i "s/prompt_size = 6/prompt_size = 4/g" ${top_dir}/src/kit/shell/src/shellEngine.c
390 391
fi

392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
# for jinheng
if [[ "$dbName" == "jh" ]]; then
  # Following files to change:
  # * src/client/src/tscSystem.c
  # * src/inc/taosdef.h
  # * src/kit/shell/CMakeLists.txt
  # * src/kit/shell/inc/shell.h
  # * src/kit/shell/src/shellEngine.c
  # * src/kit/shell/src/shellWindows.c
  # * src/kit/taosdemo/taosdemo.c
  # * src/kit/taosdump/taosdump.c
  # * src/os/src/linux/linuxEnv.c
  # * src/os/src/windows/wEnv.c
  # * src/util/src/tconfig.c
  # * src/util/src/tlog.c

  # src/dnode/src/dnodeSystem.c
  sed -i "s/TDengine/jh_iot/g"  ${top_dir}/src/dnode/src/dnodeSystem.c 
  # src/dnode/src/dnodeMain.c
  sed -i "s/TDengine/jh_iot/g"   ${top_dir}/src/dnode/src/dnodeMain.c
  # TODO: src/dnode/CMakeLists.txt
fi

415
if [[ "$httpdBuild" == "true" ]]; then
416
    BUILD_HTTP=true
417
    BUILD_TOOLS=false
418 419
else
    BUILD_HTTP=false
420
    BUILD_TOOLS=true
421
fi
422

L
lihui 已提交
423 424
# check support cpu type
if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "mips64" ]] ; then
H
Hui Li 已提交
425
  if [ "$verMode" != "cluster" ]; then
426
    # community-version compile
427
    cmake ../    -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
H
Hui Li 已提交
428
  else
429
    # enterprise-version compile
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473
    if [[ "$dbName" == "power" ]]; then
      # enterprise/src/kit/perfMonitor/perfMonitor.c
      sed -i "s/\"taosdata\"/\"powerdb\"/g" ${top_dir}/../enterprise/src/kit/perfMonitor/perfMonitor.c
      sed -i "s/TDengine/PowerDB/g" ${top_dir}/../enterprise/src/kit/perfMonitor/perfMonitor.c
      # enterprise/src/plugins/admin/src/httpAdminHandle.c
      sed -i "s/taos\.cfg/power\.cfg/g"  ${top_dir}/../enterprise/src/plugins/admin/src/httpAdminHandle.c
      # enterprise/src/plugins/grant/src/grantMain.c
      sed -i "s/taos\.cfg/power\.cfg/g"  ${top_dir}/../enterprise/src/plugins/grant/src/grantMain.c
      # enterprise/src/plugins/module/src/moduleMain.c
      sed -i "s/taos\.cfg/power\.cfg/g"  ${top_dir}/../enterprise/src/plugins/module/src/moduleMain.c
    fi
    if [[ "$dbName" == "tq" ]]; then
      # enterprise/src/kit/perfMonitor/perfMonitor.c
      sed -i "s/\"taosdata\"/\"tqueue\"/g" ${top_dir}/../enterprise/src/kit/perfMonitor/perfMonitor.c
      sed -i "s/TDengine/TQueue/g" ${top_dir}/../enterprise/src/kit/perfMonitor/perfMonitor.c
      # enterprise/src/plugins/admin/src/httpAdminHandle.c
      sed -i "s/taos\.cfg/tq\.cfg/g"  ${top_dir}/../enterprise/src/plugins/admin/src/httpAdminHandle.c
      # enterprise/src/plugins/grant/src/grantMain.c
      sed -i "s/taos\.cfg/tq\.cfg/g"  ${top_dir}/../enterprise/src/plugins/grant/src/grantMain.c
      # enterprise/src/plugins/module/src/moduleMain.c
      sed -i "s/taos\.cfg/tq\.cfg/g"  ${top_dir}/../enterprise/src/plugins/module/src/moduleMain.c
    fi
    if [[ "$dbName" == "pro" ]]; then
      # enterprise/src/kit/perfMonitor/perfMonitor.c
      sed -i "s/\"taosdata\"/\"prodb\"/g" ${top_dir}/../enterprise/src/kit/perfMonitor/perfMonitor.c
      sed -i "s/TDengine/ProDB/g" ${top_dir}/../enterprise/src/kit/perfMonitor/perfMonitor.c
      # enterprise/src/plugins/admin/src/httpAdminHandle.c
      sed -i "s/taos\.cfg/prodb\.cfg/g"  ${top_dir}/../enterprise/src/plugins/admin/src/httpAdminHandle.c
      # enterprise/src/plugins/grant/src/grantMain.c
      sed -i "s/taos\.cfg/prodb\.cfg/g"  ${top_dir}/../enterprise/src/plugins/grant/src/grantMain.c
      # enterprise/src/plugins/module/src/moduleMain.c
      sed -i "s/taos\.cfg/prodb\.cfg/g"  ${top_dir}/../enterprise/src/plugins/module/src/moduleMain.c
    fi
    if [[ "$dbName" == "kh" ]]; then
      # enterprise/src/kit/perfMonitor/perfMonitor.c
      sed -i "s/\"taosdata\"/\"khroot\"/g" ${top_dir}/../enterprise/src/kit/perfMonitor/perfMonitor.c
      sed -i "s/TDengine/KingHistorian/g" ${top_dir}/../enterprise/src/kit/perfMonitor/perfMonitor.c
      # enterprise/src/plugins/admin/src/httpAdminHandle.c
      sed -i "s/taos\.cfg/kinghistorian\.cfg/g"  ${top_dir}/../enterprise/src/plugins/admin/src/httpAdminHandle.c
      # enterprise/src/plugins/grant/src/grantMain.c
      sed -i "s/taos\.cfg/kinghistorian\.cfg/g"  ${top_dir}/../enterprise/src/plugins/grant/src/grantMain.c
      # enterprise/src/plugins/module/src/moduleMain.c
      sed -i "s/taos\.cfg/kinghistorian\.cfg/g"  ${top_dir}/../enterprise/src/plugins/module/src/moduleMain.c
    fi
474 475 476 477 478 479 480 481 482 483 484 485
    if [[ "$dbName" == "jh" ]]; then
      # enterprise/src/kit/perfMonitor/perfMonitor.c
      sed -i "s/\"taosdata\"/\"jhdata\"/g" ${top_dir}/../enterprise/src/kit/perfMonitor/perfMonitor.c
      sed -i "s/TDengine/jh_iot/g" ${top_dir}/../enterprise/src/kit/perfMonitor/perfMonitor.c
      # enterprise/src/plugins/admin/src/httpAdminHandle.c
      #sed -i "s/taos\.cfg/taos\.cfg/g"  ${top_dir}/../enterprise/src/plugins/admin/src/httpAdminHandle.c
      # enterprise/src/plugins/grant/src/grantMain.c
      #sed -i "s/taos\.cfg/taos\.cfg/g"  ${top_dir}/../enterprise/src/plugins/grant/src/grantMain.c
      # enterprise/src/plugins/module/src/moduleMain.c
      #sed -i "s/taos\.cfg/taos\.cfg/g"  ${top_dir}/../enterprise/src/plugins/module/src/moduleMain.c
    fi

486
    cmake ../../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
H
Hui Li 已提交
487
  fi
L
lihui 已提交
488
else
H
Hui Li 已提交
489 490
  echo "input cpuType=${cpuType} error!!!"
  exit 1
L
lihui 已提交
491 492
fi

493 494
if [[ "$allocator" == "jemalloc" ]]; then
    # jemalloc need compile first, so disable parallel build
495
    make -j 8 && ${csudo} make install
496
else
497
    make -j 8 && ${csudo} make install
498
fi
H
hzcheng 已提交
499 500 501

cd ${curr_dir}

H
Hui Li 已提交
502
# 3. Call the corresponding script for packaging
S
slguan 已提交
503
if [ "$osType" != "Darwin" ]; then
H
Hui Li 已提交
504
  if [[ "$verMode" != "cluster" ]] && [[ "$cpuType" == "x64" ]] && [[ "$dbName" == "taos" ]]; then
505
    ret='0'
P
plum-lihui 已提交
506
    command -v dpkg >/dev/null 2>&1 || { ret='1'; }
507
    if [ "$ret" -eq 0 ]; then
P
plum-lihui 已提交
508 509 510 511 512 513 514 515
      echo "====do deb package for the ubuntu system===="
      output_dir="${top_dir}/debs"
      if [ -d ${output_dir} ]; then
        ${csudo} rm -rf ${output_dir}
      fi
      ${csudo} mkdir -p ${output_dir}
      cd ${script_dir}/deb
      ${csudo} ./makedeb.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType}
516 517 518 519 520

      if [ -d ${top_dir}/src/kit/taos-tools/packaging/deb ]; then
          cd ${top_dir}/src/kit/taos-tools/packaging/deb
          [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0"

521
          taos_tools_ver=$(git describe --tags|sed -e 's/ver-//g'|awk -F '-' '{print $1}')
522 523 524
          ${csudo} ./make-taos-tools-deb.sh ${top_dir} \
              ${compile_dir} ${output_dir} ${taos_tools_ver} ${cpuType} ${osType} ${verMode} ${verType}
      fi
P
plum-lihui 已提交
525 526
    else
      echo "==========dpkg command not exist, so not release deb package!!!"
H
Hui Li 已提交
527
    fi
528
    ret='0'
P
plum-lihui 已提交
529
    command -v rpmbuild >/dev/null 2>&1 || { ret='1'; }
530
    if [ "$ret" -eq 0 ]; then
P
plum-lihui 已提交
531 532 533 534 535 536 537 538
      echo "====do rpm package for the centos system===="
      output_dir="${top_dir}/rpms"
      if [ -d ${output_dir} ]; then
        ${csudo} rm -rf ${output_dir}
      fi
      ${csudo} mkdir -p ${output_dir}
      cd ${script_dir}/rpm
      ${csudo} ./makerpm.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType}
539 540 541 542 543

      if [ -d ${top_dir}/src/kit/taos-tools/packaging/rpm ]; then
          cd ${top_dir}/src/kit/taos-tools/packaging/rpm
          [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0"

544
          taos_tools_ver=$(git describe --tags|sed -e 's/ver-//g'|awk -F '-' '{print $1}'|sed -e 's/-/_/g')
545 546 547
          ${csudo} ./make-taos-tools-rpm.sh ${top_dir} \
              ${compile_dir} ${output_dir} ${taos_tools_ver} ${cpuType} ${osType} ${verMode} ${verType}
      fi
P
plum-lihui 已提交
548 549
    else
      echo "==========rpmbuild command not exist, so not release rpm package!!!"
S
slguan 已提交
550
    fi
H
Hui Li 已提交
551
  fi
552

H
Hui Li 已提交
553 554
  echo "====do tar.gz package for all systems===="
  cd ${script_dir}/tools
555 556

  if [[ "$dbName" == "taos" ]]; then
557
    ${csudo} ./makepkg.sh    ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${verNumberComp}
H
Hui Li 已提交
558 559
    ${csudo} ./makeclient.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
    ${csudo} ./makearbi.sh   ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
560
  elif [[ "$dbName" == "tq" ]]; then
561
    ${csudo} ./makepkg_tq.sh    ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${verNumberComp}
562 563
    ${csudo} ./makeclient_tq.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName}
    ${csudo} ./makearbi_tq.sh   ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
564 565 566 567
  elif [[ "$dbName" == "pro" ]]; then
    ${csudo} ./makepkg_pro.sh    ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${verNumberComp}
    ${csudo} ./makeclient_pro.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName}
    ${csudo} ./makearbi_pro.sh   ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
568 569 570 571
  elif [[ "$dbName" == "kh" ]]; then
    ${csudo} ./makepkg_kh.sh    ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${verNumberComp}
    ${csudo} ./makeclient_kh.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName}
    ${csudo} ./makearbi_kh.sh   ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
572 573 574 575
  elif [[ "$dbName" == "jh" ]]; then
    ${csudo} ./makepkg_jh.sh    ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${verNumberComp}
    ${csudo} ./makeclient_jh.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName}
    ${csudo} ./makearbi_jh.sh   ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
H
Hui Li 已提交
576
  else
577
    ${csudo} ./makepkg_power.sh    ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${verNumberComp}
H
Hui Li 已提交
578 579 580
    ${csudo} ./makeclient_power.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName}
    ${csudo} ./makearbi_power.sh   ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
  fi
S
slguan 已提交
581
else
582
  # only make client for Darwin
H
Hui Li 已提交
583
  cd ${script_dir}/tools
H
Hui Li 已提交
584
  ./makeclient.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${dbName}
H
hzcheng 已提交
585
fi