File nginx-module-brotli.spec of Package nginx-module-brotli
#
# spec file for package nginx-module-brotli
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%if 0%{?suse_version} != 1315 || 0%{?is_opensuse}
%bcond_without libatomic
%else
%bcond_with libatomic
%endif
%if 0%{?suse_version} > 1220
%bcond_without pcre_jit
%else
%bcond_with pcre_jit
%endif
%define commit 12529813a9f8475718370a19007c7905601a62ad
%define shortcommit %(c=%{commit}; echo ${c:0:7})
%define project_name ngx_brotli
%define nginx_moduledir %{_libdir}/nginx/modules
Name: nginx-module-brotli
Version: 0.0.0+git08092016.%{shortcommit}
Release: 0
Summary: NGINX module for Brotli compression
# FIXME: Select a correct license from https://github.com/openSUSE/spec-cleaner#spdx-licenses
# FIXME: use correct group, see "https://en.opensuse.org/openSUSE:Package_group_guidelines"
License: BSD-2-Clause
Group: Productivity/Networking/Web/Proxy
Url: https://github.com/google/%{project_name}
Source: https://github.com/google/%{project_name}/archive/%{commit}.tar.gz#/ngx_brotli.tar.gz
Patch0: update-brotli-v1.patch
BuildRequires: libbrotli-devel
BuildRequires: nginx-source
BuildRequires: pcre-devel
%if %{with libatomic}
BuildRequires: libatomic-ops-devel
%endif
Requires: nginx = %(rpm -q nginx-source | rev | cut -d. --complement -f1 | cut -d"-" -f2 | rev)
%description
Brotli is a generic-purpose lossless compression algorithm that compresses data
using a combination of a modern variant of the LZ77 algorithm, Huffman coding
and 2nd order context modeling, with a compression ratio comparable to the best
currently available general-purpose compression methods. It is similar in speed
with deflate but offers more dense compression.
ngx_brotli is a set of two nginx modules:
ngx_brotli filter module - used to compress responses on-the-fly,
ngx_brotli static module - used to serve pre-compressed files.
%prep
mkdir %{project_name}
tar -xzf %{SOURCE0} --strip-components=1 -C %{project_name}
patch -p1 -d %{project_name} < %{PATCH0}
cp -r /usr/src/nginx .
%build
cd nginx
# configure macro cannot be used, because this configure script doesn't
# accept some options provided by the macro (like i.e. --host).
./configure \
--user=nginx --group=nginx \
--without-select_module \
--without-poll_module \
--without-http_gzip_module \
--with-threads \
--with-file-aio \
--with-ipv6 \
--with-pcre \
%if %{with pcre_jit}
--with-pcre-jit \
%endif
%if %{with libatomic}
--with-libatomic \
%endif
--with-compat \
--add-dynamic-module=../%{project_name} \
%if 0%{?suse_version} > 1220
--with-cc-opt="%{optflags} -fPIC -D_GNU_SOURCE -std=gnu99 -fstack-protector" \
--with-ld-opt="-Wl,-z,relro,-z,now -pie"
%else
--with-cc-opt="%{optflags}"
%endif
make modules
%install
mkdir -p %{buildroot}%{nginx_moduledir}
install -D -m 0644 nginx/objs/ngx_http_brotli_filter_module.so %{buildroot}%{nginx_moduledir}
install -D -m 0644 nginx/objs/ngx_http_brotli_static_module.so %{buildroot}%{nginx_moduledir}
%files
%license %{project_name}/LICENSE
%dir %{_libdir}/nginx
%dir %{nginx_moduledir}
%{nginx_moduledir}/ngx_http_brotli_filter_module.so
%{nginx_moduledir}/ngx_http_brotli_static_module.so
%changelog