summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2015-05-09 17:11:51 -0500
committerTristan Sloughter <t@crashfast.com>2015-05-09 17:12:26 -0500
commitc612b0e1fdeb502bb7892b52a288b0fcbbb8b457 (patch)
treec3ad60e419949c22af5e1379fd24fc5ad2941892
parentb833dbfde403a2f3da6103f53fd475a870d4d874 (diff)
check registry for missing package that may exist for mix
-rw-r--r--src/rebar_packages.erl13
-rw-r--r--src/rebar_prv_install_deps.erl13
2 files changed, 23 insertions, 3 deletions
diff --git a/src/rebar_packages.erl b/src/rebar_packages.erl
index fb2d094..4ab5f9f 100644
--- a/src/rebar_packages.erl
+++ b/src/rebar_packages.erl
@@ -2,6 +2,7 @@
-export([get_packages/1
,registry/1
+ ,check_registry/3
,find_highest_matching/3]).
-export_type([package/0]).
@@ -52,6 +53,18 @@ registry(State) ->
error
end.
+check_registry(Pkg, Vsn, State) ->
+ case rebar_state:registry(State) of
+ {ok, T} ->
+ case ets:lookup(T, Pkg) of
+ [{Pkg, [Vsns]}] ->
+ lists:member(Vsn, Vsns);
+ _ ->
+ false
+ end;
+ error ->
+ false
+ end.
%% Hex supports use of ~> to specify the version required for a dependency.
%% Since rebar3 requires exact versions to choose from we find the highest
diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl
index 5aa34c3..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}) ->
@@ -210,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),
@@ -242,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, [])],