tdengine.spec 8.8 KB
Newer Older
wafwerar's avatar
wafwerar 已提交
1 2 3 4
%define homepath         /usr/local/taos
%define userlocalpath    /usr/local
%define cfg_install_dir  /etc/taos
%define __strip /bin/true
5
%global __python /usr/bin/python3
6
%global _build_id_links none
wafwerar's avatar
wafwerar 已提交
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46

Name:		tdengine
Version:	%{_version}
Release:	3%{?dist}
Summary:	tdengine from taosdata
Group:	  Application/Database
License:	AGPL
URL:		  www.taosdata.com
AutoReqProv: no

#BuildRoot:  %_topdir/BUILDROOT
BuildRoot:   %{_tmppath}/%{name}-%{version}-%{release}-root

#Prefix: /usr/local/taos

#BuildRequires:
#Requires:

%description
Big Data Platform Designed and Optimized for IoT

#"prep" Nothing needs to be done
#%prep
#%setup -q
#%setup -T

#"build" Nothing needs to be done
#%build
#%configure
#make %{?_smp_mflags}

%install
#make install DESTDIR=%{buildroot}
rm -rf %{buildroot}

echo topdir: %{_topdir}
echo version: %{_version}
echo buildroot: %{buildroot}

libfile="libtaos.so.%{_version}"
47
wslibfile="libtaosws.so"
wafwerar's avatar
wafwerar 已提交
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65

# create install path, and cp file
mkdir -p %{buildroot}%{homepath}/bin
mkdir -p %{buildroot}%{homepath}/cfg
#mkdir -p %{buildroot}%{homepath}/connector
mkdir -p %{buildroot}%{homepath}/driver
mkdir -p %{buildroot}%{homepath}/examples
mkdir -p %{buildroot}%{homepath}/include
#mkdir -p %{buildroot}%{homepath}/init.d
mkdir -p %{buildroot}%{homepath}/script

cp %{_compiledir}/../packaging/cfg/taos.cfg         %{buildroot}%{homepath}/cfg
if [ -f %{_compiledir}/test/cfg/taosadapter.toml ]; then
    cp %{_compiledir}/test/cfg/taosadapter.toml         %{buildroot}%{homepath}/cfg
fi
if [ -f %{_compiledir}/test/cfg/taosadapter.service ]; then
    cp %{_compiledir}/test/cfg/taosadapter.service %{buildroot}%{homepath}/cfg
fi
66 67 68 69 70 71 72 73 74

if [ -f %{_compiledir}/../build-taoskeeper/config/taoskeeper.toml ]; then
    cp %{_compiledir}/../build-taoskeeper/config/taoskeeper.toml %{buildroot}%{homepath}/cfg ||:
fi

if [ -f %{_compiledir}/../build-taoskeeper/taoskeeper.service ]; then
    cp %{_compiledir}/../build-taoskeeper/taoskeeper.service %{buildroot}%{homepath}/cfg ||:
fi

wafwerar's avatar
wafwerar 已提交
75 76 77 78 79 80 81 82
#cp %{_compiledir}/../packaging/rpm/taosd            %{buildroot}%{homepath}/init.d
cp %{_compiledir}/../packaging/tools/post.sh        %{buildroot}%{homepath}/script
cp %{_compiledir}/../packaging/tools/preun.sh       %{buildroot}%{homepath}/script
cp %{_compiledir}/../packaging/tools/startPre.sh    %{buildroot}%{homepath}/bin
cp %{_compiledir}/../packaging/tools/set_core.sh    %{buildroot}%{homepath}/bin
cp %{_compiledir}/../packaging/tools/taosd-dump-cfg.gdb    %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/bin/taos                    %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/bin/taosd                   %{buildroot}%{homepath}/bin
wafwerar's avatar
wafwerar 已提交
83
cp %{_compiledir}/build/bin/udfd                    %{buildroot}%{homepath}/bin
wafwerar's avatar
wafwerar 已提交
84
cp %{_compiledir}/build/bin/taosBenchmark           %{buildroot}%{homepath}/bin
wafwerar's avatar
wafwerar 已提交
85

86 87 88 89
if [ -f %{_compiledir}/../build-taoskeeper/taoskeeper ]; then
    cp %{_compiledir}/../build-taoskeeper/taoskeeper %{buildroot}%{homepath}/bin
fi

