ninenines / erlang.mk

A build tool for Erlang that just works.
https://erlang.mk
ISC License
578 stars 241 forks source link

How to customize name of output tarball? #959

Closed h9812 closed 2 years ago

h9812 commented 2 years ago

How can I do if I want the output tarball name to contain git commit ID? For example: project_release-<commit id>.tar.gz instead of project_release-1.tar.gz. Thank you for helping!

essen commented 2 years ago

The 1 comes from the release version in relx.config. You can probably set "1" to {git, short} instead (or {git, long} if you prefer). Not sure it's going to work with everything though as I haven't tested it.

h9812 commented 2 years ago

It didn't work. Here is my relx.config file:

{release, {testerl2_release, {git, short}}, [testerl2, sasl, runtime_tools]}.
{dev_mode, false}.
{include_erts, true}.
{extended_start_script, true}.
{sys_config, "config/sys.config"}.
{vm_args, "config/vm.args"}.

Output of make clean && make command:

init terminating in do_boot ({badarg,[{io,format,[[_],[_]],[{_},{_},{_}]},{erl_eval,do_apply,7,[{_},{_}]},{erl_eval,exprs,6,[{_},{_}]},{init,start_it,1,[]},{init,start_em,1,[]},{init,do_boot,3,[]}]})

Crash dump is being written to: erl_crash.dump...done
 GEN    clean-app
 GEN    coverdata-clean
init terminating in do_boot ({badarg,[{io,format,[[_],[_]],[{_},{_},{_}]},{erl_eval,do_apply,7,[{_},{_}]},{erl_eval,exprs,6,[{_},{_}]},{init,start_it,1,[]},{init,start_em,1,[]},{init,do_boot,3,[]}]})

Crash dump is being written to: erl_crash.dump...done
init terminating in do_boot ({badarg,[{io,format,[[_],[_]],[{_},{_},{_}]},{erl_eval,do_apply,7,[{_},{_}]},{erl_eval,exprs,6,[{_},{_}]},{init,start_it,1,[]},{init,start_em,1,[]},{init,do_boot,3,[]}]})

Crash dump is being written to: erl_crash.dump...done
 DEPEND testerl2.d
init terminating in do_boot ({badarg,[{io,format,[[_],[_]],[{_},{_},{_}]},{erl_eval,do_apply,7,[{_},{_}]},{erl_eval,exprs,6,[{_},{_}]},{init,start_it,1,[]},{init,start_em,1,[]},{init,do_boot,3,[]}]})

Crash dump is being written to: erl_crash.dump...done
 ERLC   testerl2_app.erl testerl2_sup.erl
 APP    testerl2
erl +A1 -noinput -boot no_dot_erlang -pa ebin/ -pz /home/user1/testerl2/.erlang.mk/rebar/ebin -eval "   {ok, Config} = file:consult(\"/home/user1/testerl2/relx.config\"),  {release, {Name, Vsn0}, _} = lists:keyfind(release, 1, Config),Vsn = case Vsn0 of       {cmd, Cmd} -> os:cmd(Cmd);      semver -> \"\";     {semver, _} -> \"\";        VsnStr -> Vsn0  end,    {ok, _} = relx:build_release(#{name => Name, vsn => Vsn}, Config),  halt(0)." -- erlang.mk
{"init terminating in do_boot",{{badkey,{testerl2_release,{git,short}}},[{erlang,map_get,[{testerl2_release,{git,short}},#{{testerl2_release,"2763dd0"}=>{release_t,testerl2_release,"2763dd0",undefined,[{testerl2,#{included_applications=>undefined,name=>testerl2,type=>undefined,vsn=>undefined}},{sasl,#{included_applications=>undefined,name=>sasl,type=>undefined,vsn=>undefined}},{runtime_tools,#{included_applications=>undefined,name=>runtime_tools,type=>undefined,vsn=>undefined}}],false,[],[],undefined,[]}}],[{error_info,#{module=>erl_erts_errors}}]},{rlx_state,get_configured_release,3,[{file,"src/rlx_state.erl"},{line,281}]},{relx,build_release_,3,[{file,"src/relx.erl"},{line,168}]},{relx,build_release,3,[{file,"src/relx.erl"},{line,87}]},{erl_eval,do_apply,7,[{file,"erl_eval.erl"},{line,744}]},{erl_eval,expr,6,[{file,"erl_eval.erl"},{line,492}]},{erl_eval,exprs,6,[{file,"erl_eval.erl"},{line,136}]},{init,start_it,1,[]}]}}
init terminating in do_boot ({{badkey,{testerl2_release,{git,short}}},[{erlang,map_get,[{_},],[{_}]},{rlx_state,get_configured_release,3,[{_},{_}]},{relx,build_release_,3,[{_},{_}]},{relx,build_release,3,[{_},{_}]},{erl_eval,do_apply,7,[{_},{_}]},{erl_eval,expr,6,[{_},{_}]},{erl_eval,exprs,6,[{_},{_}]},{init,start_it,1,[]}]})

Crash dump is being written to: erl_crash.dump...done
make: *** [erlang.mk:7541: relx-rel] Error 1
essen commented 2 years ago

OK then I guess the code must be modified to support it, sorry.

essen commented 2 years ago

I suppose you can always edit the file automatically and put the commit as a string one way or another, perhaps extending rel::. But it's not built-in currently.

h9812 commented 2 years ago

I'll try your suggestion. Thank you for your helping!