You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

211 lines
6.4 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. %global requires pcre openssl mbedtls libsodium >= 1.0.4 libev c-ares
  2. %global conflicts python-shadowsocks python3-shadowsocks
  3. %if 0%{?fedora} || 0%{?rhel}
  4. %global requires %{?requires} libcap
  5. %endif
  6. %if 0%{?suse_version}
  7. %global requires %{?requires} libcap-progs
  8. %endif
  9. %global project_desc shadowsocks-libev is a lightweight secured socks5 proxy for embedded devices and low end boxes.
  10. %if 0%{?fedora} >= 15 || 0%{?rhel} >=7 || 0%{?suse_version} >= 1210
  11. %global use_systemd 1
  12. %else
  13. %global use_systemd 0
  14. %endif
  15. # https://fedoraproject.org/wiki/Changes/RemoveLaFiles
  16. %global __brp_remove_la_files %nil
  17. Name: @NAME@
  18. Version: @VERSION@
  19. Release: @RELEASE@%{?dist}
  20. Summary: A lightweight and secure socks5 proxy
  21. Group: Applications/Internet
  22. License: GPLv3+
  23. URL: https://github.com/shadowsocks/%{name}
  24. Source0: @SOURCE@
  25. BuildRequires: make gcc pcre-devel asciidoc xmlto automake libtool mbedtls-devel libsodium-devel >= 1.0.4 libev-devel c-ares-devel
  26. %if 0%{?suse_version}
  27. BuildRequires: libopenssl-devel
  28. %else
  29. BuildRequires: openssl-devel
  30. %endif
  31. AutoReq: no
  32. Conflicts: %{?conflicts}
  33. Requires: %{?requires}
  34. %if 0%{?use_systemd}
  35. %{?systemd_requires}
  36. %if 0%{?suse_version}
  37. BuildRequires: systemd-rpm-macros
  38. %else
  39. BuildRequires: systemd
  40. %endif
  41. %endif
  42. %description
  43. %{?project_desc}
  44. %prep
  45. %setup -q -n @NAME_VERSION@
  46. %build
  47. ./autogen.sh
  48. %if 0%{?use_system_lib}
  49. %configure --enable-shared --enable-system-shared-lib
  50. %else
  51. %configure --enable-shared
  52. %endif
  53. make %{?_smp_mflags}
  54. %install
  55. make install DESTDIR=%{buildroot}
  56. mkdir -p %{buildroot}/etc/shadowsocks-libev
  57. %if ! 0%{?use_systemd}
  58. mkdir -p %{buildroot}%{_initddir}
  59. install -m 755 %{_builddir}/%{buildsubdir}/rpm/SOURCES/etc/init.d/shadowsocks-libev %{buildroot}%{_initddir}/shadowsocks-libev
  60. %else
  61. mkdir -p %{buildroot}%{_sysconfdir}/sysconfig
  62. mkdir -p %{buildroot}%{_unitdir}
  63. install -m 644 %{_builddir}/%{buildsubdir}/rpm/SOURCES/systemd/shadowsocks-libev.default %{buildroot}%{_sysconfdir}/sysconfig/shadowsocks-libev
  64. install -m 644 %{_builddir}/%{buildsubdir}/rpm/SOURCES/systemd/shadowsocks-libev*.service %{buildroot}%{_unitdir}/
  65. %endif
  66. install -m 644 %{_builddir}/%{buildsubdir}/debian/config.json %{buildroot}%{_sysconfdir}/shadowsocks-libev/config.json
  67. mkdir -p %{buildroot}%{_datadir}/bash-completion/completions/
  68. install -m 644 %{_builddir}/%{buildsubdir}/completions/bash/* %{buildroot}%{_datadir}/bash-completion/completions/
  69. mkdir -p %{buildroot}%{_datadir}/zsh/site-functions/
  70. install -m 644 %{_builddir}/%{buildsubdir}/completions/zsh/* %{buildroot}%{_datadir}/zsh/site-functions/
  71. %pre
  72. %if 0%{?use_systemd} && 0%{?suse_version}
  73. %service_add_pre shadowsocks-libev.service
  74. %endif
  75. %post
  76. %if ! 0%{?use_systemd}
  77. /sbin/chkconfig --add shadowsocks-libev > /dev/null 2>&1 || :
  78. %else
  79. %if 0%{?suse_version}
  80. %service_add_post shadowsocks-libev.service
  81. %else
  82. %systemd_post shadowsocks-libev.service
  83. %endif
  84. %endif
  85. setcap cap_net_bind_service+ep %{_bindir}/ss-local \
  86. cap_net_bind_service,cap_net_admin+ep %{_bindir}/ss-redir \
  87. cap_net_bind_service+ep %{_bindir}/ss-server \
  88. cap_net_bind_service+ep %{_bindir}/ss-tunnel
  89. %preun
  90. %if ! 0%{?use_systemd}
  91. if [ $1 -eq 0 ]; then
  92. /sbin/service shadowsocks-libev stop > /dev/null 2>&1 || :
  93. /sbin/chkconfig --del shadowsocks-libev > /dev/null 2>&1 || :
  94. fi
  95. %else
  96. %if 0%{?suse_version}
  97. %service_del_preun shadowsocks-libev.service
  98. %service_del_preun shadowsocks-libev-local.service
  99. %else
  100. %systemd_preun shadowsocks-libev.service
  101. %systemd_preun shadowsocks-libev-local.service
  102. if [ $1 -eq 0 ] ; then
  103. # Package removal, not upgrade
  104. systemctl stop shadowsocks-libev-server@'*'.service > /dev/null 2>&1 || :
  105. systemctl stop shadowsocks-libev-local@'*'.service > /dev/null 2>&1 || :
  106. systemctl stop shadowsocks-libev-tunnel@'*'.service > /dev/null 2>&1 || :
  107. systemctl stop shadowsocks-libev-redir@'*'.service > /dev/null 2>&1 || :
  108. systemctl --no-reload disable shadowsocks-libev-server@.service > /dev/null 2>&1 || :
  109. systemctl --no-reload disable shadowsocks-libev-local@.service > /dev/null 2>&1 || :
  110. systemctl --no-reload disable shadowsocks-libev-tunnel@.service > /dev/null 2>&1 || :
  111. systemctl --no-reload disable shadowsocks-libev-redir@.service > /dev/null 2>&1 || :
  112. fi
  113. %endif
  114. %endif
  115. %postun
  116. %if 0%{?use_systemd}
  117. %if 0%{?suse_version}
  118. %service_del_postun shadowsocks-libev.service
  119. %else
  120. %systemd_postun_with_restart shadowsocks-libev.service
  121. %systemd_postun_with_restart shadowsocks-libev-local.service
  122. %systemd_postun_with_restart shadowsocks-libev-server@'*'.service
  123. %systemd_postun_with_restart shadowsocks-libev-local@'*'.service
  124. %systemd_postun_with_restart shadowsocks-libev-tunnel@'*'.service
  125. %systemd_postun_with_restart shadowsocks-libev-redir@'*'.service
  126. %endif
  127. %endif
  128. %files
  129. %doc %{_docdir}/shadowsocks-libev/*.html
  130. %exclude %{_docdir}/shadowsocks-libev/ss-nat.html
  131. %{_bindir}/*
  132. %exclude %{_bindir}/ss-nat
  133. %config(noreplace) %{_sysconfdir}/shadowsocks-libev/config.json
  134. %{_datadir}/bash-completion/completions/*
  135. %doc %{_mandir}/man*/*
  136. %exclude %{_mandir}/man1/ss-nat.1.*
  137. %if ! 0%{?use_systemd}
  138. %{_initddir}/shadowsocks-libev
  139. %else
  140. %{_unitdir}/shadowsocks-libev*.service
  141. %config(noreplace) %{_sysconfdir}/sysconfig/shadowsocks-libev
  142. %endif
  143. %package -n libshadowsocks-libev
  144. Summary: %{?summary} (shared library)
  145. AutoReq: no
  146. Requires: pcre openssl mbedtls libsodium >= 1.0.4 libev c-ares
  147. %description -n libshadowsocks-libev
  148. Shared library powered by shadowsocks-libev.
  149. %{?project_desc}
  150. %files -n libshadowsocks-libev
  151. %{_libdir}/*.so.*
  152. %post -n libshadowsocks-libev
  153. /sbin/ldconfig
  154. %postun -n libshadowsocks-libev
  155. /sbin/ldconfig
  156. %package -n libshadowsocks-libev-devel
  157. Summary: Development files for shadowsocks-libev
  158. Provides: shadowsocks-libev-devel = %{version}-%{release}
  159. Requires: libshadowsocks-libev = %{version}-%{release}
  160. Obsoletes: shadowsocks-libev-devel < %{version}-%{release}
  161. %description -n libshadowsocks-libev-devel
  162. Development files for libshadowsocks-libev.
  163. %{?project_desc}
  164. %files -n libshadowsocks-libev-devel
  165. %{_includedir}/*
  166. %{_libdir}/pkgconfig/*.pc
  167. %{_libdir}/libshadowsocks-libev.la
  168. %{_libdir}/libshadowsocks-libev.so
  169. %package zsh-completion
  170. Summary: This package installs zsh completion files for shadowsocks-libev.
  171. Requires: zsh shadowsocks-libev = %{version}-%{release}
  172. %description zsh-completion
  173. zsh completion files for shadowsocks-libev.
  174. %{?project_desc}
  175. %files zsh-completion
  176. %{_datadir}/zsh/site-functions/*
  177. %changelog