wafwerar's avatar
wafwerar 已提交
90
if [ -f %{_compiledir}/build/bin/taosadapter ]; then
91
    cp %{_compiledir}/build/bin/taosadapter                    %{buildroot}%{homepath}/bin
wafwerar's avatar
wafwerar 已提交
92 93
fi
cp %{_compiledir}/build/lib/${libfile}              %{buildroot}%{homepath}/driver
94
[ -f %{_compiledir}/build/lib/${wslibfile} ] && cp %{_compiledir}/build/lib/${wslibfile}            %{buildroot}%{homepath}/driver ||:
wafwerar's avatar
wafwerar 已提交
95 96 97
cp %{_compiledir}/../include/client/taos.h          %{buildroot}%{homepath}/include
cp %{_compiledir}/../include/common/taosdef.h       %{buildroot}%{homepath}/include
cp %{_compiledir}/../include/util/taoserror.h       %{buildroot}%{homepath}/include
98
cp %{_compiledir}/../include/libs/function/taosudf.h       %{buildroot}%{homepath}/include
99
[ -f %{_compiledir}/build/include/taosws.h ] && cp %{_compiledir}/build/include/taosws.h            %{buildroot}%{homepath}/include ||:
wafwerar's avatar
wafwerar 已提交
100 101 102 103 104 105 106
#cp -r %{_compiledir}/../src/connector/python        %{buildroot}%{homepath}/connector
#cp -r %{_compiledir}/../src/connector/go            %{buildroot}%{homepath}/connector
#cp -r %{_compiledir}/../src/connector/nodejs        %{buildroot}%{homepath}/connector
#cp %{_compiledir}/build/lib/taos-jdbcdriver*.*      %{buildroot}%{homepath}/connector ||:
cp -r %{_compiledir}/../examples/*                  %{buildroot}%{homepath}/examples

if [ -f %{_compiledir}/build/bin/jemalloc-config ]; then
107 108 109 110 111 112
    mkdir -p %{buildroot}%{homepath}/jemalloc/ ||:
    mkdir -p %{buildroot}%{homepath}/jemalloc/include/jemalloc/ ||:
    mkdir -p %{buildroot}%{homepath}/jemalloc/lib/ ||:
    mkdir -p %{buildroot}%{homepath}/jemalloc/lib/pkgconfig ||:

    cp %{_compiledir}/build/bin/jemalloc-config %{buildroot}%{homepath}/jemalloc/bin
wafwerar's avatar
wafwerar 已提交
113
    if [ -f %{_compiledir}/build/bin/jemalloc.sh ]; then
114
        cp %{_compiledir}/build/bin/jemalloc.sh %{buildroot}%{homepath}/jemalloc/bin
wafwerar's avatar
wafwerar 已提交
115 116
    fi
    if [ -f %{_compiledir}/build/bin/jeprof ]; then
117
        cp %{_compiledir}/build/bin/jeprof %{buildroot}%{homepath}/jemalloc/bin
wafwerar's avatar
wafwerar 已提交
118 119
    fi
    if [ -f %{_compiledir}/build/include/jemalloc/jemalloc.h ]; then
120
        cp %{_compiledir}/build/include/jemalloc/jemalloc.h %{buildroot}%{homepath}/jemalloc/include/jemalloc/
wafwerar's avatar
wafwerar 已提交
121 122
    fi
    if [ -f %{_compiledir}/build/lib/libjemalloc.so.2 ]; then
123 124
        cp %{_compiledir}/build/lib/libjemalloc.so.2 %{buildroot}%{homepath}/jemalloc/lib
        ln -sf libjemalloc.so.2 %{buildroot}%{homepath}/jemalloc/lib/libjemalloc.so
wafwerar's avatar
wafwerar 已提交
125 126
    fi
    if [ -f %{_compiledir}/build/lib/libjemalloc.a ]; then
127
        cp %{_compiledir}/build/lib/libjemalloc.a %{buildroot}%{homepath}/jemalloc/lib
wafwerar's avatar
wafwerar 已提交
128 129
    fi
    if [ -f %{_compiledir}/build/lib/libjemalloc_pic.a ]; then
130
        cp %{_compiledir}/build/lib/libjemalloc_pic.a %{buildroot}%{homepath}/jemalloc/lib
wafwerar's avatar
wafwerar 已提交
131 132
    fi
    if [ -f %{_compiledir}/build/lib/pkgconfig/jemalloc.pc ]; then
133
        cp %{_compiledir}/build/lib/pkgconfig/jemalloc.pc %{buildroot}%{homepath}/jemalloc/lib/pkgconfig
wafwerar's avatar
wafwerar 已提交
134 135
    fi
fi
136 137 138
ls -al %{buildroot}%{homepath}/bin
tree -L 5
echo "==============================copying files done"
wafwerar's avatar
wafwerar 已提交
139 140
#Scripts executed before installation
%pre
wafwerar's avatar
wafwerar 已提交
141 142 143 144
if [ -f /var/lib/taos/dnode/dnodeCfg.json ]; then
  echo -e "The default data directory \033[41;37m/var/lib/taos\033[0m contains old data of tdengine 2.x, please clear it before installing!"
  exit 1
fi
wafwerar's avatar
wafwerar 已提交
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo "
fi

# Stop the service if running
if pidof taosd &> /dev/null; then
    if pidof systemd &> /dev/null; then
        ${csudo}systemctl stop taosd || :
    elif $(which service  &> /dev/null); then
        ${csudo}service taosd stop || :
    else
        pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
        if [ -n "$pid" ]; then
           ${csudo}kill -9 $pid   || :
        fi
    fi
    echo "Stop taosd service success!"
    sleep 1
fi
# if taos.cfg already exist, remove it
if [ -f %{cfg_install_dir}/taos.cfg ]; then
    ${csudo}rm -f %{cfg_install_dir}/cfg/taos.cfg   || :
fi

# if taosadapter.toml already exist, remove it
if [ -f %{cfg_install_dir}/taosadapter.toml ]; then
    ${csudo}rm -f %{cfg_install_dir}/cfg/taosadapter.toml || :
fi

# there can not libtaos.so*, otherwise ln -s  error
${csudo}rm -f %{homepath}/driver/libtaos*   || :

#Scripts executed after installation
%post
csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo "
fi
cd %{homepath}/script
${csudo}./post.sh

# Scripts executed before uninstall
%preun
csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo "
fi
# only remove package to call preun.sh, not but update(2)
if [ $1 -eq 0 ];then
  #cd %{homepath}/script
  #${csudo}./preun.sh

  if [ -f %{homepath}/script/preun.sh ]; then
    cd %{homepath}/script
    ${csudo}./preun.sh
  else
    bin_link_dir="/usr/bin"
    lib_link_dir="/usr/lib"
    inc_link_dir="/usr/include"

    data_link_dir="/usr/local/taos/data"
    log_link_dir="/usr/local/taos/log"
    cfg_link_dir="/usr/local/taos/cfg"

    # Remove all links
    ${csudo}rm -f ${bin_link_dir}/taos       || :
    ${csudo}rm -f ${bin_link_dir}/taosd      || :
wafwerar's avatar
wafwerar 已提交
213
    ${csudo}rm -f ${bin_link_dir}/udfd       || :
wafwerar's avatar
wafwerar 已提交
214
    ${csudo}rm -f ${bin_link_dir}/taosadapter       || :
215
    ${csudo}rm -f ${bin_link_dir}/taoskeeper       || :
wafwerar's avatar
wafwerar 已提交
216 217 218 219
    ${csudo}rm -f ${cfg_link_dir}/*          || :
    ${csudo}rm -f ${inc_link_dir}/taos.h     || :
    ${csudo}rm -f ${inc_link_dir}/taosdef.h     || :
    ${csudo}rm -f ${inc_link_dir}/taoserror.h     || :
220
    ${csudo}rm -f ${inc_link_dir}/taosudf.h     || :    
wafwerar's avatar
wafwerar 已提交
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
    ${csudo}rm -f ${lib_link_dir}/libtaos.*  || :

    ${csudo}rm -f ${log_link_dir}            || :
    ${csudo}rm -f ${data_link_dir}           || :

    pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
    if [ -n "$pid" ]; then
      ${csudo}kill -9 $pid   || :
    fi
  fi
fi

# Scripts executed after uninstall
%postun

# clean build dir
%clean
csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo "
fi
${csudo}rm -rf %{buildroot}

#Specify the files to be packaged
%files
/*
#%doc

#Setting default permissions
%defattr  (-,root,root,0755)
#%{prefix}

#%changelog