File rebar.spec of Package rebar

%define bname rebar
Name: %bname
Version: 2.6.4
Release: 23
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: %bname-2.6.4-fix-link-drv.patch
BuildArch: noarch
Requires: erlang
Requires: erl_interface
Requires: /usr/sbin/update-alternatives
Provides: erlang-rebar = %version-%release
Provides: %name-reltool = %version-%release
Obsoletes: %bname-reltool < %version-%release
Provides: %name-plugin-abnfc = %version-%release
Provides: %name-plugin-asn1 = %version-%release
Provides: %name-plugin-diameter = %version-%release
Provides: %name-plugin-dia = %version-%release
Conflicts: %name-plugin-erlydtl < %version-%release
Provides: %name-plugin-neotoma = %version-%release
Provides: %name-plugin-proto = %version-%release

BuildRequires: rpm-macros-erlang >= 0.9.1 rpm-build-erlang >= 0.10.0
BuildRequires: erlang erlang-tools erlang-otp-devel erl_interface erlang-syntax_tools
BuildRequires: erlang-edoc
BuildRequires: /usr/sbin/update-alternatives
BuildRequires: erlang-crypto erlang-eunit erlang-diameter

%description
%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 plugin-erlydtl
Summary: Plugin for rebar that compiles ErlyDTL templates
Group: Development/Tools/Other
Requires: %name = %version-%release
Requires: erlydtl

%description plugin-erlydtl
The rebar_erlydtl_compiler module is a plugin for rebar that compiles ErlyDTL
templates.


%package plugin-lfe
Summary: Plugin for rebar that compiles Lisp Flavoured Erlang (*.lfe) sources
Group: Development/Tools/Other
Requires: %name = %version-%release

%description plugin-lfe
The rebar_lfe_compiler module is a plugin for rebar that compiles Lisp Flavoured
Erlang (*.lfe) sources.


%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).


%prep
%setup -q -n %bname-%version
%patch0 -p1
%patch1 -p1


%build
erl -noshell -eval '
{ok, L} = file:consult("rebar.config"),
file:write_file("rebar.config",
                lists:map(fun(E) -> [io_lib:print(E), ".\n"] end,
                          [{erl_opts, [inline, no_debug_info|lists:delete(debug_info, proplists:get_value(erl_opts, L, []))]},
                           {edoc_opts, [{preprocess, true}|proplists:get_value(edoc_opts, L, [])]},
                           {escript_shebang, "#!%__escript\n"}, {escript_comment, ""}, {escript_emu_args, ""}
                           |lists:foldl(fun proplists:delete/2, L, [erl_opts, edoc_opts])]),
                [raw]),
init:stop().'

./bootstrap
./rebar %{?_smp_mflags} doc

cat > %bname.escript <<__EOF__
#!%__escript
%%%%
%%%%
main(A) -> rebar:main(A).
__EOF__


%install
install -pD -m 0755 %bname %buildroot%_bindir/%bname-bundle
ln -sf %bname-bundle %buildroot%_bindir/%bname-static
install -d -m 0755 %buildroot%_otplibdir/%bname-%version/ebin
install -p -m 0644 ebin/*.beam %buildroot%_otplibdir/%bname-%version/ebin/
sed -r '/^[[:blank:]]*%{bname}_lfe_compiler,/d' ebin/%bname.app > %buildroot%_otplibdir/%bname-%version/ebin/%bname.app
install -d -m 0755 %buildroot%_otplibdir/%bname-%version/priv/templates
install -p -m 0644 priv/templates/* %buildroot%_otplibdir/%bname-%version/priv/templates/
install -pD %bname.escript -m 0755 %buildroot%_bindir/%bname-otp
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 CONTRIBUTING* README* RELEASE-NOTES* THANKS* %buildroot%_docdir/%name/

# completion
install -pD -m 0644 priv/shell-completion/bash/%bname %buildroot%_sysconfdir/bash_completion.d/%bname.sh

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

# RPM macros
install -d -m 0755 %buildroot%_rpmmacrosdir
cat > %buildroot%_rpmmacrosdir/macros.%bname <<__EOF__
%__rebar env REBAR_DEPS_PREFER_LIBS=1 %_bindir/%bname
%__rebar_compile %__rebar compile
%__rebar_doc %__rebar doc
%__rebar_eunit %__rebar eunit
__EOF__

%add_erlang_req_app_skiplist dialyzer reltool
%add_erlang_req_beam_skiplist dialyzer
%add_erlang_req_beam_skiplist reltool reltool_server
%add_erlang_req_beam_skiplist asn1ct diameter_codegen diameter_dict_util
%add_erlang_req_beam_skiplist abnfc neotoma
%add_erlang_req_beam_skiplist erlydtl
%add_erlang_req_beam_skiplist eflame
%add_erlang_req_beam_skiplist gpb_compile protobuffs_compile
%add_erlang_req_beam_skiplist rebar_rnd


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

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


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

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


%check
./rebar eunit


%files
%defattr(-,root,root)
%doc %_docdir/%name
%_bindir/%bname-otp
%_otplibdir/*
%exclude %_otplibdir/%bname-*/ebin/%{bname}_lfe_compiler.beam
%_sysconfdir/bash_completion.d/*
%ghost %_bindir/%bname
%ghost %_sysconfdir/alternatives/*
%_rpmmacrosdir


%files plugin-erlydtl
%defattr(-,root,root)


%files plugin-lfe
%defattr(-,root,root)
%_otplibdir/%bname-*/ebin/%{bname}_lfe_compiler.beam


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


