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

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

L
lihui 已提交
8 9
# releash.sh  -v [cluster | edge]  
#             -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]
H
Hui Li 已提交
14
#             -d [taos | power]
H
Hui Li 已提交
15
#             -n [2.0.0.3]
H
Hui Li 已提交
16
#             -m [2.0.0.0]
L
lihui 已提交
17 18

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

H
Hui Li 已提交
29
while getopts "hv:V:c:o:l:s:d:n:m:" arg
L
lihui 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42 43
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 已提交
44 45 46 47
    l)
      #echo "pagMode=$OPTARG"
      pagMode=$(echo $OPTARG)
      ;;
H
Hui Li 已提交
48 49 50 51
    s)
      #echo "soMode=$OPTARG"
      soMode=$(echo $OPTARG)
      ;;
H
Hui Li 已提交
52 53 54 55
    d)
      #echo "dbName=$OPTARG"
      dbName=$(echo $OPTARG)
      ;;
H
Hui Li 已提交
56 57 58 59
    n)
      #echo "verNumber=$OPTARG"
      verNumber=$(echo $OPTARG)
      ;;
H
Hui Li 已提交
60 61 62 63
    m)
      #echo "verNumberComp=$OPTARG"
      verNumberComp=$(echo $OPTARG)
      ;;
L
lihui 已提交
64 65 66 67 68
    o)
      #echo "osType=$OPTARG"
      osType=$(echo $OPTARG)
      ;;
    h)
H
Hui Li 已提交
69 70
      echo "Usage: `basename $0` -v [cluster | edge] "
      echo "                  -c [aarch32 | aarch64 | x64 | x86 | mips64 ...] "
H
Hui Li 已提交
71
      echo "                  -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...] "
H
Hui Li 已提交
72 73
      echo "                  -V [stable | beta] "
      echo "                  -l [full | lite] "
H
Hui Li 已提交
74
      echo "                  -s [static | dynamic] "
H
Hui Li 已提交
75
      echo "                  -d [taos | power] "
H
Hui Li 已提交
76
      echo "                  -n [version number] "
H
Hui Li 已提交
77
      echo "                  -m [compatible version number] "
L
lihui 已提交
78 79 80 81 82 83 84 85 86
      exit 0
      ;;
    ?) #unknow option 
      echo "unkonw argument"
      exit 1
      ;;
  esac
done

H
Hui Li 已提交
87
echo "verMode=${verMode} verType=${verType} cpuType=${cpuType} osType=${osType} pagMode=${pagMode} soMode=${soMode} dbName=${dbName} verNumber=${verNumber} verNumberComp=${verNumberComp}"
H
hzcheng 已提交
88 89

curr_dir=$(pwd)
S
slguan 已提交
90 91

if [ "$osType" != "Darwin" ]; then
H
Hui Li 已提交
92 93
  script_dir="$(dirname $(readlink -f $0))"
  top_dir="$(readlink -f ${script_dir}/..)"
S
slguan 已提交
94
else
H
Hui Li 已提交
95 96 97 98
  script_dir=`dirname $0`
  cd ${script_dir}
  script_dir="$(pwd)"
  top_dir=${script_dir}/..
S
slguan 已提交
99 100
fi

P
plum-lihui 已提交
101
csudo=""
H
Hui Li 已提交
102
#if command -v sudo > /dev/null; then
H
Hui Li 已提交
103
#  csudo="sudo"
H
Hui Li 已提交
104
#fi
P
plum-lihui 已提交
105

H
hzcheng 已提交
106
function is_valid_version() {
H
Hui Li 已提交
107
  [ -z $1 ] && return 1 || :
H
hzcheng 已提交
108

H
Hui Li 已提交
109 110 111 112 113
  rx='^([0-9]+\.){3}(\*|[0-9]+)$'
  if [[ $1 =~ $rx ]]; then
    return 0
  fi
  return 1
H
hzcheng 已提交
114 115 116
}

