File telemetry.spec of Package telemetry

%define bname telemetry
Name: %bname
Version: 1.2.1
Release: 6
Summary: Dynamic dispatching erlang library for metrics and instrumentations
License: Apache-2.0
Group: Development/Tools/Other
URL: https://github.com/beam-telemetry/%bname
Source: %bname-%version.tar.xz
Patch0: %bname-1.2.1-git.patch
Patch1: 0001-Inform-user-about-usage-of-local-functions-as-handle.patch
Patch2: 0002-Fix-link-to-telemetry-attach-4-docs-in-warning-91.patch
Patch3: 0003-Rewrite-unclear-warning-fix-typos-96.patch
Patch4: 0004-Use-rebar3_ex_doc.patch
Patch5: 0005-Post-1.1.0-updates-108.patch
Patch11: %bname-1.2.1-defs.patch
Patch12: telemetry-1.2.1-git-509a4ae-doc.patch
Provides: erlang-%bname = %version-%release
BuildArch: noarch
Requires: erlang >= 1:18

BuildRequires: rpm-macros-erlang rpm-build-erlang
BuildRequires: rebar >= 2.6.1-7
BuildRequires: erlang-common_test

%description
Telemetry is a lightweight library for dynamic dispatching of events,
with a focus on metrics and instrumentation.
Any Erlang or Elixir library can use telemetry to emit events.
Application code and other libraries can then hook into those events and run
custom handlers.


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

%description doc
Telemetry is a lightweight library for dynamic dispatching of events,
with a focus on metrics and instrumentation.
Any Erlang or Elixir library can use telemetry to emit events.
This package contains documentation of %bname.


%prep
%setup -q -n %bname-%version
%patch -p1 -P0
%if %_otp_release < 21
%patch -R -p1 -P5 -P4 -P3 -P2 -P1
%endif
%patch -p1 -P11 -P12


%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:keystore(edoc_opts, 1, lists:keydelete(deps, 1, L), {edoc_opts, [{preprocess, true}]})),
                [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/* %buildroot%_otplibdir/%bname-%version/ebin/
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* CHANGELOG* %buildroot%_docdir/%name/


%check
ERL_COMPILER_OPTIONS='[inline,nowarn_export_all,{i,"./src"},verbose]' rebar -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
* Tue Feb 18 2025 Led <ledest@gmail.com> 1.2.1-6
- fix patches applying

* Fri Mar 01 2024 Led <ledest@gmail.com> 1.2.1-5
- git aa65dee

* Fri Oct 06 2023 Led <ledest@gmail.com> 1.2.1-4
- git 509a4ae
- add patches:
  + telemetry-1.2.1-git-509a4ae-doc.patch

* Wed Mar 08 2023 Led <ledest@gmail.com> 1.2.1-3
- add patches:
  + 0001-Inform-user-about-usage-of-local-functions-as-handle.patch
  + 0002-Fix-link-to-telemetry-attach-4-docs-in-warning-91.patch
  + 0003-Rewrite-unclear-warning-fix-typos-96.patch
  + 0004-Use-rebar3_ex_doc.patch
  + 0005-Post-1.1.0-updates-108.patch

* Tue Mar 07 2023 Led <ledest@gmail.com> 1.2.1-2
- fix URL

* Tue Mar 07 2023 Led <ledest@gmail.com> 1.2.1-1
- 1.2.1
openSUSE Build Service is sponsored by