From 279ab4bf7ae5baa51638710a8967d86b3d4cf5ae Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Mon, 11 Mar 2013 19:14:03 -0500 Subject: replace erl sript in copied erts with generated version --- src/rcl_prv_assembler.erl | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/rcl_prv_assembler.erl b/src/rcl_prv_assembler.erl index 63bd167..e85b293 100644 --- a/src/rcl_prv_assembler.erl +++ b/src/rcl_prv_assembler.erl @@ -285,6 +285,7 @@ include_erts(State, Release, OutputDir, RelDir) -> true -> ok = ec_file:mkdir_p(LocalErts), ok = ec_file:copy(ErtsDir, LocalErts, [recursive]), + ok = file:write_file(filename:join([LocalErts, "bin", "erl"]), erl_script(ErtsVersion)), make_boot_script(State, Release, OutputDir, RelDir) end; _ -> @@ -345,6 +346,22 @@ get_code_paths(Release, OutDir) -> rcl_app_info:vsn_as_string(App), "ebin"]) || App <- rcl_release:application_details(Release)]. +erl_script(ErtsVsn) -> + [<<"#!/bin/sh +set -e + +SCRIPT_DIR=`dirname $0` +ROOTDIR=`cd $SCRIPT_DIR/../../ && pwd` +BINDIR=$ROOTDIR/erts-">>, ErtsVsn, <<"/bin +EMU=beam +PROGNAME=`echo $0 | sed 's/.*\\///'` +export EMU +export ROOTDIR +export BINDIR +export PROGNAME +exec \"$BINDIR/erlexec\" ${1+\"$@\"} +">>]. + bin_file_contents(RelName, RelVsn, ErtsVsn, ErlOpts) -> [<<"#!/bin/sh @@ -358,14 +375,6 @@ ERTS_VSN=">>, ErtsVsn, <<" REL_DIR=$RELEASE_ROOT_DIR/releases/$REL_NAME-$REL_VSN ERL_OPTS=">>, ErlOpts, <<" -ERTS_DIR= -SYS_CONFIG= -ROOTDIR= - -ERTS_DIR= -SYS_CONFIG= -ROOTDIR= - find_erts_dir() { local erts_dir=$RELEASE_ROOT_DIR/erts-$ERTS_VSN if [ -d \"$erts_dir\" ]; then -- cgit v1.2.3 From 937c776c131c9e2e04aefc6b4f320e37b35115c2 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Mon, 11 Mar 2013 19:37:17 -0500 Subject: copy start_clean boot file along with erts --- Makefile | 2 +- README.md | 10 +++++++++- src/rcl_prv_assembler.erl | 7 +++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 96e14ae..5a5e097 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ update-deps: compile: $(REBAR) skip_deps=true compile -escript: compile +escript: deps $(REBAR) skip_deps=true escriptize doc: diff --git a/README.md b/README.md index 5407002..419bc50 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,19 @@ applications it will generate a release output. That output depends heavily on what plugins available and what options are defined, but usually it is simple a well configured release directory. - relcool -c relcool.config -l ~/my-dirs --relname foo --relvsn 0.0.1 --target-spec myapp --target-spec getopt>=0.5.1 -o output-dir + relcool -c relcool.config -l ~/my-dirs --relname foo --relvsn 0.0.1 --target-spec myapp --target-spec getopt>=0.5.1 -o output-dir The *release-specification-file* is optional but otherwise contains additional specification information for releases. +# BUILDING + +To build relcool and generate a standalone escript executable: + + $ make escript + +This creates the executable `relcool`. + # OPTIONS -r *STRING*, \--root *STRING* diff --git a/src/rcl_prv_assembler.erl b/src/rcl_prv_assembler.erl index e85b293..23a13bf 100644 --- a/src/rcl_prv_assembler.erl +++ b/src/rcl_prv_assembler.erl @@ -286,6 +286,13 @@ include_erts(State, Release, OutputDir, RelDir) -> ok = ec_file:mkdir_p(LocalErts), ok = ec_file:copy(ErtsDir, LocalErts, [recursive]), ok = file:write_file(filename:join([LocalErts, "bin", "erl"]), erl_script(ErtsVersion)), + case rcl_state:get(State, extended_start_script, false) of + true -> + ok = ec_file:copy(filename:join([Prefix, "bin", "start_clean.boot"]), + filename:join([OutputDir, "bin", "start_clean.boot"])); + false -> + ok + end, make_boot_script(State, Release, OutputDir, RelDir) end; _ -> -- cgit v1.2.3 From b69815402b3456699a47273a8c731850fb6b7871 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Tue, 12 Mar 2013 18:49:31 -0500 Subject: update do type spec for undefined config --- src/rcl_prv_config.erl | 4 ++-- src/relcool.erl | 6 +++--- test/rclt_release_SUITE.erl | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/rcl_prv_config.erl b/src/rcl_prv_config.erl index 60655b1..1027edf 100644 --- a/src/rcl_prv_config.erl +++ b/src/rcl_prv_config.erl @@ -54,8 +54,8 @@ do(State) -> -spec format_error(Reason::term()) -> iolist(). format_error({consult, ConfigFile, Reason}) -> - io_lib:format("Unable to read file ~s: ~s", [ConfigFile, - file:format_error(Reason)]); + io_lib:format("Unable to read file ~s: ~s", [ConfigFile, + file:format_error(Reason)]); format_error({invalid_term, Term}) -> io_lib:format("Invalid term in config file: ~p", [Term]). diff --git a/src/relcool.erl b/src/relcool.erl index c8c0cde..7750efa 100644 --- a/src/relcool.erl +++ b/src/relcool.erl @@ -70,7 +70,7 @@ main(Args) -> %% @param OutputDir - The directory where the release should be built to %% @param Configs - The list of config files for the system -spec do(atom(), string(), [goal()], [file:name()], rcl_log:log_level(), - [file:name()], file:name()) -> + [file:name()], file:name() | undefined) -> ok | error() | {ok, rcl_state:t()}. do(RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Config) -> {ok, Cwd} = file:get_cwd(), @@ -87,7 +87,7 @@ do(RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Config) -> %% @param OutputDir - The directory where the release should be built to %% @param Configs - The list of config files for the system -spec do(file:name(), atom(), string(), [goal()], [file:name()], - rcl_log:log_level(), [file:name()], file:name()) -> + rcl_log:log_level(), [file:name()], file:name() | undefined) -> ok | error() | {ok, rcl_state:t()}. do(RootDir, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Configs) -> do(RootDir, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, [], Configs). @@ -104,7 +104,7 @@ do(RootDir, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Configs) -> %% @param Overrides - A list of overrides for the system %% @param Configs - The list of config files for the system -spec do(file:name(), atom(), string(), [goal()], [file:name()], - rcl_log:log_level(), [file:name()], [{atom(), file:name()}], file:name()) -> + rcl_log:log_level(), [file:name()], [{atom(), file:name()}], file:name() | undefined) -> ok | error() | {ok, rcl_state:t()}. do(RootDir, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Overrides, Config) -> State = rcl_state:new([{relname, RelName}, diff --git a/test/rclt_release_SUITE.erl b/test/rclt_release_SUITE.erl index 1104303..dd03b9f 100644 --- a/test/rclt_release_SUITE.erl +++ b/test/rclt_release_SUITE.erl @@ -244,7 +244,8 @@ make_implicit_config_release(Config) -> ok = file:set_cwd(FooRoot), {ok, FooRoot} = file:get_cwd(), {ok, State} = relcool:do(undefined, undefined, [], [LibDir1], 2, - OutputDir, []), + OutputDir, undefined), + [{{foo, "0.0.1"}, Release}] = ec_dictionary:to_list(rcl_state:releases(State)), ?assert(ec_file:exists(OutputDir)), AppSpecs = rcl_release:applications(Release), @@ -294,7 +295,7 @@ make_rerun_overridden_release(Config) -> OutputDir, [{OverrideAppName, OverrideAppDir}], ConfigFile), - %% Now we run it again to see if it failse. + %% Now we run it again to see if it fails. {ok, State} = relcool:do(Cwd,undefined, undefined, [], [LibDir1], 2, OutputDir, [{OverrideAppName, OverrideAppDir}], ConfigFile), -- cgit v1.2.3