summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2015-07-24 21:40:43 -0500
committerTristan Sloughter <t@crashfast.com>2015-07-24 21:40:43 -0500
commit6e9df6cc577f84cac330065c26ba2ada7bc56a32 (patch)
treeb647a7f2c02c9607659d1ae57d0c7767876f4d2a /src
parent04fedc7422c26002785f6e7cb6e814fdb8a2f0dd (diff)
parse old format of OTP versions
Diffstat (limited to 'src')
-rw-r--r--src/rebar_utils.erl19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 26125a3..c71808d 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -306,8 +306,8 @@ check_min_otp_version(undefined) ->
check_min_otp_version(MinOtpVersion) ->
%% Fully-qualify with ?MODULE so the function can be meck'd in rebar_utils_SUITE
OtpRelease = ?MODULE:otp_release(),
- {MinMajor, MinMinor} = split_version(MinOtpVersion),
- {OtpMajor, OtpMinor} = split_version(OtpRelease),
+ {MinMajor, MinMinor} = version_tuple(MinOtpVersion),
+ {OtpMajor, OtpMinor} = version_tuple(OtpRelease),
case {OtpMajor, OtpMinor} >= {MinMajor, MinMinor} of
true ->
@@ -341,11 +341,16 @@ abort_if_blacklisted(BlacklistedRegex, OtpRelease) ->
%% ====================================================================
%% Internal functions
%% ====================================================================
-
-split_version(Version) ->
- list_to_tuple(lists:map(
- fun(S) -> list_to_integer(S) end,
- string:tokens(Version, "."))).
+version_tuple(OtpRelease) ->
+ case re:run(OtpRelease, "R?(\\d+)B?-?(\\d+)?", [{capture, all, list}]) of
+ {match, [_Full, Maj, Min]} ->
+ {list_to_integer(Maj), list_to_integer(Min)};
+ {match, [_Full, Maj]} ->
+ {list_to_integer(Maj), 0};
+ nomatch ->
+ ?WARN("", []),
+ {0,0}
+ end.
otp_release() ->
otp_release1(erlang:system_info(otp_release)).