File jsxd.spec of Package jsxd

%define bname jsxd
Name: %bname
Version: 0.1.10
Release: 3
Summary: JSX style data structure manipulation for Erlang/OTP
License: CDDL-1.0
Group: Development/Tools/Other
URL: https://github.com/Licenser/%bname
Source: %bname-%version.tar.xz
Patch1: jsxd-update-get-2.patch
BuildArch: noarch
Provides: erlang-%bname = %version-%release

BuildRequires: rpm-macros-erlang rpm-build-erlang
BuildRequires: rebar erl_interface

%description
%bname is a library to sanely work with nested data structures as jsx produces.
The data structures can represent objects (key value lists) or arrays (lists).


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

%description doc
%bname is a library to sanely work with nested data structures as jsx produces.
This package contains documentation of %bname.


%prep
%setup -q -n %bname-%version
%patch -p1 -P1


%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:foldl(fun(K, A) -> lists:keydelete(K, 1, A) end, L, [deps, lib_dirs])),
                [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/%name-%version/doc %buildroot%_docdir/%name/html
install -p -m 0644 *.md %buildroot%_docdir/%name/


%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> 0.1.10-3
- fix patch applying
- move docs to separate subpackage

* Fri Mar 18 2016 Led <ledest@gmail.com> 0.1.10-2
- clean up BuildRequires
- add patches:
  + jsxd-update-get-2.patch

* Mon Dec 28 2015 Led <ledest@gmail.com> 0.1.10-1
- initial build
openSUSE Build Service is sponsored by