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.

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