File locks.spec of Package locks

%define bname locks
Name: %bname
Version: 0.2.0
Release: 1
Summary: Scalable deadlock-resolving locking system
License: MPL-2.0
Group: Development/Tools/Other
URL: https://github.com/uwiger/%name
Source: %bname-%version.tar.xz
#Patch: %bname-%version-git.patch
Provides: erlang-%bname = %version-%release
BuildArch: noarch

BuildRequires: rpm-macros-erlang rpm-build-erlang
BuildRequires: rebar >= 2.6.4-26
# check
BuildRequires: epmd erlang-common_test erlang-common_test-devel

%description
A scalable, deadlock-resolving resource locker.
This application is based on an algorithm designed by Ulf Wiger 1993, and later
model-checked (and refined) by Thomas Arts.
Compared to the implementation verified by Thomas Arts, 'locks' has included
a hierarchical lock structure and has both read and write locks. It is also
distributed, supporting multi-node locks and quorum ('majority').
The algorithm is based on computing potential indirect dependencies and informing
dependent transactions in a 'fill-in-the-blanks' manner.
Eventually, one transaction will have enough information to detect a deadlock,
even though no central dependency graph or dependency probes are used. Resolution
happens with a (at least close to) minimal number of messages, making
the algorithm unusually scalable. Since it uses deadlock detection instead
of deadlock prevention, there are no phantom deadlocks.
Note: Unlock has not (yet) been implemented. Once the transaction ends, all locks
held by it are released automatically.


%package devel
Summary: Headers of %bname
Group: Development/Tools/Other
Provides: erlang-%bname-devel = %version-%release

%description devel
A scalable, deadlock-resolving resource locker.
This application is based on an algorithm designed by Ulf Wiger 1993, and later
model-checked (and refined) by Thomas Arts.
Compared to the implementation verified by Thomas Arts, 'locks' has included
a hierarchical lock structure and has both read and write locks. It is also
distributed, supporting multi-node locks and quorum ('majority').
The algorithm is based on computing potential indirect dependencies and informing
dependent transactions in a 'fill-in-the-blanks' manner.
Eventually, one transaction will have enough information to detect a deadlock,
even though no central dependency graph or dependency probes are used. Resolution
happens with a (at least close to) minimal number of messages, making
the algorithm unusually scalable. Since it uses deadlock detection instead
of deadlock prevention, there are no phantom deadlocks.
Note: Unlock has not (yet) been implemented. Once the transaction ends, all locks
held by it are released automatically.
This package contains Headers of %bname.


%package doc
Summary: %bname documentation
Group: Documentation/HTML
Provides: erlang-%bname-doc = %version-%release

%description doc
A scalable, deadlock-resolving resource locker.
This application is based on an algorithm designed by Ulf Wiger 1993, and later
model-checked (and refined) by Thomas Arts.
Compared to the implementation verified by Thomas Arts, 'locks' has included
a hierarchical lock structure and has both read and write locks. It is also
distributed, supporting multi-node locks and quorum ('majority').
The algorithm is based on computing potential indirect dependencies and informing
dependent transactions in a 'fill-in-the-blanks' manner.
Eventually, one transaction will have enough information to detect a deadlock,
even though no central dependency graph or dependency probes are used. Resolution
happens with a (at least close to) minimal number of messages, making
the algorithm unusually scalable. Since it uses deadlock detection instead
of deadlock prevention, there are no phantom deadlocks.
Note: Unlock has not (yet) been implemented. Once the transaction ends, all locks
held by it are released automatically.
This package contains documentation in HTML and Markdown format.


%prep
%setup -q -n %bname-%version
#patch -p1
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, ~81p}.~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",
                lists:map(fun(E) -> [io_lib:print(E), ".\n"] end,
                          lists:keystore(edoc_opts, 1, lists:keydelete(deps, 1, L),
                                         {edoc_opts,
                                          case lists:keyfind(edoc_opts, 1, L) of
                                              {_, [_|_] = O} ->
                                                  lists:keystore(new, 1, lists:keydelete(doclet, 1, O), {new, true});
                                              _ -> [{new, true}]
                                          end})),
                [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/include
install -p -m 0644 include/* %buildroot%_otplibdir/%bname-%version/include/
install -d -m 0755 %buildroot%_otplibdir/%bname-%version/doc
for i in css html md png; do
	install -p -m 0644 doc/*.$i %buildroot%_otplibdir/%bname-%version/doc/
done
cp -r examples %buildroot%_otplibdir/%bname-%version/doc/
install -d -m 0755 %buildroot%_docdir
ln -sf %_otplibdir/%bname-%version/doc %buildroot%_docdir/%name


%check
ERL_COMPILER_OPTIONS="[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
* Sun May 19 2019 Led <ledest@gmail.com> 0.2.0-1
- 0.2.0
openSUSE Build Service is sponsored by