File turtle.spec of Package turtle

%def_disable check

%define bname turtle
Name: %bname
Version: 1.9.4
Release: 22
Summary: A wrapper on the RabbitMQ Erlang Client
License: Apache-2.0
Group: Development/Tools/Other
URL: https://github.com/shopgun/%bname
Source: %bname-%version.tar.xz
Patch0: %bname-%version-git.patch
Patch1: remove-turtle_time.patch
Patch2: turtle_janitor-replace-maps-take-2-for-comatibility-.patch
Patch3: %bname-%version-fix-vsn.patch
Patch11: 0011-turtle-add-consume-3.patch
Patch12: 0012-turtle-update-consume-2-consume-3.patch
Patch13: 0013-turtle_subscriber-add-no_ack-support.patch
Patch14: 0014-turtle_subscriber-add-missed-clause-to-handle_comman.patch
Patch15: 0015-turtle_subscriber-remove-warning-in-handle_commands-.patch
Patch21: 0021-no_ack-reimplemented-as-new-simple-mode.patch
Patch22: 0022-turtle_subscriber-stylistic-changes.patch
Patch23: 0023-turtle_service-update-mode_ok-1-for-simple-mode.patch
Patch24: 0024-turtle_subscriber-shrink-handle_message-4-format_amq.patch
Patch25: 0025-turtle_subscriber-shrink-handle_message-5.patch
Patch27: 0027-turtle_subscriber-add-missed-clause-to-handle_comman.patch
Patch31: 0031-turtle_publisher-add-guards-to-mk_publish-5.patch
Patch32: 0032-turtle_publisher-add-channel-monitoring.patch
Patch33: 0033-turtle_publisher-fix-result-format-for-publish-4-cla.patch
Patch34: 0034-turtle_publisher-add-clause-to-handle_rpc-2-for-exis.patch
Patch35: 0035-turtle_subscriber-can-use-exchange-from-state-for-RP.patch
Patch36: 0036-turtle_service-update-validate_config-1-for-connecti.patch
BuildArch: noarch
Provides: erlang-%bname = %version-%release

BuildRequires: rpm-macros-erlang rpm-build-erlang
BuildRequires: rebar >= 2.6.1-7
BuildRequires: erlang-lager-devel >= 2
BuildRequires: erlang-amqp_client-devel >= 3.6.10
%if_enabled check
# check
BuildRequires: epmd erlang-common_test
BuildRequires: erlang-gproc erlang-exometer_core erlang-amqp_client
BuildRequires: erlang-rabbit_common rabbitmq-server rabbitmqctl
%endif

%description
The turtle application is built to be a wrapper around the RabbitMQ standard
Erlang driver. The purpose is to enable faster implementation and use of RabbitMQ
by factoring out common tasks into a specific application targeted toward ease of
use.
The secondary purpose is to make the Erlang client better behaving toward an OTP
setup. The official client makes lots of assumptions which are not always true in
an OTP setting.


%package doc
Summary: %bname documentation
Group: Documentation/HTML
Conflicts: %name < 1.9.1-1

%description doc
The turtle application is built to be a wrapper around the RabbitMQ standard
Erlang driver. The purpose is to enable faster implementation and use of RabbitMQ
by factoring out common tasks into a specific application targeted toward ease of
use.
The secondary purpose is to make the Erlang client better behaving toward an OTP
setup. The official client makes lots of assumptions which are not always true in
an OTP setting.
This package contains documentation in HTML format.


%prep
%setup -q -n %bname-%version
%patch0 -p1
%patch1 -p1 -F1
%patch2 -p1
%patch3 -p1
%patch -p1 -P 11 -P 12 -P 13 -P 14 -P 15
%patch -p1 -P 21 -P 22 -P 23 -P 24 -P 25 -P 27
%patch -p1 -P 31 -P 32 -P 33 -P 34 -P 35 -P 36
%if %_otp_release >= 21
sed -i 's/Class:Error/&:Stacktrace/;s/erlang:get_stacktrace()/Stacktrace/' src/%{bname}_subscriber.erl
%endif
sed -i '/ct:sleep(200)/s/200/500/' test/turtle_SUITE.erl
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, ~101p}.~n",
                              [lists:keystore(applications, 1, L,
                                              {applications,
                                               lists:delete(uuid, proplists:get_value(applications, L, []))})]),
                [raw]),
init:stop().'


