tdengine.spec 8.3 KB
Newer Older
H
hzcheng 已提交
1
%define homepath         /usr/local/taos
2
%define userlocalpath    /usr/local
H
hzcheng 已提交
3
%define cfg_install_dir  /etc/taos
H
huili 已提交
4
%define __strip /bin/true
H
hzcheng 已提交
5

6
Name:		tdengine
H
hzcheng 已提交
7 8 9 10 11 12
Version:	%{_version}
Release:	3%{?dist}
Summary:	tdengine from taosdata
Group:	  Application/Database
License:	AGPL
URL:		  www.taosdata.com
13
AutoReqProv: no
H
hzcheng 已提交
14 15

#BuildRoot:  %_topdir/BUILDROOT
16
BuildRoot:   %{_tmppath}/%{name}-%{version}-%{release}-root
H
hzcheng 已提交
17 18 19

#Prefix: /usr/local/taos

20 21
#BuildRequires:
#Requires:
H
hzcheng 已提交
22 23 24 25

%description
Big Data Platform Designed and Optimized for IoT

26
#"prep" Nothing needs to be done
H
hzcheng 已提交
27 28
#%prep
#%setup -q
29
#%setup -T
H
hzcheng 已提交
30

31
#"build" Nothing needs to be done
H
hzcheng 已提交
32 33 34 35 36 37 38 39 40 41 42 43
#%build
#%configure
#make %{?_smp_mflags}

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

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

L
lihui 已提交
44
libfile="libtaos.so.%{_version}"
H
huili 已提交
45

H
hzcheng 已提交
46 47 48 49 50 51 52 53 54 55 56
# 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
57 58 59
if [ -f %{_compiledir}/test/cfg/blm.toml ]; then
    cp %{_compiledir}/test/cfg/blm.toml         %{buildroot}%{homepath}/cfg
fi
60 61 62
if [ -f %{_compiledir}/test/cfg/blm3.service ]; then
    cp %{_compiledir}/test/cfg/blm3.service %{buildroot}%{homepath}/cfg
fi
H
hzcheng 已提交
63 64 65
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
66 67 68
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
H
hzcheng 已提交
69
cp %{_compiledir}/build/bin/taos                    %{buildroot}%{homepath}/bin
70
cp %{_compiledir}/build/bin/taosd                   %{buildroot}%{homepath}/bin
71 72 73
if [ -f %{_compiledir}/build/bin/blm3 ]; then
    cp %{_compiledir}/build/bin/blm3                    %{buildroot}%{homepath}/bin ||:
