Преглед на файлове

Skip update and compilation if possible.

This detects existence of Hex registry at
$HOME/.cache/rebar3/hex/default/registry and skips "rebar3 update" step.
It also detect presence of bootstrap dependencies in _build/default/lib/
and skips fetching them.
pull/982/head
Gleb Peregud преди 9 години
родител
ревизия
cde592150b
променени са 1 файла, в които са добавени 28 реда и са изтрити 12 реда
  1. +28
    -12
      bootstrap

+ 28
- 12
bootstrap Целия файл

@ -2,8 +2,7 @@
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ft=erlang ts=4 sw=4 et
main(_Args) ->
main(_) ->
application:start(crypto),
application:start(asn1),
application:start(public_key),
@ -34,7 +33,14 @@ main(_Args) ->
setup_env(),
os:putenv("REBAR_PROFILE", "bootstrap"),
rebar3:run(["update"]),
RegistryFile = default_registry_file(),
case filelib:is_file(RegistryFile) of
true ->
ok;
false ->
rebar3:run(["update"])
end,
{ok, State} = rebar3:run(["compile"]),
reset_env(),
os:putenv("REBAR_PROFILE", ""),
@ -62,6 +68,11 @@ main(_Args) ->
ok
end.
default_registry_file() ->
{ok, [[Home]]} = init:get_argument(home),
CacheDir = filename:join([Home, ".cache", "rebar3"]),
filename:join([CacheDir, "hex", "default", "registry"]).
fetch_and_compile({Name, ErlFirstFiles}, Deps) ->
case lists:keyfind(Name, 1, Deps) of
{Name, Vsn} ->
@ -79,15 +90,20 @@ fetch_and_compile({Name, ErlFirstFiles}, Deps) ->
fetch({pkg, Name, Vsn}, App) ->
Dir = filename:join([filename:absname("_build/default/lib/"), App]),
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])
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) ->

Зареждане…
Отказ
Запис