%changelog
* Sun Feb 25 2018 Led <ledest@gmail.com> 2.6.4-23
- add rebar-plugin-erlydtl virtual subpackage

* Sun Feb 25 2018 Led <ledest@gmail.com> 2.6.4-22
- skip requires of erlydtl

* Tue Feb 20 2018 Led <ledest@gmail.com> 2.6.4-21
- add Conflicts to rebar-plugin-erlydtl

* Tue Feb 20 2018 Led <ledest@gmail.com> 2.6.4-20
- revert rebar_erlydtl_compiler module to main package

* Fri Feb 02 2018 Led <ledest@gmail.com> 2.6.4-19
- git b6d3094

* Mon Aug 21 2017 Led <ledest@gmail.com> 2.6.4-18
- git 8076675

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

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

* Sun Mar 05 2017 Led <ledest@gmail.com> 2.6.4-15
- remove erlydtl and lfe plugins from rebar.app

* Sun Mar 05 2017 Led <ledest@gmail.com> 2.6.4-14
- remove subpackages rebar-plugin-{abnfc,asn1,diameter,neotoma,proto}

* Sun Mar 05 2017 Led <ledest@gmail.com> 2.6.4-13
- remove plugins from rebar.app

* Sun Mar 05 2017 Led <ledest@gmail.com> 2.6.4-12
- move rebar_proto_compiler, rebar_proto_gpb_compiler, rebar_protobuffs_compiler
  modules to subpackage rebar-plugin-proto

* Sun Mar 05 2017 Led <ledest@gmail.com> 2.6.4-11
- move rebar_asn1_compiler module to subpackage rebar-plugin-asn1

* Sun Mar 05 2017 Led <ledest@gmail.com> 2.6.4-10
- move rebar_dia_compiler module to subpackage rebar-plugin-diameter

* Sun Mar 05 2017 Led <ledest@gmail.com> 2.6.4-9
- move rebar_lfe_compiler module to subpackage rebar-plugin-lfe

* Sun Mar 05 2017 Led <ledest@gmail.com> 2.6.4-8
- move rebar_neotoma_compiler module to subpackage rebar-plugin-neotoma

* Sun Mar 05 2017 Led <ledest@gmail.com> 2.6.4-7
- move rebar_erlydtl_compiler module to subpackage rebar-plugin-erlydtl

* Sun Mar 05 2017 Led <ledest@gmail.com> 2.6.4-6
- add Requires to rebar-plugin-abnfc

* Sun Mar 05 2017 Led <ledest@gmail.com> 2.6.4-5
- move rebar_abnfc_compiler module to subpackage rebar-plugin-abnfc

* Thu Feb 23 2017 Led <ledest@gmail.com> 2.6.4-4
- git 2a52f60

* Mon Sep 19 2016 Led <ledest@gmail.com> 2.6.4-3
- git 0d6b671

* Wed Sep 14 2016 Led <ledest@gmail.com> 2.6.4-2
- update patches:
  + rebar-2.6.4-fix-link-drv.patch

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

* Sun Aug 28 2016 Led <ledest@gmail.com> 2.6.3-2
- ignore requires of rebar_rnd

* Sun Aug 28 2016 Led <ledest@gmail.com> 2.6.3-1
- 2.6.3
- clean up spec
- update patches:
  + rebar-2.6.3-fix-link-drv.patch

* Fri Aug 12 2016 Led <ledest@gmail.com> 2.6.2-1
- 2.6.2
- git 16993de
- update patches:
  + rebar-2.6.2-fix-link-drv.patch

* Tue Jun 21 2016 Led <ledest@gmail.com> 2.6.1-12
- ignore requires of diameter

