From 6996cd4fcc9dbd80591db38fd3cccfc8ee4aec16 Mon Sep 17 00:00:00 2001 From: Ulf Wiger Date: Sat, 21 Jul 2012 17:35:14 +0200 Subject: Use a more appropriate method to check reltool's vsn If running e.g. rebar generate using an OTP development build, rebar will complain that reltool has the version "", which is less than the required "0.5.2". This is because rebar_reltool simply checks the path returned by code:which(reltool), which doesn't yield version information if used in a development build. This patch substitutes a more robust method (load reltool and fetch the info from application:loaded_applications()). As it happens, this will not be enough to make things work, but now Reltool will explain that it cannot generate a spec from a system that is not installed, giving a better hint as to what needs to be done. --- src/rebar_reltool.erl | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/rebar_reltool.erl b/src/rebar_reltool.erl index c8e8cb6..be208a4 100644 --- a/src/rebar_reltool.erl +++ b/src/rebar_reltool.erl @@ -81,19 +81,20 @@ clean(Config, ReltoolFile) -> %% =================================================================== check_vsn() -> - case code:lib_dir(reltool) of - {error, bad_name} -> - ?ABORT("Reltool support requires the reltool application " - "to be installed!", []); - Path -> - ReltoolVsn = filename:basename(Path), - case ReltoolVsn < "reltool-0.5.2" of - true -> - ?ABORT("Reltool support requires at least reltool-0.5.2; " - "this VM is using ~s\n", [ReltoolVsn]); - false -> - ok - end + application:load(reltool), + ReltoolVsn = + case lists:keysearch(reltool, 1, application:loaded_applications()) of + {value, {_, _, V}} -> + V; + _ -> + "" + end, + case ReltoolVsn < "0.5.2" of + true -> + ?ABORT("Reltool support requires at least reltool-0.5.2; " + "this VM is using ~s\n", [ReltoolVsn]); + false -> + ok end. process_overlay(ReltoolConfig) -> -- cgit v1.1