tyk.spec 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. ##
  2. ## tyk.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2022 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 version
  24. %define V_tyk_base 4.0.1
  25. %define V_tyk_snap 20220428
  26. # package information
  27. Name: tyk
  28. Summary: API Gateway
  29. URL: http://tyk.io/
  30. Vendor: Tyk Technologies Ltd
  31. Packager: OpenPKG Project
  32. Distribution: OpenPKG Community
  33. Class: EVAL
  34. Group: Networking
  35. License: MPL
  36. Version: %{V_tyk_base}.%{V_tyk_snap}
  37. Release: 20220428
  38. # list of sources
  39. Source0: http://download.openpkg.org/components/versioned/tyk/tyk-%{V_tyk_snap}.tar.xz
  40. Source1: rc.tyk
  41. Source2: tyk.conf
  42. # build information
  43. BuildPreReq: OpenPKG, openpkg >= 20160101, go
  44. PreReq: OpenPKG, openpkg >= 20160101, redis
  45. %description
  46. Tyk is a lightweight, open source API Gateway and enables you to
  47. control who accesses your API, when they access it and how they
  48. access it. Tyk will also record detailed analytics on how your users
  49. are interacting with your API and when things go wrong. Tyk can act
  50. as an OAUTH 2.0 provider for authorization.
  51. %track
  52. prog tyk:release = {
  53. version = %{V_tyk_base}
  54. url = https://github.com/TykTechnologies/tyk/releases
  55. regex = (\d+\.\d+(?:\.\d+)*)\.tar\.gz
  56. }
  57. prog tyk:snapshot = {
  58. version = %{V_tyk_snap}
  59. url = http://download.openpkg.org/components/versioned/tyk/
  60. regex = tyk-(__VER__)\.tar\.xz
  61. }
  62. %prep
  63. %setup -q -n tyk
  64. %build
  65. # build program
  66. export GOPATH=`pwd`
  67. cd src/github.com/TykTechnologies/tyk
  68. %{l_shtool} subst -e 's;/etc/tyk/tyk\.conf;%{l_prefix}/etc/tyk/tyk.conf;g' main.go
  69. go build -v -o tyk
  70. %install
  71. # create directory 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/tyk \
  76. $RPM_BUILD_ROOT%{l_prefix}/libexec/tyk/apps \
  77. $RPM_BUILD_ROOT%{l_prefix}/var/tyk/log \
  78. $RPM_BUILD_ROOT%{l_prefix}/var/tyk/run
  79. # install program
  80. %{l_shtool} install -c -s -m 755 \
  81. src/github.com/TykTechnologies/tyk/tyk \
  82. $RPM_BUILD_ROOT%{l_prefix}/sbin/tyk
  83. # install program addons
  84. cp -rp \
  85. src/github.com/TykTechnologies/tyk/templates \
  86. src/github.com/TykTechnologies/tyk/middleware \
  87. src/github.com/TykTechnologies/tyk/policies \
  88. $RPM_BUILD_ROOT%{l_prefix}/etc/tyk/
  89. # install default configuration
  90. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  91. %{SOURCE tyk.conf} $RPM_BUILD_ROOT%{l_prefix}/etc/tyk/
  92. # install run-command script
  93. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  94. %{SOURCE rc.tyk} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  95. # determine installation files
  96. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  97. %{l_files_std} \
  98. '%config %{l_prefix}/etc/tyk/*' \
  99. '%config %{l_prefix}/etc/tyk/*/*' \
  100. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/tyk/*'
  101. %files -f files
  102. %clean
  103. %post
  104. if [ $1 -eq 2 ]; then
  105. # after upgrade, restart service
  106. eval `%{l_rc} tyk status 2>/dev/null`
  107. [ ".$tyk_active" = .yes ] && %{l_rc} tyk restart
  108. fi
  109. exit 0
  110. %preun
  111. # before erase, stop service and remove log files
  112. if [ $1 -eq 0 ]; then
  113. %{l_rc} tyk stop 2>/dev/null
  114. rm -f $RPM_INSTALL_PREFIX/var/tyk/log/* >/dev/null 2>&1 || true
  115. rm -f $RPM_INSTALL_PREFIX/var/tyk/run/* >/dev/null 2>&1 || true
  116. fi
  117. exit 0