|
|
@ -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 |
|
|
|