|
@ -82,7 +82,7 @@ extract(Binary) -> |
|
|
{ok, Contents}. |
|
|
{ok, Contents}. |
|
|
|
|
|
|
|
|
request(Url) -> |
|
|
request(Url) -> |
|
|
setHttpcOptions(), |
|
|
|
|
|
|
|
|
set_httpc_options(), |
|
|
case httpc:request(get, {Url, []}, |
|
|
case httpc:request(get, {Url, []}, |
|
|
[{relaxed, true}], |
|
|
[{relaxed, true}], |
|
|
[{body_format, binary}]) of |
|
|
[{body_format, binary}]) of |
|
@ -92,45 +92,30 @@ request(Url) -> |
|
|
Error |
|
|
Error |
|
|
end. |
|
|
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. |
|
|
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) -> |
|
|
compile(App, FirstFiles) -> |
|
|
Dir = filename:join(filename:absname("_build/default/lib/"), App), |
|
|
Dir = filename:join(filename:absname("_build/default/lib/"), App), |
|
|
filelib:ensure_dir(filename:join([Dir, "ebin", "dummy.beam"])), |
|
|
filelib:ensure_dir(filename:join([Dir, "ebin", "dummy.beam"])), |
|
|