release.sh 10.0 KB
Newer Older
P
plum-lihui 已提交
1 2
#!/bin/bash
#
wafwerar's avatar
wafwerar 已提交
3
# Generate the deb package for ubuntu, or rpm package for centos, or tar.gz package for other linux os
P
plum-lihui 已提交
4 5

set -e
6
# set -x
P
plum-lihui 已提交
7

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

P
plum-lihui 已提交
19
# set parameters by default value
wafwerar's avatar
wafwerar 已提交
20
verMode=edge    # [cluster, edge, cloud]
wafwerar's avatar
wafwerar 已提交
21
verType=stable  # [stable, beta]
22
cpuType=x64     # [aarch32 | aarch64 | x64 | x86 | mips64 loongarch64...]
wafwerar's avatar
wafwerar 已提交
23 24 25 26 27 28
osType=Linux    # [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...]
pagMode=full    # [full | lite]
soMode=dynamic  # [static | dynamic]
dbName=taos     # [taos | ...]
allocator=glibc # [glibc | jemalloc]
verNumber=""
wafwerar's avatar
wafwerar 已提交
29
verNumberComp="3.0.0.0"
wafwerar's avatar
wafwerar 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
httpdBuild=false

while getopts "hv:V:c:o:l:s:d:a:n:m:H:" arg; 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)
    #echo "pagMode=$OPTARG"
    pagMode=$(echo $OPTARG)
    ;;
  s)
    #echo "soMode=$OPTARG"
    soMode=$(echo $OPTARG)
    ;;
  d)
    #echo "dbName=$OPTARG"
    dbName=$(echo $OPTARG)
    ;;
  a)
    #echo "allocator=$OPTARG"
    allocator=$(echo $OPTARG)
    ;;
  n)
    #echo "verNumber=$OPTARG"
    verNumber=$(echo $OPTARG)
    ;;
  m)
    #echo "verNumberComp=$OPTARG"
    verNumberComp=$(echo $OPTARG)
    ;;
  o)
    #echo "osType=$OPTARG"
    osType=$(echo $OPTARG)
    ;;
  H)
    #echo "httpdBuild=$OPTARG"
    httpdBuild=$(echo $OPTARG)
    ;;
  h)
    echo "Usage: $(basename $0) -v [cluster | edge] "
80
    echo "                  -c [aarch32 | aarch64 | x64 | x86 | mips64 | loongarch64 ...] "
wafwerar's avatar
wafwerar 已提交
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
    echo "                  -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...] "
    echo "                  -V [stable | beta] "
    echo "                  -l [full | lite] "
    echo "                  -a [glibc | jemalloc] "
    echo "                  -s [static | dynamic] "
    echo "                  -d [taos | ...] "
    echo "                  -n [version number] "
    echo "                  -m [compatible version number] "
    echo "                  -H [false | true] "
    exit 0
    ;;
  ?) #unknow option
    echo "unkonw argument"
    exit 1
    ;;
  esac
done

99 100
osType=$(uname)

wafwerar's avatar
wafwerar 已提交
101
echo "verMode=${verMode} verType=${verType} cpuType=${cpuType} osType=${osType} pagMode=${pagMode} soMode=${soMode} dbName=${dbName} allocator=${allocator} verNumber=${verNumber} verNumberComp=${verNumberComp} httpdBuild=${httpdBuild}"
P
plum-lihui 已提交
102 103 104

curr_dir=$(pwd)

wafwerar's avatar
wafwerar 已提交
105 106 107 108 109 110 111 112 113 114 115
if [ "$osType" == "Darwin" ]; then
  script_dir=$(dirname $0)
  cd ${script_dir}
  script_dir="$(pwd)"
  top_dir=${script_dir}/..
else
  script_dir="$(dirname $(readlink -f $0))"
  top_dir="$(readlink -f ${script_dir}/..)"
fi

csudo=""
sangshuduo's avatar
sangshuduo 已提交
116 117 118
#if command -v sudo > /dev/null; then
#  csudo="sudo "
#fi
wafwerar's avatar
wafwerar 已提交
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 153 154 155 156 157 158 159 160 161 162 163 164 165

function is_valid_version() {
  [ -z $1 ] && return 1 || :

  rx='^([0-9]+\.){3}(\*|[0-9]+)$'
  if [[ $1 =~ $rx ]]; then
    return 0
  fi
  return 1
}

function vercomp() {
  if [[ $1 == $2 ]]; then
    echo 0
    exit 0
  fi

  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

  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
    fi
  done
  echo 0
}

# 1. check version information
if ( (! is_valid_version $verNumber) || (! is_valid_version $verNumberComp) || [[ "$(vercomp $verNumber $verNumberComp)" == '2' ]]); then
  echo "please enter correct version"
  exit 0
