summaryrefslogtreecommitdiff
path: root/src/rebar_prv_install_deps.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_prv_install_deps.erl')
-rw-r--r--src/rebar_prv_install_deps.erl50
1 files changed, 33 insertions, 17 deletions
diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl
index e25e2c5..3fb2d71 100644
--- a/src/rebar_prv_install_deps.erl
+++ b/src/rebar_prv_install_deps.erl
@@ -99,6 +99,8 @@ format_error({bad_constraint, Name, Constraint}) ->
io_lib:format("Unable to parse version for package ~s: ~s", [Name, Constraint]);
format_error({parse_dep, Dep}) ->
io_lib:format("Failed parsing dep ~p", [Dep]);
+format_error({not_rebar_package, Package, Version}) ->
+ io_lib:format("Package not buildable with rebar3: ~s-~s", [Package, Version]);
format_error({missing_package, Package, Version}) ->
io_lib:format("Package not found in registry: ~s-~s", [Package, Version]);
format_error({cycles, Cycles}) ->
@@ -128,30 +130,39 @@ handle_deps(Profile, State, Deps, Locks) when is_list(Locks) ->
handle_deps(_Profile, State, [], _, _) ->
{ok, [], State};
handle_deps(Profile, State0, Deps, Upgrade, Locks) ->
- %% Read in package index and dep graph
- {Packages, Graph} = rebar_state:packages(State0),
- Registry = rebar_packages:registry(State0),
- State = rebar_state:packages(rebar_state:registry(State0, Registry), {Packages, Graph}),
%% Split source deps from pkg deps, needed to keep backwards compatibility
- DepsDir = profile_dep_dir(State, Profile),
- {SrcDeps, PkgDeps} = parse_deps(DepsDir, Deps, State, Locks, 0),
+ DepsDir = profile_dep_dir(State0, Profile),
+
+ {SrcDeps, PkgDeps} = parse_deps(DepsDir, Deps, State0, Locks, 0),
%% Fetch transitive src deps
- {State1, SrcApps, PkgDeps1, Seen} =
- update_src_deps(Profile, 0, SrcDeps, PkgDeps, [], State, Upgrade, sets:new(), Locks),
+ {State1, SrcApps, PkgDeps1, Seen} = update_src_deps(Profile, 0, SrcDeps, PkgDeps, []
+ ,State0, Upgrade, sets:new(), Locks),
- {Solved, State2} =
- update_pkg_deps(Profile, Packages, PkgDeps1, Graph, Upgrade, Seen, State1),
+ {Solved, State4} =
+ case PkgDeps1 of
+ [] ->
+ {[], State1};
+ _ ->
+ %% Read in package index and dep graph
+ {Packages, Graph} = rebar_state:packages(State1),
+ Registry = rebar_packages:registry(State1),
+ State2 = rebar_state:packages(rebar_state:registry(State1, Registry)
+ ,{Packages, Graph}),
+
+ update_pkg_deps(Profile, Packages, PkgDeps1
+ ,Graph, Upgrade, Seen, State2)
+ end,
AllDeps = lists:ukeymerge(2
,lists:ukeysort(2, SrcApps)
,lists:ukeysort(2, Solved)),
- State3 = rebar_state:update_all_deps(State2, AllDeps),
+ State5 = rebar_state:update_all_deps(State4, AllDeps),
CodePaths = [rebar_app_info:ebin_dir(A) || A <- AllDeps],
- State4 = rebar_state:update_code_paths(State3, all_deps, CodePaths),
+ State6 = rebar_state:update_code_paths(State5, all_deps, CodePaths),
- {ok, AllDeps, State4}.
+ {ok, AllDeps, State6}.
%% ===================================================================
%% Internal functions
@@ -201,7 +212,7 @@ update_pkg_deps(Profile, Pkgs, Packages, Upgrade, Seen, State) ->
{Solved, State1}.
handle_pkg_dep(Profile, Pkg, Packages, Upgrade, DepsDir, Fetched, Seen, State) ->
- AppInfo = package_to_app(DepsDir, Packages, Pkg),
+ AppInfo = package_to_app(DepsDir, Packages, Pkg, State),
Level = rebar_app_info:dep_level(AppInfo),
{NewSeen, NewState} = maybe_lock(Profile, AppInfo, Seen, State, Level),
{_, AppInfo1} = maybe_fetch(AppInfo, Profile, Upgrade, Seen, NewState),
@@ -233,10 +244,15 @@ maybe_lock(Profile, AppInfo, Seen, State, Level) ->
{Seen, State}
end.
-package_to_app(DepsDir, Packages, {Name, Vsn, Level}) ->
+package_to_app(DepsDir, Packages, {Name, Vsn, Level}, State) ->
case dict:find({Name, Vsn}, Packages) of
error ->
- throw(?PRV_ERROR({missing_package, Name, Vsn}));
+ case rebar_packages:check_registry(Name, Vsn, State) of
+ true ->
+ throw(?PRV_ERROR({not_rebar_package, Name, Vsn}));
+ false ->
+ throw(?PRV_ERROR({missing_package, Name, Vsn}))
+ end;
{ok, P} ->
PkgDeps = [{PkgName, PkgVsn}
|| {PkgName,PkgVsn} <- proplists:get_value(<<"deps">>, P, [])],
@@ -617,7 +633,7 @@ not_needs_compile(App) ->
get_package(Dep, State) ->
case rebar_state:registry(State) of
{ok, T} ->
- HighestDepVsn = rebar_packages:find_highest_matching(Dep, "0", T),
+ {ok, HighestDepVsn} = rebar_packages:find_highest_matching(Dep, "0", T),
{Dep, HighestDepVsn};
error ->
throw(?PRV_ERROR({load_registry_fail, Dep}))