# %if 0%{?rhel} || 0%{?amzn} || 0%{?fedora} %define _group System Environment/Daemons BuildRequires: openssl-devel %endif %if 0%{?suse_version} >= 1315 %define _group Productivity/Networking/Web/Servers BuildRequires: libopenssl-devel %define _debugsource_template %{nil} %endif %if 0%{?rhel} == 7 %define epoch 1 Epoch: %{epoch} %define dist .el7 %endif %if 0%{?rhel} == 8 %define epoch 1 Epoch: %{epoch} %define dist .el8 %define _debugsource_template %{nil} %endif %if 0%{?fedora} %define _debugsource_template %{nil} %global _hardened_build 1 %endif %define nginx_version 1.22.0 %define base_release 1%{?dist}.ngx %define stremki_release 1.1%{?dist}.stremki # Since v0.10.16 lua-resty-core is mandatory. # It is not supported yet. %define dmod_version 0.10.16 %define devkit_version 0.3.1 %define luajit_version 2.1.0 %define luaresty_core 0.1.18 %define luaresty_lrucache 0.10 %define bdir %{_builddir}/%{name}-%{nginx_version}_%{dmod_version} Summary: nginx lua dynamic module Name: nginx-module-lua Version: %{nginx_version}_%{dmod_version} Release: %{stremki_release} Vendor: OpenResty, Inc. URL: https://github.com/openresty/lua-nginx-module Group: %{_group} Source0: http://nginx.org/download/nginx-%{nginx_version}.tar.gz Source1: https://github.com/openresty/lua-nginx-module/archive/v%{dmod_version}.tar.gz Source2: https://github.com/vision5/ngx_devel_kit/archive/v%{devkit_version}.tar.gz Source3: https://github.com/openresty/lua-resty-core/archive/v%{luaresty_core}.tar.gz Source4: https://github.com/openresty/lua-resty-lrucache/archive/v%{luaresty_lrucache}.tar.gz Source5: COPYRIGHT_ngx_module_lua License: 2-clause BSD-like license BuildRoot: %{_tmppath}/%{name}-%{nginx_version}-%{base_release}-root BuildRequires: zlib-devel BuildRequires: pcre-devel BuildRequires: nginx == %{?epoch:%{epoch}:}%{nginx_version}-%{base_release} BuildRequires: openresty-luajit-devel >= %{luajit_version} Requires: nginx == %{?epoch:%{epoch}:}%{nginx_version}-%{base_release} Requires: nginx-module-development-kit == %{?epoch:%{epoch}:}%{nginx_version}_%{devkit_version}-%{stremki_release} Requires: openresty-luajit >= %{luajit_version} %description Embed the power of Lua into Nginx HTTP Servers. %if 0%{?suse_version} || 0%{?amzn} %debug_package %endif %define NGINX_COMPILED_FLAGS $(nginx -V 2>&1 | grep ^config | cut -c22-) %define BASE_CONFIGURE_ARGS $(echo "%{NGINX_COMPILED_FLAGS}" | sed 's/--with-cc-opt=.*//; s/--with-ld-opt=.*//') %define WITH_CC_OPT $(echo "%{NGINX_COMPILED_FLAGS}" | grep -Eo \"\\\--with-cc-opt='[^']+'\" | tr -d "'" | cut -c15-) %define WITH_LD_OPT $(echo "%{NGINX_COMPILED_FLAGS}" | grep -Eo \"\\\--with-ld-opt='[^']+'\" | tr -d "'" | cut -c15-) %define MODULE_CONFIGURE_ARGS $(echo "--add-dynamic-module=modules/nginx-module-development-kit --add-dynamic-module=modules/nginx-module-lua") %prep %setup -qcTn %{name}-%{nginx_version}_%{dmod_version} tar --strip-components=1 -zxf %{SOURCE0} mkdir -p modules/%{name} modules/nginx-module-development-kit cd modules/%{name} tar --strip-components=1 -zxf %{SOURCE1} cd ../../ cd modules/nginx-module-development-kit tar --strip-components=1 -zxf %{SOURCE2} cd ../../ mkdir -p lua-resty-core lua-resty-lrucache cd lua-resty-core tar --strip-components=1 -zxf %{SOURCE3} cd ../lua-resty-lrucache tar --strip-components=1 -zxf %{SOURCE4} cd ../ %build cd %{bdir} echo "BASE_CONFIGURE_ARGS: %{BASE_CONFIGURE_ARGS}" echo "MODULE_CONFIGURE_ARGS: %{MODULE_CONFIGURE_ARGS}" echo "WITH_CC_OPT: %{WITH_CC_OPT}" echo "WITH_LD_OPT: %{WITH_LD_OPT}" export LUAJIT_LIB="%{_libdir}/libluajit-5.1.so" export LUAJIT_INC="%{_includedir}/luajit-2.1" ./configure %{BASE_CONFIGURE_ARGS} %{MODULE_CONFIGURE_ARGS} \ --with-cc-opt="%{WITH_CC_OPT} " \ --with-ld-opt="%{WITH_LD_OPT} " \ --with-debug make -f objs/Makefile %{?_smp_mflags} modules for so in `find %{bdir}/objs/ -type f -name "*.so"`; do debugso=`echo $so | sed -e "s|.so|-debug.so|"` mv $so $debugso done ./configure %{BASE_CONFIGURE_ARGS} %{MODULE_CONFIGURE_ARGS} \ --with-cc-opt="%{WITH_CC_OPT} " \ --with-ld-opt="%{WITH_LD_OPT} " make -f objs/Makefile %{?_smp_mflags} modules %install cd %{bdir} %{__rm} -rf $RPM_BUILD_ROOT %{__mkdir} -p $RPM_BUILD_ROOT%{_datadir}/doc/nginx-module-lua %{__mkdir} -p $RPM_BUILD_ROOT%{_datadir}/doc/luajit2 %{__install} -m 644 -p %{SOURCE5} \ $RPM_BUILD_ROOT%{_datadir}/doc/nginx-module-lua/COPYRIGHT # This module is installed seperately rm -f %{bdir}/objs/ndk_http_module* %{__mkdir} -p $RPM_BUILD_ROOT%{_libdir}/nginx/modules find %{bdir}/objs/ -type f -name "*-debug.so" -delete for so in `find %{bdir}/objs/ -maxdepth 1 -type f -name "*.so"`; do %{__install} -m755 $so $RPM_BUILD_ROOT%{_libdir}/nginx/modules/ done _dir=$RPM_BUILD_ROOT%{_datadir}/lua/5.1 %{__mkdir} -p ${_dir} for mod in core lrucache; do for _src in $(find lua-resty-${mod}/lib/ \ -mindepth 1 -type f -iname '*.lua'); do _dst=$(echo ${_src} | sed "s|lua-resty-${mod}/lib/||g"); %{__mkdir} -p $(dirname ${_dir}/${_dst}); %{__install} -m 644 -p ${_src} ${_dir}/${_dst}; echo %{_datadir}/lua/5.1/${_dst} >> lua.list done done %check %{__rm} -rf $RPM_BUILD_ROOT/usr/src cd %{bdir} grep -v 'usr/src' debugfiles.list > debugfiles.list.new && mv debugfiles.list.new debugfiles.list cat /dev/null > debugsources.list %if 0%{?suse_version} >= 1500 cat /dev/null > debugsourcefiles.list %endif %clean %{__rm} -rf $RPM_BUILD_ROOT %files -f lua.list %defattr(-,root,root) %{_libdir}/nginx/modules/* %dir %{_datadir}/doc/nginx-module-lua %{_datadir}/doc/nginx-module-lua/COPYRIGHT %post if [ $1 -eq 1 ]; then cat < - 0.10.16-1.0 - Rebuilt for module version 0.10.16 - lua-resty-core and lua-resty-lrucache are now shipped with module as they are reauired to start the server * Wed Jul 1 2020 Dzmitry Stremkouski - 0.10.15-1.1 - Removing debug libs from main package * Wed Jul 1 2020 Dzmitry Stremkouski - 0.10.15-1 - Compiled for nginx base version 1.18.0, module version 0.10.15