fi
P
plum-lihui 已提交
166

wafwerar's avatar
wafwerar 已提交
167
echo "=======================new version number: ${verNumber}, compatible version: ${verNumberComp}======================================"
P
plum-lihui 已提交
168 169 170

build_time=$(date +"%F %R")

wafwerar's avatar
wafwerar 已提交
171 172
# get commint id from git
gitinfo=$(git rev-parse --verify HEAD)
P
plum-lihui 已提交
173

wafwerar's avatar
wafwerar 已提交
174
if [[ "$verMode" == "cluster" ]] || [[ "$verMode" == "cloud" ]]; then
wafwerar's avatar
wafwerar 已提交
175 176 177 178 179 180
  enterprise_dir="${top_dir}/../enterprise"
  cd ${enterprise_dir}
  gitinfoOfInternal=$(git rev-parse --verify HEAD)
else
  gitinfoOfInternal=NULL
fi
P
plum-lihui 已提交
181

wafwerar's avatar
wafwerar 已提交
182
cd "${curr_dir}"
P
plum-lihui 已提交
183 184 185

# 2. cmake executable file
compile_dir="${top_dir}/debug"
sangshuduo's avatar
sangshuduo 已提交
186 187 188
if [ -d ${compile_dir} ]; then
  rm -rf ${compile_dir}
fi
P
plum-lihui 已提交
189

sangshuduo's avatar
sangshuduo 已提交
190
mkdir -p ${compile_dir}
P
plum-lihui 已提交
191 192
cd ${compile_dir}

wafwerar's avatar
wafwerar 已提交
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
if [[ "$allocator" == "jemalloc" ]]; then
  allocator_macro="-DJEMALLOC_ENABLED=true"
else
  allocator_macro=""
fi

if [[ "$dbName" != "taos" ]]; then
  source ${enterprise_dir}/packaging/oem/sed_$dbName.sh
  replace_community_$dbName
fi

if [[ "$httpdBuild" == "true" ]]; then
  BUILD_HTTP=true
else
  BUILD_HTTP=false
fi
P
plum-lihui 已提交
209

wafwerar's avatar
wafwerar 已提交
210
if [[ "$verMode" == "cluster" ]] || [[ "$verMode" == "cloud" ]]; then
wafwerar's avatar
wafwerar 已提交
211 212
  BUILD_HTTP=internal
fi
P
plum-lihui 已提交
213

wafwerar's avatar
wafwerar 已提交
214 215 216 217
if [[ "$pagMode" == "full" ]]; then
  BUILD_TOOLS=true
else
  BUILD_TOOLS=false
P
plum-lihui 已提交
218 219
fi

wafwerar's avatar
wafwerar 已提交
220
# check support cpu type
221
if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "arm64" ]] || [[ "$cpuType" == "arm32" ]] || [[ "$cpuType" == "mips64" ]] || [[ "$cpuType" == "loongarch64" ]] ; then
wafwerar's avatar
wafwerar 已提交
222
  if [ "$verMode" == "edge" ]; then
wafwerar's avatar
wafwerar 已提交
223
    # community-version compile
wafwerar's avatar
wafwerar 已提交
224
    cmake ../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -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}
wafwerar's avatar
wafwerar 已提交
225
  elif [ "$verMode" == "cloud" ]; then
W
wenzhouwww 已提交
226
    cmake ../../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DBUILD_TAOSX=true -DBUILD_CLOUD=true -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}
wafwerar's avatar
wafwerar 已提交
227
  elif [ "$verMode" == "cluster" ]; then
wafwerar's avatar
wafwerar 已提交
228 229 230
    if [[ "$dbName" != "taos" ]]; then
      replace_enterprise_$dbName
    fi
W
wenzhouwww 已提交
231
    cmake ../../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DBUILD_TAOSX=true -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}
wafwerar's avatar
wafwerar 已提交
232 233 234 235 236
  fi
else
  echo "input cpuType=${cpuType} error!!!"
  exit 1
fi
P
plum-lihui 已提交
237

238 239 240 241 242 243
ostype=`uname`
if [ "${ostype}" == "Darwin" ]; then
    CORES=$(sysctl -n hw.ncpu)
else
    CORES=$(grep -c ^processor /proc/cpuinfo)
fi
P
plum-lihui 已提交
244

wafwerar's avatar
wafwerar 已提交
245 246 247 248 249 250 251 252
if [[ "$allocator" == "jemalloc" ]]; then
  # jemalloc need compile first, so disable parallel build
  make -j ${CORES} && ${csudo}make install
else
  make -j ${CORES} && ${csudo}make install
fi

