From 8dc0fafb36702703867306f8df16714f0dbdc17c Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 11 Jul 2015 12:25:53 -0500 Subject: fix for empty rebar.lock during bootstrap --- bootstrap | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bootstrap b/bootstrap index 71c44da..4e85d20 100755 --- a/bootstrap +++ b/bootstrap @@ -61,8 +61,12 @@ main(_Args) -> end. fetch_and_compile({Name, ErlFirstFiles}, Deps) -> - {Name, _, Repo} = lists:keyfind(Name, 1, Deps), - ok = fetch(Repo, Name), + 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, compile(Name, ErlFirstFiles). fetch({pkg, Name, Vsn}, App) -> @@ -279,6 +283,11 @@ write_windows_scripts() -> get_deps() -> case file:consult("rebar.lock") of + {ok, [[]]} -> + %% Something went wrong in a previous build, lock file shouldn't be empty + ok = file:delete("rebar.lock"), + {ok, Config} = file:consult("rebar.config"), + proplists:get_value(deps, Config); {ok, [Deps]} -> [{binary_to_atom(Name, utf8), "", Source} || {Name, Source, _Level} <- Deps]; _ -> -- cgit v1.1 From a06a2f8917a9075bdd150d692a85dd65f211a51d Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 11 Jul 2015 12:42:38 -0500 Subject: handle global plugins installing plugins to build deps --- src/rebar_state.erl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rebar_state.erl b/src/rebar_state.erl index d0b28de..4b8a282 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -289,7 +289,13 @@ apply_profiles(State, Profile) when not is_list(Profile) -> apply_profiles(State, [default]) -> State; apply_profiles(State=#state_t{default = Defaults, current_profiles=CurrentProfiles}, Profiles) -> - AppliedProfiles = deduplicate(CurrentProfiles ++ Profiles), + AppliedProfiles = case Profiles of + [global | _] -> + Profiles; + _ -> + deduplicate(CurrentProfiles ++ Profiles) + end, + ConfigProfiles = rebar_state:get(State, profiles, []), NewOpts = -- cgit v1.1 From a67ce27ac17234aae720ec159ef6eb733a30f716 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 11 Jul 2015 16:14:49 -0500 Subject: add comment for global apply_profiles and log message for bad bootstrap lock file --- bootstrap | 1 + src/rebar_state.erl | 3 +++ 2 files changed, 4 insertions(+) diff --git a/bootstrap b/bootstrap index 4e85d20..e35445c 100755 --- a/bootstrap +++ b/bootstrap @@ -285,6 +285,7 @@ get_deps() -> case file:consult("rebar.lock") of {ok, [[]]} -> %% Something went wrong in a previous build, lock file shouldn't be empty + io:format("Empty list in lock file, deleting rebar.lock~n"), ok = file:delete("rebar.lock"), {ok, Config} = file:consult("rebar.config"), proplists:get_value(deps, Config); diff --git a/src/rebar_state.erl b/src/rebar_state.erl index 4b8a282..1e0abc5 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -290,6 +290,9 @@ apply_profiles(State, [default]) -> State; apply_profiles(State=#state_t{default = Defaults, current_profiles=CurrentProfiles}, Profiles) -> AppliedProfiles = case Profiles of + %% Head of list global profile is special, only for use by rebar3 + %% It does not clash if a user does `rebar3 as global...` but when + %% it is the head we must make sure not to prepend `default` [global | _] -> Profiles; _ -> -- cgit v1.1