makeclient.sh 10.0 KB
Newer Older
wafwerar's avatar
wafwerar 已提交
1 2 3 4
#!/bin/bash
#
# Generate tar.gz package for linux client in all os system
set -e
sangshuduo's avatar
sangshuduo 已提交
5
set -x
wafwerar's avatar
wafwerar 已提交
6 7 8 9 10 11 12 13 14 15

curr_dir=$(pwd)
compile_dir=$1
version=$2
build_time=$3
cpuType=$4
osType=$5
verMode=$6
verType=$7
pagMode=$8
X
xinsheng Ren 已提交
16 17 18 19 20 21 22
#comVersion=$9
dbName=$10

productName2="${11}"
#serverName2="${12}d"
clientName2="${12}"
# cusEmail2=${13}
wafwerar's avatar
wafwerar 已提交
23 24 25

productName="TDengine"
clientName="taos"
sangshuduo's avatar
sangshuduo 已提交
26
benchmarkName="taosBenchmark"
wafwerar's avatar
wafwerar 已提交
27
configFile="taos.cfg"
28
tarName="package.tar.gz"
wafwerar's avatar
wafwerar 已提交
29

sangshuduo's avatar
sangshuduo 已提交
30 31
benchmarkName2="${clientName2}Benchmark"

wafwerar's avatar
wafwerar 已提交
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
if [ "$osType" != "Darwin" ]; then
  script_dir="$(dirname $(readlink -f $0))"
  top_dir="$(readlink -f ${script_dir}/../..)"
else
  script_dir=$(dirname $0)
  cd ${script_dir}
  script_dir="$(pwd)"
  top_dir=${script_dir}/../..
fi

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

#package_name='linux'

if [ "$verMode" == "cluster" ]; then
X
xinsheng Ren 已提交
50
  install_dir="${release_dir}/${productName2}-enterprise-client-${version}"
wafwerar's avatar
wafwerar 已提交
51
elif [ "$verMode" == "cloud" ]; then
X
xinsheng Ren 已提交
52
  install_dir="${release_dir}/${productName2}-cloud-client-${version}"
wafwerar's avatar
wafwerar 已提交
53
else
X
xinsheng Ren 已提交
54
  install_dir="${release_dir}/${productName2}-client-${version}"
wafwerar's avatar
wafwerar 已提交
55 56 57 58
fi

# Directories and files.

sangshuduo's avatar
sangshuduo 已提交
59 60 61 62 63 64
#if [ "$verMode" == "cluster" ]; then
#  sed -i 's/verMode=edge/verMode=cluster/g' ${script_dir}/remove_client.sh
#  sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" ${script_dir}/remove_client.sh
#  sed -i "s/configFile2=\"taos\"/configFile2=\"${clientName2}\"/g" ${script_dir}/remove_client.sh
#  sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" ${script_dir}/remove_client.sh
#fi
X
xinsheng Ren 已提交
65

wafwerar's avatar
wafwerar 已提交
66 67 68 69 70 71 72
if [ "$osType" != "Darwin" ]; then
  if [ "$pagMode" == "lite" ]; then
    strip ${build_dir}/bin/${clientName}
    bin_files="${build_dir}/bin/${clientName} \
        ${script_dir}/remove_client.sh"
  else
    bin_files="${build_dir}/bin/${clientName} \
sangshuduo's avatar
sangshuduo 已提交
73
        ${build_dir}/bin/${benchmarkName} \
wafwerar's avatar
wafwerar 已提交
74 75 76 77 78
        ${script_dir}/remove_client.sh \
        ${script_dir}/set_core.sh \
        ${script_dir}/get_client.sh"
  fi
  lib_files="${build_dir}/lib/libtaos.so.${version}"
79
  wslib_files="${build_dir}/lib/libtaosws.so"
wafwerar's avatar
wafwerar 已提交
80 81 82
else
  bin_files="${build_dir}/bin/${clientName} ${script_dir}/remove_client.sh"
  lib_files="${build_dir}/lib/libtaos.${version}.dylib"
83
  wslib_files="${build_dir}/lib/libtaosws.dylib"
wafwerar's avatar
wafwerar 已提交
84 85
fi

86
header_files="${code_dir}/include/client/taos.h ${code_dir}/include/common/taosdef.h ${code_dir}/include/util/taoserror.h ${code_dir}/include/util/tdef.h ${code_dir}/include/libs/function/taosudf.h"
87 88
wsheader_files="${build_dir}/include/taosws.h"

wafwerar's avatar
wafwerar 已提交
89 90 91 92 93 94 95 96 97 98 99
if [ "$dbName" != "taos" ]; then
  cfg_dir="${top_dir}/../enterprise/packaging/cfg"
else
  cfg_dir="${top_dir}/packaging/cfg"
fi

install_files="${script_dir}/install_client.sh"

# make directories.
mkdir -p ${install_dir}
mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc
100 101
[ -f ${wsheader_files} ] && cp ${wsheader_files} ${install_dir}/inc

