chore(mix): copy more files required by relup

This commit is contained in:
Thales Macedo Garitezi 2021-12-27 16:07:38 -03:00
parent 432faf7bd2
commit 360a00622b
No known key found for this signature in database
GPG Key ID: DD279F8152A9B6DD
2 changed files with 37 additions and 23 deletions

View File

@ -308,8 +308,9 @@ permafy(TargetNode, RelName, Vsn) ->
make_permanent, [Vsn], ?TIMEOUT), make_permanent, [Vsn], ?TIMEOUT),
?INFO("Made release permanent: ~p", [Vsn]), ?INFO("Made release permanent: ~p", [Vsn]),
%% upgrade/downgrade the scripts by replacing them %% upgrade/downgrade the scripts by replacing them
Scripts = [RelNameStr, RelNameStr++"_ctl", "cuttlefish", "nodetool", Scripts = [RelNameStr, RelNameStr ++ "_ctl",
"install_upgrade.escript"], "common_defs.sh", "common_defs2.sh", "common_functions.sh",
"nodetool", "install_upgrade.escript"],
[{ok, _} = file:copy(filename:join(["bin", File++"-"++Vsn]), [{ok, _} = file:copy(filename:join(["bin", File++"-"++Vsn]),
filename:join(["bin", File])) filename:join(["bin", File]))
|| File <- Scripts], || File <- Scripts],

55
mix.exs
View File

@ -286,28 +286,33 @@ defmodule EMQXUmbrella.MixProject do
vm_args_rendered vm_args_rendered
) )
Enum.each( for name <- [
[ "emqx",
"emqx", "emqx_ctl",
"emqx_ctl", "common_defs.sh",
"common_defs.sh", "common_defs2.sh",
"common_defs2.sh", "common_functions.sh"
"common_functions.sh" ] do
], Mix.Generator.copy_file(
&Mix.Generator.copy_file( "bin/#{name}",
"bin/#{&1}", Path.join(bin, name),
Path.join(bin, &1),
force: overwrite? force: overwrite?
) )
)
Enum.each( # Files with the version appended are expected by the release
[ # upgrade script `install_upgrade.escript`
"emqx", Mix.Generator.copy_file(
"emqx_ctl" Path.join(bin, name),
], Path.join(bin, name <> "-#{release.version}"),
&File.chmod!(Path.join(bin, &1), 0o755) force: overwrite?
) )
end
for base_name <- ["emqx", "emqx_ctl"],
suffix <- ["", "-#{release.version}"] do
name = base_name <> suffix
File.chmod!(Path.join(bin, name), 0o755)
end
release release
end end
@ -354,11 +359,19 @@ defmodule EMQXUmbrella.MixProject do
|> File.read!() |> File.read!()
|> String.split("\n", parts: 2) |> String.split("\n", parts: 2)
path = Path.join([release.path, "bin", escript_name])
# the elixir version of escript + start.boot required the boot_var # the elixir version of escript + start.boot required the boot_var
# RELEASE_LIB to be defined. # RELEASE_LIB to be defined.
boot_var = "%%!-boot_var RELEASE_LIB $RUNNER_ROOT_DIR/lib" boot_var = "%%!-boot_var RELEASE_LIB $RUNNER_ROOT_DIR/lib"
File.write!(path, [shebang, "\n", boot_var, "\n", rest])
# Files with the version appended are expected by the release
# upgrade script `install_upgrade.escript`
Enum.each(
[escript_name, escript_name <> "-" <> release.version],
fn name ->
path = Path.join([release.path, "bin", name])
File.write!(path, [shebang, "\n", boot_var, "\n", rest])
end
)
release release
end end