Merge pull request #8646 from zmstone/0803-build-fix-relup-overwrite-escript
build: fix relup app overwrite escript
This commit is contained in:
commit
df6303d793
2
build
2
build
|
@ -100,7 +100,7 @@ make_relup() {
|
||||||
if [ ! -f "${emqx_rel_file}" ]; then
|
if [ ! -f "${emqx_rel_file}" ]; then
|
||||||
./rebar3 as "${PROFILE}" release
|
./rebar3 as "${PROFILE}" release
|
||||||
fi
|
fi
|
||||||
scripts/emqx_rel_otp_app_overwrite.escript "${releases_dir}" "${PROFILE}" "${PKG_VSN}" "${RELX_BASE_VERSIONS}"
|
scripts/emqx_rel_otp_app_overwrite.escript "${releases_dir}" "${PKG_VSN}" "${RELX_BASE_VERSIONS}"
|
||||||
fi
|
fi
|
||||||
./rebar3 as "$PROFILE" relup --relname emqx --relvsn "${PKG_VSN}"
|
./rebar3 as "$PROFILE" relup --relname emqx --relvsn "${PKG_VSN}"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env escript
|
#!/usr/bin/env -S escript -c
|
||||||
%% This script is part of 'relup' process to overwrite the OTP app versions (incl. ERTS) in rel files from upgrade base
|
%% This script is part of 'relup' process to overwrite the OTP app versions (incl. ERTS) in rel files from upgrade base
|
||||||
%% so that 'rebar relup' call will not generate instructions for restarting OTP apps or restarting the emulator.
|
%% so that 'rebar relup' call will not generate instructions for restarting OTP apps or restarting the emulator.
|
||||||
%%
|
%%
|
||||||
|
@ -7,19 +7,25 @@
|
||||||
%%
|
%%
|
||||||
%% note, we use NEW to overwrite OLD is because the modified NEW rel file will be overwritten by next 'rebar relup'
|
%% note, we use NEW to overwrite OLD is because the modified NEW rel file will be overwritten by next 'rebar relup'
|
||||||
%%
|
%%
|
||||||
main([Dir, Profile, RelVsn, BASE_VERSIONS]) ->
|
|
||||||
{ErtsVsn, Overwrites} = get_otp_apps(rel_file(Profile, Dir, RelVsn), RelVsn),
|
main([Dir, RelVsn, BASE_VERSIONS]) ->
|
||||||
|
{ErtsVsn, Overwrites} = get_otp_apps(rel_file(Dir, RelVsn), RelVsn),
|
||||||
lists:foreach(fun(BaseVer) ->
|
lists:foreach(fun(BaseVer) ->
|
||||||
base_rel_overwrites(BaseVer, Profile, Dir, ErtsVsn, Overwrites)
|
base_rel_overwrites(BaseVer, Dir, ErtsVsn, Overwrites)
|
||||||
end, string:tokens(BASE_VERSIONS, ",")).
|
end, string:tokens(BASE_VERSIONS, ",")).
|
||||||
|
|
||||||
get_otp_apps(RelFile, RelVsn) ->
|
get_otp_apps(RelFile, RelVsn) ->
|
||||||
{ok, [{release, {"emqx", RelVsn}, {erts, ErtsVsn}, AppList}]} = file:consult(RelFile),
|
case file:consult(RelFile) of
|
||||||
Apps = lists:filter(fun(X) -> lists:member(element(1, X), otp_apps()) end, AppList),
|
{ok, [{release, {"emqx", RelVsn}, {erts, ErtsVsn}, AppList}]} ->
|
||||||
{ErtsVsn, Apps}.
|
Apps = lists:filter(fun(X) -> lists:member(element(1, X), otp_apps()) end, AppList),
|
||||||
|
{ErtsVsn, Apps};
|
||||||
|
{error, Reason} ->
|
||||||
|
io:format(standard_error, "failed_to_read_file ~p for release ~p~nreason=~p~n", [RelFile, RelVsn, Reason]),
|
||||||
|
halt(1)
|
||||||
|
end.
|
||||||
|
|
||||||
base_rel_overwrites(RelVsn, Profile, Dir, ErtsVsn, Overwrites) ->
|
base_rel_overwrites(RelVsn, Dir, ErtsVsn, Overwrites) ->
|
||||||
RelFile = rel_file(Profile, Dir, RelVsn),
|
RelFile = rel_file(Dir, RelVsn),
|
||||||
file:copy(RelFile, RelFile++".bak"),
|
file:copy(RelFile, RelFile++".bak"),
|
||||||
{ok, [{release, {"emqx", RelVsn}, {erts, _BaseErtsVsn}, BaseAppList}]} = file:consult(RelFile),
|
{ok, [{release, {"emqx", RelVsn}, {erts, _BaseErtsVsn}, BaseAppList}]} = file:consult(RelFile),
|
||||||
NewData = [ {release, {"emqx", RelVsn}, {erts, ErtsVsn},
|
NewData = [ {release, {"emqx", RelVsn}, {erts, ErtsVsn},
|
||||||
|
@ -34,10 +40,8 @@ base_rel_overwrites(RelVsn, Profile, Dir, ErtsVsn, Overwrites) ->
|
||||||
],
|
],
|
||||||
ok = file:write_file(RelFile, io_lib:format("~p.", NewData)).
|
ok = file:write_file(RelFile, io_lib:format("~p.", NewData)).
|
||||||
|
|
||||||
rel_file("emqx-edge", Dir, RelVsn)->
|
rel_file(Dir, RelVsn)->
|
||||||
rel_file("emqx", Dir, RelVsn);
|
filename:join([Dir, RelVsn, "emqx.rel"]).
|
||||||
rel_file(Profile, Dir, RelVsn)->
|
|
||||||
filename:join([Dir, RelVsn, Profile++".rel"]).
|
|
||||||
|
|
||||||
otp_apps() ->
|
otp_apps() ->
|
||||||
{ok, [Apps]} = file:consult("scripts/rel_otp_apps.eterm"),
|
{ok, [Apps]} = file:consult("scripts/rel_otp_apps.eterm"),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env escript
|
#!/usr/bin/env -S escript -c
|
||||||
|
|
||||||
main(_) ->
|
main(_) ->
|
||||||
OtpRelease = list_to_integer(erlang:system_info(otp_release)),
|
OtpRelease = list_to_integer(erlang:system_info(otp_release)),
|
||||||
|
|
Loading…
Reference in New Issue