diff options
author | Tristan Sloughter <t@crashfast.com> | 2015-05-09 17:28:55 -0500 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2015-05-09 17:28:55 -0500 |
commit | a6f33258e210d8169a3ca411a0489feb22acca22 (patch) | |
tree | be48b9c93763366a397f8c21fc4166e22bd38a14 /bootstrap | |
parent | b904c5b57a4dbe393009da0bc6720c2a78a310e1 (diff) |
fix failure on missing OTP_VERSION file #403
Diffstat (limited to 'bootstrap')
-rwxr-xr-x | bootstrap | 45 |
1 files changed, 24 insertions, 21 deletions
@@ -298,25 +298,28 @@ 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. |