summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rebar_rel_utils.erl15
-rw-r--r--src/rebar_reltool.erl23
-rw-r--r--src/rebar_upgrade.erl17
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) ->