소스 검색

chore(mix): copy more files required by relup

Thales Macedo Garitezi 4 년 전
부모
커밋
360a00622b
2개의 변경된 파일37개의 추가작업 그리고 23개의 파일을 삭제
  1. 3 2
      bin/install_upgrade.escript
  2. 34 21
      mix.exs

+ 3 - 2
bin/install_upgrade.escript

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

+ 34 - 21
mix.exs

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