mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
Implement update-deps and disable auto update
This commit is contained in:
parent
57e593a319
commit
d8e50e8c2d
3 changed files with 44 additions and 24 deletions
|
@ -10,7 +10,7 @@ _rebar()
|
||||||
lopts=" --help --commands --verbose --force --jobs= --version"
|
lopts=" --help --commands --verbose --force --jobs= --version"
|
||||||
cmdsnvars="build-plt check-plt check-deps clean compile \
|
cmdsnvars="build-plt check-plt check-deps clean compile \
|
||||||
create create-app create-node ct dialyze doc delete-deps eunit \
|
create create-app create-node ct dialyze doc delete-deps eunit \
|
||||||
get-deps generate help list-templates version xref \
|
get-deps generate help list-templates update-deps version xref \
|
||||||
case= debug_info=1 force=1 jobs= suite= verbose=1 appid= \
|
case= debug_info=1 force=1 jobs= suite= verbose=1 appid= \
|
||||||
skip_deps=1 template= template_dir="
|
skip_deps=1 template= template_dir="
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,7 @@ doc Generate Erlang program documentation
|
||||||
|
|
||||||
check-deps Display to be fetched dependencies
|
check-deps Display to be fetched dependencies
|
||||||
get-deps Fetch dependencies
|
get-deps Fetch dependencies
|
||||||
|
update-deps Update fetched dependencies
|
||||||
delete-deps Delete fetched dependencies
|
delete-deps Delete fetched dependencies
|
||||||
|
|
||||||
generate [dump_spec=0/1] Build release with reltool
|
generate [dump_spec=0/1] Build release with reltool
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
compile/2,
|
compile/2,
|
||||||
'check-deps'/2,
|
'check-deps'/2,
|
||||||
'get-deps'/2,
|
'get-deps'/2,
|
||||||
|
'update-deps'/2,
|
||||||
'delete-deps'/2]).
|
'delete-deps'/2]).
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ preprocess(Config, _) ->
|
||||||
%% Get the list of deps for the current working directory and identify those
|
%% Get the list of deps for the current working directory and identify those
|
||||||
%% deps that are available/present.
|
%% deps that are available/present.
|
||||||
Deps = rebar_config:get_local(Config, deps, []),
|
Deps = rebar_config:get_local(Config, deps, []),
|
||||||
{AvailableDeps, MissingDeps} = find_deps(Deps),
|
{AvailableDeps, MissingDeps} = find_deps(find, Deps),
|
||||||
|
|
||||||
?DEBUG("Available deps: ~p\n", [AvailableDeps]),
|
?DEBUG("Available deps: ~p\n", [AvailableDeps]),
|
||||||
?DEBUG("Missing deps : ~p\n", [MissingDeps]),
|
?DEBUG("Missing deps : ~p\n", [MissingDeps]),
|
||||||
|
@ -93,7 +94,7 @@ compile(Config, AppFile) ->
|
||||||
'check-deps'(Config, _) ->
|
'check-deps'(Config, _) ->
|
||||||
%% Get the list of immediate (i.e. non-transitive) deps that are missing
|
%% Get the list of immediate (i.e. non-transitive) deps that are missing
|
||||||
Deps = rebar_config:get_local(Config, deps, []),
|
Deps = rebar_config:get_local(Config, deps, []),
|
||||||
case find_deps(Deps) of
|
case find_deps(find, Deps) of
|
||||||
{_, []} ->
|
{_, []} ->
|
||||||
%% No missing deps
|
%% No missing deps
|
||||||
ok;
|
ok;
|
||||||
|
@ -108,26 +109,31 @@ compile(Config, AppFile) ->
|
||||||
'get-deps'(Config, _) ->
|
'get-deps'(Config, _) ->
|
||||||
%% Determine what deps are available and missing
|
%% Determine what deps are available and missing
|
||||||
Deps = rebar_config:get_local(Config, deps, []),
|
Deps = rebar_config:get_local(Config, deps, []),
|
||||||
{AvailableDeps, MissingDeps} = find_deps(Deps),
|
{_AvailableDeps, MissingDeps} = find_deps(find, Deps),
|
||||||
|
|
||||||
%% For each missing dep with a specified source, try to pull it.
|
%% For each missing dep with a specified source, try to pull it.
|
||||||
PulledDeps0 = [use_source(D) || D <- MissingDeps, D#dep.source /= undefined],
|
PulledDeps = [use_source(D) || D <- MissingDeps, D#dep.source /= undefined],
|
||||||
|
|
||||||
%% For each available dep try to update the source to the specified
|
|
||||||
%% version.
|
|
||||||
PulledDeps1 = [update_source(D) || D <- AvailableDeps,
|
|
||||||
D#dep.source /= undefined],
|
|
||||||
|
|
||||||
%% Add each pulled dep to our list of dirs for post-processing. This yields
|
%% Add each pulled dep to our list of dirs for post-processing. This yields
|
||||||
%% the necessary transitivity of the deps
|
%% the necessary transitivity of the deps
|
||||||
erlang:put(?MODULE, [D#dep.dir || D <- PulledDeps0 ++ PulledDeps1]),
|
erlang:put(?MODULE, [D#dep.dir || D <- PulledDeps]),
|
||||||
|
ok.
|
||||||
|
|
||||||
|
'update-deps'(Config, _) ->
|
||||||
|
%% Determine what deps are available and missing
|
||||||
|
Deps = rebar_config:get_local(Config, deps, []),
|
||||||
|
UpdatedDeps = [update_source(D) || D <- find_deps(read, Deps),
|
||||||
|
D#dep.source /= undefined],
|
||||||
|
%% Add each updated dep to our list of dirs for post-processing. This yields
|
||||||
|
%% the necessary transitivity of the deps
|
||||||
|
erlang:put(?MODULE, [D#dep.dir || D <- UpdatedDeps]),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
'delete-deps'(Config, _) ->
|
'delete-deps'(Config, _) ->
|
||||||
%% Delete all the available deps in our deps/ directory, if any
|
%% Delete all the available deps in our deps/ directory, if any
|
||||||
DepsDir = get_deps_dir(),
|
DepsDir = get_deps_dir(),
|
||||||
Deps = rebar_config:get_local(Config, deps, []),
|
Deps = rebar_config:get_local(Config, deps, []),
|
||||||
{AvailableDeps, _} = find_deps(Deps),
|
{AvailableDeps, _} = find_deps(find, Deps),
|
||||||
_ = [delete_dep(D) || D <- AvailableDeps,
|
_ = [delete_dep(D) || D <- AvailableDeps,
|
||||||
lists:prefix(DepsDir, D#dep.dir) == true],
|
lists:prefix(DepsDir, D#dep.dir) == true],
|
||||||
ok.
|
ok.
|
||||||
|
@ -163,35 +169,48 @@ update_deps_code_path([Dep | Rest]) ->
|
||||||
end,
|
end,
|
||||||
update_deps_code_path(Rest).
|
update_deps_code_path(Rest).
|
||||||
|
|
||||||
find_deps(Deps) ->
|
|
||||||
find_deps(Deps, {[], []}).
|
|
||||||
|
|
||||||
find_deps([], {Avail, Missing}) ->
|
find_deps(find=Mode, Deps) ->
|
||||||
|
find_deps(Mode, Deps, {[], []});
|
||||||
|
find_deps(read=Mode, Deps) ->
|
||||||
|
find_deps(Mode, Deps, []).
|
||||||
|
|
||||||
|
find_deps(find, [], {Avail, Missing}) ->
|
||||||
{lists:reverse(Avail), lists:reverse(Missing)};
|
{lists:reverse(Avail), lists:reverse(Missing)};
|
||||||
find_deps([App | Rest], Acc) when is_atom(App) ->
|
find_deps(read, [], Deps) ->
|
||||||
find_deps([{App, ".*", undefined} | Rest], Acc);
|
lists:reverse(Deps);
|
||||||
find_deps([{App, VsnRegex} | Rest], Acc) when is_atom(App) ->
|
find_deps(Mode, [App | Rest], Acc) when is_atom(App) ->
|
||||||
find_deps([{App, VsnRegex, undefined} | Rest], Acc);
|
find_deps(Mode, [{App, ".*", undefined} | Rest], Acc);
|
||||||
find_deps([{App, VsnRegex, Source} | Rest], {Avail, Missing}) ->
|
find_deps(Mode, [{App, VsnRegex} | Rest], Acc) when is_atom(App) ->
|
||||||
|
find_deps(Mode, [{App, VsnRegex, undefined} | Rest], Acc);
|
||||||
|
find_deps(Mode, [{App, VsnRegex, Source} | Rest], Acc) ->
|
||||||
Dep = #dep { app = App,
|
Dep = #dep { app = App,
|
||||||
vsn_regex = VsnRegex,
|
vsn_regex = VsnRegex,
|
||||||
source = Source },
|
source = Source },
|
||||||
case is_app_available(App, VsnRegex) of
|
case is_app_available(App, VsnRegex) of
|
||||||
{true, AppDir} ->
|
{true, AppDir} ->
|
||||||
find_deps(Rest, {[Dep#dep { dir = AppDir } | Avail], Missing});
|
find_deps(Mode, Rest, acc_deps(Mode, avail, Dep, AppDir, Acc));
|
||||||
{false, _} ->
|
{false, _} ->
|
||||||
AppDir = filename:join(get_deps_dir(), Dep#dep.app),
|
AppDir = filename:join(get_deps_dir(), Dep#dep.app),
|
||||||
case is_app_available(App, VsnRegex, AppDir) of
|
case is_app_available(App, VsnRegex, AppDir) of
|
||||||
{true, AppDir} ->
|
{true, AppDir} ->
|
||||||
find_deps(Rest, {[Dep#dep { dir = AppDir } | Avail], Missing});
|
find_deps(Mode, Rest,
|
||||||
|
acc_deps(Mode, avail, Dep, AppDir, Acc));
|
||||||
{false, _} ->
|
{false, _} ->
|
||||||
find_deps(Rest, {Avail, [Dep#dep { dir = AppDir } | Missing]})
|
find_deps(Mode, Rest,
|
||||||
|
acc_deps(Mode, missing, Dep, AppDir, Acc))
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
find_deps([Other | _Rest], _Acc) ->
|
find_deps(_Mode, [Other | _Rest], _Acc) ->
|
||||||
?ABORT("Invalid dependency specification ~p in ~s\n",
|
?ABORT("Invalid dependency specification ~p in ~s\n",
|
||||||
[Other, rebar_utils:get_cwd()]).
|
[Other, rebar_utils:get_cwd()]).
|
||||||
|
|
||||||
|
acc_deps(find, avail, Dep, AppDir, {Avail, Missing}) ->
|
||||||
|
{[Dep#dep { dir = AppDir } | Avail], Missing};
|
||||||
|
acc_deps(find, missing, Dep, AppDir, {Avail, Missing}) ->
|
||||||
|
{Avail, [Dep#dep { dir = AppDir } | Missing]};
|
||||||
|
acc_deps(read, _, Dep, AppDir, Acc) ->
|
||||||
|
[Dep#dep { dir = AppDir } | Acc].
|
||||||
|
|
||||||
delete_dep(D) ->
|
delete_dep(D) ->
|
||||||
case filelib:is_dir(D#dep.dir) of
|
case filelib:is_dir(D#dep.dir) of
|
||||||
|
|
Loading…
Reference in a new issue