nginx-module-brotli.spec 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. #
  2. %define nginx_user nginx
  3. %define nginx_group nginx
  4. %define __arch_install_post /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot
  5. %if 0%{?rhel} || 0%{?amzn} || 0%{?fedora}
  6. %define _group System Environment/Daemons
  7. %if 0%{?amzn} == 2
  8. BuildRequires: openssl11-devel
  9. %else
  10. BuildRequires: openssl-devel
  11. %endif
  12. %endif
  13. %if 0%{?suse_version} >= 1315
  14. %define _group Productivity/Networking/Web/Servers
  15. BuildRequires: libopenssl-devel
  16. %define _debugsource_template %{nil}
  17. %endif
  18. %if (0%{?rhel} == 7) && (0%{?amzn} == 0)
  19. %define epoch 1
  20. Epoch: %{epoch}
  21. %define dist .el7
  22. %endif
  23. %if (0%{?rhel} == 7) && (0%{?amzn} == 2)
  24. %define epoch 1
  25. Epoch: %{epoch}
  26. %endif
  27. %if 0%{?rhel} == 8
  28. %define epoch 1
  29. Epoch: %{epoch}
  30. %define _debugsource_template %{nil}
  31. %endif
  32. %if 0%{?rhel} == 9
  33. %define epoch 1
  34. Epoch: %{epoch}
  35. BuildRequires: gcc
  36. %define _debugsource_template %{nil}
  37. %endif
  38. %if 0%{?fedora}
  39. %define _debugsource_template %{nil}
  40. %global _hardened_build 1
  41. %endif
  42. BuildRequires: git
  43. BuildRequires: cmake
  44. %define base_version 1.25.3
  45. %define base_release 1%{?dist}.ngx
  46. %define bdir %{_builddir}/%{name}-%{base_version}
  47. Summary: nginx Brotli dynamic modules
  48. Name: nginx-module-brotli
  49. Version: %{base_version}
  50. Release: %{base_release}
  51. Vendor: Eugene Wu <kuretru@gmail.com>
  52. URL: https://github.com/kuretru/nginx-module-brotli
  53. Group: %{_group}
  54. #!RemoteAsset: sha256:64c5b975ca287939e828303fa857d22f142b251f17808dfe41733512d9cded86
  55. Source0: https://nginx.org/download/nginx-%{base_version}.tar.gz
  56. Source1: COPYRIGHT
  57. License: 2-clause BSD-like license
  58. BuildRoot: %{_tmppath}/%{name}-%{base_version}-%{base_release}-root
  59. BuildRequires: zlib-devel
  60. BuildRequires: pcre2-devel
  61. Requires: nginx-r%{base_version}
  62. Provides: %{name}-r%{base_version}
  63. %description
  64. nginx Brotli dynamic modules.
  65. %if 0%{?suse_version}
  66. %debug_package
  67. %endif
  68. %define WITH_CC_OPT $(echo %{optflags} $(pcre2-config --cflags))
  69. %define WITH_LD_OPT -Wl,-z,relro -Wl,-z,now
  70. %define BASE_CONFIGURE_ARGS $(echo "--prefix=%{_sysconfdir}/nginx --sbin-path=%{_sbindir}/nginx --modules-path=%{_libdir}/nginx/modules --conf-path=%{_sysconfdir}/nginx/nginx.conf --error-log-path=%{_localstatedir}/log/nginx/error.log --http-log-path=%{_localstatedir}/log/nginx/access.log --pid-path=%{_localstatedir}/run/nginx.pid --lock-path=%{_localstatedir}/run/nginx.lock --http-client-body-temp-path=%{_localstatedir}/cache/nginx/client_temp --http-proxy-temp-path=%{_localstatedir}/cache/nginx/proxy_temp --http-fastcgi-temp-path=%{_localstatedir}/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=%{_localstatedir}/cache/nginx/uwsgi_temp --http-scgi-temp-path=%{_localstatedir}/cache/nginx/scgi_temp --user=%{nginx_user} --group=%{nginx_group} --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module $( if [ 0%{?rhel} -eq 7 ] || [ 0%{?suse_version} -eq 1315 ]; then continue; else echo "--with-http_v3_module"; fi; ) --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module")
  71. %define MODULE_CONFIGURE_ARGS $(echo "--add-dynamic-module=./ngx_brotli/")
  72. %prep
  73. %setup -qcTn %{name}-%{base_version}
  74. tar --strip-components=1 -zxf %{SOURCE0}
  75. git clone --recursive https://github.com/google/ngx_brotli.git
  76. cd ngx_brotli/deps/brotli/
  77. mkdir out && cd out/
  78. cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_CXX_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_C_COMPILER_WORKS=ON -DCMAKE_INSTALL_PREFIX=./installed ..
  79. cmake --build . --config Release --target brotlienc
  80. cd ../../../../
  81. %build
  82. cd %{bdir}
  83. ./configure %{BASE_CONFIGURE_ARGS} %{MODULE_CONFIGURE_ARGS} \
  84. --with-cc-opt="%{WITH_CC_OPT} " \
  85. --with-ld-opt="%{WITH_LD_OPT} " \
  86. --with-debug
  87. make %{?_smp_mflags} modules
  88. for so in `find %{bdir}/objs/ -type f -name "*.so"`; do
  89. debugso=`echo $so | sed -e 's|\.so$|-debug.so|'`
  90. mv $so $debugso
  91. done
  92. ./configure %{BASE_CONFIGURE_ARGS} %{MODULE_CONFIGURE_ARGS} \
  93. --with-cc-opt="%{WITH_CC_OPT} " \
  94. --with-ld-opt="%{WITH_LD_OPT} "
  95. make %{?_smp_mflags} modules
  96. %install
  97. cd %{bdir}
  98. %{__rm} -rf $RPM_BUILD_ROOT
  99. %{__mkdir} -p $RPM_BUILD_ROOT%{_datadir}/doc/nginx-module-brotli
  100. %{__install} -m 644 -p %{SOURCE1} \
  101. $RPM_BUILD_ROOT%{_datadir}/doc/nginx-module-brotli/
  102. %{__mkdir} -p $RPM_BUILD_ROOT%{_libdir}/nginx/modules
  103. for so in `find %{bdir}/objs/ -maxdepth 1 -type f -name "*.so"`; do
  104. %{__install} -m755 $so \
  105. $RPM_BUILD_ROOT%{_libdir}/nginx/modules/
  106. done
  107. %check
  108. %{__rm} -rf $RPM_BUILD_ROOT/usr/src
  109. cd %{bdir}
  110. grep -v 'usr/src' debugfiles.list > debugfiles.list.new && mv debugfiles.list.new debugfiles.list
  111. cat /dev/null > debugsources.list
  112. %if 0%{?suse_version} >= 1500
  113. cat /dev/null > debugsourcefiles.list
  114. %endif
  115. %clean
  116. %{__rm} -rf $RPM_BUILD_ROOT
  117. %files
  118. %defattr(-,root,root)
  119. %{_libdir}/nginx/modules/*
  120. %dir %{_datadir}/doc/nginx-module-brotli
  121. %{_datadir}/doc/nginx-module-brotli/*
  122. %post
  123. if [ $1 -eq 1 ]; then
  124. cat <<BANNER
  125. ----------------------------------------------------------------------
  126. The Brotli dynamic module for nginx has been installed.
  127. To enable this module, add the following to /etc/nginx/nginx.conf
  128. and reload nginx:
  129. load_module modules/ngx_http_brotli_filter_module.so;
  130. load_module modules/ngx_http_brotli_static_module.so;
  131. Please refer to the module documentation for further details:
  132. https://github.com/google/ngx_brotli
  133. https://github.com/google/brotli
  134. ----------------------------------------------------------------------
  135. BANNER
  136. fi
  137. %changelog
  138. * Sun Oct 29 2023 Eugene Wu <kuretru@gmail.com>
  139. - base version updated to 1.25.3
  140. * Mon Aug 7 2023 Eugene Wu <kuretru@gmail.com>
  141. - base version updated to 1.25.2
  142. * Thu Jul 13 2023 Eugene Wu <kuretru@gmail.com>
  143. - base version updated to 1.25.1
  144. * Fri May 26 2023 Eugene Wu <kuretru@gmail.com>
  145. - base version updated to 1.25.0
  146. * Wed Mar 29 2023 Eugene Wu <kuretru@gmail.com>
  147. - base version updated to 1.23.4
  148. * Sun Jan 1 2023 Eugene Wu <kuretru@gmail.com>
  149. - base version updated to 1.23.3
  150. * Fri Oct 21 2022 Eugene Wu <kuretru@gmail.com>
  151. - base version updated to 1.23.2
  152. * Sat Jul 23 2022 Eugene Wu <kuretru@gmail.com>
  153. - base version updated to 1.23.1
  154. * Wed Jun 22 2022 Eugene Wu <kuretru@gmail.com>
  155. - base version updated to 1.23.0
  156. * Thu Jan 27 2022 Eugene Wu <kuretru@gmail.com>
  157. - base version updated to 1.21.6
  158. * Mon Jan 3 2022 Eugene Wu <kuretru@gmail.com>
  159. - base version updated to 1.21.5
  160. * Tue Nov 9 2021 Eugene Wu <kuretru@gmail.com>
  161. - base version updated to 1.21.4
  162. * Fri Sep 10 2021 Eugene Wu <kuretru@gmail.com>
  163. - base version updated to 1.21.3
  164. * Thu Sep 2 2021 Eugene Wu <kuretru@gmail.com>
  165. - base version updated to 1.21.2
  166. * Wed Jul 7 2021 Eugene Wu <kuretru@gmail.com>
  167. - base version updated to 1.21.1
  168. * Thu May 27 2021 Eugene Wu <kuretru@gmail.com>
  169. - base version updated to 1.21.0
  170. * Thu Apr 15 2021 Eugene Wu <kuretru@gmail.com>
  171. - base version updated to 1.19.10
  172. * Wed Mar 31 2021 Eugene Wu <kuretru@gmail.com>
  173. - base version updated to 1.19.9
  174. * Thu Mar 11 2021 Eugene Wu <kuretru@gmail.com>
  175. - base version updated to 1.19.8
  176. * Thu Feb 18 2021 Eugene Wu <kuretru@gmail.com>
  177. - base version updated to 1.19.7
  178. * Tue Dec 22 2020 Eugene Wu <kuretru@gmail.com>
  179. - base version updated to 1.19.6
  180. * Wed Nov 25 2020 Eugene Wu <kuretru@gmail.com>
  181. - base version updated to 1.19.5
  182. * Fri Oct 30 2020 Eugene Wu <kuretru@gmail.com>
  183. - base version updated to 1.19.4
  184. * Thu Oct 1 2020 Eugene Wu <kuretru@gmail.com>
  185. - base version updated to 1.19.3
  186. * Wed Aug 12 2020 Eugene Wu <kuretru@gmail.com>
  187. - base version updated to 1.19.2
  188. * Wed Jul 8 2020 Eugene Wu <kuretru@gmail.com>
  189. - base version updated to 1.19.1
  190. * Wed May 27 2020 Eugene Wu <kuretru@gmail.com>
  191. - base version updated to 1.19.0
  192. * Sat Apr 18 2020 Eugene Wu <kuretru@gmail.com>
  193. - base version updated to 1.17.10
  194. * Thu Mar 5 2020 Eugene Wu <kuretru@gmail.com>
  195. - base version updated to 1.17.9
  196. * Thu Jan 23 2020 Eugene Wu <kuretru@gmail.com>
  197. - base version updated to 1.17.8
  198. * Sat Dec 28 2019 Eugene Wu <kuretru@gmail.com>
  199. - base version updated to 1.17.7
  200. * Mon Nov 25 2019 Eugene Wu <kuretru@gmail.com>
  201. - base version updated to 1.17.6
  202. * Wed Oct 23 2019 Eugene Wu <kuretru@gmail.com>
  203. - base version updated to 1.17.5
  204. * Sun Oct 13 2019 Eugene Wu <kuretru@gmail.com>
  205. - base version updated to 1.17.4