File qdate.spec of Package qdate

%define bname qdate
Name: %bname
Version: 0.4.2
Release: 4
Summary: Erlang date and timezone library
License: MIT
Group: Development/Tools/Other
URL: https://github.com/choptastic/%bname
Source: %bname-%version.tar.xz
#Patch0: %bname-%version-git.patch
Patch1: get_timezone-should-return-default-tz-if-not-set.patch
Patch2: Fix-adding-months-to-date-that-ends-in-dec-following.patch
Patch3: %bname-0.4.2-else.patch
BuildArch: noarch
Provides: erlang-%bname = %version-%release

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

%description
Erlang date and time management is rather primitive, but improving.


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

%description doc
Documentation of %bname.


%prep
%setup -q -n %bname-%version
#patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -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().'
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,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
* Sat Jun 11 2022 Led <ledest@gmail.com> 0.4.2-4
- add patches:
  + qdate-0.4.2-else.patch

* Thu Oct 26 2017 Led <ledest@gmail.com> 0.4.2-3
- add patches:
  + Fix-adding-months-to-date-that-ends-in-dec-following.patch
- add doc subpackage

* Wed Feb 22 2017 Led <ledest@gmail.com> 0.4.2-2
- add patches:
  + get_timezone-should-return-default-tz-if-not-set.patch

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