tyk.spec 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. ##
  2. ## tyk.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_tyk_base 2.3.4
  25. %define V_tyk_snap 20170403
  26. # package information
  27. Name: tyk
  28. Summary: API Gateway
  29. URL: http://tyk.io/
  30. Vendor: Tyk Technologies Ltd
  31. Packager: OpenPKG Foundation e.V.
  32. Distribution: OpenPKG Community
  33. Class: EVAL
  34. Group: Networking
  35. License: MPL
  36. Version: %{V_tyk_base}
  37. Release: 20170403
  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.
  50. %track
  51. prog tyk:release = {
  52. version = %{V_tyk_base}
  53. url = https://github.com/TykTechnologies/tyk/releases
  54. regex = (\d+\.\d+(?:\.\d+)*)\.tar\.gz
  55. }
  56. prog tyk:snapshot = {
  57. version = %{V_tyk_snap}
  58. url = http://download.openpkg.org/components/versioned/tyk/
  59. regex = tyk-(__VER__)\.tar\.xz
  60. }
  61. %prep
  62. %setup -q -n tyk
  63. %build
  64. # build program
  65. export GOPATH=`pwd`
  66. cd src/github.com/TykTechnologies/tyk
  67. %{l_shtool} subst -e 's;/etc/tyk/tyk\.conf;%{l_prefix}/etc/tyk/tyk.conf;g' main.go
  68. go build -x -o tyk
  69. %install
  70. # create directory hierarchy
  71. %{l_shtool} mkdir -f -p -m 755 \
  72. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  73. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  74. $RPM_BUILD_ROOT%{l_prefix}/etc/tyk \
  75. $RPM_BUILD_ROOT%{l_prefix}/share/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. cp -rp \
  90. src/github.com/TykTechnologies/tyk/js \
  91. $RPM_BUILD_ROOT%{l_prefix}/share/tyk/
  92. # install default configuration
  93. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  94. %{SOURCE tyk.conf} $RPM_BUILD_ROOT%{l_prefix}/etc/tyk/
  95. # install run-command script
  96. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  97. %{SOURCE rc.tyk} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  98. # determine installation files
  99. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  100. %{l_files_std} \
  101. '%config %{l_prefix}/etc/tyk/*' \
  102. '%config %{l_prefix}/etc/tyk/*/*' \
  103. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/tyk/*'
  104. %files -f files
  105. %clean
  106. %post
  107. if [ $1 -eq 2 ]; then
  108. # after upgrade, restart service
  109. eval `%{l_rc} tyk status 2>/dev/null`
  110. [ ".$tyk_active" = .yes ] && %{l_rc} tyk restart
  111. fi
  112. exit 0
  113. %preun
  114. # before erase, stop service and remove log files
  115. if [ $1 -eq 0 ]; then
  116. %{l_rc} tyk stop 2>/dev/null
  117. rm -f $RPM_INSTALL_PREFIX/var/tyk/log/* >/dev/null 2>&1 || true
  118. rm -f $RPM_INSTALL_PREFIX/var/tyk/run/* >/dev/null 2>&1 || true
  119. fi
  120. exit 0