File cowboy.spec of Package cowboy

%def_enable check
%def_with doc

%define bname cowboy
Name: %bname
Version: 2.12.0
Release: 2
Summary: Small, fast and modern HTTP server for Erlang/OTP
License: ISC
Group: Development/Tools/Other
URL: https://github.com/ninenines/%bname
Source: %bname-%version.tar.xz
#Patch0: %bname-%version-git.patch
Patch1: %bname-2.11.0-erlang_mk.patch
BuildArch: noarch
Provides: erlang-%bname = %version-%release
Requires: erlang >= 1:19
Requires: erlang-cowlib >= 2.12.1
Requires: erlang-ranch >= 1.7.1

BuildRequires: rpm-macros-erlang rpm-build-erlang >= 0.9.9
BuildRequires: erlang >= 1:19
BuildRequires: erlang erlang-otp-base-devel
BuildRequires: erlang-cowlib-devel >= 2.12.1
BuildRequires: erlang-ranch-devel >= 1.7.1
BuildRequires: erlang-otpbp-devel >= 5.4.2
BuildRequires: fdupes
%if_with doc
# docs
BuildRequires: asciidoc dblatex w3m texlive-dvips-bin
BuildRequires: tex(fancybox.sty) tex(mathrsfs.sty) tex(fontspec.sty)
BuildRequires: tex(ptmr8t.vf) tex(pcrr8t.vf) tex(phvr8t.vf)
BuildRequires: erlang-asciideck
%endif
%if_enabled check
BuildRequires: erlang-ct_helper
BuildRequires: erlang-eunit >= 1:19
BuildRequires: erlang-cowlib >= 2.12.1
BuildRequires: erlang-ranch >= 1.7.1
BuildRequires: erlang-gun >= 1.3.0
BuildRequires: erlang-proper
%endif

%description
Cowboy is a small, fast and modern HTTP server for Erlang/OTP.
Cowboy aims to provide a complete HTTP stack in a small code base.
It is optimized for low latency and low memory usage, in part because it uses
binary strings.
Cowboy provides routing capabilities, selectively dispatching requests to
handlers written in Erlang.
Because it uses Ranch for managing connections, Cowboy can easily be embedded in
any other application.


%package devel
Summary: Behaviour modules of %bname
Group: Development/Tools/Other
Provides: erlang-%bname-devel = %version-%release
Conflicts: %name < 1.1.2-7

%description devel
Cowboy is a small, fast and modern HTTP server for Erlang/OTP.
This package contains behaviour modules of %bname.


%package doc
Summary: Documentation of %bname
Group: Documentation/Other
Provides: erlang-%bname-doc = %version-%release
Conflicts: %name < 1.1.2

%description doc
Cowboy is a small, fast and modern HTTP server for Erlang/OTP.
This package contains documentation of %bname.


%if_with doc
%package doc-pdf
Summary: Documentation of %bname in PDF format
Group: Documentation/Other
Provides: erlang-%bname-doc-pdf = %version-%release

%description doc-pdf
Cowboy is a small, fast and modern HTTP server for Erlang/OTP.
This package contains documentation of %bname in PDF format.
%endif


