rebar3: 3.0.0-beta.4 -> 3.1.0

This commit is contained in:
Eric Merritt 2016-04-22 11:03:39 -07:00
parent f36be6edbf
commit 658a49b81d
3 changed files with 161 additions and 95 deletions

View file

@ -3,16 +3,16 @@
tree, fetchFromGitHub, hexRegistrySnapshot }: tree, fetchFromGitHub, hexRegistrySnapshot }:
let let
version = "3.0.0-beta.4"; version = "3.1.0";
bootstrapper = ./rebar3-nix-bootstrap; bootstrapper = ./rebar3-nix-bootstrap;
# TODO: all these below probably should go into nixpkgs.erlangModules.sources.* # TODO: all these below probably should go into nixpkgs.erlangModules.sources.*
# {erlware_commons, "0.16.0"}, # {erlware_commons, "0.19.0"},
erlware_commons = fetchHex { erlware_commons = fetchHex {
pkg = "erlware_commons"; pkg = "erlware_commons";
version = "0.16.0"; version = "0.19.0";
sha256 = "0kh24d0001390wfx28d0xa874vrsfvjgj41g315vg4hac632krxx"; sha256 = "1gfsy9bbhjb94c5ghff2niamn93x2x08lnklh6pp7sfr5i0gkgsv";
}; };
# {ssl_verify_hostname, "1.0.5"}, # {ssl_verify_hostname, "1.0.5"},
ssl_verify_hostname = fetchHex { ssl_verify_hostname = fetchHex {
@ -20,17 +20,17 @@ let
version = "1.0.5"; version = "1.0.5";
sha256 = "1gzavzqzljywx4l59gvhkjbr1dip4kxzjjz1s4wsn42f2kk13jzj"; sha256 = "1gzavzqzljywx4l59gvhkjbr1dip4kxzjjz1s4wsn42f2kk13jzj";
}; };
# {certifi, "0.1.1"}, # {certifi, "0.4.0"},
certifi = fetchHex { certifi = fetchHex {
pkg = "certifi"; pkg = "certifi";
version = "0.1.1"; version = "0.4.0";
sha256 = "0afylwqg74gprbg116asz0my2nipmki0512c8mdiq6xdiyjdvlg6"; sha256 = "04bnvsbssdcf6b9h9bfglflds7j0gx6q5igl1xxhx6fnwaz37hhw";
}; };
# {providers, "1.5.0"}, # {providers, "1.6.0"},
providers = fetchHex { providers = fetchHex {
pkg = "providers"; pkg = "providers";
version = "1.5.0"; version = "1.6.0";
sha256 = "1hc8sp2l1mmx9dfpmh1f8j9hayfg7541rmx05wb9cmvxvih7zyvf"; sha256 = "0byfa1h57n46jilz4q132j0vk3iqc0v1vip89li38gb1k997cs0g";
}; };
# {getopt, "0.8.2"}, # {getopt, "0.8.2"},
getopt = fetchHex { getopt = fetchHex {
@ -44,11 +44,11 @@ let
version = "1.0.4"; version = "1.0.4";
sha256 = "04lvwm7f78x8bys0js33higswjkyimbygp4n72cxz1kfnryx9c03"; sha256 = "04lvwm7f78x8bys0js33higswjkyimbygp4n72cxz1kfnryx9c03";
}; };
# {relx, "3.8.0"}, # {relx, "3.17.0"},
relx = fetchHex { relx = fetchHex {
pkg = "relx"; pkg = "relx";
version = "3.8.0"; version = "3.17.0";
sha256 = "0y89iirjz3kc1rzkdvc6p3ssmwcm2hqgkklhgm4pkbc14fcz57hq"; sha256 = "1xjybi93m8gj9f9z3lkc7xbg3k5cw56yl78rcz5qfirr0223sby2";
}; };
# {cf, "0.2.1"}, # {cf, "0.2.1"},
cf = fetchHex { cf = fetchHex {
@ -56,19 +56,19 @@ let
version = "0.2.1"; version = "0.2.1";
sha256 = "19d0yvg8wwa57cqhn3vqfvw978nafw8j2rvb92s3ryidxjkrmvms"; sha256 = "19d0yvg8wwa57cqhn3vqfvw978nafw8j2rvb92s3ryidxjkrmvms";
}; };
# {cth_readable, "1.1.0"}, # {cth_readable, "1.2.2"},
cth_readable = fetchHex { cth_readable = fetchHex {
pkg = "cth_readable"; pkg = "cth_readable";
version = "1.0.1"; version = "1.2.2";
sha256 = "1cnc4fbypckqllfi5h73rdb24dz576k3177gzvp1kbymwkp1xcz1"; sha256 = "0kb9v4998liwyidpjkhcg1nin6djjzxcx6b313pbjicbp4r58n3p";
}; };
# {eunit_formatters, "0.2.0"} # {eunit_formatters, "0.3.1"}
eunit_formatters = fetchHex { eunit_formatters = fetchHex {
pkg = "eunit_formatters"; pkg = "eunit_formatters";
version = "0.2.0"; version = "0.3.1";
sha256 = "03kiszlbgzscfd2ns7na6bzbfzmcqdb5cx3p6qy3657jk2fai332"; sha256 = "0cg9dasv60v09q3q4wja76pld0546mhmlpb0khagyylv890hg934";
}; };
# {eunit_formatters, "0.2.0"} # {rebar3_hex, "1.12.0"}
rebar3_hex = fetchHex { rebar3_hex = fetchHex {
pkg = "rebar3_hex"; pkg = "rebar3_hex";
version = "1.12.0"; version = "1.12.0";
@ -82,7 +82,7 @@ stdenv.mkDerivation {
src = fetchurl { src = fetchurl {
url = "https://github.com/rebar/rebar3/archive/${version}.tar.gz"; url = "https://github.com/rebar/rebar3/archive/${version}.tar.gz";
sha256 = "0px66scjdia9aaa5z36qzxb848r56m0k98g0bxw065a2narsh4xy"; sha256 = "0r4wpnpi81ha4iirv9hcif3vrgc82qd51kah7rnhvpym55wcy9ml";
}; };
inherit bootstrapper; inherit bootstrapper;

View file

@ -1,39 +1,61 @@
diff --git a/bootstrap b/bootstrap diff --git a/bootstrap b/bootstrap
index 25bd658..b2a986b 100755 index 35759b0..939c838 100755
--- a/bootstrap --- a/bootstrap
+++ b/bootstrap +++ b/bootstrap
@@ -8,9 +8,6 @@ main(_Args) -> @@ -7,9 +7,11 @@ main(_) ->
application:start(asn1), application:start(asn1),
application:start(public_key), application:start(public_key),
application:start(ssl), application:start(ssl),
- inets:start(), - inets:start(),
- inets:start(httpc, [{profile, rebar}]), - inets:start(httpc, [{profile, rebar}]),
- set_httpc_options(), - set_httpc_options(),
+ %% Removed for hermeticity on Nix
+ %%
+ %% inets:start(),
+ %% inets:start(httpc, [{profile, rebar}]),
+ %% set_httpc_options(),
%% Fetch and build deps required to build rebar3 %% Fetch and build deps required to build rebar3
BaseDeps = [{providers, []} BaseDeps = [{providers, []}
@@ -33,7 +30,6 @@ main(_Args) -> @@ -74,12 +76,12 @@ default_registry_file() ->
filename:join([CacheDir, "hex", "default", "registry"]).
setup_env(),
os:putenv("REBAR_PROFILE", "bootstrap"), fetch_and_compile({Name, ErlFirstFiles}, Deps) ->
- rebar3:run(["update"]), - case lists:keyfind(Name, 1, Deps) of
{ok, State} = rebar3:run(["compile"]), - {Name, Vsn} ->
reset_env(), - ok = fetch({pkg, atom_to_binary(Name, utf8), list_to_binary(Vsn)}, Name);
os:putenv("REBAR_PROFILE", ""), - {Name, _, Source} ->
@@ -71,33 +67,7 @@ fetch_and_compile({Name, ErlFirstFiles}, Deps) -> - ok = fetch(Source, Name)
- end,
+ %% 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,
%% 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.
@@ -88,63 +90,63 @@ fetch_and_compile({Name, ErlFirstFiles}, Deps) ->
compile(Name, ErlFirstFiles). compile(Name, ErlFirstFiles).
fetch({pkg, Name, Vsn}, App) -> -fetch({pkg, Name, Vsn}, App) ->
- Dir = filename:join([filename:absname("_build/default/lib/"), App]), - Dir = filename:join([filename:absname("_build/default/lib/"), App]),
- CDN = "https://s3.amazonaws.com/s3.hex.pm/tarballs", - case filelib:is_dir(Dir) of
- Package = binary_to_list(<<Name/binary, "-", Vsn/binary, ".tar">>), - false ->
- Url = string:join([CDN, Package], "/"), - CDN = "https://s3.amazonaws.com/s3.hex.pm/tarballs",
- case request(Url) of - Package = binary_to_list(<<Name/binary, "-", Vsn/binary, ".tar">>),
- {ok, Binary} -> - Url = string:join([CDN, Package], "/"),
- {ok, Contents} = extract(Binary), - case request(Url) of
- ok = erl_tar:extract({binary, Contents}, [{cwd, Dir}, compressed]); - {ok, Binary} ->
- _ -> - {ok, Contents} = extract(Binary),
- io:format("Error: Unable to fetch package ~p ~p~n", [Name, Vsn]) - 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. - end.
- -
-extract(Binary) -> -extract(Binary) ->
@ -51,14 +73,17 @@ index 25bd658..b2a986b 100755
- Error -> - Error ->
- Error - Error
- end. - end.
+ ok. -
-get_rebar_config() ->
get_rebar_config() -> - {ok, [[Home]]} = init:get_argument(home),
{ok, [[Home]]} = init:get_argument(home), - ConfDir = filename:join(Home, ".config/rebar3"),
@@ -109,20 +79,6 @@ get_rebar_config() -> - case file:consult(filename:join(ConfDir, "rebar.config")) of
[] - {ok, Config} ->
end. - Config;
- _ ->
- []
- end.
-
-get_http_vars(Scheme) -> -get_http_vars(Scheme) ->
- proplists:get_value(Scheme, get_rebar_config(), []). - proplists:get_value(Scheme, get_rebar_config(), []).
- -
@ -72,7 +97,63 @@ index 25bd658..b2a986b 100755
-set_httpc_options(Scheme, Proxy) -> -set_httpc_options(Scheme, Proxy) ->
- {ok, {_, _, Host, Port, _, _}} = http_uri:parse(Proxy), - {ok, {_, _, Host, Port, _, _}} = http_uri:parse(Proxy),
- httpc:set_options([{Scheme, {{Host, Port}, []}}], rebar). - httpc:set_options([{Scheme, {{Host, Port}, []}}], rebar).
- +%% fetch({pkg, Name, Vsn}, App) ->
+%% Dir = filename:join([filename:absname("_build/default/lib/"), App]),
+%% case filelib:is_dir(Dir) of
+%% false ->
+%% CDN = "https://s3.amazonaws.com/s3.hex.pm/tarballs",
+%% 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) ->
+%% proplists:get_value(Scheme, get_rebar_config(), []).
+
+%% 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).
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"])),

View file

@ -1,8 +1,8 @@
diff --git a/src/rebar3.erl b/src/rebar3.erl diff a/src/rebar3.erl b/src/rebar3.erl
index 2b73844..af1d871 100644 index c1a1ae4..1bf1ea0 100644
--- a/src/rebar3.erl --- a/src/rebar3.erl
+++ b/src/rebar3.erl +++ b/src/rebar3.erl
@@ -282,9 +282,11 @@ start_and_load_apps(Caller) -> @@ -294,9 +294,11 @@ start_and_load_apps(Caller) ->
ensure_running(crypto, Caller), ensure_running(crypto, Caller),
ensure_running(asn1, Caller), ensure_running(asn1, Caller),
ensure_running(public_key, Caller), ensure_running(public_key, Caller),
@ -10,21 +10,14 @@ index 2b73844..af1d871 100644
- inets:start(), - inets:start(),
- inets:start(httpc, [{profile, rebar}]). - inets:start(httpc, [{profile, rebar}]).
+ ensure_running(ssl, Caller). + ensure_running(ssl, Caller).
+%% Removed due to the hermicity requirements of Nix +%% Removed due to the hermicity requirements of Nix
+%% +%%
+%% inets:start(), +%% inets:start(),
+%% inets:start(httpc, [{profile, rebar}]). +%% inets:start(httpc, [{profile, rebar}]).
ensure_running(App, Caller) -> ensure_running(App, Caller) ->
case application:start(App) of case application:start(App) of
@@ -339,4 +341,4 @@ safe_define_test_macro(Opts) -> diff a/src/rebar_hermicity.erl b/src/rebar_hermicity.erl
test_defined([{d, 'TEST'}|_]) -> true;
test_defined([{d, 'TEST', true}|_]) -> true;
test_defined([_|Rest]) -> test_defined(Rest);
-test_defined([]) -> false.
\ No newline at end of file
+test_defined([]) -> false.
diff --git a/src/rebar_hermicity.erl b/src/rebar_hermicity.erl
new file mode 100644 new file mode 100644
index 0000000..d814e2a index 0000000..d814e2a
--- /dev/null --- /dev/null
@ -72,37 +65,29 @@ index 0000000..d814e2a
+ "are as follows:", []), + "are as follows:", []),
+ ?ERROR("Requesnt: ~p ~s", [Method, Url]), + ?ERROR("Requesnt: ~p ~s", [Method, Url]),
+ erlang:halt(1). + erlang:halt(1).
diff --git a/src/rebar_pkg_resource.erl b/src/rebar_pkg_resource.erl diff a/src/rebar_pkg_resource.erl b/src/rebar_pkg_resource.erl
index 4f55ad1..f76fd5d 100644 index ec7e09d..03be343 100644
--- a/src/rebar_pkg_resource.erl --- a/src/rebar_pkg_resource.erl
+++ b/src/rebar_pkg_resource.erl +++ b/src/rebar_pkg_resource.erl
@@ -100,10 +100,10 @@ make_vsn(_) -> @@ -104,7 +104,7 @@ make_vsn(_) ->
{error, "Replacing version of type pkg not supported."}. {error, "Replacing version of type pkg not supported."}.
request(Url, ETag) -> request(Url, ETag) ->
- case httpc:request(get, {Url, [{"if-none-match", ETag} || ETag =/= false]}, - case httpc:request(get, {Url, [{"if-none-match", ETag} || ETag =/= false]++[{"User-Agent", rebar_utils:user_agent()}]},
- [{ssl, ssl_opts(Url)}, {relaxed, true}], + case rebar_hermicity:request(get, {Url, [{"if-none-match", ETag} || ETag =/= false]++[{"User-Agent", rebar_utils:user_agent()}]},
- [{body_format, binary}], [{ssl, ssl_opts(Url)}, {relaxed, true}],
- rebar) of [{body_format, binary}],
+ case rebar_hermicity:request(get, {Url, [{"if-none-match", ETag} || ETag =/= false]}, rebar) of
+ [{ssl, ssl_opts(Url)}, {relaxed, true}], diff a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl
+ [{body_format, binary}], index 5e1e253..ea25b9e 100644
+ rebar) of
{ok, {{_Version, 200, _Reason}, Headers, Body}} ->
?DEBUG("Successfully downloaded ~s", [Url]),
{"etag", ETag1} = lists:keyfind("etag", 1, Headers),
diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl
index 6637ebe..d82c1d8 100644
--- a/src/rebar_prv_update.erl --- a/src/rebar_prv_update.erl
+++ b/src/rebar_prv_update.erl +++ b/src/rebar_prv_update.erl
@@ -44,8 +44,8 @@ do(State) -> @@ -52,7 +52,7 @@ do(State) ->
TmpFile = filename:join(TmpDir, "packages.gz"), case rebar_utils:url_append_path(CDN, ?REMOTE_REGISTRY_FILE) of
{ok, Url} ->
Url = rebar_state:get(State, rebar_packages_cdn, ?DEFAULT_HEX_REGISTRY), ?DEBUG("Fetching registry from ~p", [Url]),
- case httpc:request(get, {Url, []}, - case httpc:request(get, {Url, [{"User-Agent", rebar_utils:user_agent()}]},
- [], [{stream, TmpFile}, {sync, true}], + case rebar_hermicity:request(get, {Url, [{"User-Agent", rebar_utils:user_agent()}]},
+ case rebar_hermicity:request(get, {Url, []}, [], [{stream, TmpFile}, {sync, true}],
+ [], [{stream, TmpFile}, {sync, true}], rebar) of
rebar) of {ok, saved_to_file} ->
{ok, saved_to_file} ->
{ok, Data} = file:read_file(TmpFile),