cd ${curr_dir}
P
plum-lihui 已提交
253

wafwerar's avatar
wafwerar 已提交
254 255
# 3. Call the corresponding script for packaging
if [ "$osType" != "Darwin" ]; then
wafwerar's avatar
wafwerar 已提交
256
  if [[ "$verMode" != "cluster" ]] && [[ "$verMode" != "cloud" ]] && [[ "$pagMode" == "full" ]] && [[ "$cpuType" == "x64" ]] && [[ "$dbName" == "taos" ]]; then
wafwerar's avatar
wafwerar 已提交
257 258 259 260 261 262
    ret='0'
    command -v dpkg >/dev/null 2>&1 || { ret='1'; }
    if [ "$ret" -eq 0 ]; then
      echo "====do deb package for the ubuntu system===="
      output_dir="${top_dir}/debs"
      if [ -d ${output_dir} ]; then
sangshuduo's avatar
sangshuduo 已提交
263
        rm -rf ${output_dir}
wafwerar's avatar
wafwerar 已提交
264
      fi
sangshuduo's avatar
sangshuduo 已提交
265
      mkdir -p ${output_dir}
wafwerar's avatar
wafwerar 已提交
266 267
      cd ${script_dir}/deb
      ${csudo}./makedeb.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType}
haoranc's avatar
haoranc 已提交
268

wafwerar's avatar
wafwerar 已提交
269 270 271
      if [[ "$pagMode" == "full" ]]; then
        if [ -d ${top_dir}/tools/taos-tools/packaging/deb ]; then
          cd ${top_dir}/tools/taos-tools/packaging/deb
272
          taos_tools_ver=$(git tag |grep -v taos | sort | tail -1)
wafwerar's avatar
wafwerar 已提交
273
          [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0"
P
plum-lihui 已提交
274

wafwerar's avatar
wafwerar 已提交
275
          ${csudo}./make-taos-tools-deb.sh ${top_dir} \
276
            ${compile_dir} ${output_dir} ${taos_tools_ver} ${cpuType} ${osType} ${verMode} ${verType} ${verNumberComp}
wafwerar's avatar
wafwerar 已提交
277 278 279 280 281 282 283 284 285 286 287
        fi
      fi
    else
      echo "==========dpkg command not exist, so not release deb package!!!"
    fi
    ret='0'
    command -v rpmbuild >/dev/null 2>&1 || { ret='1'; }
    if [ "$ret" -eq 0 ]; then
      echo "====do rpm package for the centos system===="
      output_dir="${top_dir}/rpms"
      if [ -d ${output_dir} ]; then
sangshuduo's avatar
sangshuduo 已提交
288
        rm -rf ${output_dir}
wafwerar's avatar
wafwerar 已提交
289
      fi
sangshuduo's avatar
sangshuduo 已提交
290
      mkdir -p ${output_dir}
wafwerar's avatar
wafwerar 已提交
291 292
      cd ${script_dir}/rpm
      ${csudo}./makerpm.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType}
P
plum-lihui 已提交
293

wafwerar's avatar
wafwerar 已提交
294 295 296
      if [[ "$pagMode" == "full" ]]; then
        if [ -d ${top_dir}/tools/taos-tools/packaging/rpm ]; then
          cd ${top_dir}/tools/taos-tools/packaging/rpm
297
          taos_tools_ver=$(git tag |grep -v taos | sort | tail -1)
wafwerar's avatar
wafwerar 已提交
298
          [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0"
P
plum-lihui 已提交
299

wafwerar's avatar
wafwerar 已提交
300
          ${csudo}./make-taos-tools-rpm.sh ${top_dir} \
301
            ${compile_dir} ${output_dir} ${taos_tools_ver} ${cpuType} ${osType} ${verMode} ${verType} ${verNumberComp}
wafwerar's avatar
wafwerar 已提交
302 303 304 305 306 307
        fi
      fi
    else
      echo "==========rpmbuild command not exist, so not release rpm package!!!"
    fi
  fi
P
plum-lihui 已提交
308

wafwerar's avatar
wafwerar 已提交
309 310
  echo "====do tar.gz package for all systems===="
  cd ${script_dir}/tools
P
plum-lihui 已提交
311

wafwerar's avatar
wafwerar 已提交
312 313
  ${csudo}./makepkg.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${verNumberComp} ${dbName}
  ${csudo}./makeclient.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName}
P
plum-lihui 已提交
314

wafwerar's avatar
wafwerar 已提交
315 316
else
  cd ${script_dir}/tools
317
  ./makepkg.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${verNumberComp} ${dbName}
wafwerar's avatar
wafwerar 已提交
318 319
  ./makeclient.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName}
fi