kapacitor.spec 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. ##
  2. ## kapacitor.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2016 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ##
  5. ## Permission to use, copy, modify, and distribute this software for
  6. ## any purpose with or without fee is hereby granted, provided that
  7. ## the above copyright notice and this permission notice appear in all
  8. ## copies.
  9. ##
  10. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  11. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  12. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  13. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  14. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  15. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  16. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  17. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  19. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  20. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  21. ## SUCH DAMAGE.
  22. ##
  23. # package information
  24. %define V_kapacitor_base 1.0.1
  25. %define V_kapacitor_snap 20160927
  26. # package information
  27. Name: kapacitor
  28. Summary: Time-Series Data Alerting
  29. URL: https://influxdata.com/time-series-platform/kapacitor/
  30. Vendor: InfluxData
  31. Packager: OpenPKG Foundation e.V.
  32. Distribution: OpenPKG Community
  33. Class: EVAL
  34. Group: Database
  35. License: MIT
  36. Version: %{V_kapacitor_base}
  37. Release: 20160927
  38. # list of sources
  39. Source0: http://download.openpkg.org/components/versioned/kapacitor/kapacitor-%{V_kapacitor_snap}.tar.xz
  40. Source1: rc.kapacitor
  41. Source2: kapacitor.conf
  42. # build information
  43. BuildPreReq: OpenPKG, openpkg >= 20160101, go
  44. PreReq: OpenPKG, openpkg >= 20160101
  45. %description
  46. Kapacitor is a framework for processing, monitoring, and alerting on
  47. time series data.
  48. %track
  49. prog kapacitor = {
  50. version = %{V_kapacitor_base}
  51. url = https://github.com/influxdata/kapacitor/releases
  52. regex = (\d+\.\d+\.\d+)\.tar\.gz
  53. }
  54. %prep
  55. %setup -q -n kapacitor
  56. %build
  57. # build program
  58. ( export GOPATH=`pwd`
  59. cd $GOPATH/src/github.com/influxdata/kapacitor
  60. go build -x -o kapacitor cmd/kapacitor/*.go
  61. go build -x -o kapacitord cmd/kapacitord/*.go
  62. ) || exit $?
  63. %install
  64. # create directory hierarchy
  65. %{l_shtool} mkdir -f -p -m 755 \
  66. $RPM_BUILD_ROOT%{l_prefix}/bin \
  67. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  68. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  69. $RPM_BUILD_ROOT%{l_prefix}/etc/kapacitor/kapacitor.d \
  70. $RPM_BUILD_ROOT%{l_prefix}/var/kapacitor/run \
  71. $RPM_BUILD_ROOT%{l_prefix}/var/kapacitor/log \
  72. $RPM_BUILD_ROOT%{l_prefix}/var/kapacitor/db/replay \
  73. $RPM_BUILD_ROOT%{l_prefix}/var/kapacitor/db/tasks
  74. # install program
  75. %{l_shtool} install -c -s -m 755 \
  76. src/github.com/influxdata/kapacitor/kapacitor \
  77. $RPM_BUILD_ROOT%{l_prefix}/bin/
  78. %{l_shtool} install -c -s -m 755 \
  79. src/github.com/influxdata/kapacitor/kapacitord \
  80. $RPM_BUILD_ROOT%{l_prefix}/sbin/
  81. # install run-command script
  82. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  83. %{SOURCE rc.kapacitor} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  84. # install default configuration
  85. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  86. %{SOURCE kapacitor.conf} \
  87. $RPM_BUILD_ROOT%{l_prefix}/etc/kapacitor/
  88. # determine installation files
  89. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  90. %{l_files_std} \
  91. '%config %{l_prefix}/etc/kapacitor/*' \
  92. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/kapacitor/*' \
  93. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/kapacitor/*/*'
  94. %files -f files
  95. %clean
  96. %post
  97. if [ $1 -eq 2 ]; then
  98. # after upgrade, restart service
  99. eval `%{l_rc} kapacitor status 2>/dev/null`
  100. [ ".$kapacitor_active" = .yes ] && %{l_rc} kapacitor restart
  101. fi
  102. exit 0
  103. %preun
  104. if [ $1 -eq 0 ]; then
  105. # before erase, stop service and remove log files
  106. %{l_rc} kapacitor stop 2>/dev/null
  107. rm -rf $RPM_INSTALL_PREFIX/var/kapacitor/log/* >/dev/null 2>&1 || true
  108. rm -rf $RPM_INSTALL_PREFIX/var/kapacitor/run/* >/dev/null 2>&1 || true
  109. rm -rf $RPM_INSTALL_PREFIX/var/kapacitor/db/* >/dev/null 2>&1 || true
  110. fi
  111. exit 0