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

5
Name:		tdengine
H
hzcheng 已提交
6 7 8 9 10 11
Version:	%{_version}
Release:	3%{?dist}
Summary:	tdengine from taosdata
Group:	  Application/Database
License:	AGPL
URL:		  www.taosdata.com
12
AutoReqProv: no
H
hzcheng 已提交
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

#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}

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

H
hzcheng 已提交
45 46 47 48 49 50 51 52 53 54 55 56 57 58
# 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
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
59 60 61
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 已提交
62
cp %{_compiledir}/build/bin/taos                    %{buildroot}%{homepath}/bin
63
cp %{_compiledir}/build/bin/taosd                   %{buildroot}%{homepath}/bin
S
slguan 已提交
64
cp %{_compiledir}/build/bin/taosdemo                %{buildroot}%{homepath}/bin
65
cp %{_compiledir}/build/bin/taosdump                %{buildroot}%{homepath}/bin
H
huili 已提交
66
cp %{_compiledir}/build/lib/${libfile}              %{buildroot}%{homepath}/driver
H
hzcheng 已提交
67
cp %{_compiledir}/../src/inc/taos.h                 %{buildroot}%{homepath}/include
L
lihui 已提交
68
cp %{_compiledir}/../src/inc/taoserror.h            %{buildroot}%{homepath}/include
Z
zyyang 已提交
69 70 71 72 73 74
if [ -d %{_compiledir}/../src/connector/grafanaplugin/dist ]; then
    cp -r %{_compiledir}/../src/connector/grafanaplugin/dist %{buildroot}%{homepath}/connector/grafanaplugin
else
    echo grafanaplugin bundled directory not found!
    exit 1
fi
H
hzcheng 已提交
75 76
cp -r %{_compiledir}/../src/connector/python        %{buildroot}%{homepath}/connector
cp -r %{_compiledir}/../src/connector/go            %{buildroot}%{homepath}/connector
H
Hui Li 已提交
77
cp -r %{_compiledir}/../src/connector/nodejs        %{buildroot}%{homepath}/connector
P
plum-lihui 已提交
78
cp %{_compiledir}/build/lib/taos-jdbcdriver*dist.*  %{buildroot}%{homepath}/connector ||:
H
hzcheng 已提交
79 80 81 82
cp -r %{_compiledir}/../tests/examples/*            %{buildroot}%{homepath}/examples

#Scripts executed before installation
%pre
P
plum-lihui 已提交
83 84 85 86 87
csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo"
fi

H
hzcheng 已提交
88 89
# Stop the service if running
if pidof taosd &> /dev/null; then
H
[NONE]  
huili 已提交
90
    if pidof systemd &> /dev/null; then
P
plum-lihui 已提交
91
        ${csudo} systemctl stop taosd || :
L
lihui 已提交
92
    elif $(which service  &> /dev/null); then
H
[NONE]  
huili 已提交
93 94 95
        ${csudo} service taosd stop || :
    else
        pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
L
lihui 已提交
96 97 98
        if [ -n "$pid" ]; then
           ${csudo} kill -9 $pid   || :
        fi
H
hzcheng 已提交
99 100 101 102 103 104
    fi
    echo "Stop taosd service success!"
    sleep 1
fi
# if taos.cfg already softlink, remove it
if [ -f %{cfg_install_dir}/taos.cfg ]; then
P
plum-lihui 已提交
105
    ${csudo} rm -f %{homepath}/cfg/taos.cfg   || :
H
hzcheng 已提交
106 107
fi 

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

H
hzcheng 已提交
111 112
#Scripts executed after installation
%post
P
plum-lihui 已提交
113 114 115 116
csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo"
fi
H
hzcheng 已提交
117
cd %{homepath}/script
P
plum-lihui 已提交
118
${csudo} ./post.sh
H
hzcheng 已提交
119 120 121
 
# Scripts executed before uninstall
%preun
P
plum-lihui 已提交
122 123 124 125
csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo"
fi
H
hzcheng 已提交
126 127
# only remove package to call preun.sh, not but update(2) 
if [ $1 -eq 0 ];then
H
[NONE]  
huili 已提交
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
  #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      || :
    ${csudo} rm -f ${bin_link_dir}/taosdemo   || :
H
Hui Li 已提交
147
    ${csudo} rm -f ${bin_link_dir}/taosdump   || :
H
[NONE]  
huili 已提交
148 149
    ${csudo} rm -f ${cfg_link_dir}/*          || :
    ${csudo} rm -f ${inc_link_dir}/taos.h     || :
L
lihui 已提交
150
    ${csudo} rm -f ${inc_link_dir}/taoserror.h     || :
H
[NONE]  
huili 已提交
151 152 153 154 155 156
    ${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}')
L
lihui 已提交
157 158 159
    if [ -n "$pid" ]; then
      ${csudo} kill -9 $pid   || :
    fi    
H
[NONE]  
huili 已提交
160
  fi  
H
hzcheng 已提交
161 162 163 164 165 166 167
fi
 
# Scripts executed after uninstall
%postun
 
# clean build dir
%clean
P
plum-lihui 已提交
168 169 170 171 172
csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo"
fi
${csudo} rm -rf %{buildroot}
H
hzcheng 已提交
173 174 175 176 177 178 179 180 181 182 183

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

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

#%changelog