mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Add support to build release with mix
This commit is contained in:
parent
72e069d9ec
commit
8ca12d4d23
1
.gitignore
vendored
1
.gitignore
vendored
@ -20,6 +20,7 @@
|
||||
/ejabberdctl
|
||||
/ejabberdctl.example
|
||||
/rel/ejabberd/
|
||||
/rel/overlays/
|
||||
/src/eldap_filter_yecc.erl
|
||||
/vars.config
|
||||
/dialyzer/
|
||||
|
75
mix.exs
75
mix.exs
@ -13,6 +13,7 @@ defmodule Ejabberd.Mixfile do
|
||||
erlc_paths: ["asn1", "src"],
|
||||
# Elixir tests are starting the part of ejabberd they need
|
||||
aliases: [test: "test --no-start"],
|
||||
releases: releases(),
|
||||
package: package(),
|
||||
deps: deps()]
|
||||
end
|
||||
@ -180,6 +181,80 @@ defmodule Ejabberd.Mixfile do
|
||||
end
|
||||
end
|
||||
|
||||
defp releases do
|
||||
maybe_tar = case Mix.env() do
|
||||
:prod -> [:tar]
|
||||
_ -> []
|
||||
end
|
||||
[
|
||||
ejabberd: [
|
||||
include_executables_for: [:unix],
|
||||
# applications: [runtime_tools: :permanent]
|
||||
steps: [©_extra_files/1, :assemble | maybe_tar]
|
||||
]
|
||||
]
|
||||
end
|
||||
|
||||
defp copy_extra_files(release) do
|
||||
assigns = [
|
||||
version: version(),
|
||||
rootdir: config(:rootdir),
|
||||
installuser: config(:installuser),
|
||||
libdir: config(:libdir),
|
||||
sysconfdir: config(:sysconfdir),
|
||||
localstatedir: config(:localstatedir),
|
||||
docdir: config(:docdir),
|
||||
erl: config(:erl),
|
||||
epmd: config(:epmd),
|
||||
bindir: Path.join([config(:release_dir), "releases", version()]),
|
||||
release_dir: config(:release_dir),
|
||||
erts_vsn: "erts-#{release.erts_version}"
|
||||
]
|
||||
ro = "rel/overlays"
|
||||
File.rm_rf(ro)
|
||||
|
||||
System.shell("sed -e 's|{{\\(\[_a-z\]*\\)}}|<%= @\\1 %>|g' ejabberdctl.template > ejabberdctl.example1")
|
||||
Mix.Generator.copy_template("ejabberdctl.example1", "ejabberdctl.example2", assigns)
|
||||
System.shell("sed -e 's|{{\\(\[_a-z\]*\\)}}|<%= @\\1 %>|g' ejabberdctl.example2 > ejabberdctl.example3")
|
||||
System.shell("sed -e 's|ERLANG_NODE=ejabberd@localhost|ERLANG_NODE=ejabberd|g' ejabberdctl.example3 > ejabberdctl.example4")
|
||||
System.shell("sed -e 's|INSTALLUSER=|ERL_OPTIONS=\"-setcookie \\$\\(cat \"\\${SCRIPT_DIR%/*}/releases/COOKIE\")\"\\nINSTALLUSER=|g' ejabberdctl.example4 > ejabberdctl.example5")
|
||||
Mix.Generator.copy_template("ejabberdctl.example5", "#{ro}/bin/ejabberdctl", assigns)
|
||||
File.chmod("#{ro}/bin/ejabberdctl", 0o755)
|
||||
|
||||
File.rm("ejabberdctl.example1")
|
||||
File.rm("ejabberdctl.example2")
|
||||
File.rm("ejabberdctl.example3")
|
||||
File.rm("ejabberdctl.example4")
|
||||
File.rm("ejabberdctl.example5")
|
||||
|
||||
suffix = case Mix.env() do
|
||||
:dev ->
|
||||
Mix.Generator.copy_file("test/ejabberd_SUITE_data/ca.pem", "#{ro}/etc/ejabberd/ca.pem")
|
||||
Mix.Generator.copy_file("test/ejabberd_SUITE_data/cert.pem", "#{ro}/etc/ejabberd/cert.pem")
|
||||
".example"
|
||||
_ -> ""
|
||||
end
|
||||
|
||||
Mix.Generator.copy_file("ejabberd.yml.example", "#{ro}/etc/ejabberd/ejabberd.yml#{suffix}")
|
||||
Mix.Generator.copy_file("ejabberdctl.cfg.example", "#{ro}/etc/ejabberd/ejabberdctl.cfg#{suffix}")
|
||||
Mix.Generator.copy_file("inetrc", "#{ro}/etc/ejabberd/inetrc")
|
||||
Mix.Generator.copy_template("rel/vm.args.mix", "#{ro}/etc/ejabberd/vm.args", assigns)
|
||||
|
||||
Enum.each(File.ls!("sql"),
|
||||
fn x ->
|
||||
Mix.Generator.copy_file("sql/#{x}", "#{ro}/lib/ejabberd-#{release.version}/priv/sql/#{x}")
|
||||
end)
|
||||
|
||||
Mix.Generator.create_directory("#{ro}/var/lib/ejabberd")
|
||||
|
||||
case Mix.env() do
|
||||
:dev -> System.shell("REL_DIR_TEMP=$PWD/rel/overlays/ rel/setup-dev.sh")
|
||||
_ -> :ok
|
||||
end
|
||||
|
||||
release
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
defmodule Mix.Tasks.Compile.Asn1 do
|
||||
|
14
rel/vm.args.mix
Normal file
14
rel/vm.args.mix
Normal file
@ -0,0 +1,14 @@
|
||||
## Customize flags given to the VM: https://erlang.org/doc/man/erl.html
|
||||
## -mode/-name/-sname/-setcookie are configured via env vars, do not set them here
|
||||
|
||||
-boot ../releases/<%= @version %>/start_clean
|
||||
-boot_var RELEASE_LIB ../lib
|
||||
|
||||
## Number of dirty schedulers doing IO work (file, sockets, and others)
|
||||
##+SDio 5
|
||||
|
||||
## Increase number of concurrent ports/sockets
|
||||
##+Q 65536
|
||||
|
||||
## Tweak GC to run more often
|
||||
##-env ERL_FULLSWEEP_AFTER 10
|
Loading…
Reference in New Issue
Block a user