File rebar3.spec of Package rebar3

%define bname rebar3
Name: %bname
Version: 3.3.6
Release: 1
Summary: A sophisticated build-tool for Erlang projects that follows OTP principles
License: Apache-2.0
Group: Development/Tools/Other
URL: https://github.com/rebar/%bname
Source: %bname-%version.tar.xz
Source9: %name-rpmlintrc
#Patch0: %bname-%version-git.patch
Patch1: 0001-Typo-seperate-separate.patch
BuildArch: noarch
Requires: erlang
Provides: erlang-%bname = %version-%release
Requires: update-alternatives
Conflicts: rebar

BuildRequires: rpm-macros-erlang >= 0.9.1 rpm-build-erlang >= 0.10.0
BuildRequires: rebar >= 2.6.1-7
BuildRequires: update-alternatives
BuildRequires: erlang-erlware_commons >= 0.18.0
BuildRequires: erlang-bbmustache >= 1.0.4
BuildRequires: erlang-certifi >= 0.4.0
BuildRequires: erlang-providers >= 1.6.0
BuildRequires: erlang-relx >= 3.17.0
BuildRequires: erlang-cf >= 0.2.0
BuildRequires: erlang-eunit_formatters >= 0.3.1
BuildRequires: erlang-cth_readable >= 1.2.2
BuildRequires: erlang-getopt >= 0.8.2
BuildRequires: erlang-ssl_verify_hostname >= 1.0.5
BuildRequires: erlang-public_key-devel
BuildRequires: erlang-termcap

%description
Rebar3 is an Erlang build tool that makes it easy to compile and test Erlang
applications, port drivers and releases. %bname is a self-contained Erlang script,
so it's easy to distribute or even embed directly in a project. Where possible,
%bname uses standard Erlang/OTP conventions for project structures, thus
minimizing the amount of build configuration work. %bname also provides dependency
management, enabling application writers to easily re-use common libraries from a
variety of locations (git, hg, etc).


%package static
Summary: A sophisticated build-tool for Erlang projects that follows OTP principles
Group: Development/Tools/Other
Provides: %name-bundle = %version-%release
Requires: erlang
Requires: erlang-otp-base erlang-syntax_tools

%description static
%bname is an Erlang build tool that makes it easy to compile and test Erlang
applications, port drivers and releases. %bname is a self-contained Erlang script,
so it's easy to distribute or even embed directly in a project. Where possible,
%bname uses standard Erlang/OTP conventions for project structures, thus
minimizing the amount of build configuration work. %bname also provides dependency
management, enabling application writers to easily re-use common libraries from a
variety of locations (git, hg, etc).


%package relx
Summary: relx support for rebar
Group: Development/Tools/Other
Requires: %name = %version-%release

%description relx
%summary.


%prep
%setup -q -n %bname-%version
#patch0 -p1
%patch1 -p1
%if 0
erl -noshell -eval '
A = "src/rebar.app.src",
{ok, [{application, rebar, L}]} = file:consult(A),
file:write_file(A, io_lib:format("{application, rebar, ~p}.~n", [[{vsn, "%version"}|proplists:delete(vsn, L)]])),
halt().'
%endif
sed -i 's/ @\(equiv \)/ \1/g' src/rebar_erlc_compiler.erl


%build
erl -noshell -eval '
{ok, L} = file:consult("rebar.config"),
file:write_file("%bname.rebar.config",
                lists:map(fun(E) -> io_lib:format("~p.~n", [E]) end,
                          [{erl_opts, [inline, slim, no_debug_info|proplists:get_value(erl_opts, L, [])]},
                           {edoc_opts, [{preprocess, true}|proplists:get_value(edoc_opts, L, [])]},
                           {escript_shebang, "#!%_bindir/escript\n"},
                           {escript_emu_args, proplists:get_value(escript_emu_args, L, "")},
                           {escript_incl_apps, [bbmustache, certifi, cf, cth_readable, eunit_formatters, erlware_commons,
                                                getopt, providers, relx, ssl_verify_hostname, termcap]},
                           {escript_comment, ""}
                           |lists:foldl(fun proplists:delete/2, L, [erl_opts, edoc_opts, deps, overrides, profiles, post_hooks])])),
halt().'