%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().'
ERL_COMPILER_OPTIONS="[inline,verbose]" 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/*.beam %buildroot%_otplibdir/%bname-%version/ebin/
erl -noshell -eval '
{ok, [{application, %bname, L}]} = file:consult("ebin/%bname.app"),
file:write_file("%buildroot%_otplibdir/%bname-%version/ebin/%bname.app",
                io_lib:format("{application, %bname, ~101p}.~n",
                              [lists:keystore(env, 1, L, {env, [{connection_config, []}]})]),
                [raw]),
init:stop().'
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 README* %buildroot%_docdir/%name/


%if_enabled check
%check
[ $(stat -c %%i /) -le 3 ] || exit 0
install -d -m 0755 test/rabbit/mnesia test/rabbit/log
export RABBITMQ_MNESIA_BASE="$PWD/test/rabbit/mnesia" RABBITMQ_LOG_BASE="$PWD/test/rabbit/log"
%_sbindir/rabbitmqctl shutdown 2>/dev/null ||:
%_sbindir/rabbitmq-server -detached
sleep 5
ERL_COMPILER_OPTIONS="[inline,verbose]" rebar -C %bname.rebar.config ct && rc=0 || rc=1
%_sbindir/rabbitmqctl shutdown ||:
exit $rc
%endif


%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
* Fri Dec 29 2023 Led <ledest@gmail.com> 1.9.4-22
- disable %%check

* Sun Aug 27 2023 Led <ledest@gmail.com> 1.9.4-21
- update BuildRequires

* Sun Aug 07 2022 Led <ledest@gmail.com> 1.9.4-20
- add hack for fix build on Erlang/OTP > 23

* Tue Nov 12 2019 Led <ledest@gmail.com> 1.9.4-19
- add patches:
  + 0036-turtle_service-update-validate_config-1-for-connecti.patch

* Mon Nov 11 2019 Led <ledest@gmail.com> 1.9.4-18
- add patches:
  + 0034-turtle_publisher-add-clause-to-handle_rpc-2-for-exis.patch
  + 0035-turtle_subscriber-can-use-exchange-from-state-for-RP.patch

* Wed Nov 06 2019 Led <ledest@gmail.com> 1.9.4-17
- add patches:
  + 0033-turtle_publisher-fix-result-format-for-publish-4-cla.patch

* Fri Aug 30 2019 Led <ledest@gmail.com> 1.9.4-16
- update BuildRequires

* Mon Jul 01 2019 Led <ledest@gmail.com> 1.9.4-15
- clean up connection_config list in app env

* Sat Jun 22 2019 Led <ledest@gmail.com> 1.9.4-14
- remove patches:
  + 0032-turtle_publisher-shrink-handle_info-gproc-_-_-_-_.patch
- update patches:
  + 0032-turtle_publisher-add-channel-monitoring.patch

* Fri Jun 21 2019 Led <ledest@gmail.com> 1.9.4-13
- remove patches:
  + 0033-turtle_publisher-add-channel-monitoring-for-reopenni.patch
- add patches:
  + 0033-turtle_publisher-add-channel-monitoring.patch

* Wed Jun 19 2019 Led <ledest@gmail.com> 1.9.4-12
- add patches:
  + 0031-turtle_publisher-add-guards-to-mk_publish-5.patch
  + 0032-turtle_publisher-shrink-handle_info-gproc-_-_-_-_.patch
  + 0033-turtle_publisher-add-channel-monitoring-for-reopenni.patch

* Wed Jun 12 2019 Led <ledest@gmail.com> 1.9.4-11
- enable %%check
- revert default env in .app
- replace 200 to 500 in ct:sleep/1

* Wed Jun 12 2019 Led <ledest@gmail.com> 1.9.4-10
- git d80587f

* Wed Apr 17 2019 Led <ledest@gmail.com> 1.9.4-9
- remove patches:
  + 0026-turtle_subscriber-add-no_ack-workaround-to-mode-1.patch

* Fri Jan 25 2019 Led <ledest@gmail.com> 1.9.4-8
- add patches:
  + 0027-turtle_subscriber-add-missed-clause-to-handle_comman.patch

* Fri Jan 25 2019 Led <ledest@gmail.com> 1.9.4-7
- add patches:
  + 0021-no_ack-reimplemented-as-new-simple-mode.patch
  + 0022-turtle_subscriber-stylistic-changes.patch
  + 0023-turtle_service-update-mode_ok-1-for-simple-mode.patch
  + 0024-turtle_subscriber-shrink-handle_message-4-format_amq.patch
  + 0025-turtle_subscriber-shrink-handle_message-5.patch
  + 0026-turtle_subscriber-add-no_ack-workaround-to-mode-1.patch

* Tue Nov 27 2018 Led <ledest@gmail.com> 1.9.4-6
- clean up connection_config list in app env

* Thu Nov 22 2018 Led <ledest@gmail.com> 1.9.4-5
- add patches:
  + 0014-turtle_subscriber-add-missed-clause-to-handle_comman.patch
  + 0015-turtle_subscriber-remove-warning-in-handle_commands-.patch

* Thu Nov 08 2018 Led <ledest@gmail.com> 1.9.4-4
- add patches:
  + turtle-1.9.4-fix-vsn.patch

* Thu Nov 08 2018 Led <ledest@gmail.com> 1.9.4-3
- fix changelog

* Sun Nov 04 2018 Led <ledest@gmail.com> 1.9.4-2
- add patches:
  + 0011-turtle-add-consume-3.patch
  + 0012-turtle-update-consume-2-consume-3.patch
  + 0013-turtle_subscriber-add-no_ack-support.patch

* Sun Nov 04 2018 Led <ledest@gmail.com> 1.9.4-1
- 1.9.4

* Sun Nov 04 2018 Led <ledest@gmail.com> 1.9.3-1
- 1.9.3

* Sun Nov 04 2018 Led <ledest@gmail.com> 1.9.2-1
- 1.9.2

* Sun Feb 25 2018 Led <ledest@gmail.com> 1.9.1-4
- fix Group

* Sun Feb 25 2018 Led <ledest@gmail.com> 1.9.1-3
- disable %%check

* Thu Feb 15 2018 Led <ledest@gmail.com> 1.9.1-2
- fix summary and description

* Thu Dec 14 2017 Led <ledest@gmail.com> 1.9.1-1
- 1.9.1
- mode docs to separate subpackage

* Tue Oct 17 2017 Led <ledest@gmail.com> 1.9.0-6
- add patches:
  + turtle_janitor-replace-maps-take-2-for-comatibility-.patch
- update %%check

* Tue Oct 17 2017 Led <ledest@gmail.com> 1.9.0-5
- update %%check

* Thu Oct 12 2017 Led <ledest@gmail.com> 1.9.0-4
- update %%check

* Thu Oct 12 2017 Led <ledest@gmail.com> 1.9.0-3
- enable %%check

* Sun Sep 17 2017 Led <ledest@gmail.com> 1.9.0-2
- add patches:
  + remove-turtle_time.patch

* Fri Sep 15 2017 Led <ledest@gmail.com> 1.9.0-1
- initial build
openSUSE Build Service is sponsored by