File partisan.spec of Package partisan

%define bname partisan
Name: %bname
Version: 2.1.0
Release: 6
Summary: TCP-based membership system for Erlang/Elixir
License: Apache-2.0
Group: Development/Tools/Other
URL: https://github.com/lasp-lang/%bname
Source: %bname-%version.tar.xz
#Patch0: %bname-%version-git.patch
Patch1: 0001-delete-amqp-manager-in-README.patch
Patch11: 0011-remove-rand_compat-and-time_compat-deps.patch
Patch21: %bname-2.1.0-doc.patch
Patch22: %bname-2.1.0-deprecated.patch
Provides: erlang-%bname = %version-%release
BuildArch: noarch

BuildRequires: rpm-macros-erlang rpm-build-erlang
BuildRequires: rebar >= 2.6.1-7
BuildRequires: erlang-lager-devel >= 3.5
BuildRequires: erlang-acceptor_pool >= 1.0.0
BuildRequires: erlang-otpbp-devel >= 4.16.0
# check
BuildRequires: erlang-otpbp >= 4.16.0
#BuildRequires: epmd erlang-common_test erlang-lager erlang-ssl erlang-types erlang-crypto

%description
Partisan is a flexible, TCP-based membership system for Erlang/Elixir.
Partisan features:
  - Single node testing, facilitated by a disterl control channel for figuring
    out which ports the peer service is operating at.
  - Messages are sent via TCP connections that are maintained to all cluster
    members.
  - Failure detection is performed TCP.
  - Connections are verified at each gossip round.
  - Configurable fanout.
  - On join, gossip is performed immediately, instead of having to wait for the
    next gossip round.
  - HyParView implementation.
Partisan has many available peer service managers:
  - Full membership with TCP-based failure detection:
    partisan_default_peer_service_manager.
  - Client/server topology: partisan_client_server_peer_service_manager.
  - HyParView, hybrid partial view membership protocol, with TCP-based failure
    detection: partisan_hyparview_peer_service_manager.
  - Static topology: partisan_static_peer_service_manager.


%package devel
Summary: Headers of %bname
Group: Development/Tools/Other
Provides: erlang-%bname-devel = %version-%release

%description devel
Partisan is a flexible, TCP-based membership system for Erlang/Elixir.
This package contains headers of %bname.


%package doc
Summary: Documentation of %bname
Group: Documentation/HTML
Provides: erlang-%bname-doc = %version-%release

%description doc
Partisan is a flexible, TCP-based membership system for Erlang/Elixir.
This package contains documentation of %bname.


%prep
%setup -q -n %bname-%version
#patch0 -p1
%patch1 -p1
%patch11 -p1
%patch21 -p1
%patch22 -p1


%build
erl -noshell -eval '
{ok, L} = file:consult("rebar.config"),
file:write_file("%bname.rebar.config", [[io_lib:print(E), ".\n"] || E <- lists:keydelete(deps, 1, L)], [raw]),
init:stop().'
%if %_otp_release >= 24
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/include
install -p -m 0644 include/* %buildroot%_otplibdir/%bname-%version/include/
install -d -m 0755 %buildroot%_otplibdir/%bname-%version/doc
install -p -m 0644 doc/*.{css,html,png} %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 *.md %buildroot%_docdir/%name/


%check
%if %_otp_release >= 24
export ERL_COMPILER_OPTIONS="[nowarn_export_all,inline,verbose,nowarn_deprecated_function,{parse_transform,otpbp_pt}]"
%else
export ERL_COMPILER_OPTIONS="[nowarn_export_all,inline,verbose]"
%endif
rebar -C %bname.rebar.config eunit -v
#rebar -C %bname.rebar.config ct


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


%files devel
%defattr(-,root,root)
%dir %_otplibdir/%bname-*
%_otplibdir/%bname-*/include


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


%changelog
* Mon Aug 08 2022 Led <ledest@gmail.com> 2.1.0-6
- add patches:
  + 0001-delete-amqp-manager-in-README.patch

* Mon Aug 08 2022 Led <ledest@gmail.com> 2.1.0-5
- fix build on Erlang/OTP 25

* Mon Aug 23 2021 Led <ledest@gmail.com> 2.1.0-4
- add patches:
  + partisan-2.1.0-deprecated.patch
- update BuildRequires

* Sun Aug 22 2021 Led <ledest@gmail.com> 2.1.0-3
- use otpbp_pt for deprecated ssl functions

* Sat Jul 06 2019 Led <ledest@gmail.com> 2.1.0-2
- fix build on Erlang/OTP >= 21

* Mon Jun 11 2018 Led <ledest@gmail.com> 2.1.0-1
- 2.1.0
- update patches:
  + partisan-2.1.0-doc.patch
  + 0011-remove-rand_compat-and-time_compat-deps.patch

* Sun Dec 17 2017 Led <ledest@gmail.com> 1.4.1-2
- add nowarn_export_all to %%check

* Tue Dec 12 2017 Led <ledest@gmail.com> 1.4.1-1
- initial build
openSUSE Build Service is sponsored by