wafwerar's avatar
wafwerar 已提交
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/${configFile} ${install_dir}/cfg/${configFile}
mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/*

if [ -f ${build_dir}/bin/jemalloc-config ]; then
  mkdir -p ${install_dir}/jemalloc/{bin,lib,lib/pkgconfig,include/jemalloc,share/doc/jemalloc,share/man/man3}
  cp ${build_dir}/bin/jemalloc-config ${install_dir}/jemalloc/bin
  if [ -f ${build_dir}/bin/jemalloc.sh ]; then
    cp ${build_dir}/bin/jemalloc.sh ${install_dir}/jemalloc/bin
  fi
  if [ -f ${build_dir}/bin/jeprof ]; then
    cp ${build_dir}/bin/jeprof ${install_dir}/jemalloc/bin
  fi
  if [ -f ${build_dir}/include/jemalloc/jemalloc.h ]; then
    cp ${build_dir}/include/jemalloc/jemalloc.h ${install_dir}/jemalloc/include/jemalloc
  fi
  if [ -f ${build_dir}/lib/libjemalloc.so.2 ]; then
    cp ${build_dir}/lib/libjemalloc.so.2 ${install_dir}/jemalloc/lib
    ln -sf libjemalloc.so.2 ${install_dir}/jemalloc/lib/libjemalloc.so
  fi
121 122 123 124 125 126
  # if [ -f ${build_dir}/lib/libjemalloc.a ]; then
  #   cp ${build_dir}/lib/libjemalloc.a ${install_dir}/jemalloc/lib
  # fi
  # if [ -f ${build_dir}/lib/libjemalloc_pic.a ]; then
  #   cp ${build_dir}/lib/libjemalloc_pic.a ${install_dir}/jemalloc/lib
  # fi
wafwerar's avatar
wafwerar 已提交
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
  if [ -f ${build_dir}/lib/pkgconfig/jemalloc.pc ]; then
    cp ${build_dir}/lib/pkgconfig/jemalloc.pc ${install_dir}/jemalloc/lib/pkgconfig
  fi
  if [ -f ${build_dir}/share/doc/jemalloc/jemalloc.html ]; then
    cp ${build_dir}/share/doc/jemalloc/jemalloc.html ${install_dir}/jemalloc/share/doc/jemalloc
  fi
  if [ -f ${build_dir}/share/man/man3/jemalloc.3 ]; then
    cp ${build_dir}/share/man/man3/jemalloc.3 ${install_dir}/jemalloc/share/man/man3
  fi
fi

cd ${install_dir}

if [ "$osType" != "Darwin" ]; then
  tar -zcv -f ${tarName} * --remove-files || :
else
  tar -zcv -f ${tarName} * || :
  mv ${tarName} ..
  rm -rf ./*
  mv ../${tarName} .
fi

cd ${curr_dir}
cp ${install_files} ${install_dir}
X
xinsheng Ren 已提交
151
cp ${install_dir}/install_client.sh install_client_temp.sh
wafwerar's avatar
wafwerar 已提交
152
if [ "$osType" == "Darwin" ]; then
X
xinsheng Ren 已提交
153
  sed -i 's/osType=Linux/osType=Darwin/g' install_client_temp.sh
wafwerar's avatar
wafwerar 已提交
154 155 156 157
  mv install_client_temp.sh ${install_dir}/install_client.sh
fi

if [ "$verMode" == "cluster" ]; then
X
xinsheng Ren 已提交
158 159 160
  sed -i 's/verMode=edge/verMode=cluster/g' install_client_temp.sh
  sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" install_client_temp.sh
  sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" install_client_temp.sh
sangshuduo's avatar
sangshuduo 已提交
161
  sed -i "s/configFile2=\"taos.cfg\"/configFile2=\"${clientName2}.cfg\"/g" install_client_temp.sh
X
xinsheng Ren 已提交
162 163 164
  sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" install_client_temp.sh
  sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusEmail2}\"/g" install_client_temp.sh

wafwerar's avatar
wafwerar 已提交
165 166
  mv install_client_temp.sh ${install_dir}/install_client.sh
fi
wafwerar's avatar
wafwerar 已提交
167
if [ "$verMode" == "cloud" ]; then
X
xinsheng Ren 已提交
168
  sed -i 's/verMode=edge/verMode=cloud/g' install_client_temp.sh
wafwerar's avatar
wafwerar 已提交
169 170
  mv install_client_temp.sh ${install_dir}/install_client.sh
fi
wafwerar's avatar
wafwerar 已提交
171 172

if [ "$pagMode" == "lite" ]; then
X
xinsheng Ren 已提交
173
  sed -i 's/pagMode=full/pagMode=lite/g' install_client_temp.sh
wafwerar's avatar
wafwerar 已提交
174 175 176 177
  mv install_client_temp.sh ${install_dir}/install_client.sh
fi
chmod a+x ${install_dir}/install_client.sh

178
if [[ $productName == "TDengine" ]] && [ "$verMode" != "cloud" ]; then
wafwerar's avatar
wafwerar 已提交
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
  # Copy example code
  mkdir -p ${install_dir}/examples
  examples_dir="${top_dir}/examples"
  cp -r ${examples_dir}/c ${install_dir}/examples
  if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then
    cp -r ${examples_dir}/JDBC ${install_dir}/examples
    cp -r ${examples_dir}/matlab ${install_dir}/examples
    cp -r ${examples_dir}/python ${install_dir}/examples
    cp -r ${examples_dir}/R ${install_dir}/examples
    cp -r ${examples_dir}/go ${install_dir}/examples
    cp -r ${examples_dir}/nodejs ${install_dir}/examples
    cp -r ${examples_dir}/C# ${install_dir}/examples
    mkdir -p ${install_dir}/examples/taosbenchmark-json && cp ${examples_dir}/../tools/taos-tools/example/* ${install_dir}/examples/taosbenchmark-json
  fi

194
  if [ "$verMode" == "cluster" ]; then
wafwerar's avatar
wafwerar 已提交
195 196 197 198 199
      # Copy connector
      connector_dir="${code_dir}/connector"
      mkdir -p ${install_dir}/connector
      if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then
          if [ "$osType" != "Darwin" ]; then
200 201
              jars=$(ls ${build_dir}/lib/*.jar 2>/dev/null|wc -l)
              [ "${jars}" != "0" ] && cp ${build_dir}/lib/*.jar ${install_dir}/connector || :
wafwerar's avatar
wafwerar 已提交
202
          fi
203 204 205
          git clone --depth 1 https://github.com/taosdata/driver-go ${install_dir}/connector/go
          rm -rf ${install_dir}/connector/go/.git ||:

wafwerar's avatar
wafwerar 已提交
206 207 208 209 210 211 212 213 214
          git clone --depth 1 https://github.com/taosdata/taos-connector-python ${install_dir}/connector/python
          rm -rf ${install_dir}/connector/python/.git ||:
#          cp -r ${connector_dir}/python ${install_dir}/connector
          git clone --depth 1 https://github.com/taosdata/taos-connector-node ${install_dir}/connector/nodejs
          rm -rf ${install_dir}/connector/nodejs/.git ||:

          git clone --depth 1 https://github.com/taosdata/taos-connector-dotnet ${install_dir}/connector/dotnet
          rm -rf ${install_dir}/connector/dotnet/.git ||:
#          cp -r ${connector_dir}/nodejs ${install_dir}/connector
215
          git clone --depth 1 https://github.com/taosdata/taos-connector-rust ${install_dir}/connector/rust
wafwerar's avatar
wafwerar 已提交
216 217 218 219 220 221 222 223 224 225 226
          rm -rf ${install_dir}/connector/rust/.git ||:
      fi
  fi
fi
# Copy driver
mkdir -p ${install_dir}/driver
cp ${lib_files} ${install_dir}/driver

# Copy connector
connector_dir="${code_dir}/connector"
mkdir -p ${install_dir}/connector
227
[ -f ${wslib_files} ] && cp ${wslib_files} ${install_dir}/driver
wafwerar's avatar
wafwerar 已提交
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

if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then
  if [ "$osType" != "Darwin" ]; then
    cp ${build_dir}/lib/*.jar ${install_dir}/connector || :
  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
  cp -r ${connector_dir}/python ${install_dir}/connector || :
  cp -r ${connector_dir}/nodejs ${install_dir}/connector || :
fi
# Copy release note
# cp ${script_dir}/release_note ${install_dir}

# exit 1

cd ${release_dir}

#  install_dir has been distinguishes  cluster from  edege, so comments this code
pkg_name=${install_dir}-${osType}-${cpuType}

# if [ "$verMode" == "cluster" ]; then
#   pkg_name=${install_dir}-${osType}-${cpuType}
# elif [ "$verMode" == "edge" ]; then
#   pkg_name=${install_dir}-${osType}-${cpuType}
# else
#   echo "unknow verMode, nor cluster or edge"
#   exit 1
# fi

if [[ "$verType" == "beta" ]] || [[ "$verType" == "preRelease" ]]; then
  pkg_name=${install_dir}-${verType}-${osType}-${cpuType}
elif [ "$verType" == "stable" ]; then
  pkg_name=${pkg_name}
else
  echo "unknow verType, nor stabel or beta"
  exit 1
fi

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

if [ "$osType" != "Darwin" ]; then
  tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || :
else
  tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) || :
277 278 279
#  mv "$(basename ${pkg_name}).tar.gz" ..
  rm -rf ${install_dir} ||:
#  mv ../"$(basename ${pkg_name}).tar.gz" .
wafwerar's avatar
wafwerar 已提交
280 281 282
fi

cd ${curr_dir}