frp.spec 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. ##
  2. ## frp.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_opkg 0.42.0
  25. %define V_dist 20220428
  26. # package information
  27. Name: frp
  28. Summary: Fast Reverse Proxy
  29. URL: https://github.com/fatedier/frp
  30. Vendor: Fatedier
  31. Packager: OpenPKG Project
  32. Distribution: OpenPKG Community
  33. Class: EVAL
  34. Group: Networking
  35. License: Apache
  36. Version: %{V_opkg}.%{V_dist}
  37. Release: 20220428
  38. # package options
  39. %option with_server yes
  40. %option with_client yes
  41. # list of sources
  42. Source0: http://download.openpkg.org/components/versioned/frp/frp-%{V_dist}.tar.xz
  43. Source1: frpc.ini
  44. Source2: frps.ini
  45. Source3: rc.frp
  46. Patch0: frp.patch
  47. # build information
  48. BuildPreReq: OpenPKG, openpkg >= 20160101, go
  49. PreReq: OpenPKG, openpkg >= 20160101
  50. %description
  51. FRP is a fast reverse proxy to help you expose a local service
  52. behind a NAT or firewall to the Internet. It supports TCP, UDP, HTTP
  53. and HTTPS protocol when requests can be forwarded by domains to
  54. backward web services.
  55. %track
  56. prog frp:release = {
  57. version = %{V_opkg}
  58. url = https://github.com/fatedier/frp/releases
  59. regex = (\d+\.\d+\.\d+)\.tar\.gz
  60. }
  61. prog frp:snapshot = {
  62. version = %{V_dist}
  63. url = http://download.openpkg.org/components/versioned/frp/
  64. regex = frp-(__VER__)\.tar\.xz
  65. }
  66. %prep
  67. %setup -q -n frp
  68. %patch -p0
  69. %build
  70. # build program
  71. export GOPATH=`pwd`
  72. cd src/github.com/fatedier/frp
  73. %{l_make} %{l_mflags} build
  74. %install
  75. # create installation hierarchy
  76. %{l_shtool} mkdir -f -p -m 755 \
  77. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  78. $RPM_BUILD_ROOT%{l_prefix}/etc/frp \
  79. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  80. $RPM_BUILD_ROOT%{l_prefix}/var/frp/log \
  81. $RPM_BUILD_ROOT%{l_prefix}/var/frp/run
  82. # install program
  83. %{l_shtool} install -c -s -m 755 \
  84. src/github.com/fatedier/frp/bin/frpc \
  85. src/github.com/fatedier/frp/bin/frps \
  86. $RPM_BUILD_ROOT%{l_prefix}/sbin/
  87. # install run-command script
  88. %if "%{with_server}" == "yes"
  89. daemons="${daemons}${daemons+ }frps"
  90. %endif
  91. %if "%{with_client}" == "yes"
  92. daemons="${daemons}${daemons+ }frpc"
  93. %endif
  94. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  95. -e "s;@daemons@;$daemons;g" \
  96. %{SOURCE rc.frp} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  97. # install default configuration
  98. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  99. %{SOURCE frpc.ini} %{SOURCE frps.ini} \
  100. $RPM_BUILD_ROOT%{l_prefix}/etc/frp/
  101. # determine installation files
  102. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  103. %{l_files_std} \
  104. '%config %{l_prefix}/etc/frp/*' \
  105. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/frp/*'
  106. %files -f files
  107. %clean
  108. %post
  109. if [ $1 -eq 2 ]; then
  110. # after upgrade, restart service
  111. eval `%{l_rc} frp status 2>/dev/null`
  112. [ ".$frp_active" = .yes ] && %{l_rc} frp restart
  113. fi
  114. exit 0
  115. %preun
  116. if [ $1 -eq 0 ]; then
  117. # before erase, stop service and remove log files
  118. %{l_rc} frp stop 2>/dev/null
  119. rm -rf $RPM_INSTALL_PREFIX/var/frp/log/* >/dev/null 2>&1 || true
  120. rm -rf $RPM_INSTALL_PREFIX/var/frp/run/* >/dev/null 2>&1 || true
  121. fi
  122. exit 0