|
|
@@ -93,7 +93,7 @@ defmodule EMQXUmbrella.MixProject do
|
|
|
|
|
|
defp releases() do
|
|
|
[
|
|
|
- emqx: [
|
|
|
+ emqx_base: [
|
|
|
applications: [
|
|
|
logger: :permanent,
|
|
|
esasl: :load,
|
|
|
@@ -202,44 +202,65 @@ defmodule EMQXUmbrella.MixProject do
|
|
|
force: overwrite?
|
|
|
)
|
|
|
|
|
|
+ # FIXME: change variables by package type???
|
|
|
+ assigns = [
|
|
|
+ platform_bin_dir: "bin",
|
|
|
+ platform_data_dir: "data",
|
|
|
+ platform_etc_dir: "etc",
|
|
|
+ platform_lib_dir: "lib",
|
|
|
+ platform_log_dir: "log",
|
|
|
+ platform_plugins_dir: "plugins",
|
|
|
+ runner_root_dir: "$(cd $(dirname $(readlink $0 || echo $0))/..; pwd -P)",
|
|
|
+ runner_bin_dir: "$RUNNER_ROOT_DIR/bin",
|
|
|
+ runner_etc_dir: "$RUNNER_ROOT_DIR/etc",
|
|
|
+ runner_lib_dir: "$RUNNER_ROOT_DIR/lib",
|
|
|
+ runner_log_dir: "$RUNNER_ROOT_DIR/log",
|
|
|
+ runner_data_dir: "$RUNNER_ROOT_DIR/data",
|
|
|
+ runner_user: "",
|
|
|
+ release_version: release.version,
|
|
|
+ erts_vsn: release.erts_version,
|
|
|
+ # FIXME: this is empty in `make emqx` ???
|
|
|
+ erl_opts: "",
|
|
|
+ # FIXME: varies with edge/community/enterprise
|
|
|
+ emqx_description: "EMQ X Community Edition"
|
|
|
+ ]
|
|
|
+
|
|
|
# This is generated by `scripts/merge-config.escript` or `make
|
|
|
# conf-segs`. So, this should be run before the release.
|
|
|
# TODO: run as a "compiler" step???
|
|
|
-
|
|
|
- conf_rebar_template = File.read!("apps/emqx_conf/etc/emqx.conf.all")
|
|
|
- # we must not consider surrounding space in the template var name
|
|
|
- # because some help strings contain informative variables that
|
|
|
- # should not be interpolated, and those have no spaces.
|
|
|
- conf_eex_template =
|
|
|
- Regex.replace(
|
|
|
- ~r/\{\{ ([a-zA-Z0-9_]+) \}\}/,
|
|
|
- conf_rebar_template,
|
|
|
- "<%= \\g{1} %>"
|
|
|
- )
|
|
|
-
|
|
|
- # FIXME: change variables by package type???
|
|
|
conf_rendered =
|
|
|
- EEx.eval_string(conf_eex_template,
|
|
|
- platform_bin_dir: "bin",
|
|
|
- platform_data_dir: "data",
|
|
|
- platform_etc_dir: "etc",
|
|
|
- platform_lib_dir: "lib",
|
|
|
- platform_log_dir: "log",
|
|
|
- platform_plugins_dir: "plugins",
|
|
|
- runner_root_dir: "$(cd $(dirname $(readlink $0 || echo $0))/..; pwd -P)",
|
|
|
- runner_bin_dir: "$RUNNER_ROOT_DIR/bin",
|
|
|
- runner_etc_dir: "$RUNNER_ROOT_DIR/etc",
|
|
|
- runner_lib_dir: "$RUNNER_ROOT_DIR/lib",
|
|
|
- runner_log_dir: "$RUNNER_ROOT_DIR/log",
|
|
|
- runner_data_dir: "$RUNNER_ROOT_DIR/data",
|
|
|
- runner_user: ""
|
|
|
- )
|
|
|
+ File.read!("apps/emqx_conf/etc/emqx.conf.all")
|
|
|
+ |> from_rebar_to_eex_template()
|
|
|
+ |> EEx.eval_string(assigns)
|
|
|
|
|
|
File.write!(
|
|
|
Path.join(etc, "emqx.conf"),
|
|
|
conf_rendered
|
|
|
)
|
|
|
|
|
|
+ vars_rendered =
|
|
|
+ File.read!("data/emqx_vars")
|
|
|
+ |> from_rebar_to_eex_template()
|
|
|
+ |> EEx.eval_string(assigns)
|
|
|
+
|
|
|
+ File.write!(
|
|
|
+ Path.join([release.path, "releases", "emqx_vars"]),
|
|
|
+ vars_rendered
|
|
|
+ )
|
|
|
+
|
|
|
+ Enum.each(
|
|
|
+ [
|
|
|
+ "common_defs.sh",
|
|
|
+ "common_defs2.sh",
|
|
|
+ "common_functions.sh",
|
|
|
+ ],
|
|
|
+ &Mix.Generator.copy_file(
|
|
|
+ "bin/#{&1}",
|
|
|
+ Path.join(bin, &1),
|
|
|
+ force: overwrite?
|
|
|
+ )
|
|
|
+ )
|
|
|
+
|
|
|
release
|
|
|
end
|
|
|
|
|
|
@@ -364,4 +385,15 @@ defmodule EMQXUmbrella.MixProject do
|
|
|
|
|
|
String.downcase(opt) != "false"
|
|
|
end
|
|
|
+
|
|
|
+ defp from_rebar_to_eex_template(str) do
|
|
|
+ # we must not consider surrounding space in the template var name
|
|
|
+ # because some help strings contain informative variables that
|
|
|
+ # should not be interpolated, and those have no spaces.
|
|
|
+ Regex.replace(
|
|
|
+ ~r/\{\{ ([a-zA-Z0-9_]+) \}\}/,
|
|
|
+ str,
|
|
|
+ "<%= \\g{1} %>"
|
|
|
+ )
|
|
|
+ end
|
|
|
end
|