Skip to content

Instantly share code, notes, and snippets.

@bborysenko
Last active January 23, 2017 13:49
Show Gist options
  • Save bborysenko/31b83b284dc4f72555e4f55b31179842 to your computer and use it in GitHub Desktop.
Save bborysenko/31b83b284dc4f72555e4f55b31179842 to your computer and use it in GitHub Desktop.
RPM spec for ngx_devel_kit
#
%define dist %(sh /usr/lib/rpm/redhat/dist.sh)
%define nginx_user nginx
%define nginx_group nginx
%if 0%{?rhel} || 0%{?amzn}
%define _group System Environment/Daemons
BuildRequires: openssl-devel
%endif
%if 0%{?suse_version} == 1315
%define _group Productivity/Networking/Web/Servers
BuildRequires: libopenssl-devel
%endif
%if 0%{?rhel} == 7
%define epoch 1
Epoch: %{epoch}
%endif
%define main_version 1.10.2
%define main_release 1%{?dist}.ngx
%define ndk_version 0.3.0
%define module_ndk_version %{main_version}
%define module_ndk_release 1%{?dist}.ngx
%define bdir %{_builddir}/%{name}-%{main_version}
Summary: nginx ndk dynamic modules
Name: nginx-module-ndk
Version: %{module_ndk_version}
Release: %{module_ndk_release}
URL: https://github.com/simpl/ngx_devel_kit
Group: %{_group}
License: The 3-Clause BSD License
Source0: http://nginx.org/download/nginx-%{main_version}.tar.gz
Source1: https://github.com/simpl/ngx_devel_kit/archive/v%{ndk_version}.tar.gz#/ngx-devel-kit-%{ndk_version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{main_version}-%{main_release}-root
BuildRequires: zlib-devel
BuildRequires: pcre-devel
Requires: nginx == %{?epoch:%{epoch}:}%{main_version}-%{main_release}
%description
nginx ndk dynamic module.
%if 0%{?suse_version} || 0%{?amzn}
%debug_package
%endif
%define NDK_MODULE $(echo "-DNDK_SET_VAR")
%define WITH_CC_OPT $(echo %{optflags} $(pcre-config --cflags) %{NDK_MODULE})
%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-file-aio --with-threads --with-ipv6 --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 --with-mail --with-mail_ssl_module --with-stream --with-stream_ssl_module")
%define MODULE_CONFIGURE_ARGS $(echo "--add-dynamic-module=ngx_devel_kit-%{ndk_version}")
%prep
%setup -qcTn %{name}-%{main_version}
tar --strip-components=1 -zxf %{SOURCE0}
tar zxf %{SOURCE1}
%build
cd %{bdir}
./configure %{BASE_CONFIGURE_ARGS} %{MODULE_CONFIGURE_ARGS} \
--with-cc-opt="%{WITH_CC_OPT}" \
--with-debug
make %{?_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}"
make %{?_smp_mflags} modules
%install
cd %{bdir}
%{__rm} -rf $RPM_BUILD_ROOT
%{__mkdir} -p $RPM_BUILD_ROOT%{_datadir}/doc/nginx-module-ndk
%{__install} -m644 %{bdir}/ngx_devel_kit-%{ndk_version}/README.md $RPM_BUILD_ROOT%{_datadir}/doc/nginx-module-ndk/
%{__install} -m644 %{bdir}/ngx_devel_kit-%{ndk_version}/README_AUTO_LIB $RPM_BUILD_ROOT%{_datadir}/doc/nginx-module-ndk/
%{__install} -m644 %{bdir}/ngx_devel_kit-%{ndk_version}/LICENSE $RPM_BUILD_ROOT%{_datadir}/doc/nginx-module-ndk/
%{__mkdir} -p $RPM_BUILD_ROOT%{_libdir}/nginx/modules
for so in `find %{bdir}/objs/ -maxdepth 1 -type f -name "*.so"`; do
%{__install} -m755 $so \
$RPM_BUILD_ROOT%{_libdir}/nginx/modules/
done
%clean
%{__rm} -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%{_libdir}/nginx/modules/ndk*
%dir %{_datadir}/doc/nginx-module-ndk
%{_datadir}/doc/nginx-module-ndk/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment