File esmtp.spec of Package esmtp

%define bname esmtp
Name: %bname
Version: 0.3
Release: 4
Summary: A simple SMTP client for Erlang
License: BSD-3-Clause
Group: Development/Tools/Other
URL: https://github.com/pugpharm/%bname
Source: %bname.tar.xz
BuildArch: noarch
Provides: erlang-%bname = %version-%release

BuildRequires: rpm-macros-erlang rpm-build-erlang
BuildRequires: rebar >= 2.6.1-7
# check
BuildRequires: erlang-inets

%description
%bname is a simple OTP application providing a way to send emails (and
attachments) from erlang systems.


%package devel
Summary: Headers of %bname
Group: Development/Tools/Other
Provides: erlang-%bname-devel = %version-%release
Conflicts: %name < 0.3-4

%description devel
%bname is a simple OTP application providing a way to send emails (and
attachments) from erlang systems.
This package contains headers of %bname.


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

%description doc
%bname is a simple OTP application providing a way to send emails (and
attachments) from erlang systems.
This package contains documentation of %bname.


%prep
%setup -q -n %bname
sed -i 's/{@vsn}/%version/' src/*.erl include/*.hrl


%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="[nowarn_deprecated_function,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/include
install -p -m 0644 include/* %buildroot%_otplibdir/%bname-%version/include/
install -d -m 0755 %buildroot%_otplibdir/%bname-%version/priv
install -p -m 0644 priv/* %buildroot%_otplibdir/%bname-%version/priv/
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/%name-%version/doc %buildroot%_docdir/%name/html
install -p -m 0644 README* %buildroot%_docdir/%name/


%check
ERL_COMPILER_OPTIONS="[nowarn_deprecated_function,inline,verbose]" rebar -C %bname.rebar.config eunit -v


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


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


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


%changelog
* Wed Sep 11 2019 Led <ledest@gmail.com> 0.3-4
- update BuildRequires
- move headers and docs to separate subpackages

* Fri Jul 15 2016 Led <ledest@gmail.com> 0.3-3
- add nowarn_deprecated_function compile option

* Sat Jul 25 2015 Led <ledest@gmail.com> 0.3-2
- fix Summary and description

* Sat Jul 25 2015 Led <ledest@gmail.com> 0.3-1
- initial build
openSUSE Build Service is sponsored by