summaryrefslogtreecommitdiff
path: root/bootstrap
diff options
context:
space:
mode:
Diffstat (limited to 'bootstrap')
-rwxr-xr-xbootstrap59
1 files changed, 22 insertions, 37 deletions
diff --git a/bootstrap b/bootstrap
index 1e56263..ad94561 100755
--- a/bootstrap
+++ b/bootstrap
@@ -82,7 +82,7 @@ extract(Binary) ->
{ok, Contents}.
request(Url) ->
- setHttpcOptions(),
+ set_httpc_options(),
case httpc:request(get, {Url, []},
[{relaxed, true}],
[{body_format, binary}]) of
@@ -92,45 +92,30 @@ request(Url) ->
Error
end.
-setHttpcOptions() ->
- %% Get http_proxy and https_proxy environment variables
- case os:getenv("http_proxy") of
- false ->
- Http = "";
- Http ->
- Http
- end,
- case os:getenv("https_proxy") of
- false ->
- Https = "";
- Https ->
- Https
- end,
-
- %% Parse the variables to extract host and port
- Opts = [],
- case http_uri:parse(Http) of
- {ok,{_, [], Host, Port, _, []}} ->
- Opts1 = Opts ++ [{proxy, {{Host, Port}, []}}];
- {error, _} ->
- Opts1 = Opts
- end,
-
- case http_uri:parse(Https) of
- {ok,{_, [], Host2, Port2, _, []}} ->
- Opts2 = Opts1 ++ [{https_proxy, {{Host2, Port2}, []}}];
- {error, _} ->
- Opts2 = Opts1
- end,
-
- case Opts2 of
- [] ->
- ok;
+get_http_var() ->
+ {ok, [[Home]]} = init:get_argument(home),
+ ConfDir = filename:join(Home, ".config/rebar3"),
+ case file:consult(filename:join(ConfDir, "rebar.config")) of
+ {ok, Config} ->
+ Config;
_ ->
- httpc:set_options(Opts2),
- ok
+ []
end.
+get_http(Scheme) ->
+ proplists:get_value(Scheme, get_http_var(), "").
+
+set_httpc_options() ->
+ set_httpc_options(https_proxy, get_http(https_proxy)),
+ set_httpc_options(proxy, get_http(http_proxy)).
+
+set_httpc_options(_, []) ->
+ ok;
+
+set_httpc_options(Scheme, Proxy) ->
+ {ok, {_, _, Host, Port, _, _}} = http_uri:parse(Proxy),
+ httpc:set_options([{Scheme, {{Host, Port}, []}}]).
+
compile(App, FirstFiles) ->
Dir = filename:join(filename:absname("_build/default/lib/"), App),
filelib:ensure_dir(filename:join([Dir, "ebin", "dummy.beam"])),