File pooler.spec of Package pooler

%define bname pooler
Name: %bname
Version: 1.5.2
Release: 5
Summary: An Erlang OTP process pool application
License: Apache-2.0
Group: Development/Tools/Other
URL: https://github.com/seth/%bname
Source: %bname-%version.tar.xz
Patch0: %bname-%version-git.patch
Patch1: %bname-test.patch
BuildArch: noarch
Provides: erlang-%bname = %version-%release

BuildRequires: rpm-macros-erlang rpm-build-erlang
BuildRequires: rebar >= 2.6.1-10
BuildRequires: erlang-otpbp-devel >= 4.18.0
# check
BuildRequires: erlang-otpbp >= 4.26.2

%description
The pooler application allows you to manage pools of OTP behaviors such as
gen_servers, gen_fsms, or supervisors, and provide consumers with exclusive
access to pool members.


%package doc
Summary: Documentation of %bname
Group: Documentation/HTML
Provides: erlang-%bname-doc = %version-%release
Conflicts: %name < 1.5.2-2

%description doc
The pooler application allows you to manage pools of OTP behaviors such as
gen_servers, gen_fsms, or supervisors, and provide consumers with exclusive
access to pool members.
This package contains documentation of %bname.


%prep
%setup -q -n %bname-%version
%patch0 -p1
%patch1 -p1
erl -noshell -eval '
{ok, [{application, %bname, L}]} = file:consult("src/%bname.app.src"),
file:write_file("src/%bname.app.src",
                io_lib:format("{application, %bname, ~81p}.~n", [lists:keystore(vsn, 1, L, {vsn, "%version"})]),
                [raw]),
init:stop().'


%build
erl -noshell -eval '
{ok, L} = file:consult("rebar.config"),
file:write_file("%bname.rebar.config",
                lists:map(fun(E) -> [io_lib:print(E), ".\n"] end,
                          lists:foldl(fun(K, A) -> lists:keydelete(K, 1, A) end, L, [deps, eunit_opts])),
                [raw]),
init:stop().'
%if %_otp_release > 23
ERL_COMPILER_OPTIONS='[inline,verbose,{parse_transform,otpbp_pt}]' \
%else
ERL_COMPILER_OPTIONS='[inline,verbose]' \
%endif
rebar %{?_smp_mflags} -C %bname.rebar.config compile -v
rebar %{?_smp_mflags} -C %bname.rebar.config doc -v


%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%_otplibdir/%bname-%version/config
install -p -m 0644 config/* %buildroot%_otplibdir/%bname-%version/config/
install -d -m 0755 %buildroot%_otplibdir/%bname-%version/doc
install -p -m 0644 doc/*.{css,html,png,jpg} %buildroot%_otplibdir/%bname-%version/doc/
install -d -m 0755 %buildroot%_docdir/%name
ln -sf %_otplibdir/%bname-%version/doc %buildroot%_docdir/%name/html
install -p -m 0644 README* NEWS* %buildroot%_docdir/%name/


%check
%if %_otp_release > 23
ERL_COMPILER_OPTIONS='[inline,verbose,nowarn_export_all,{parse_transform,otpbp_pt}]' \
%else
ERL_COMPILER_OPTIONS='[inline,verbose,nowarn_export_all]' \
%endif
rebar -j1 -C %bname.rebar.config eunit -v


%files
%defattr(-,root,root)
%_otplibdir/*
%exclude %_otplibdir/%bname-*/doc


%files doc
%defattr(-,root,root)
%doc %_docdir/%name
%doc %dir %_otplibdir/%bname-*
%doc %_otplibdir/%bname-*/doc


%changelog
* Sun Aug 07 2022 Led <ledest@gmail.com> 1.5.2-5
- update BuildRequires

* Sun Aug 07 2022 Led <ledest@gmail.com> 1.5.2-4
- update BuildRequires

* Sun Aug 07 2022 Led <ledest@gmail.com> 1.5.2-3
- fix build via otpbp

* Sat Nov 07 2020 Led <ledest@gmail.com> 1.5.2-2
- git 9c28fb4
- move docs to separate subpackage
- add patches:
  + pooler-test.patch

* Sun May 29 2016 Led <ledest@gmail.com> 1.5.2-1
- initial build
openSUSE Build Service is sponsored by