From 6e9df6cc577f84cac330065c26ba2ada7bc56a32 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 24 Jul 2015 21:40:43 -0500 Subject: parse old format of OTP versions --- src/rebar_utils.erl | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src') 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)). -- cgit v1.1