cratedb.spec 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. ##
  2. ## cratedb.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2019 OpenPKG Project <http://openpkg.org/>
  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. Name: cratedb
  25. Summary: IoT Database
  26. URL: https://crate.io/products/cratedb/
  27. Vendor: Crate.io
  28. Packager: OpenPKG Project
  29. Distribution: OpenPKG Community
  30. Class: EVAL
  31. Group: Database
  32. License: Apache
  33. Version: 4.0.6
  34. Release: 20191003
  35. # list of sources
  36. Source0: https://cdn.crate.io/downloads/releases/crate-%{version}.tar.gz
  37. Source1: rc.cratedb
  38. # build information
  39. BuildPreReq: OpenPKG, openpkg >= 20160101
  40. PreReq: OpenPKG, openpkg >= 20160101, java, JAVA-JDK, python
  41. %description
  42. CrateDB is a distributed SQL database for IoT time-series data,
  43. built on top of a NoSQL foundation. It combines the familiarity of
  44. SQL with the scalability and data flexibility of NoSQL, enabling
  45. developers to: Use SQL to process any type of data, structured or
  46. unstructured; perform SQL queries at realtime speed, even JOINs
  47. and aggregates; scale simply. Customers often use CrateDB to store
  48. and query machine data. This is because CrateDB makes it easy and
  49. economical to handle the velocity, volume, and diversity of machine
  50. and log data.
  51. %track
  52. prog cratedb = {
  53. version = %{version}
  54. url = https://cdn.crate.io/downloads/releases/
  55. regex = crate-(__VER__)\.tar\.gz
  56. }
  57. %prep
  58. %setup -q -n crate-%{version}
  59. %build
  60. %install
  61. # create installation hierarchy
  62. %{l_shtool} mkdir -f -p -m 755 \
  63. $RPM_BUILD_ROOT%{l_prefix}/bin \
  64. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  65. $RPM_BUILD_ROOT%{l_prefix}/etc/cratedb \
  66. $RPM_BUILD_ROOT%{l_prefix}/lib/cratedb \
  67. $RPM_BUILD_ROOT%{l_prefix}/var/cratedb/log \
  68. $RPM_BUILD_ROOT%{l_prefix}/var/cratedb/run \
  69. $RPM_BUILD_ROOT%{l_prefix}/var/cratedb/db
  70. # install program
  71. rm -f bin/*.bat
  72. cp -rp bin lib plugins \
  73. $RPM_BUILD_ROOT%{l_prefix}/lib/cratedb/
  74. ln -s ../../etc/cratedb \
  75. $RPM_BUILD_ROOT%{l_prefix}/lib/cratedb/config
  76. ln -s ../../var/cratedb/log \
  77. $RPM_BUILD_ROOT%{l_prefix}/lib/cratedb/logs
  78. # install configuration
  79. %{l_shtool} install -c -m 644 \
  80. -e 's;^#path\.data: /path/to/data$;path.data: %{l_prefix}/var/cratedb/db;' \
  81. -e 's;^#network\.host: 192\.168\.0\.1$;network.host: 127.0.0.1;' \
  82. config/* $RPM_BUILD_ROOT%{l_prefix}/etc/cratedb/
  83. # install wrapper for shell
  84. ( echo "#!/bin/sh"
  85. echo "PYTHON_EXECUTABLE=%{l_prefix}/bin/python; export PYTHON_EXECUTABLE"
  86. echo "exec \$PYTHON_EXECUTABLE %{l_prefix}/lib/cratedb/bin/crash_standalone \"\${1+\"\$@\"}\""
  87. ) >crash.sh
  88. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  89. crash.sh $RPM_BUILD_ROOT%{l_prefix}/bin/crash
  90. # install run-command script
  91. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  92. %{SOURCE rc.cratedb} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  93. # determine installation files
  94. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  95. %{l_files_std} \
  96. '%config %{l_prefix}/etc/cratedb/*' \
  97. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/cratedb/*'
  98. %files -f files
  99. %clean
  100. %post
  101. # after upgrade, restart service
  102. if [ $1 -eq 2 ]; then
  103. eval `%{l_rc} cratedb status 2>/dev/null`
  104. [ ".$cratedb_active" = .yes ] && %{l_rc} cratedb restart
  105. fi
  106. exit 0
  107. %preun
  108. if [ $1 -eq 0 ]; then
  109. # before erase, stop service and remove log files
  110. %{l_rc} cratedb stop 2>/dev/null
  111. rm -f $RPM_INSTALL_PREFIX/var/cratedb/log/* >/dev/null 2>&1 || true
  112. rm -f $RPM_INSTALL_PREFIX/var/cratedb/run/* >/dev/null 2>&1 || true
  113. rm -rf $RPM_INSTALL_PREFIX/var/cratedb/db/* >/dev/null 2>&1 || true
  114. fi
  115. exit 0