mattermost.spec 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. ##
  2. ## mattermost.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2020 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: mattermost
  25. Summary: Web Collaboration Platform
  26. URL: http://mattermost.org/
  27. Vendor: Mattermost, Inc.
  28. Packager: OpenPKG Project
  29. Distribution: OpenPKG Community
  30. Class: PLUS
  31. Group: CMS
  32. License: Apache
  33. Version: 5.26.1
  34. Release: 20200830
  35. # list of sources
  36. Source0: https://github.com/mattermost/mattermost-server/archive/v%{version}.tar.gz
  37. Source1: https://releases.mattermost.com/%{version}/mattermost-%{version}-linux-amd64.tar.gz
  38. Source2: rc.mattermost
  39. Source3: mattermost.sh
  40. Source4: mattermost-setup.sh
  41. Source5: mattermost-post.sh
  42. Patch0: mattermost.patch
  43. # build information
  44. BuildPreReq: OpenPKG, openpkg >= 20140101, go
  45. PreReq: OpenPKG, openpkg >= 20140101, postgresql, curl
  46. %description
  47. Mattermost is a flexible instant messaging platform that meets even
  48. the most demanding privacy and security standards.
  49. %track
  50. prog mattermost = {
  51. version = %{version}
  52. url = https://mattermost.com/download/
  53. regex = mattermost-(\d+\.\d+(\.\d+)?)
  54. }
  55. %prep
  56. %setup -q -c
  57. %setup -q -T -D -a 1
  58. %patch -p0
  59. %build
  60. # build server
  61. export GOPATH=`pwd`
  62. mkdir -p src/github.com/mattermost/
  63. ln -s `pwd`/mattermost-server-%{version} src/github.com/mattermost/mattermost-server
  64. ( cd src/github.com/mattermost/mattermost-server
  65. %{l_make} %{l_mflags} build BUILD_NUMBER=%{version}
  66. ) || exit $?
  67. # strip down regular distribution
  68. rm -f mattermost/client/*.js.map
  69. rm -f mattermost/client/*.css.map
  70. %install
  71. # create installation hierarchy
  72. %{l_shtool} mkdir -f -p -m 755 \
  73. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  74. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  75. $RPM_BUILD_ROOT%{l_prefix}/etc/mattermost/plugins \
  76. $RPM_BUILD_ROOT%{l_prefix}/libexec/mattermost \
  77. $RPM_BUILD_ROOT%{l_prefix}/lib/mattermost \
  78. $RPM_BUILD_ROOT%{l_prefix}/var/mattermost/data-db \
  79. $RPM_BUILD_ROOT%{l_prefix}/var/mattermost/data-fs \
  80. $RPM_BUILD_ROOT%{l_prefix}/var/mattermost/data-plugins \
  81. $RPM_BUILD_ROOT%{l_prefix}/var/mattermost/run \
  82. $RPM_BUILD_ROOT%{l_prefix}/var/mattermost/log
  83. # install programs
  84. %{l_shtool} install -c -m 755 \
  85. mattermost-server-%{version}/mattermost \
  86. $RPM_BUILD_ROOT%{l_prefix}/libexec/mattermost/mattermost
  87. # install wrapper scripts
  88. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  89. %{SOURCE mattermost.sh} $RPM_BUILD_ROOT%{l_prefix}/sbin/mattermost
  90. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  91. %{SOURCE mattermost-post.sh} $RPM_BUILD_ROOT%{l_prefix}/sbin/mattermost-post
  92. # install configuration
  93. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  94. mattermost/config/config.json \
  95. $RPM_BUILD_ROOT%{l_prefix}/etc/mattermost/mattermost.json
  96. # install regular distribution parts
  97. cp -rp \
  98. mattermost/client \
  99. mattermost/fonts \
  100. mattermost/i18n \
  101. mattermost/prepackaged_plugins \
  102. mattermost/templates \
  103. $RPM_BUILD_ROOT%{l_prefix}/lib/mattermost/
  104. # provide directory symlinks
  105. ln -s ../../etc/mattermost \
  106. $RPM_BUILD_ROOT%{l_prefix}/lib/mattermost/config
  107. ln -s ../../var/mattermost/log \
  108. $RPM_BUILD_ROOT%{l_prefix}/lib/mattermost/logs
  109. ln -s ../../var/mattermost/data-plugins \
  110. $RPM_BUILD_ROOT%{l_prefix}/lib/mattermost/plugins
  111. # install run-command script
  112. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  113. %{SOURCE rc.mattermost} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  114. # install database setup script
  115. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  116. %{SOURCE mattermost-setup.sh} $RPM_BUILD_ROOT%{l_prefix}/sbin/mattermost-setup
  117. # determine installation files
  118. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  119. %{l_files_std} \
  120. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/etc/mattermost' \
  121. '%config %attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/etc/mattermost/*' \
  122. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mattermost' \
  123. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mattermost/*'
  124. %files -f files
  125. %clean
  126. %post
  127. if [ $1 -eq 1 ]; then
  128. # display final hints on initial installation
  129. ( echo "1. To complete this installation of Mattermost please start PostgreSQL"
  130. echo " and initialize the Mattermost database like this:"
  131. echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc postgresql start"
  132. echo " \$ $RPM_INSTALL_PREFIX/sbin/mattermost-setup install"
  133. echo ""
  134. echo "2. After this post-installation, start Mattermost by running"
  135. echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc mattermost start"
  136. echo " and initialize the Mattermost database by connecting to:"
  137. echo " http://127.0.0.1:8080/"
  138. ) | %{l_rpmtool} msg -b -t notice
  139. fi
  140. if [ $1 -eq 2 ]; then
  141. # after upgrade, restart service
  142. eval `%{l_rc} mattermost status 2>/dev/null`
  143. [ ".$mattermost_active" = .yes ] && %{l_rc} mattermost restart
  144. fi
  145. exit 0
  146. %preun
  147. if [ $1 -eq 0 ]; then
  148. # before erase, stop service and remove log files
  149. %{l_rc} mattermost stop 2>/dev/null
  150. # remove database
  151. $RPM_INSTALL_PREFIX/sbin/mattermost-setup uninstall >/dev/null 2>&1 || true
  152. # remove run-time files
  153. rm -rf $RPM_INSTALL_PREFIX/var/mattermost/data-db/* >/dev/null 2>&1 || true
  154. rm -rf $RPM_INSTALL_PREFIX/var/mattermost/data-fs/* >/dev/null 2>&1 || true
  155. rm -rf $RPM_INSTALL_PREFIX/var/mattermost/data-plugins/* >/dev/null 2>&1 || true
  156. rm -f $RPM_INSTALL_PREFIX/var/mattermost/log/* >/dev/null 2>&1 || true
  157. rm -f $RPM_INSTALL_PREFIX/var/mattermost/run/* >/dev/null 2>&1 || true
  158. fi
  159. exit 0