couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [40/50] rebar commit: updated refs/heads/import to e9f62c4
Date Mon, 01 Jun 2015 20:42:34 GMT
rebar_utils:otp_release/0: handle vsn like x.y.z**

As mentioned in the OTP documentation, licensed customers may use
patched OTP installations where the otp_patch_apply tool adds a '**'
suffix as a flag saying the system consists of application versions from
multiple OTP versions. When we get such a version string, we drop the
suffix, as we cannot obtain relevant information from it as far as
tooling is concerned.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-rebar/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-rebar/commit/9b060f2d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-rebar/tree/9b060f2d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-rebar/diff/9b060f2d

Branch: refs/heads/import
Commit: 9b060f2de9d92d0245edf440b08b0a8eb6b52251
Parents: 873d236
Author: Tuncer Ayaz <tuncer.ayaz@gmail.com>
Authored: Thu Jul 17 20:03:56 2014 +0200
Committer: Tuncer Ayaz <tuncer.ayaz@gmail.com>
Committed: Thu Jul 17 21:18:43 2014 +0200

----------------------------------------------------------------------
 src/rebar_utils.erl              | 22 ++++++++++++++++++++--
 test/rebar_otp_release_tests.erl | 16 ++++++++++------
 2 files changed, 30 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-rebar/blob/9b060f2d/src/rebar_utils.erl
----------------------------------------------------------------------
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index be16610..2a14503 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -384,14 +384,32 @@ otp_release1([$R,N|_]=Rel) when is_integer(N) ->
 %% If OTP >= 17.x, erlang:system_info(otp_release) returns just the
 %% major version number, we have to read the full version from
 %% a file. See http://www.erlang.org/doc/system_principles/versions.html
+%% Read vsn strinf from the 'OTP_VERSION' file and return as list without
+%% the "\n".
 otp_release1(Rel) ->
     File = filename:join([code:root_dir(), "releases", Rel, "OTP_VERSION"]),
     {ok, Vsn} = file:read_file(File),
+
     %% NOTE: 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.
-    %% Return as list without the "\n".
-    binary:bin_to_list(Vsn, {0, byte_size(Vsn) - 1}).
+    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.
 
 get_deprecated_3(Get, Config, OldOpt, NewOpt, Default, When) ->
     case Get(Config, NewOpt, Default) of

http://git-wip-us.apache.org/repos/asf/couchdb-rebar/blob/9b060f2d/test/rebar_otp_release_tests.erl
----------------------------------------------------------------------
diff --git a/test/rebar_otp_release_tests.erl b/test/rebar_otp_release_tests.erl
index 05e9993..61efdad 100644
--- a/test/rebar_otp_release_tests.erl
+++ b/test/rebar_otp_release_tests.erl
@@ -28,16 +28,20 @@
 
 -include_lib("eunit/include/eunit.hrl").
 
-otp_release_test() ->
-    ?_assert(check_otp_release()).
-
-check_otp_release() ->
+check_otp_release_test() ->
     case rebar_utils:otp_release() of
         %% <= R16
         [$R,N|_] when is_integer(N) ->
-            true;
+            ?assert(true);
         %% >= 17.x
         [N|_]=Rel when is_integer(N) ->
             %% Check that it has at least Major.Minor
-            length(string:tokens(Rel, ".")) > 1
+            ?assert(length(string:tokens(Rel, ".")) > 1),
+
+            %% If otp_patch_apply was used and the release version has
+            %% a "**" suffix, we drop that part in otp_release/0.
+            ?assertEqual(0, string:str(Rel, "*")),
+
+            %% Check that "\n" is dropped in otp_release/0.
+            ?assertEqual(0, string:str(Rel, "\n"))
     end.


Mime
View raw message