for i in compile escriptize doc; do
	rebar -C %bname.rebar.config $i -v
done

cat > %bname.escript <<__EOF__
#!/usr/bin/escript
%%%%
main(A) -> rebar3:main(A).
__EOF__


%install
install -pD -m 0755 %bname %buildroot%_bindir/%bname-bundle
ln -sf %bname-bundle %buildroot%_bindir/%bname-static
for d in ebin priv/templates; do
	install -d -m 0755 %buildroot%_otplibdir/rebar-%version/$d
	install -p -m 0644 $d/* %buildroot%_otplibdir/rebar-%version/$d/
done
install -pD %bname.escript -m 0755 %buildroot%_bindir/%bname-otp
install -d -m 0755 %buildroot%_otplibdir/rebar-%version/doc
install -p -m 0644 doc/*.{css,html,png} %buildroot%_otplibdir/rebar-%version/doc/
install -d -m 0755 %buildroot%_docdir/%name
ln -sf %_otplibdir/rebar-%version/doc %buildroot%_docdir/%name/html
install -p -m 0644 CONTRIBUTING* README* THANKS* %buildroot%_docdir/%name/

# alternatives
install -d -m 0755 %buildroot%_sysconfdir/alternatives
touch %buildroot%_sysconfdir/alternatives/%bname
ln -sf %_sysconfdir/alternatives/%bname %buildroot%_bindir/%bname

%add_erlang_req_app_skiplist relx


%post
%_sbindir/update-alternatives --quiet --install %_bindir/%bname %bname %_bindir/%bname-otp 10

%preun
[ "$1" != 0 ] || %_sbindir/update-alternatives --quiet --remove %bname %_bindir/%bname-otp


%post static
%_sbindir/update-alternatives --quiet --install %_bindir/%bname %bname %_bindir/%bname-bundle 5

%preun static
[ "$1" != 0 ] || %_sbindir/update-alternatives --quiet --remove %bname %_bindir/%bname-bundle


%if 0
%check
./rebar3 ct
%endif


%files
%defattr(-,root,root)
%doc %_docdir/%name
%_bindir/%bname-otp
%_otplibdir/*
%ghost %_bindir/%bname
%ghost %_sysconfdir/alternatives/*
%exclude %_otplibdir/rebar-*/ebin/rebar_relx*
%exclude %_otplibdir/rebar-*/ebin/rebar_prv_rel*
%exclude %_otplibdir/rebar-*/ebin/rebar_prv_tar.*


%files relx
%defattr(-,root,root)
%_otplibdir/rebar-*/ebin/rebar_relx.*
%_otplibdir/rebar-*/ebin/rebar_prv_rel*
%_otplibdir/rebar-*/ebin/rebar_prv_tar.*


%files static
%defattr(-,root,root)
%doc CONTRIBUTING* README* THANKS*
%_bindir/%bname-bundle
%_bindir/%bname-static
%ghost %_bindir/%bname
%ghost %_sysconfdir/alternatives/*


%changelog
* Thu Mar 30 2017 Led <ledest@gmail.com> 3.3.6-1
- 3.3.6
- add patches:
  + 0001-Typo-seperate-separate.patch

* Fri Mar 10 2017 Led <ledest@gmail.com> 3.3.5-2
- update BuildRequires

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

* Tue Dec 27 2016 Led <ledest@gmail.com> 3.3.4-1
- 3.3.4

* Mon Dec 12 2016 Led <ledest@gmail.com> 3.3.3-1
- 3.3.3
- remove patches:
  + rebar3-3.1.0-doc.patch

* Sun Oct 30 2016 Led <ledest@gmail.com> 3.3.2-1
- 3.3.2

* Mon Sep 12 2016 Led <ledest@gmail.com> 3.3.1-1
- 3.3.1

* Fri Aug 12 2016 Led <ledest@gmail.com> 3.2.0-1
- 3.2.0

* Fri Jul 15 2016 Led <ledest@gmail.com> 3.1.0-3
- fix BuildRequires

* Sun Apr 10 2016 Led <ledest@gmail.com> 3.1.0-2
- add conflicts to rebar

* Sun Apr 10 2016 Led <ledest@gmail.com> 3.1.0-1
- initial build
openSUSE Build Service is sponsored by