[erlang-questions] packaging erlang application for ubuntu
Håkan Mattsson
hakan@REDACTED
Thu Sep 24 14:54:00 CEST 2009
On Mon, Sep 21, 2009 at 2:12 AM, Pablo Platt <pablo.platt@REDACTED> wrote:
> Hi,
>
> I have an erlang application that I want to distribute to clients using ubuntu.
> I don't want to include the source code, only the compiled beam files.
> The installation needs to be automatic, install all the dependencies and
> create a boot script that will run the application as daemon on startup.
>
> Is reltools fits this task?
> Does an application release includes the erlang runtime so copying this folder
> will be sufficient to run the application?
Yes, you can use reltool for this. As you can see below, the standalone target
system is self contained with an escript and a complete runtime system. The
standalone system is relocatable and can be moved to a new location without
the need to run any installation command.
If you use the 'rel' parameter you can specify which applications you
want to start
without bothering about their version numbers. If you want to have a
target system
that a system with a couple of applications you can use the 'rel'
parameter like
this to generate a customized .rel file:
12 > reltool:get_rel([{sys, [{rel, "start_clean", "1.0", [kernel,
stdlib, sasl, mnesia]}]}], "start_clean").
{ok,{release,{"start_clean","1.0"},
{erts,"5.7.3"},
[{kernel,"2.13.3"},{stdlib,"1.16.3"},{sasl,"2.1.7"},{mnesia,"4.4.11"}]}}
Here I have an example of how you can generate a small standalone target system
with reltool. Eflex is a small graphical tool which is started with an
escript that runs in
the background with the -detached flag (see the attached escript). The
escript is
invoked with ".../eflex2/bin/eflex".
To start with I configure a simple standalone target system (commands 1..4).
In the printouts from the shell you can see which files that the target system
will consist of.
Then I add a few configuration parameters to strip away stuff that I do not use.
Such as a few applications (hipe, erts, crypto, syntax_tools) and some
executables
(epmd, heart, beam).
In the generated target system the applications are packaged in
archive files. But
as wx has a driver, its priv directory resides outside the archive.
/Håkan
Erlang R13B02 (erts-5.7.3) [64-bit] [smp:4:4] [rq:4] [async-threads:0]
[kernel-p oll:false]
Eshell V5.7.3 (abort with ^G)
1> Sys = {sys, [{lib_dirs, ["/home/hakan/erl_libs"]},
{escript, "/home/hakan/bin/eflex", [{incl_cond, include}]},
{profile, standalone}]}, ok.
ok
2> file:make_dir("eflex").
ok
3> reltool:create_target([Sys], "eflex").
ok.
4> io:format("~s\n", [os:cmd("find eflex")]).
eflex
eflex/bin
eflex/bin/erl
eflex/bin/epmd
eflex/bin/eflex.escript
eflex/bin/eflex
eflex/bin/start.boot
eflex/bin/start_clean.boot
eflex/lib
eflex/lib/hipe-3.7.3.ez
eflex/lib/kernel-2.13.3.ez
eflex/lib/crypto-1.6.1.ez
eflex/lib/xmerl-1.2.1.ez
eflex/lib/eflex-0.1.ez
eflex/lib/erts-5.7.3.ez
eflex/lib/stdlib-1.16.3.ez
eflex/lib/compiler-4.6.3.ez
eflex/lib/crypto-1.6.1
eflex/lib/crypto-1.6.1/priv
eflex/lib/crypto-1.6.1/priv/lib
eflex/lib/crypto-1.6.1/priv/lib/crypto_drv.so
eflex/lib/crypto-1.6.1/priv/obj
eflex/lib/crypto-1.6.1/priv/obj/Makefile
eflex/lib/crypto-1.6.1/priv/obj/crypto_drv.o
eflex/lib/wx-0.98.3.ez
eflex/lib/syntax_tools-1.6.3.ez
eflex/lib/wx-0.98.3
eflex/lib/wx-0.98.3/priv
eflex/lib/wx-0.98.3/priv/x86_64-unknown-linux-gnu
eflex/lib/wx-0.98.3/priv/x86_64-unknown-linux-gnu/wxe_driver.so
eflex/lib/wx-0.98.3/priv/erlang-logo32.png
eflex/lib/wx-0.98.3/priv/erlang-logo64.png
eflex/erts-5.7.3
eflex/erts-5.7.3/bin
eflex/erts-5.7.3/bin/erl
eflex/erts-5.7.3/bin/beam
eflex/erts-5.7.3/bin/epmd
eflex/erts-5.7.3/bin/heart
eflex/erts-5.7.3/bin/beam.smp
eflex/erts-5.7.3/bin/erlexec
eflex/erts-5.7.3/bin/inet_gethost
eflex/erts-5.7.3/bin/child_setup
ok
5> Sys2 = {sys, [{lib_dirs, ["/home/hakan/erl_libs"]},
{escript, "/home/hakan/bin/eflex", [{incl_cond, include}]},
{app, hipe, [{incl_cond, exclude}]},
{app, erts, [{incl_cond, exclude}]},
{app, crypto, [{incl_cond, exclude}]},
{app, syntax_tools, [{incl_cond, exclude}]},
{profile, standalone},
{excl_sys_filters,{add, ["^bin/(epmd|start.boot)(|\\.exe)$",
"^erts.*/bin/(beam|epmd|heart)(|\\.exe)$"]}}]}, ok.
ok
6> file:make_dir("eflex2").
ok
7> reltool:create_target([Sys2], "eflex2").
ok
8> io:format("~s\n", [os:cmd("find eflex2")]).
eflex2
eflex2/bin
eflex2/bin/erl
eflex2/bin/eflex.escript
eflex2/bin/eflex
eflex2/bin/start_clean.boot
eflex2/lib
eflex2/lib/kernel-2.13.3.ez
eflex2/lib/xmerl-1.2.1.ez
eflex2/lib/eflex-0.1.ez
eflex2/lib/stdlib-1.16.3.ez
eflex2/lib/compiler-4.6.3.ez
eflex2/lib/wx-0.98.3.ez
eflex2/lib/wx-0.98.3
eflex2/lib/wx-0.98.3/priv
eflex2/lib/wx-0.98.3/priv/x86_64-unknown-linux-gnu
eflex2/lib/wx-0.98.3/priv/x86_64-unknown-linux-gnu/wxe_driver.so
eflex2/lib/wx-0.98.3/priv/erlang-logo32.png
eflex2/lib/wx-0.98.3/priv/erlang-logo64.png
eflex2/erts-5.7.3
eflex2/erts-5.7.3/bin
eflex2/erts-5.7.3/bin/erl
eflex2/erts-5.7.3/bin/beam.smp
eflex2/erts-5.7.3/bin/erlexec
eflex2/erts-5.7.3/bin/inet_gethost
eflex2/erts-5.7.3/bin/child_setup
ok
9> reltool:get_target_spec([Sys2]).
{ok,[{create_dir,"bin",
[{copy_file,"eflex.escript","/home/hakan/bin/eflex"},
{copy_file,"eflex","erts-5.7.3/bin/escript"},
{copy_file,"erl","erts-5.7.3/bin/dyn_erl"},
{write_file,"start_clean.boot",
<<131,104,3,100,0,6,115,99,114,105,112,116,104,2,107,0,
...>>}]},
{create_dir,"erts-5.7.3",
[{create_dir,"bin",
[{copy_file,"child_setup"},
{copy_file,"inet_gethost"},
{copy_file,"erlexec"},
{copy_file,"beam.smp"},
{copy_file,"erl","erts-5.7.3/bin/dyn_erl"}]}]},
{create_dir,"lib",
[{archive,"compiler-4.6.3.ez",[],
[{create_dir,"compiler-4.6.3",
[{create_dir,"ebin",
[{copy_file,"compiler.app"},
{copy_file,"beam_asm.beam"},
{copy_file,"beam_block.beam"},
{copy_file,"beam_bool.beam"},
{copy_file,"beam_bsm.beam"},
{copy_file,[...]},
{copy_file,...},
{...}|...]}]}]},
{archive,"eflex-0.1.ez",[],
[{create_dir,"eflex-0.1","/home/hakan/erl_libs/eflex",
[{create_dir,"ebin",
[{copy_file,"eflex.app"},
{copy_file,"eflex.beam"},
{copy_file,"eflex_break.beam"},
{copy_file,[...]},
{copy_file,...},
{...}|...]}]}]},
{archive,"kernel-2.13.3.ez",[],
[{create_dir,"kernel-2.13.3",
[{create_dir,"ebin",
[{copy_file,"kernel.app"},
{copy_file,"application.beam"},
{copy_file,"application_controller.beam"},
{copy_file,[...]},
{copy_file,...},
{...}|...]}]}]},
{archive,"stdlib-1.16.3.ez",[],
[{create_dir,"stdlib-1.16.3",
[{create_dir,"ebin",
[{copy_file,"stdlib.app"},
{copy_file,"array.beam"},
{copy_file,[...]},
{copy_file,...},
{...}|...]}]}]},
{archive,"wx-0.98.3.ez",[],
[{create_dir,"wx-0.98.3",
[{create_dir,"ebin",
[{copy_file,"gl.beam"},
{copy_file,[...]},
{copy_file,...},
{...}|...]}]}]},
{create_dir,"wx-0.98.3",
[{create_dir,"priv",
[{copy_file,"erlang-logo64.png"},
{copy_file,"erlang-logo32.png"},
{create_dir,"x86_64-unknown-linux-gnu",
[{copy_file,...}]}]}]},
{archive,"xmerl-1.2.1.ez",[],
[{create_dir,"xmerl-1.2.1",
[{create_dir,"ebin",[{copy_file,...},{...}|...]}]}]}]}]}
10>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: eflex
Type: application/octet-stream
Size: 792 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090924/a8b2a8dd/attachment.obj>
More information about the erlang-questions
mailing list