File bitcask.spec of Package bitcask

%define bname bitcask
Name: %bname
Version: 2.0.8
Release: 11
Summary: A Log-Structured Hash Table for Fast Key/Value Data
License: Apache-2.0
Group: Development/Tools/Other
URL: https://github.com/basho/%bname
Source: %bname-%version.tar.xz
#Patch0: %bname-%version-git.patch
Patch1: %bname-2.0.8-fileop.patch
Patch2: %bname-2.0.8-crypto.patch
Patch3: %bname-2.0.8-now.patch
Patch4: %bname-2.0.8-rand.patch
Patch5: %bname-2.0.8-no_inline.patch
Patch6: %bname-2.0.8-stacktrace.patch
Provides: erlang-%bname = %version-%release
Requires: erlang >= 1:18
Requires: erlang-otp-base >= 1:18

BuildRequires: erlang >= 1:18
BuildRequires: erlang-otp-base >= 1:18
BuildRequires: rpm-macros-erlang rpm-build-erlang
BuildRequires: rebar >= 2.6.1-7
BuildRequires: erts-devel
# check
BuildRequires: erlang-meck >= 0.8
BuildRequires: erlang-cuttlefish >= 2.0
BuildRequires: erlang-lager

%description
Bitcask is a log-structured hash table for fast key/value data.


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

%description devel
Bitcask is a log-structured hash table for fast key/value data.
This package contains headers of %bname.


%package doc
Summary: %bname documentation
Group: Documentation/HTML
Provides: erlang-%bname-doc = %version-%release
Conflicts: %name < 2.0.8-5

%description doc
Bitcask is a log-structured hash table for fast key/value data.
This package contains documentation in HTML format.


%prep
%setup -q -n %bname-%version
#patch0 -p1
%patch1 -p1
%patch -p1 -P 2 -P 3 -P 4 -P 5
%if %_otp_release >= 21
%patch6 -p1
%endif
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, ~p}.~n", [lists:keystore(vsn, 1, L, {vsn, "%version"})]),
                [raw]),
init:stop().'


%build
erl -noshell -eval '
{ok, L} = file:consult("rebar.config"),
file:write_file("%bname.rebar.config",
                [[io_lib:print(E), ".\n"] || {K, _} = E <- L, not lists:member(K, [deps, plugins])],
                [raw]),
init:stop().'
CC=%__cc LINKER=%__cc CFLAGS="%optflags" \
ERL_COMPILER_OPTIONS="[nowarn_export_all,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/
cp -a priv %buildroot%_otplibdir/%bname-%version/
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 THANKS doc/*.pdf %buildroot%_docdir/%name/


%check
CC=%__cc LINKER=%__cc CFLAGS="%optflags" \
ERL_COMPILER_OPTIONS="[nowarn_export_all,inline,verbose]" \
rebar -C %bname.rebar.config eunit -v


%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 Feb 13 2023 Led <ledest@gmail.com> 2.0.8-11
- update BuildRequires

* Sat Jul 03 2021 Led <ledest@gmail.com> 2.0.8-10
- add patches:
  + bitcask-2.0.8-no_inline.patch
  + bitcask-2.0.8-stacktrace.patch

* Sat Jul 03 2021 Led <ledest@gmail.com> 2.0.8-9
- fix vsn

* Sat Jul 03 2021 Led <ledest@gmail.com> 2.0.8-8
- add Erlang/OTP 24 support

* Mon Apr 27 2020 Led <ledest@gmail.com> 2.0.8-7
- nowarn_nif_inline

* Sun Jul 07 2019 Led <ledest@gmail.com> 2.0.8-6
- fix build on Erlang/OTP >= 21

* Sat Jul 06 2019 Led <ledest@gmail.com> 2.0.8-5
- add patches:
  + bitcask-2.0.8-crypto.patch
  + bitcask-2.0.8-fileop.patch
  + bitcask-2.0.8-now.patch
  + bitcask-2.0.8-rand.patch
- enable %%check
- update Requires
- update BuildRequires
- move docs and headers to separate subpackages

* Sun May 21 2017 Led <ledest@gmail.com> 2.0.8-4
- revert BuildRequires

* Sat May 20 2017 Led <ledest@gmail.com> 2.0.8-3
- update BuildRequires

* Fri May 05 2017 Led <ledest@gmail.com> 2.0.8-2
- add no_inline option for bitcask_nifs module

* Sun Mar 19 2017 Led <ledest@gmail.com> 2.0.8-1
- 2.0.8

* Tue Feb 07 2017 Led <ledest@gmail.com> 2.0.7-1
- 2.0.7

* Mon Dec 12 2016 Led <ledest@gmail.com> 2.0.6-1
- 2.0.6
- add nowarn_export_all compile option

* Mon Jun 27 2016 Led <ledest@gmail.com> 2.0.2-2
- add bitcask-intro.pdf

* Sun Jun 26 2016 Led <ledest@gmail.com> 2.0.2-1
- 2.0.2

* Mon Jan 18 2016 Led <ledest@gmail.com> 2.0.1-1
- initial build
openSUSE Build Service is sponsored by