Browse Source

Fetch the version from rebar.lock if not specified in rebar.config

This fixes hackney.
Loïc Hoguin 7 years ago
parent
commit
c067f6f41e
1 changed files with 22 additions and 0 deletions
  1. 22 0
      core/deps.mk

+ 22 - 0
core/deps.mk

@@ -269,11 +269,33 @@ define dep_autopatch_rebar.erl
 		end,
 		end,
 		Write("\n")
 		Write("\n")
 	end(),
 	end(),
+	GetHexVsn = fun(N) ->
+		case file:consult("$(call core_native_path,$(DEPS_DIR)/$1/rebar.lock)") of
+			{ok, Lock} ->
+				io:format("~p~n", [Lock]),
+				case lists:keyfind("1.1.0", 1, Lock) of
+					{_, LockPkgs} ->
+						io:format("~p~n", [LockPkgs]),
+						case lists:keyfind(atom_to_binary(N, latin1), 1, LockPkgs) of
+							{_, {pkg, _, Vsn}, _} ->
+								io:format("~p~n", [Vsn]),
+								{N, {hex, binary_to_list(Vsn)}};
+							_ ->
+								false
+						end;
+					_ ->
+						false
+				end;
+			_ ->
+				false
+		end
+	end,
 	fun() ->
 	fun() ->
 		File = case lists:keyfind(deps, 1, Conf) of
 		File = case lists:keyfind(deps, 1, Conf) of
 			false -> [];
 			false -> [];
 			{_, Deps} ->
 			{_, Deps} ->
 				[begin case case Dep of
 				[begin case case Dep of
+							N when is_atom(N) -> GetHexVsn(N);
 							{N, S} when is_atom(N), is_list(S) -> {N, {hex, S}};
 							{N, S} when is_atom(N), is_list(S) -> {N, {hex, S}};
 							{N, S} when is_tuple(S) -> {N, S};
 							{N, S} when is_tuple(S) -> {N, S};
 							{N, _, S} -> {N, S};
 							{N, _, S} -> {N, S};