File erlang-setup.spec of Package erlang-setup

%define bname setup
Name: erlang-%bname
Version: 1.8.1
Release: 1
Summary: Generic setup utility for Erlang-based systems
License: Apache-2.0
Group: Development/Tools/Other
Source: %bname-%version.tar.xz
#Patch: %bname-%version-git.patch
BuildArch: noarch
Provides: erlang-%bname = %version-%release

BuildRequires: rpm-macros-erlang rpm-build-erlang
BuildRequires: rebar >= 2.6.1-7

This utility offers a framework for initializing and configuring a system, with a
set of conventions allowing each component to provide callbacks for different
steps in the installation procedure.

%setup -q -n %bname-%version
#patch -p1
rm -f doc/edoc-info
erl -noshell -eval '
A = "src/",
{ok, [{application, %bname, L}]} = file:consult(A),
file:write_file(A, io_lib:format("{application, %bname, ~81p}.~n", [lists:keystore(vsn, 1, L, {vsn, "%version"})])),

erl -noshell -eval '
{ok, L} = file:consult("rebar.config"),
                lists:map(fun(E) -> [io_lib:print(E), ".\n"] end,
                          [{erl_opts, [slim, inline, no_debug_info|lists:delete(debug_info, proplists:get_value(erl_opts, L, []))]},
                           {edoc_opts, proplists:delete(doclet, lists:foldl(fun(E, A) -> proplists:get_value(E, A, []) end, L, [profiles, docs, edoc_opts]))}
                           |lists:foldl(fun proplists:delete/2, L, [erl_opts, deps, post_hooks, profiles])])),
ln -s rebar.config.script %bname.rebar.config.script
MAKE=rebar \
rebar -C %bname.rebar.config compile -v
rebar -C %bname.rebar.config doc -v
cat > setup_gen.escript <<__EOF__
main(A) -> setup_gen:main(A).

install -pD -m 0755 setup_gen.escript %buildroot%_bindir/setup_gen
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/examples
install -p -m 0644 examples/* %buildroot%_otplibdir/%bname-%version/examples/
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
ln -sf %_otplibdir/%bname-%version/examples %buildroot%_docdir/%name/examples
install -p -m 0644 *.md %buildroot%_docdir/%name/

rebar -C %bname.rebar.config eunit -v

%doc %_docdir/%name

* Sun Feb 12 2017 Led <> 1.0.3-1
- initial build