From e940d6583ab17f1467c4740c9cc206f72b6cc7ce Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Thu, 28 Aug 2014 10:48:54 -0500 Subject: restrict packages to those that work on users system --- src/rebar_prv_update.erl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') 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, "&"). -- cgit v1.1