rebar3 icon indicating copy to clipboard operation
rebar3 copied to clipboard

"rebar3 as prod tar" overlay does not take effect

Open leonlee2007 opened this issue 1 year ago • 0 comments

When upgrading rebar3 of an umbrella project from 3.12 to 3.19, I encounter a problem: Packaging with rebar3 as prod tar, it is found that the overlay configured in the app does not replace the general overlay. but rebar3 as prod release is ok.

{relx, [
        {release, 
         {a, "0.1.0"}, 
         [a, sasl],
         %overlay does not take effect
         [{overlay, [{copy, "test_data", "test_data"}]}]
        },  
        {release, {b, "0.1.0"}, [b, sasl]},
        {overlay,[ {copy, "test_dir", "test_dir"} ] },
        {dev_mode, true},
        {include_erts, false},
        {extended_start_script, true},
        {sys_config, "./config/sys.config"},
        {vm_args, "./config/vm.args"}
]}.

Try to modify the code of relx.erl: https://github.com/erlware/relx/blob/main/src/relx.erl

build_release_(#{name := RelName,
                 vsn := RelVsn}, Apps, State) ->
    Release = rlx_state:get_configured_release(State, RelName, RelVsn),
    {ok, RealizedRelease, State1} =
        rlx_resolve:solve_release(Release, rlx_state:available_apps(State, Apps)),
    {ok, State2} = rlx_assemble:do(RealizedRelease, State1),
    _ = rlx_overlay:render(RealizedRelease, State2),
    RealizedRelease.

build_tar(Release=#{name := RelName,
                    vsn := RelVsn}, Apps, State) when is_atom(RelName) ,
                                                      is_list(RelVsn) ->
    RealizedRelease = build_release_(Release, Apps, State),
    build_tar_(RealizedRelease, State),
    {ok, RealizedRelease};

Change it to the following:

build_release_(#{name := RelName,
                 vsn := RelVsn}, Apps, State) ->
    Release = rlx_state:get_configured_release(State, RelName, RelVsn),
    {ok, RealizedRelease, State1} =
        rlx_resolve:solve_release(Release, rlx_state:available_apps(State, Apps)),
    {ok, State2} = rlx_assemble:do(RealizedRelease, State1),
    _ = rlx_overlay:render(RealizedRelease, State2),
    %RealizedRelease.
    {ok, State2, RealizedRelease}.

build_tar(Release=#{name := RelName,
                    vsn := RelVsn}, Apps, State) when is_atom(RelName) ,
                                                      is_list(RelVsn) ->
    %RealizedRelease = build_release_(Release, Apps, State),
    %build_tar_(RealizedRelease, State),
    {ok, State1, RealizedRelease} = build_release_(Release, Apps, State),
	build_tar_(RealizedRelease, State1),
    {ok, RealizedRelease};

After recompiling rebar3, the problem is solved.

leonlee2007 avatar Jun 29 '22 07:06 leonlee2007