* Sat Jun 18 2016 Led <ledest@gmail.com> 2.6.1-11
- git f695144

* Sat May 14 2016 Led <ledest@gmail.com> 2.6.1-10
- git 9281b84
- remove patches:
  + rebar-2.6.1-find-deps-locally-first.patch
- add erlang-diameter to BuildRequires (for tests)
- add macro.rebar

* Mon Mar 21 2016 Led <ledest@gmail.com> 2.6.1-9
- ignore requires of reltool_server

* Mon Mar 21 2016 Led <ledest@gmail.com> 2.6.1-8
- remove rebar-reltool subpackage

* Thu Mar 17 2016 Led <ledest@gmail.com> 2.6.1-7
- add requires erl_interface
- change alternatives for compatibility

* Thu Mar 17 2016 Led <ledest@gmail.com> 2.6.1-6
- enable find deps locally first by default

* Mon Mar 07 2016 Led <ledest@gmail.com> 2.6.1-5
- don't remove rebar_reltool from rebar.app
- skip requires of dialyzer

* Mon Mar 07 2016 Led <ledest@gmail.com> 2.6.1-4
- add bash completion
- add patches:
  + rebar-2.6.1-find-deps-locally-first.patch

* Sun Jan 17 2016 Led <ledest@gmail.com> 2.6.1-3
- fix URL

* Mon Nov 30 2015 Led <ledest@gmail.com> 2.6.1-2
- update patches:
  + rebar-2.6.1-fix-link-drv.patch

* Tue Oct 20 2015 Led <ledest@gmail.com> 2.6.1-1
- 2.6.1
- update patches:
  + rebar-2.6.1-fix-link-drv.patch

* Sun Sep 27 2015 Led <ledest@gmail.com> 2.6.0-5
- fix build docs
- fix tests for Erlang 18.1

* Sat Jul 04 2015 Led <ledest@gmail.com> 2.6.0-4
- ignore requires of reltool app

* Fri Jun 26 2015 Led <ledest@gmail.com> 2.6.0-3
- fix test on Erlang 18

* Sun Jun 21 2015 Led <ledest@gmail.com> 2.6.0-2
- build docs
- ignore requires of eflame and gpb_compile modules

* Sat Jun 20 2015 Led <ledest@gmail.com> 2.6.0-1
- 2.6.0

* Sun May 31 2015 Led <ledest@gmail.com> 2.5.1-14
- remove rebar_reltool entry in rebar.app

* Sun Apr 12 2015 Led <ledest@gmail.com> 2.5.1-13
- update patches:
  + rebar-2.5.1-fix-link-drv.patch

* Sun Apr 12 2015 Led <ledest@gmail.com> 2.5.1-12
- cosmetic fixes

* Sun Apr 12 2015 Led <ledest@gmail.com> 2.5.1-11
- add patches:
  + rebar-2.5.1-fix-link-drv.patch

* Sun Apr 05 2015 Led <ledest@gmail.com> 2.5.1-10
- add erl_opts
- add %%check

* Sun Mar 22 2015 Led <ledest@gmail.com> 2.5.1-9
- use alternatives

* Sat Feb 21 2015 Led  <ledest@gmail.com> 2.5.1-8
- add rebar-reltool subpackage

* Thu Jan 29 2015 Led <ledest@gmail.com> 2.5.1-7
- ignore requires of protobuffs_compile module

* Thu Jan 29 2015 Led <ledest@gmail.com> 2.5.1-6
- ignore requires of neotoma module

* Thu Jan 29 2015 Led <ledest@gmail.com> 2.5.1-5
- ignore requires of lfe_comp module

* Thu Jan 29 2015 Led <ledest@gmail.com> 2.5.1-4
- ignore requires of erlydtl module

* Thu Jan 29 2015 Led <ledest@gmail.com> 2.5.1-3
- ignore requires of abnfc module

* Thu Jan 29 2015 Led <ledest@gmail.com> 2.5.1-2
- add %%name-static subpackage

* Fri Jan 16 2015 Led <ledest@gmail.com> 2.5.1-1
- 2.5.1
- fixed License
- updated BuildRequires
- updated Requires
- updated Provides

* Sat Mar 03 2012 Led <led@massivesolutions.co.uk> 2-2
- spec:
  + added Buildroot
  + updated BuildRequires

* Mon Feb 13 2012 Led <led@massivesolutions.co.uk> 2-1
- removed erlang-common_test from Requires

* Mon Feb 06 2012 Led <led@massivesolutions.co.uk> 2-0
- initial build for openSUSE
openSUSE Build Service is sponsored by