fi
S
slguan 已提交
74
cp %{_compiledir}/build/bin/taosdemo                %{buildroot}%{homepath}/bin
75
cp %{_compiledir}/build/bin/taosdump                %{buildroot}%{homepath}/bin
H
huili 已提交
76
cp %{_compiledir}/build/lib/${libfile}              %{buildroot}%{homepath}/driver
H
hzcheng 已提交
77
cp %{_compiledir}/../src/inc/taos.h                 %{buildroot}%{homepath}/include
L
lihui 已提交
78
cp %{_compiledir}/../src/inc/taoserror.h            %{buildroot}%{homepath}/include
H
hzcheng 已提交
79 80
cp -r %{_compiledir}/../src/connector/python        %{buildroot}%{homepath}/connector
cp -r %{_compiledir}/../src/connector/go            %{buildroot}%{homepath}/connector
H
Hui Li 已提交
81
cp -r %{_compiledir}/../src/connector/nodejs        %{buildroot}%{homepath}/connector
82
cp %{_compiledir}/build/lib/taos-jdbcdriver*.*      %{buildroot}%{homepath}/connector ||:
H
hzcheng 已提交
83 84
cp -r %{_compiledir}/../tests/examples/*            %{buildroot}%{homepath}/examples

85 86 87 88 89 90 91 92
if [ -f %{_compiledir}/build/lib/libavro.so.23.0.0 ]; then
    cp %{_compiledir}/build/lib/libavro.so.23.0.0 %{buildroot}%{homepath}/driver
    ln -sf libavro.so.23.0.0 %{buildroot}%{homepath}/driver/libavro.so.23
    ln -sf libavro.so.23 %{buildroot}%{homepath}/driver/libavro.so
fi
if [ -f %{_compiledir}/build/lib/libavro.a ]; then
    cp %{_compiledir}/build/lib/libavro.a %{buildroot}%{homepath}/driver
fi
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136

if [ -f %{_compiledir}/build/bin/jemalloc-config ]; then
    mkdir -p %{buildroot}%{userlocalpath}/bin
    mkdir -p %{buildroot}%{userlocalpath}/lib
    mkdir -p %{buildroot}%{userlocalpath}/lib/pkgconfig
    mkdir -p %{buildroot}%{userlocalpath}/include
    mkdir -p %{buildroot}%{userlocalpath}/include/jemalloc
    mkdir -p %{buildroot}%{userlocalpath}/share
    mkdir -p %{buildroot}%{userlocalpath}/share/doc
    mkdir -p %{buildroot}%{userlocalpath}/share/doc/jemalloc
    mkdir -p %{buildroot}%{userlocalpath}/share/man
    mkdir -p %{buildroot}%{userlocalpath}/share/man/man3

    cp %{_compiledir}/build/bin/jemalloc-config %{buildroot}%{userlocalpath}/bin/
    if [ -f %{_compiledir}/build/bin/jemalloc.sh ]; then
        cp %{_compiledir}/build/bin/jemalloc.sh %{buildroot}%{userlocalpath}/bin/
    fi
    if [ -f %{_compiledir}/build/bin/jeprof ]; then
        cp %{_compiledir}/build/bin/jeprof %{buildroot}%{userlocalpath}/bin/
    fi
    if [ -f %{_compiledir}/build/include/jemalloc/jemalloc.h ]; then
        cp %{_compiledir}/build/include/jemalloc/jemalloc.h %{buildroot}%{userlocalpath}/include/jemalloc/
    fi
    if [ -f %{_compiledir}/build/lib/libjemalloc.so.2 ]; then
        cp %{_compiledir}/build/lib/libjemalloc.so.2 %{buildroot}%{userlocalpath}/lib/
        ln -sf libjemalloc.so.2 %{buildroot}%{userlocalpath}/lib/libjemalloc.so
    fi
    if [ -f %{_compiledir}/build/lib/libjemalloc.a ]; then
        cp %{_compiledir}/build/lib/libjemalloc.a %{buildroot}%{userlocalpath}/lib/
    fi
    if [ -f %{_compiledir}/build/lib/libjemalloc_pic.a ]; then
        cp %{_compiledir}/build/lib/libjemalloc_pic.a %{buildroot}%{userlocalpath}/lib/
    fi
    if [ -f %{_compiledir}/build/lib/pkgconfig/jemalloc.pc ]; then
        cp %{_compiledir}/build/lib/pkgconfig/jemalloc.pc %{buildroot}%{userlocalpath}/lib/pkgconfig/
    fi
    if [ -f %{_compiledir}/build/share/doc/jemalloc/jemalloc.html ]; then
        cp %{_compiledir}/build/share/doc/jemalloc/jemalloc.html %{buildroot}%{userlocalpath}/share/doc/jemalloc/
    fi
    if [ -f %{_compiledir}/build/share/man/man3/jemalloc.3 ]; then
        cp %{_compiledir}/build/share/man/man3/jemalloc.3 %{buildroot}%{userlocalpath}/share/man/man3/
    fi
fi

H
hzcheng 已提交
137 138
#Scripts executed before installation
%pre
P
plum-lihui 已提交
139 140 141 142 143
csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo"
fi

H
hzcheng 已提交
144 145
# Stop the service if running
if pidof taosd &> /dev/null; then
H
[NONE]  
huili 已提交
146
    if pidof systemd &> /dev/null; then
P
plum-lihui 已提交
147
        ${csudo} systemctl stop taosd || :
L
lihui 已提交
148
    elif $(which service  &> /dev/null); then
H
[NONE]  
huili 已提交
149 150 151
        ${csudo} service taosd stop || :
    else
        pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
L
lihui 已提交
152 153 154
        if [ -n "$pid" ]; then
           ${csudo} kill -9 $pid   || :
        fi
H
hzcheng 已提交
155 156 157 158
    fi
    echo "Stop taosd service success!"
    sleep 1
fi
159
# if taos.cfg already exist, remove it
H
hzcheng 已提交
160
if [ -f %{cfg_install_dir}/taos.cfg ]; then
161
    ${csudo} rm -f %{cfg_install_dir}/cfg/taos.cfg   || :
162
fi
H
hzcheng 已提交
163

164
# if blm.toml already exist, remove it
165
if [ -f %{cfg_install_dir}/blm.toml ]; then
166
    ${csudo} rm -f %{cfg_install_dir}/cfg/blm.toml || :
167 168
fi

H
[NONE]  
huili 已提交
169 170
# there can not libtaos.so*, otherwise ln -s  error
${csudo} rm -f %{homepath}/driver/libtaos*   || :
H
huili 已提交
171

H
hzcheng 已提交
172 173
#Scripts executed after installation
%post
P
plum-lihui 已提交
174 175 176 177
csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo"
fi
H
hzcheng 已提交
178
cd %{homepath}/script
P
plum-lihui 已提交
179
${csudo} ./post.sh
180

H
hzcheng 已提交
181 182
# Scripts executed before uninstall
%preun
P
plum-lihui 已提交
183 184 185 186
csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo"
fi
187
# only remove package to call preun.sh, not but update(2)
H
hzcheng 已提交
188
if [ $1 -eq 0 ];then
H
[NONE]  
huili 已提交
189 190
  #cd %{homepath}/script
  #${csudo} ./preun.sh
191

H
[NONE]  
huili 已提交
192 193 194 195 196 197 198
  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"
199

H
[NONE]  
huili 已提交
200 201 202 203 204 205 206
    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      || :
207
    ${csudo} rm -f ${bin_link_dir}/blm3       || :
H
[NONE]  
huili 已提交
208
    ${csudo} rm -f ${bin_link_dir}/taosdemo   || :
H
Hui Li 已提交
209
    ${csudo} rm -f ${bin_link_dir}/taosdump   || :
H
[NONE]  
huili 已提交
210 211
    ${csudo} rm -f ${cfg_link_dir}/*          || :
    ${csudo} rm -f ${inc_link_dir}/taos.h     || :
L
lihui 已提交
212
    ${csudo} rm -f ${inc_link_dir}/taoserror.h     || :
H
[NONE]  
huili 已提交
213
    ${csudo} rm -f ${lib_link_dir}/libtaos.*  || :
214

H
[NONE]  
huili 已提交
215 216
    ${csudo} rm -f ${log_link_dir}            || :
    ${csudo} rm -f ${data_link_dir}           || :
217

H
[NONE]  
huili 已提交
218
    pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
L
lihui 已提交
219 220
    if [ -n "$pid" ]; then
      ${csudo} kill -9 $pid   || :
221 222
    fi
  fi
H
hzcheng 已提交
223
fi
224

H
hzcheng 已提交
225 226
# Scripts executed after uninstall
%postun
227

H
hzcheng 已提交
228 229
# clean build dir
%clean
P
plum-lihui 已提交
230 231 232 233 234
csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo"
fi
${csudo} rm -rf %{buildroot}
H
hzcheng 已提交
235 236 237 238 239 240 241 242 243 244 245

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

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

#%changelog