Skip to content

Instantly share code, notes, and snippets.

@evanmcc
Created June 7, 2012 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evanmcc/2890276 to your computer and use it in GitHub Desktop.
Save evanmcc/2890276 to your computer and use it in GitHub Desktop.
proposed rebar change
check_versions(Config) ->
ErtsRegex = rebar_config:get(Config, require_erts_vsn, ".*"),
ReOpts = [{capture, none}],
case re:run(erlang:system_info(version), ErtsRegex, ReOpts) of
match ->
?DEBUG("Matched required ERTS version: ~s -> ~s\n",
[erlang:system_info(version), ErtsRegex]);
nomatch ->
?ABORT("ERTS version ~s does not match required regex ~s\n",
[erlang:system_info(version), ErtsRegex])
end,
OtpRegex = rebar_config:get(Config, require_otp_vsn, ".*"),
case re:run(erlang:system_info(otp_release), OtpRegex, ReOpts) of
match ->
?DEBUG("Matched required OTP release: ~s -> ~s\n",
[erlang:system_info(otp_release), OtpRegex]);
nomatch ->
?ABORT("OTP release ~s does not match required regex ~s\n",
[erlang:system_info(otp_release), OtpRegex])
end,
MinOtpVers = rebar_config:get(Config, require_min_otp_vsn, nil),
if
MinOtpVers /= nil ->
{MinMaj, MinMin} = case otp_vers_to_tup(MinOtpVers, "configured") of
{Maj, Min} -> {Maj, Min};
Other -> Other
end,
{OtpMaj, OtpMin} = case otp_vers_to_tup(erlang:system_info(otp_release),
"OTP Release") of
{Maj1, Min1} -> {Maj1, Min1};
Other1 -> Other1
end,
case OtpMaj >= MinMaj andalso OtpMin >= MinMin of
true ->
?DEBUG("OTP release ~s is later than ~s~n",
[erlang:system_info(otp_release), MinOtpVers]);
false ->
?ABORT("OTP release ~s is earlier than ~s~n",
[erlang:system_info(otp_release), MinOtpVers])
end;
MinOtpVers == nil -> ?DEBUG("Min OTP version unconfigured~n", [])
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment