reltool の sample をそのまま写経してみた

とりあえず reltool をなぞってみました。良くできてますねこれほんと。escript の example を見てみたら特に変なことしてなかったので、escript はスルーしてみましたが、無事出来ました。理解するのが面倒な仕組みですね、ほんと。

% erl
Erlang R13B03 (erts-5.7.4) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [kernel-poll:false]

Eshell V5.7.4  (abort with ^G)
1> Config = {sys, [{app, inets, [{incl_cond, include}]}, {app, mnesia, [{incl_cond, exclude}]}, {app, ssl, [{incl_cond, exclude}]}, {app, runtime_tools, [{incl_cond, exclude}]}, {app, syntax_tools, [{incl_cond, exclude}]}]}.
{sys,[{app,inets,[{incl_cond,include}]},
      {app,mnesia,[{incl_cond,exclude}]},
      {app,ssl,[{incl_cond,exclude}]},
      {app,runtime_tools,[{incl_cond,exclude}]},
      {app,syntax_tools,[{incl_cond,exclude}]}]}
3> {ok, Spect} = reltool:get_target_spec([Config]).
{ok,[{create_dir,"releases",
         [{write_file,"start_erl.data","5.7.4 1.0\n"},
          {create_dir,"1.0",
              [{write_file,"start_clean.rel",
                   [37,37,32,114,101,108,32,103,101,110,101,114,97,116|...]},
               {write_file,"start_clean.script",
                   [37,37,32,115,99,114,105,112,116,32,103,101,110|...]},
               {write_file,"start_clean.boot",
                   <<131,104,3,100,0,6,115,99,114,105,112,116,...>>},
               {write_file,"start_sasl.rel",
                   [37,37,32,114,101,108,32,103,101,110,101|...]},
               {write_file,"start_sasl.script",
                   [37,37,32,115,99,114,105,112,116,32|...]},
               {write_file,"start_sasl.boot",
                   <<131,104,3,100,0,6,115,99,114,...>>}]}]},
     {create_dir,"bin",
         [{copy_file,"typer","erts-5.7.4/bin/typer"},
          {copy_file,"to_erl","erts-5.7.4/bin/to_erl"},
          {copy_file,"start","erts-5.7.4/bin/start"},
          {copy_file,"run_erl","erts-5.7.4/bin/run_erl"},
          {copy_file,"escript","erts-5.7.4/bin/escript"},
          {copy_file,"erlc","erts-5.7.4/bin/erlc"},
          {copy_file,"erl","erts-5.7.4/bin/dyn_erl"},
          {copy_file,"epmd","erts-5.7.4/bin/epmd"},
          {copy_file,"dialyzer","erts-5.7.4/bin/dialyzer"},
          {write_file,"start_clean.boot",
              <<131,104,3,100,0,6,115,99,114,...>>},
          {write_file,"start_sasl.boot",
              <<131,104,3,100,0,6,115,99,...>>},
          {write_file,"start.boot",<<131,104,3,100,0,6,115,...>>}]},
     {create_dir,"usr",
         [{create_dir,"lib",
              [{copy_file,"liberts_r.a"},{copy_file,"liberts.a"}]},
          {create_dir,"include",
              [{create_dir,"obsolete",[{copy_file,"driver.h"}]},
               {copy_file,"erl_nif_api_funcs.h"},
               {copy_file,"erl_nif.h"},
               {copy_file,"erl_memory_trace_parser.h"},
               {copy_file,"erl_int_sizes_config.h"},
               {copy_file,"erl_fixed_size_int_types.h"},
               {copy_file,"erl_driver.h"},
               {copy_file,"driver_int.h"}]}]},
     {create_dir,"misc",
         [{copy_file,"makewhatis"},{copy_file,"format_man_pages"}]},
     {copy_file,"Install"},
     {create_dir,"erts-5.7.4",
         [{create_dir,"src",[{copy_file,"setuid_socket_wrap.c"}]},
          {create_dir,"man",[]},
          {create_dir,"lib",
              [{copy_file,"liberts_r.a"},
               {copy_file,"liberts.a"},
               {create_dir,"internal",
                   [{copy_file,"README"},
                    {copy_file,"libethread.a"},
                    {copy_file,"liberts_internal_r.a"},
                    {copy_file,[...]}]}]},
          {create_dir,"include",
              [{create_dir,"internal",
                   [{create_dir,"x86_64",[{copy_file,[...]}]},
                    {create_dir,"tile",[{copy_file,...},{...}]},
                    {create_dir,"sparc64",[{...}]},
                    {create_dir,"sparc32",[...]},
                    {copy_file,[...]},
                    {create_dir,...},
                    {...}|...]},
               {copy_file,"erl_nif_api_funcs.h"},
               {copy_file,"erl_nif.h"},
               {copy_file,"erl_memory_trace_parser.h"},
               {copy_file,"erl_int_sizes_config.h"},
               {copy_file,"erl_fixed_size_int_types.h"},
               {copy_file,"erl_driver.h"},
               {copy_file,"driver_int.h"}]},
          {create_dir,"doc",[]},
          {create_dir,"bin",
              [{copy_file,"typer"},
               {copy_file,"to_erl"},
               {copy_file,"start"},
               {copy_file,"run_erl"},
               {copy_file,"inet_gethost"},
               {copy_file,"heart"},
               {copy_file,[...]},
               {copy_file,...},
               {...}|...]}]},
     {create_dir,"lib",
         [{archive,"compiler-4.6.4.ez",[],
              [{create_dir,"compiler-4.6.4",
                   [{create_dir,"src",
                        [{copy_file,"v3_life.hrl"},
                         {copy_file,[...]},
                         {copy_file,...},
                         {...}|...]},
                    {create_dir,"ebin",
                        [{copy_file,[...]},{copy_file,...},{...}|...]}]}]},
          {archive,"crypto-1.6.3.ez",[],
              [{create_dir,"crypto-1.6.3",
                   [{create_dir,"src",
                        [{copy_file,[...]},{copy_file,...},{...}|...]},
                    {create_dir,"ebin",[{copy_file,...},{...}|...]}]}]},
          {create_dir,"crypto-1.6.3",
              [{create_dir,"priv",
                   [{create_dir,"obj",[{copy_file,[...]},{copy_file,...}]},
                    {create_dir,"lib",[{copy_file,...}]}]}]},
          {archive,"erts-5.7.4.ez",[],
              [{create_dir,"erts-5.7.4",
                   [{create_dir,"src",[{...}|...]},
                    {create_dir,"ebin",[...]}]}]},
          {archive,"hipe-3.7.4.ez",[],
              [{create_dir,"hipe-3.7.4",
                   [{copy_file,"vsn.mk"},
                    {create_dir,[...],...},
                    {create_dir,...},
                    {...}|...]}]},
          {archive,"inets-5.2.ez",[],
              [{create_dir,"inets-5.2",
                   [{create_dir,[...],...},{create_dir,...},{...}]}]},
          {create_dir,"inets-5.2",
              [{create_dir,"priv",[{create_dir,[...],...}]}]},
          {archive,"kernel-2.13.4.ez",[],
              [{create_dir,"kernel-2.13.4",[{...}|...]}]},
          {create_dir,"kernel-2.13.4",
              [{create_dir,"include",[{...}|...]}]},
          {archive,"stdlib-1.16.4.ez",[],[{create_dir,[...],...}]},
          {create_dir,"stdlib-1.16.4",[{create_dir,[...],...}]}]}]}
5> TargetDir = "my_target_dir".
"my_target_dir"
6> reltool:eval_target_spec(Spec, code:root_dir(), TargetDir).
{error,"/private/tmp/my_target_dir: no such file or directory"}
7> file:make_dir(TargetDir).
ok
8> reltool:eval_target_spec(Spec, code:root_dir(), TargetDir).
ok
9> file:list_dir(TargetDir).
{ok,["usr","releases","misc","lib","Install","erts-5.7.4",
     "bin"]}
10> file:list_dir(filename:join([TargetDir, "lib"])).
{ok,["stdlib-1.16.4.ez","stdlib-1.16.4","kernel-2.13.4.ez",
     "kernel-2.13.4","inets-5.2.ez","inets-5.2","hipe-3.7.4.ez",
     "erts-5.7.4.ez","crypto-1.6.3.ez","crypto-1.6.3",
     "compiler-4.6.4.ez"]}