webhook.spec 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. ##
  2. ## webhook.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2017 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 version
  24. %define V_webhook_base 2.6.2
  25. %define V_webhook_snap 20170402
  26. # package information
  27. Name: webhook
  28. Summary: Web Hook Daemon
  29. URL: https://github.com/adnanh/webhook/
  30. Vendor: Adnan Hajdarevic
  31. Packager: OpenPKG Foundation e.V.
  32. Distribution: OpenPKG Community
  33. Class: EVAL
  34. Group: Web
  35. License: MIT
  36. Version: %{V_webhook_base}.%{V_webhook_snap}
  37. Release: 20170402
  38. # list of sources
  39. Source0: http://download.openpkg.org/components/versioned/webhook/webhook-%{V_webhook_snap}.tar.xz
  40. Source1: hooks.json
  41. Source2: rc.webhook
  42. Source3: sample.sh
  43. # build information
  44. BuildPreReq: OpenPKG, openpkg >= 20160101, go
  45. PreReq: OpenPKG, openpkg >= 20160101
  46. %description
  47. webhook is a lightweight configurable tool written in Go, that
  48. allows you to easily create HTTP endpoints (hooks) on your server,
  49. which you can use to execute configured commands. You can also
  50. pass data from the HTTP request (such as headers, payload or query
  51. variables) to your commands. webhook also allows you to specify
  52. rules which have to be satisfied in order for the hook to be
  53. triggered.
  54. %track
  55. prog webhook:release = {
  56. version = %{V_webhook_base}
  57. url = https://github.com/adnanh/webhook/releases
  58. regex = (\d+\.\d+\.\d+)\.tar\.gz
  59. }
  60. prog webhook:snapshot = {
  61. version = %{V_webhook_snap}
  62. url = http://download.openpkg.org/components/versioned/webhook/
  63. regex = webhook-(__VER__)\.tar\.xz
  64. }
  65. %prep
  66. %setup -q -n webhook
  67. %build
  68. # build program
  69. export GOPATH=`pwd`
  70. cd src/github.com/adnanh/webhook
  71. go build -x -o webhook
  72. %install
  73. # create directory hierarchy
  74. %{l_shtool} mkdir -f -p -m 755 \
  75. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  76. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  77. $RPM_BUILD_ROOT%{l_prefix}/etc/webhook \
  78. $RPM_BUILD_ROOT%{l_prefix}/libexec/webhook \
  79. $RPM_BUILD_ROOT%{l_prefix}/var/webhook/log \
  80. $RPM_BUILD_ROOT%{l_prefix}/var/webhook/run
  81. # install program
  82. %{l_shtool} install -c -s -m 755 \
  83. src/github.com/adnanh/webhook/webhook \
  84. $RPM_BUILD_ROOT%{l_prefix}/sbin/
  85. # install configuration
  86. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  87. %{SOURCE hooks.json} \
  88. $RPM_BUILD_ROOT%{l_prefix}/etc/webhook/
  89. # install run-command script
  90. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  91. %{SOURCE rc.webhook} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  92. # install sample hook
  93. %{l_shtool} install -c -m 755 \
  94. %{SOURCE sample.sh} \
  95. $RPM_BUILD_ROOT%{l_prefix}/libexec/webhook/
  96. # determine installation files
  97. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  98. %{l_files_std} \
  99. '%config %{l_prefix}/etc/webhook' \
  100. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/webhook/*'
  101. %files -f files
  102. %clean
  103. %post
  104. # after upgrade, restart service
  105. [ $1 -eq 2 ] || exit 0
  106. eval `%{l_rc} webhook status 2>/dev/null`
  107. [ ".$webhook_active" = .yes ] && %{l_rc} webhook restart
  108. exit 0
  109. %preun
  110. # before erase, stop service and remove log files
  111. [ $1 -eq 0 ] || exit 0
  112. %{l_rc} webhook stop 2>/dev/null
  113. rm -rf $RPM_INSTALL_PREFIX/var/webhook/log/* >/dev/null 2>&1 || true
  114. rm -rf $RPM_INSTALL_PREFIX/var/webhook/run/* >/dev/null 2>&1 || true
  115. exit 0