couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [39/50] rebar commit: updated refs/heads/import to e9f62c4
Date Mon, 01 Jun 2015 20:42:33 GMT
Adapt arch string to versioning scheme changes (>= 17.x)


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

Branch: refs/heads/import
Commit: 873d236ce9b4b88d46c4bb1c6868df70363e8a57
Parents: 6f60256
Author: Tuncer Ayaz <tuncer.ayaz@gmail.com>
Authored: Thu Jul 17 18:53:58 2014 +0200
Committer: Tuncer Ayaz <tuncer.ayaz@gmail.com>
Committed: Thu Jul 17 18:53:58 2014 +0200

----------------------------------------------------------------------
 src/rebar_utils.erl              | 23 ++++++++++++++++++-
 test/rebar_otp_release_tests.erl | 43 +++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-rebar/blob/873d236c/src/rebar_utils.erl
----------------------------------------------------------------------
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 0ff1267..be16610 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -66,6 +66,9 @@
          processing_base_dir/2,
          patch_env/2]).
 
+%% for internal use only
+-export([otp_release/0]).
+
 -include("rebar.hrl").
 
 %% ====================================================================
@@ -86,7 +89,7 @@ is_arch(ArchRegex) ->
 
 get_arch() ->
     Words = wordsize(),
-    erlang:system_info(otp_release) ++ "-"
+    otp_release() ++ "-"
         ++ erlang:system_info(system_architecture) ++ "-" ++ Words.
 
 wordsize() ->
@@ -372,6 +375,24 @@ patch_env(Config, [E | Rest]) ->
 %% Internal functions
 %% ====================================================================
 
+otp_release() ->
+    otp_release1(erlang:system_info(otp_release)).
+
+%% If OTP <= R16, otp_release is already what we want.
+otp_release1([$R,N|_]=Rel) when is_integer(N) ->
+    Rel;
+%% 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
+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}).
+
 get_deprecated_3(Get, Config, OldOpt, NewOpt, Default, When) ->
     case Get(Config, NewOpt, Default) of
         Default ->

http://git-wip-us.apache.org/repos/asf/couchdb-rebar/blob/873d236c/test/rebar_otp_release_tests.erl
----------------------------------------------------------------------
diff --git a/test/rebar_otp_release_tests.erl b/test/rebar_otp_release_tests.erl
new file mode 100644
index 0000000..05e9993
--- /dev/null
+++ b/test/rebar_otp_release_tests.erl
@@ -0,0 +1,43 @@
+%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ts=4 sw=4 et
+%% -------------------------------------------------------------------
+%%
+%% rebar: Erlang Build Tools
+%%
+%% Copyright (c) 2014 Tuncer Ayaz
+%%
+%% Permission is hereby granted, free of charge, to any person obtaining a copy
+%% of this software and associated documentation files (the "Software"), to deal
+%% in the Software without restriction, including without limitation the rights
+%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+%% copies of the Software, and to permit persons to whom the Software is
+%% furnished to do so, subject to the following conditions:
+%%
+%% The above copyright notice and this permission notice shall be included in
+%% all copies or substantial portions of the Software.
+%%
+%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+%% THE SOFTWARE.
+%% -------------------------------------------------------------------
+-module(rebar_otp_release_tests).
+
+-include_lib("eunit/include/eunit.hrl").
+
+otp_release_test() ->
+    ?_assert(check_otp_release()).
+
+check_otp_release() ->
+    case rebar_utils:otp_release() of
+        %% <= R16
+        [$R,N|_] when is_integer(N) ->
+            true;
+        %% >= 17.x
+        [N|_]=Rel when is_integer(N) ->
+            %% Check that it has at least Major.Minor
+            length(string:tokens(Rel, ".")) > 1
+    end.


Mime
View raw message