summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2015-05-09 17:28:55 -0500
committerTristan Sloughter <t@crashfast.com>2015-05-09 17:28:55 -0500
commita6f33258e210d8169a3ca411a0489feb22acca22 (patch)
treebe48b9c93763366a397f8c21fc4166e22bd38a14 /src
parentb904c5b57a4dbe393009da0bc6720c2a78a310e1 (diff)
fix failure on missing OTP_VERSION file #403
Diffstat (limited to 'src')
-rw-r--r--src/rebar_utils.erl45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 4f0bc80..160d547 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -304,27 +304,30 @@ otp_release1([$R,N|_]=Rel) when is_integer(N) ->
%% the "\n".
otp_release1(Rel) ->
File = filename:join([code:root_dir(), "releases", Rel, "OTP_VERSION"]),
- {ok, Vsn} = file:read_file(File),
-
- %% It's fine to rely on the binary module here because we can
- %% be sure that it's available when the otp_release string does
- %% not begin with $R.
- Size = byte_size(Vsn),
- %% The shortest vsn string consists of at least two digits
- %% followed by "\n". Therefore, it's safe to assume Size >= 3.
- case binary:part(Vsn, {Size, -3}) of
- <<"**\n">> ->
- %% The OTP documentation mentions that a system patched
- %% using the otp_patch_apply tool available to licensed
- %% customers will leave a '**' suffix in the version as a
- %% flag saying the system consists of application versions
- %% from multiple OTP versions. We ignore this flag and
- %% drop the suffix, given for all intents and purposes, we
- %% cannot obtain relevant information from it as far as
- %% tooling is concerned.
- binary:bin_to_list(Vsn, {0, Size - 3});
- _ ->
- binary:bin_to_list(Vsn, {0, Size - 1})
+ case file:read_file(File) of
+ {error, _} ->
+ Rel;
+ {ok, Vsn} ->
+ %% It's fine to rely on the binary module here because we can
+ %% be sure that it's available when the otp_release string does
+ %% not begin with $R.
+ Size = byte_size(Vsn),
+ %% The shortest vsn string consists of at least two digits
+ %% followed by "\n". Therefore, it's safe to assume Size >= 3.
+ case binary:part(Vsn, {Size, -3}) of
+ <<"**\n">> ->
+ %% The OTP documentation mentions that a system patched
+ %% using the otp_patch_apply tool available to licensed
+ %% customers will leave a '**' suffix in the version as a
+ %% flag saying the system consists of application versions
+ %% from multiple OTP versions. We ignore this flag and
+ %% drop the suffix, given for all intents and purposes, we
+ %% cannot obtain relevant information from it as far as
+ %% tooling is concerned.
+ binary:bin_to_list(Vsn, {0, Size - 3});
+ _ ->
+ binary:bin_to_list(Vsn, {0, Size - 1})
+ end
end.
%% We do the shell variable substitution ourselves on Windows and hope that the