summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2014-08-28 10:48:54 -0500
committerTristan Sloughter <t@crashfast.com>2014-08-28 10:48:54 -0500
commite940d6583ab17f1467c4740c9cc206f72b6cc7ce (patch)
tree9ebb1ea18d4e5f77bf203d18a7fcdb9291a57bc8 /src
parent393abe92d01040a847bfc42a80d61b33f0254ca7 (diff)
restrict packages to those that work on users system
Diffstat (limited to 'src')
-rw-r--r--src/rebar_prv_update.erl15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl
index 081a3b0..042a069 100644
--- a/src/rebar_prv_update.erl
+++ b/src/rebar_prv_update.erl
@@ -52,7 +52,8 @@ do(State) ->
{ok, State1};
[] ->
?INFO("Updating package index...", []),
- Url = rebar_state:get(State, rebar_packages_url, "http://polar-caverns-6802.herokuapp.com/"),
+ Url = url(State),
+ io:format("Url ~s~n", [Url]),
ec_file:mkdir_p(filename:join([os:getenv("HOME"), ".rebar"])),
PackagesFile = filename:join([os:getenv("HOME"), ".rebar", "packages"]),
{ok, RequestId} = httpc:request(get, {Url, []}, [], [{stream, PackagesFile}, {sync, false}]),
@@ -68,3 +69,15 @@ wait(RequestId, State) ->
io:format("."),
wait(RequestId, State)
end.
+
+url(State) ->
+ SystemArch = erlang:system_info(system_architecture),
+ ErtsVsn = erlang:system_info(version),
+ {glibc, GlibcVsn, _, _} = erlang:system_info(allocator),
+ GlibcVsnStr = io_lib:format("~p.~p", GlibcVsn),
+
+ Qs = [io_lib:format("~s=~s", [X, Y]) || {X, Y} <- [{"arch", SystemArch}
+ ,{"erts", ErtsVsn}
+ ,{"glibc", GlibcVsnStr}]],
+ Url = rebar_state:get(State, rebar_packages_url, "http://polar-caverns-6802.herokuapp.com"),
+ Url ++ "?" ++ string:join(Qs, "&").