diff options
author | joewilliams <joe@joetify.com> | 2011-09-20 09:44:41 -0700 |
---|---|---|
committer | joewilliams <joe@joetify.com> | 2011-09-20 09:44:41 -0700 |
commit | cb5056b2e362aa0b1eb0ccfc6009613426682ed5 (patch) | |
tree | a1a7c429923bd139b27a64d4acdda069d92d38cc /src | |
parent | 5998c6c721b22a9413c66f2b2b034f9d5bd5bb3d (diff) |
Get rid of app.config
app.config has been a long standing erroneous file in rebar. Erlang/OTP
documentation suggests a sys.config file instead. This file is stored in
the releases/VSN directory. This does a few things but most importantly
it ensures your config (contained in the application environment)
survives a hot upgrade. It also has the advantage of allowing the
configuration of the application to be versioned along side the
application code. This patch flips rebar to use sys.config rather than
app.config.
Additionally it makes this flip to vm.args as well, making them
versioned just like sys.config.
This patch also includes runner script changes to support the old
etc/app.config config file location and support for Windows.
Thanks to mokele for the initial work and kick in the pants to make this
finially happen.
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_rel_utils.erl | 15 | ||||
-rw-r--r-- | src/rebar_reltool.erl | 23 | ||||
-rw-r--r-- | src/rebar_upgrade.erl | 17 |
3 files changed, 40 insertions, 15 deletions
diff --git a/src/rebar_rel_utils.erl b/src/rebar_rel_utils.erl index bdf58d3..d9a1fc6 100644 --- a/src/rebar_rel_utils.erl +++ b/src/rebar_rel_utils.erl @@ -55,11 +55,16 @@ is_rel_dir(Dir) -> end. %% Get release name and version from a reltool.config -get_reltool_release_info(ReltoolConfig) -> - %% expect the first rel in the proplist to be the one you want - {sys, Config} = get_sys_tuple(ReltoolConfig), +get_reltool_release_info([{sys, Config}| _]) -> {rel, Name, Ver, _} = proplists:lookup(rel, Config), - {Name, Ver}. + {Name, Ver}; +get_reltool_release_info(ReltoolFile) when is_list(ReltoolFile) -> + case file:consult(ReltoolFile) of + {ok, ReltoolConfig} -> + get_reltool_release_info(ReltoolConfig); + _ -> + ?ABORT("Failed to parse ~s~n", [ReltoolFile]) + end. %% Get release name and version from a rel file get_rel_release_info(RelFile) -> @@ -170,4 +175,4 @@ make_proplist([H|T], Acc) -> Ver = element(2, H), make_proplist(T, [{App,Ver}|Acc]); make_proplist([], Acc) -> - Acc. + Acc.
\ No newline at end of file diff --git a/src/rebar_reltool.erl b/src/rebar_reltool.erl index b1b4a4c..363b384 100644 --- a/src/rebar_reltool.erl +++ b/src/rebar_reltool.erl @@ -173,10 +173,17 @@ run_reltool(Server, _Config, ReltoolConfig) -> [Reason]) end, + {BootRelName, BootRelVsn} = + rebar_rel_utils:get_reltool_release_info(ReltoolConfig), + + ok = create_RELEASES(TargetDir, BootRelName, BootRelVsn), + %% Initialize overlay vars with some basics %% (that can get overwritten) - OverlayVars0 = dict:from_list([{erts_vsn, "erts-" ++ erlang:system_info(version)}, - {target_dir, TargetDir}]), + OverlayVars0 = + dict:from_list([{erts_vsn, "erts-" ++ erlang:system_info(version)}, + {rel_vsn, BootRelVsn}, + {target_dir, TargetDir}]), %% Load up any variables specified by overlay_vars OverlayVars1 = overlay_vars(OverlayVars0, ReltoolConfig), @@ -312,3 +319,15 @@ execute_overlay([Other | _Rest], _Vars, _BaseDir, _TargetDir) -> apply_file_info(InFile, OutFile) -> {ok, FileInfo} = file:read_file_info(InFile), ok = file:write_file_info(OutFile, FileInfo). + +create_RELEASES(TargetDir, RelName, RelVsn) -> + ReleasesDir = filename:join(TargetDir, "releases"), + case release_handler:create_RELEASES(TargetDir, ReleasesDir, + filename:join([ReleasesDir, RelVsn, RelName ++ ".rel"]), + filename:join(TargetDir, "lib")) of + ok -> + ok; + {error, Reason} -> + ?ABORT("Failed to create RELEASES file: ~p\n", + [Reason]) + end.
\ No newline at end of file diff --git a/src/rebar_upgrade.erl b/src/rebar_upgrade.erl index 009715e..0cecaab 100644 --- a/src/rebar_upgrade.erl +++ b/src/rebar_upgrade.erl @@ -32,6 +32,8 @@ -export(['generate-upgrade'/2]). +-define(TMP, "_tmp"). + %% ==================================================================== %% Public API %% ==================================================================== @@ -141,22 +143,21 @@ run_systools(NewVer, Name) -> end. boot_files(TargetDir, Ver, Name) -> - Tmp = "_tmp", - ok = file:make_dir(filename:join([".", Tmp])), - ok = file:make_dir(filename:join([".", Tmp, "releases"])), - ok = file:make_dir(filename:join([".", Tmp, "releases", Ver])), + ok = file:make_dir(filename:join([".", ?TMP])), + ok = file:make_dir(filename:join([".", ?TMP, "releases"])), + ok = file:make_dir(filename:join([".", ?TMP, "releases", Ver])), ok = file:make_symlink( filename:join(["start.boot"]), - filename:join([".", Tmp, "releases", Ver, Name ++ ".boot"])), + filename:join([".", ?TMP, "releases", Ver, Name ++ ".boot"])), {ok, _} = file:copy( filename:join([TargetDir, "releases", Ver, "start_clean.boot"]), - filename:join([".", Tmp, "releases", Ver, "start_clean.boot"])). + filename:join([".", ?TMP, "releases", Ver, "start_clean.boot"])). make_tar(NameVer) -> Filename = NameVer ++ ".tar.gz", {ok, Cwd} = file:get_cwd(), Absname = filename:join([Cwd, Filename]), - ok = file:set_cwd("_tmp"), + ok = file:set_cwd(?TMP), ok = erl_tar:extract(Absname, [compressed]), ok = file:delete(Absname), {ok, Tar} = erl_tar:open(Absname, [write, compressed]), @@ -176,7 +177,7 @@ cleanup(NameVer) -> ], lists:foreach(fun(F) -> ok = file:delete(F) end, Files), - ok = remove_dir_tree("_tmp"). + ok = remove_dir_tree(?TMP). %% adapted from http://www.erlang.org/doc/system_principles/create_target.html remove_dir_tree(Dir) -> |