%prep
%setup -q -n %bname-%version
#patch -p1 -P0
%patch -p1 -P1
rm -f ebin/*
sed -i '/^test-build:/s/^/#/' Makefile


%build
make %{?_smp_mflags} SKIP_DEPS=1 V=1 \
%if %_otp_release < 21
	ERL_COMPILER_OPTIONS="[inline,{parse_transform,otpbp_pt}]" \
%else
	ERL_COMPILER_OPTIONS="[inline]" \
%endif
	all \
	%{?_with_doc:EDOC_OPTS="{preprocess, true}" docs}
for i in *.asciidoc; do
	a2x -v -f text $i
done


%install
install -d -m 0755 %buildroot%_otplibdir/%bname-%version/ebin
install -p -m 0644 ebin/* %buildroot%_otplibdir/%bname-%version/ebin/

install -d -m 0755 %buildroot%_docdir/%name
for i in *.text; do
	install -p -m 0644 $i %buildroot%_docdir/%name/$(basename $i .text)
done
cp -a examples %buildroot%_docdir/%name/
%if_with doc
install -d -m 0755 %buildroot%_docdir/%name/html
install -p -m 0644 doc/*.pdf %buildroot%_docdir/%name/
install -p -m 0644 doc/html/* %buildroot%_docdir/%name/html/
install -d -m 0755 %buildroot%_mandir/man3 %buildroot%_mandir/man7
for i in 3 7; do
	install -d -m 0755 %buildroot%_mandir/man$i
	install -p -m 0644 doc/man$i/* %buildroot%_mandir/man$i/
done
%endif

erl -noshell -eval '
lists:foreach(fun(F) ->
                  {ok, {M, [{exports, Fs}]}} = beam_lib:chunks(F, [exports]),
                  lists:sort(Fs) =:= [{behaviour_info, 1}, {module_info, 0}, {module_info, 1}] andalso
                      io:fwrite("%_otplibdir/%bname-%version/ebin/~s.beam~n", [M])
              end, filelib:wildcard("./ebin/*.beam")),
init:stop().' | tee behaviours.list | sed 's/^/%%exclude /' > behaviours-exclude.list
[ ! -s behaviours.list ] || sed -i '1i%%dir %_otplibdir/%bname-%version/ebin' behaviours.list

%fdupes %buildroot%_docdir/%name/examples

%if %_otp_release < 22
%add_erlang_req_beam_skiplist persistent_term
%endif


%if_enabled check
%check
make %{?_smp_mflags} SKIP_DEPS=1 V=1 \
%if %_otp_release < 21
	ERL_COMPILER_OPTIONS="[inline,{parse_transform,otpbp_pt}]" \
%else
	ERL_COMPILER_OPTIONS="[inline]" \
%endif
	eunit
%endif

%files -f behaviours-exclude.list
%defattr(-,root,root)
%_otplibdir/*


%files -f behaviours.list devel
%defattr(-,root,root)
%dir %_otplibdir/%bname-*


%files doc
%defattr(-,root,root)
%doc %_docdir/%name
%if_with doc
%exclude %_docdir/%name/*.pdf
%_mandir/man3/*
%_mandir/man7/*
%endif


%if_with doc
%files doc-pdf
%defattr(-,root,root)
%dir %_docdir/%name
%doc %_docdir/%name/*.pdf
%endif


%changelog
* Wed Apr 10 2024 Led <ledest@gmail.com> 2.12.0-2
- enable check

* Wed Apr 10 2024 Led <ledest@gmail.com> 2.12.0-1
- 2.12.0
- disable check

* Tue Feb 13 2024 Led <ledest@gmail.com> 2.11.0-2
- add patches:
  + cowboy-2.11.0-erlang_mk.patch

* Mon Feb 12 2024 Led <ledest@gmail.com> 2.11.0-1
- 2.11.0

* Sun Oct 08 2023 Led <ledest@gmail.com> 2.10.0-3
- fix Requires for Erlang/OTP < 21.2

* Sun Aug 20 2023 Led <ledest@gmail.com> 2.10.0-2
- remove patches:
  + cowboy-2.9.0-catch.patch

* Sun Aug 20 2023 Led <ledest@gmail.com> 2.10.0-1
- 2.10.0
- git 22adc4d
- remove patches:
  + 0001-Fix-data-sent-after-RST_STREAM-in-HTTP-2-in-rare-cas.patch
  + 0002-Fix-OTP-26-warnings-in-test-suites.patch

* Sun Aug 20 2023 Led <ledest@gmail.com> 2.9.0-1
- 2.9.0
- remove patches:
  + cowboy-2.8.0-cowboy_rest.patch
- add patches:
  + cowboy-2.9.0-catch.patch

* Sun Aug 20 2023 Led <ledest@gmail.com> 2.8.0-3
- add patches:
  + 0002-Fix-OTP-26-warnings-in-test-suites.patch

* Sun Aug 20 2023 Led <ledest@gmail.com> 2.8.0-2
- add patches:
  + 0001-Fix-data-sent-after-RST_STREAM-in-HTTP-2-in-rare-cas.patch

* Sun Aug 20 2023 Led <ledest@gmail.com> 2.8.0-1
- 2.8.0
- git 70d393c
- remove patches:
  + cowboy-2.6.3-stacktrace.patch
- add patches:
  + cowboy-2.8.0-cowboy_rest.patch

* Fri Aug 18 2023 Led <ledest@gmail.com> 2.7.0-1
- 2.7.0
- git 3b85b80

* Fri Aug 18 2023 Led <ledest@gmail.com> 2.6.3-1
- 2.6.3
- git 3030c2d
- update patches:
  + cowboy-2.6.3-stacktrace.patch

* Fri Aug 18 2023 Led <ledest@gmail.com> 2.5.0-2
- add patches:
  + cowboy-2.5.0-stacktrace.patch

* Fri Aug 18 2023 Led <ledest@gmail.com> 2.5.0-1
- 2.5.0
- git 3310849
- remove patches:
  + 0001-Move-some-test-functions-off-to-ct_helper.patch

* Fri Aug 18 2023 Led <ledest@gmail.com> 2.4.0-3
- enable check

* Fri Aug 18 2023 Led <ledest@gmail.com> 2.4.0-2
- fix BuildRequres

* Fri Aug 18 2023 Led <ledest@gmail.com> 2.4.0-1
- 2.4.0
- git f0d9805
- disable check

* Sun Aug 06 2023 Led <ledest@gmail.com> 2.3.0-2
- fix build on Erlang/OTP >= 21

* Fri Aug 04 2023 Led <ledest@gmail.com> 2.3.0-1
- 2.3.0
- add patches:
  + 0001-Move-some-test-functions-off-to-ct_helper.patch

* Fri Aug 04 2023 Led <ledest@gmail.com> 2.2.2-1
- 2.2.2
- git d27a373
- update BuildRequres

* Fri Aug 04 2023 Led <ledest@gmail.com> 2.1.0-2
- fix Requires and BuildRequres

* Fri Aug 04 2023 Led <ledest@gmail.com> 2.1.0-1
- 2.1.0
- git 32d9d49
- update BuildRequres
- add Requires

* Fri Aug 04 2023 Led <ledest@gmail.com> 2.0.0-1
- 2.0.0
- git c602871
- update description
- enable check

* Sat Aug 21 2021 Led <ledest@gmail.com> 1.2.3-1
- 1.2.3

* Tue Nov 12 2019 Led <ledest@gmail.com> 1.2.2-1
- 1.2.2

* Sat Aug 10 2019 Led <ledest@gmail.com> 1.2.1-1
- 1.2.1
- update URL
- remove patches
- clean up %%build

* Tue Aug 06 2019 Led <ledest@gmail.com> 1.1.2-22
- update patches:
  + 0011-Use-cow_ws-for-the-Websocket-parsing-code.patch
- revert behaviour-only to cowboy.app's modules

* Thu Jul 25 2019 Led <ledest@gmail.com> 1.1.2-21
- clean up %%files

* Tue Jul 23 2019 Led <ledest@gmail.com> 1.1.2-20
- generate behaviour-only module list

* Tue Jul 23 2019 Led <ledest@gmail.com> 1.1.2-19
- remove optional alternate cowboy_websocket module

* Fri Jul 05 2019 Led <ledest@gmail.com> 1.1.2-18
- remove cow_uri module (already in cowlib >= 2.0.0-pre.1)
- update BuildRequires

* Mon Jul 01 2019 Led <ledest@gmail.com> 1.1.2-17
- add patches:
  + cowboy-1.1.2-stacktrace.patch

* Sun Jun 30 2019 Led <ledest@gmail.com> 1.1.2-16
- add patches:
  + cowboy_websocket-get-compress-level-from-env.patch
- update patches:
  + cowboy-1.1.2-ws-compress-level.patch

* Sat Jun 29 2019 Led <ledest@gmail.com> 1.1.2-15
- add patches:
  + cowboy_websocket-update-extensions-definition-in-state-record.patch

* Sat Jun 29 2019 Led <ledest@gmail.com> 1.1.2-14
- add patches:
  + 0012-Update-Cowlib-to-1.2.0-adds-Websocket-permessage-def.patch
- update patches:
  + cowboy-1.1.2-ws-compress-level.patch

* Sat Jun 29 2019 Led <ledest@gmail.com> 1.1.2-13
- fix Group for doc subpackage
- add patches:
  + 0011-Use-cow_ws-for-the-Websocket-parsing-code.patch
- update patches:
  + cowboy-1.1.2-ws-compress-level.patch

* Sat Jun 29 2019 Led <ledest@gmail.com> 1.1.2-12
- revert cowboy_websocket.erl

* Sat Jun 29 2019 Led <ledest@gmail.com> 1.1.2-11
- add patches:
  + 0001-Use-cowlib-master.patch
- update BuildRequires
- remove cowboy_websocket.erl

* Mon Dec 17 2018 Led <ledest@gmail.com> 1.1.2-10
- add patches:
  + cowboy-1.1.2-ws-compress-level.patch

* Mon Dec 17 2018 Led <ledest@gmail.com> 1.1.2-9
- update cowboy_websocket.erl

* Sun Dec 16 2018 Led <ledest@gmail.com> 1.1.2-8
- add cowboy_websocket.erl
- without alt_ws

* Sun Dec 16 2018 Led <ledest@gmail.com> 1.1.2-7
- move behaviour modules to devel subpackage

* Sun Dec 16 2018 Led <ledest@gmail.com> 1.1.2-6
- remove patches:
  + 0001-Use-cowlib-master.patch
  + 0011-Use-cow_ws-for-the-Websocket-parsing-code.patch
  + 0012-Adds-Websocket-permessage-deflate.patch
- add Provides

* Sat Dec 15 2018 Led <ledest@gmail.com> 1.1.2-5
- add patches:
  + 0011-Use-cow_ws-for-the-Websocket-parsing-code.patch
  + 0012-Adds-Websocket-permessage-deflate.patch

* Sat Dec 15 2018 Led <ledest@gmail.com> 1.1.2-4
- remove patches:
  + cowboy-1.1.2-cowlib-compat.patch
- add patches:
  + 0001-Use-cowlib-master.patch

* Sat Dec 15 2018 Led <ledest@gmail.com> 1.1.2-3
- add patches:
  + cowboy-1.1.2-cowlib-compat.patch
- update BuildRequires

* Tue Aug 21 2018 Led <ledest@gmail.com> 1.1.2-2
- update %%build

* Thu Oct 12 2017 Led <ledest@gmail.com> 1.1.2-1
- 1.1.2
- remove patches:
  + cowboy-1.0.3-integer_to_binary.patch
- fix License
- add doc subpackage

* Fri Aug 25 2017 Led <ledest@gmail.com> 1.0.4-4
- remove slim option

* Sun May 21 2017 Led <ledest@gmail.com> 1.0.4-3
- revert BuildRequires

* Sat May 20 2017 Led <ledest@gmail.com> 1.0.4-2
- update BuildRequires

* Sun Nov 29 2015 Led <ledest@gmail.com> 1.0.4-1
- 1.0.4

* Sun Sep 27 2015 Led <ledest@gmail.com> 1.0.3-2
- fix build on Erlang R15
- add patches:
  + cowboy-1.0.3-integer_to_binary.patch

* Sun Aug 09 2015 Led <ledest@gmail.com> 1.0.3-1
- 1.0.3

* Sat Jul 04 2015 Led <ledest@gmail.com> 1.0.2-2
- fix BuildRequires

* Sat Jul 04 2015 Led <ledest@gmail.com> 1.0.2-1
- 1.0.2

* Mon Apr 13 2015 Led <ledest@gmail.com> 1.0.1-4
- update BuildRequires

* Sun Apr 12 2015 Led <ledest@gmail.com> 1.0.1-3
- clean up BuildRequires

* Wed Apr 01 2015 Led <ledest@gmail.com> 1.0.1-2
- build docs

* Wed Apr 01 2015 Led <ledest@gmail.com> 1.0.1-1
- initial build
openSUSE Build Service is sponsored by