diff options
-rwxr-xr-x | bootstrap | 53 | ||||
-rw-r--r-- | rebar.config | 37 | ||||
-rw-r--r-- | rebar.lock | 26 |
3 files changed, 61 insertions, 55 deletions
@@ -4,6 +4,15 @@ main(_Args) -> + case crypto:start() of + ok -> ok; + {error,{already_started,crypto}} -> ok + end, + application:start(asn1), + application:start(public_key), + application:start(ssl), + inets:start(), + %% Fetch and build deps required to build rebar3 BaseDeps = [{providers, []} ,{getopt, []} @@ -24,6 +33,7 @@ main(_Args) -> setup_env(), os:putenv("REBAR_PROFILE", "bootstrap"), + rebar3:run(["update"]), {ok, State} = rebar3:run(["compile"]), reset_env(), os:putenv("REBAR_PROFILE", ""), @@ -56,28 +66,33 @@ fetch_and_compile({Name, ErlFirstFiles}, Deps) -> ok = fetch(Repo, Name), compile(Name, ErlFirstFiles). -fetch({git, Url, Source}, App) -> +fetch({pkg, Name, Vsn}, App) -> Dir = filename:join([filename:absname("_build/default/lib/"), App]), - case filelib:is_dir(Dir) of - true -> - true = code:add_path(filename:join(Dir, "ebin")), - ok; - false -> - fetch_source(Dir, Url, Source), - ok + 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. -fetch_source(Dir, Url, {ref, Ref}) -> - ok = filelib:ensure_dir(Dir), - os:cmd(io_lib:format("git clone ~s ~s", [Url, Dir])), - {ok, Cwd} = file:get_cwd(), - file:set_cwd(Dir), - os:cmd(io_lib:format("git checkout -q ~s", [Ref])), - file:set_cwd(Cwd); -fetch_source(Dir, Url, {_, Branch}) -> - ok = filelib:ensure_dir(Dir), - os:cmd(io_lib:format("git clone ~s ~s -b ~s --single-branch", - [Url, Dir, Branch])). +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}]) of + {ok, {{_Version, 200, _Reason}, _Headers, Body}} -> + {ok, Body}; + Error -> + Error + end. compile(App, FirstFiles) -> Dir = filename:join(filename:absname("_build/default/lib/"), App), diff --git a/rebar.config b/rebar.config index 895c78b..ab679dc 100644 --- a/rebar.config +++ b/rebar.config @@ -3,12 +3,10 @@ {deps, [ {erlware_commons, "0.12.0"}, - {providers, "1.4.1"}, - {getopt, "0.8.2"}, - {bbmustache, "1.0.0"}, - {relx, "", - {git, "https://github.com/erlware/relx.git", - {branch, "master"}}}]}. + {providers, "1.4.1"}, + {getopt, "0.8.2"}, + {bbmustache, "1.0.1"}, + {relx, "2.1.0"}]}. {escript_name, rebar3}. {escript_emu_args, "%%! +sbtu +A0\n"}. @@ -33,7 +31,9 @@ {erl_opts, [debug_info]} ]}, - {bootstrap, []} + {bootstrap, []}, + + {dialyze, [{erl_opts, [debug_info]}]} ]}. %% Overrides @@ -42,16 +42,23 @@ {platform_define, "^R1[4|5]", deprecated_crypto}, no_debug_info, warnings_as_errors]}, - {deps, []}, {plugins, []} + {deps, []}, {plugins, []}, + {profiles, [{dialyze, [{erl_opts, [debug_info]}]}]} ]}, - {override, mustache, [ - {erl_opts, [{platform_define, "^[0-9]+", namespaced_types}, - no_debug_info]}, - {deps, []}, {plugins, []}]}, - {override, getopt, [{erl_opts, [no_debug_info]}]}, - {override, providers, [{erl_opts, [no_debug_info]}]}, + {override, bbmustache, [ + {erl_opts, [no_debug_info, + {platform_define, "^[0-9]+", namespaced_types}]}, + {deps, []}, {plugins, []}, + {profiles, [{dialyze, [{erl_opts, [debug_info]}]}]} + ]}, + {override, getopt, [{erl_opts, [no_debug_info]}, + {profiles, [{dialyze, [{erl_opts, [debug_info]}]}]}]}, + {override, providers, [{erl_opts, [no_debug_info]}, + {profiles, [{dialyze, [{erl_opts, [debug_info]}]}]}]}, {override, relx, [{erl_opts, [{platform_define, "^[0-9]+", namespaced_types}, {platform_define, "^R1[4|5]", deprecated_crypto}, no_debug_info, - warnings_as_errors]}]} + warnings_as_errors]}, + {profiles, [{dialyze, [{erl_opts, [debug_info]}]}]} + ]} ]}. @@ -1,21 +1,5 @@ -[{<<"bbmustache">>,{pkg,<<"bbmustache">>,<<"1.0.0">>},0}, - {<<"relx">>, - {git,"https://github.com/erlware/relx.git", - {ref,"74fec3455ba6dbb7d9e369137c1b15ab10804993"}}, - 0}, - {<<"providers">>, - {git,"https://github.com/tsloughter/providers.git", - {ref,"adc0af0a3f5de2049419a753777686b94f4e2c90"}}, - 0}, - {<<"mustache">>, - {git,"https://github.com/soranoba/mustache.git", - {ref,"e5401042c66039eef20ee81abc1537ced1f22bc7"}}, - 0}, - {<<"getopt">>, - {git,"https://github.com/jcomellas/getopt.git", - {ref,"626698975e63866156159661d100785d65eab6f9"}}, - 0}, - {<<"erlware_commons">>, - {git,"https://github.com/erlware/erlware_commons.git", - {ref,"ef0d252b11c863f9c228af2fe93a4e42fba2f7f3"}}, - 0}]. +[{<<"bbmustache">>,{pkg,<<"bbmustache">>,<<"1.0.1">>},0}, + {<<"providers">>,{pkg,<<"providers">>,<<"1.4.1">>},0}, + {<<"erlware_commons">>,{pkg,<<"erlware_commons">>,<<"0.12.0">>},0}, + {<<"relx">>,{pkg,<<"relx">>,<<"2.1.0">>},0}, + {<<"getopt">>,{pkg,<<"getopt">>,<<"0.8.2">>},0}]. |