nixpkgs/pkgs/development/tools/build-managers/rebar3/hermetic-bootstrap.patch

170 lines
5.9 KiB
Diff
Raw Normal View History

diff --git a/bootstrap b/bootstrap
2016-11-23 21:06:15 +00:00
index c36fddb..9fcb718 100755
--- a/bootstrap
+++ b/bootstrap
2016-04-22 19:03:39 +01:00
@@ -7,9 +7,11 @@ main(_) ->
application:start(asn1),
application:start(public_key),
application:start(ssl),
- inets:start(),
- inets:start(httpc, [{profile, rebar}]),
- set_httpc_options(),
2016-11-23 21:06:15 +00:00
+ %% Removed for hermeticity on Nix
2016-04-22 19:03:39 +01:00
+ %%
2016-11-23 21:06:15 +00:00
+ %% inets:start(),
+ %% inets:start(httpc, [{profile, rebar}]),
+ %% set_httpc_options(),
%% Fetch and build deps required to build rebar3
BaseDeps = [{providers, []}
2016-11-23 21:06:15 +00:00
@@ -73,13 +75,13 @@ default_registry_file() ->
CacheDir = filename:join([Home, ".cache", "rebar3"]),
2016-04-22 19:03:39 +01:00
filename:join([CacheDir, "hex", "default", "registry"]).
2016-11-23 21:06:15 +00:00
-fetch_and_compile({Name, ErlFirstFiles}, Deps) ->
2016-04-22 19:03:39 +01:00
- case lists:keyfind(Name, 1, Deps) of
- {Name, Vsn} ->
- ok = fetch({pkg, atom_to_binary(Name, utf8), list_to_binary(Vsn)}, Name);
- {Name, _, Source} ->
- ok = fetch(Source, Name)
- end,
2016-11-23 21:06:15 +00:00
+fetch_and_compile({Name, ErlFirstFiles}, _Deps) ->
2016-04-22 19:03:39 +01:00
+ %% case lists:keyfind(Name, 1, Deps) of
+ %% {Name, Vsn} ->
+ %% ok = fetch({pkg, atom_to_binary(Name, utf8), list_to_binary(Vsn)}, Name);
+ %% {Name, _, Source} ->
+ %% ok = fetch(Source, Name)
+ %% end,
2016-11-23 21:06:15 +00:00
2016-04-22 19:03:39 +01:00
%% Hack: erlware_commons depends on a .script file to check if it is being built with
%% rebar2 or rebar3. But since rebar3 isn't built yet it can't get the vsn with get_key.
2016-11-23 21:06:15 +00:00
@@ -88,67 +90,67 @@ fetch_and_compile({Name, ErlFirstFiles}, Deps) ->
compile(Name, ErlFirstFiles).
2016-11-23 21:06:15 +00:00
2016-04-22 19:03:39 +01:00
-fetch({pkg, Name, Vsn}, App) ->
- Dir = filename:join([filename:absname("_build/default/lib/"), App]),
2016-04-22 19:03:39 +01:00
- case filelib:is_dir(Dir) of
- false ->
2016-11-23 21:06:15 +00:00
- CDN = "https://repo.hex.pm/tarballs",
2016-04-22 19:03:39 +01:00
- Package = binary_to_list(<<Name/binary, "-", Vsn/binary, ".tar">>),
- Url = string:join([CDN, Package], "/"),
- case request(Url) of
- {ok, Binary} ->
- {ok, Contents} = extract(Binary),
- ok = erl_tar:extract({binary, Contents}, [{cwd, Dir}, compressed]);
- _ ->
- io:format("Error: Unable to fetch package ~p ~p~n", [Name, Vsn])
- end;
- true ->
- io:format("Dependency ~s already exists~n", [Name])
- end.
-
-extract(Binary) ->
- {ok, Files} = erl_tar:extract({binary, Binary}, [memory]),
- {"contents.tar.gz", Contents} = lists:keyfind("contents.tar.gz", 1, Files),
- {ok, Contents}.
-
-request(Url) ->
- case httpc:request(get, {Url, []},
- [{relaxed, true}],
- [{body_format, binary}],
- rebar) of
- {ok, {{_Version, 200, _Reason}, _Headers, Body}} ->
- {ok, Body};
- Error ->
- Error
- end.
2016-04-22 19:03:39 +01:00
-
-get_rebar_config() ->
- {ok, [[Home]]} = init:get_argument(home),
- ConfDir = filename:join(Home, ".config/rebar3"),
- case file:consult(filename:join(ConfDir, "rebar.config")) of
- {ok, Config} ->
- Config;
- _ ->
- []
- end.
-
-get_http_vars(Scheme) ->
2016-11-23 21:06:15 +00:00
- OS = case os:getenv(atom_to_list(Scheme)) of
- Str when is_list(Str) -> Str;
- _ -> []
- end,
- proplists:get_value(Scheme, get_rebar_config(), OS).
-
-set_httpc_options() ->
- set_httpc_options(https_proxy, get_http_vars(https_proxy)),
- set_httpc_options(proxy, get_http_vars(http_proxy)).
-
-set_httpc_options(_, []) ->
- ok;
-
-set_httpc_options(Scheme, Proxy) ->
- {ok, {_, _, Host, Port, _, _}} = http_uri:parse(Proxy),
- httpc:set_options([{Scheme, {{Host, Port}, []}}], rebar).
2016-04-22 19:03:39 +01:00
+%% fetch({pkg, Name, Vsn}, App) ->
+%% Dir = filename:join([filename:absname("_build/default/lib/"), App]),
+%% case filelib:is_dir(Dir) of
+%% false ->
2016-11-23 21:06:15 +00:00
+%% CDN = "https://repo.hex.pm/tarballs",
2016-04-22 19:03:39 +01:00
+%% Package = binary_to_list(<<Name/binary, "-", Vsn/binary, ".tar">>),
+%% Url = string:join([CDN, Package], "/"),
+%% case request(Url) of
+%% {ok, Binary} ->
+%% {ok, Contents} = extract(Binary),
+%% ok = erl_tar:extract({binary, Contents}, [{cwd, Dir}, compressed]);
+%% _ ->
+%% io:format("Error: Unable to fetch package ~p ~p~n", [Name, Vsn])
+%% end;
+%% true ->
+%% io:format("Dependency ~s already exists~n", [Name])
+%% end.
+
+%% extract(Binary) ->
+%% {ok, Files} = erl_tar:extract({binary, Binary}, [memory]),
+%% {"contents.tar.gz", Contents} = lists:keyfind("contents.tar.gz", 1, Files),
+%% {ok, Contents}.
+
+%% request(Url) ->
+%% case httpc:request(get, {Url, []},
+%% [{relaxed, true}],
+%% [{body_format, binary}],
+%% rebar) of
+%% {ok, {{_Version, 200, _Reason}, _Headers, Body}} ->
+%% {ok, Body};
+%% Error ->
+%% Error
+%% end.
+
+%% get_rebar_config() ->
+%% {ok, [[Home]]} = init:get_argument(home),
+%% ConfDir = filename:join(Home, ".config/rebar3"),
+%% case file:consult(filename:join(ConfDir, "rebar.config")) of
+%% {ok, Config} ->
+%% Config;
+%% _ ->
+%% []
+%% end.
+
+%% get_http_vars(Scheme) ->
2016-11-23 21:06:15 +00:00
+%% OS = case os:getenv(atom_to_list(Scheme)) of
+%% Str when is_list(Str) -> Str;
+%% _ -> []
+%% end,
+%% proplists:get_value(Scheme, get_rebar_config(), OS).
2016-04-22 19:03:39 +01:00
+
+%% set_httpc_options() ->
+%% set_httpc_options(https_proxy, get_http_vars(https_proxy)),
+%% set_httpc_options(proxy, get_http_vars(http_proxy)).
+
+%% set_httpc_options(_, []) ->
+%% ok;
+
+%% set_httpc_options(Scheme, Proxy) ->
+%% {ok, {_, _, Host, Port, _, _}} = http_uri:parse(Proxy),
+%% httpc:set_options([{Scheme, {{Host, Port}, []}}], rebar).
2016-11-23 21:06:15 +00:00
compile(App, FirstFiles) ->
Dir = filename:join(filename:absname("_build/default/lib/"), App),