function vercomp () {
H
Hui Li 已提交
117
  if [[ $1 == $2 ]]; then
H
hzcheng 已提交
118
    echo 0
H
Hui Li 已提交
119 120 121 122 123 124 125 126 127 128
    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
H
hzcheng 已提交
129

H
Hui Li 已提交
130 131 132 133 134 135 136 137 138 139 140 141
  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 已提交
142 143
    fi
  done
H
Hui Li 已提交
144 145 146 147 148 149 150 151
  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
H
Hui Li 已提交
152

H
Hui Li 已提交
153
echo "=======================new version number: ${verNumber}, compatible version: ${verNumberComp}======================================"
H
hzcheng 已提交
154 155

build_time=$(date +"%F %R")
H
Hui Li 已提交
156 157 158 159 160 161 162

# get commint id from git
gitinfo=$(git rev-parse --verify HEAD)
enterprise_dir="${top_dir}/../enterprise"
cd ${enterprise_dir}
gitinfoOfInternal=$(git rev-parse --verify HEAD)
cd ${curr_dir}
L
lihui 已提交
163

H
hzcheng 已提交
164
# 2. cmake executable file
L
lihui 已提交
165
compile_dir="${top_dir}/debug"
H
hzcheng 已提交
166
if [ -d ${compile_dir} ]; then
H
Hui Li 已提交
167
  ${csudo} rm -rf ${compile_dir}
H
hzcheng 已提交
168 169
fi

S
slguan 已提交
170
if [ "$osType" != "Darwin" ]; then
H
Hui Li 已提交
171
  ${csudo} mkdir -p ${compile_dir}
S
slguan 已提交
172
else
H
Hui Li 已提交
173
  mkdir -p ${compile_dir}
S
slguan 已提交
174
fi
H
hzcheng 已提交
175
cd ${compile_dir}
L
lihui 已提交
176

L
lihui 已提交
177 178
# check support cpu type
if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "mips64" ]] ; then
H
Hui Li 已提交
179
  if [ "$verMode" != "cluster" ]; then
H
Hui Li 已提交
180
    cmake ../    -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode}
H
Hui Li 已提交
181
  else
H
Hui Li 已提交
182
    cmake ../../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp}
H
Hui Li 已提交
183
  fi
L
lihui 已提交
184
else
H
Hui Li 已提交
185 186
  echo "input cpuType=${cpuType} error!!!"
  exit 1
L
lihui 已提交
187 188 189
fi

make
H
hzcheng 已提交
190 191 192

cd ${curr_dir}

H
Hui Li 已提交
193
# 3. Call the corresponding script for packaging
S
slguan 已提交
194
if [ "$osType" != "Darwin" ]; then
H
Hui Li 已提交
195
  if [[ "$verMode" != "cluster" ]] && [[ "$cpuType" == "x64" ]] && [[ "$dbName" == "taos" ]]; then
H
Hui Li 已提交
196 197 198 199 200 201 202 203 204 205 206 207 208
    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}

    echo "====do rpm package for the centos system===="
    output_dir="${top_dir}/rpms"
    if [ -d ${output_dir} ]; then
      ${csudo} rm -rf ${output_dir}
S
slguan 已提交
209
    fi
H
Hui Li 已提交
210 211 212 213
    ${csudo} mkdir -p ${output_dir}
    cd ${script_dir}/rpm
    ${csudo} ./makerpm.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType}
  fi
S
slguan 已提交
214
	
H
Hui Li 已提交
215 216 217
  echo "====do tar.gz package for all systems===="
  cd ${script_dir}/tools
  
H
Hui Li 已提交
218 219 220 221 222 223 224 225 226
  if [[ "$dbName" == "taos" ]]; then  
    ${csudo} ./makepkg.sh    ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
    ${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}
  else
    ${csudo} ./makepkg_power.sh    ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName}
    ${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 已提交
227
else
H
Hui Li 已提交
228
  cd ${script_dir}/tools
H
Hui Li 已提交
229
  ./makeclient.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${dbName}
H
hzcheng 已提交
230 231
fi