From 58fd80917a2fab2353bc19f9f4bc648d8e54db92 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Fri, 7 Jan 2011 16:32:36 +0100 Subject: Fix file existence checks --- src/rebar_rel_utils.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rebar_rel_utils.erl') diff --git a/src/rebar_rel_utils.erl b/src/rebar_rel_utils.erl index b955a53..978f9d6 100644 --- a/src/rebar_rel_utils.erl +++ b/src/rebar_rel_utils.erl @@ -33,7 +33,7 @@ is_rel_dir() -> is_rel_dir(Dir) -> Fname = filename:join([Dir, "reltool.config"]), - case filelib:is_file(Fname) of + case filelib:is_regular(Fname) of true -> {true, Fname}; false -> -- cgit v1.1 From c466076ffb5a1ea4c00d49fefff0dcfbceb58236 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Mon, 31 Jan 2011 17:43:31 +0100 Subject: Clean up emacs file local variables --- src/rebar_rel_utils.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rebar_rel_utils.erl') diff --git a/src/rebar_rel_utils.erl b/src/rebar_rel_utils.erl index 978f9d6..91031e8 100644 --- a/src/rebar_rel_utils.erl +++ b/src/rebar_rel_utils.erl @@ -1,4 +1,4 @@ -%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*- +%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*- %% ex: ts=4 sw=4 et %% ------------------------------------------------------------------- %% -- cgit v1.1 From 4e8dcfbfade08b48fe38bfe041459960b0ff74c3 Mon Sep 17 00:00:00 2001 From: joewilliams Date: Wed, 16 Feb 2011 09:46:40 -0800 Subject: Clean up rebar_appups and rebar_upgrade --- src/rebar_rel_utils.erl | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'src/rebar_rel_utils.erl') diff --git a/src/rebar_rel_utils.erl b/src/rebar_rel_utils.erl index 91031e8..94a10b0 100644 --- a/src/rebar_rel_utils.erl +++ b/src/rebar_rel_utils.erl @@ -26,7 +26,14 @@ %% ------------------------------------------------------------------- -module(rebar_rel_utils). --export([is_rel_dir/0, is_rel_dir/1]). +-export([is_rel_dir/0, + is_rel_dir/1, + get_reltool_release_info/1, + get_rel_release_info/1, + get_rel_release_info/2, + get_previous_release_path/0]). + +-include("rebar.hrl"). is_rel_dir() -> is_rel_dir(rebar_utils:get_cwd()). @@ -39,3 +46,42 @@ is_rel_dir(Dir) -> false -> false end. + +%% Get release name and version from a reltool.config +get_reltool_release_info(ReltoolFile) -> + %% expect sys to be the first proplist in reltool.config + case file:consult(ReltoolFile) of + {ok, [{sys, Config}| _]} -> + %% expect the first rel in the proplist to be the one you want + {rel, Name, Ver, _} = proplists:lookup(rel, Config), + {Name, Ver}; + _ -> + ?ABORT("Failed to parse ~s~n", [ReltoolFile]) + end. + +%% Get release name and version from a rel file +get_rel_release_info(RelFile) -> + case file:consult(RelFile) of + {ok, [{release, {Name, Ver}, _, _}]} -> + {Name, Ver}; + _ -> + ?ABORT("Failed to parse ~s~n", [RelFile]) + end. + +%% Get release name and version from a name and a path +get_rel_release_info(Name, Path) -> + [RelFile] = filelib:wildcard(filename:join([Path, "releases", "*", + Name ++ ".rel"])), + [BinDir|_] = re:replace(RelFile, Name ++ "\\.rel", ""), + get_rel_release_info(filename:join([binary_to_list(BinDir), + Name ++ ".rel"])). + +%% Get the previous release path from a global variable +get_previous_release_path() -> + case rebar_config:get_global(previous_release, false) of + false -> + ?ABORT("previous_release=PATH is required to " + "create upgrade package~n", []); + OldVerPath -> + OldVerPath + end. -- cgit v1.1 From 1e9b2b844b844a990269f68535f5bbf02ac522b3 Mon Sep 17 00:00:00 2001 From: joewilliams Date: Thu, 17 Feb 2011 10:12:32 -0800 Subject: Clean up trailing whitespace --- src/rebar_rel_utils.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/rebar_rel_utils.erl') diff --git a/src/rebar_rel_utils.erl b/src/rebar_rel_utils.erl index 94a10b0..9729e20 100644 --- a/src/rebar_rel_utils.erl +++ b/src/rebar_rel_utils.erl @@ -26,7 +26,7 @@ %% ------------------------------------------------------------------- -module(rebar_rel_utils). --export([is_rel_dir/0, +-export([is_rel_dir/0, is_rel_dir/1, get_reltool_release_info/1, get_rel_release_info/1, @@ -73,7 +73,7 @@ get_rel_release_info(Name, Path) -> [RelFile] = filelib:wildcard(filename:join([Path, "releases", "*", Name ++ ".rel"])), [BinDir|_] = re:replace(RelFile, Name ++ "\\.rel", ""), - get_rel_release_info(filename:join([binary_to_list(BinDir), + get_rel_release_info(filename:join([binary_to_list(BinDir), Name ++ ".rel"])). %% Get the previous release path from a global variable -- cgit v1.1