summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rebar.config4
-rw-r--r--rebar.lock4
-rw-r--r--src/rebar_prv_install_deps.erl26
-rw-r--r--src/rebar_prv_packages.erl10
-rw-r--r--src/rebar_prv_upgrade.erl3
-rw-r--r--test/rebar_pkg_SUITE.erl12
6 files changed, 40 insertions, 19 deletions
diff --git a/rebar.config b/rebar.config
index 2ce40e2..1b3a8c8 100644
--- a/rebar.config
+++ b/rebar.config
@@ -5,8 +5,8 @@
{ssl_verify_hostname, "1.0.5"},
{providers, "1.4.1"},
{getopt, "0.8.2"},
- {bbmustache, "1.0.3"},
- {relx, "3.4.0"}]}.
+ {bbmustache, "1.0.4"},
+ {relx, "3.5.0"}]}.
{escript_name, rebar3}.
{escript_emu_args, "%%! +sbtu +A0\n"}.
diff --git a/rebar.lock b/rebar.lock
index fbf62de..614749c 100644
--- a/rebar.lock
+++ b/rebar.lock
@@ -1,6 +1,6 @@
-[{<<"bbmustache">>,{pkg,<<"bbmustache">>,<<"1.0.3">>},0},
+[{<<"bbmustache">>,{pkg,<<"bbmustache">>,<<"1.0.4">>},0},
{<<"erlware_commons">>,{pkg,<<"erlware_commons">>,<<"0.15.0">>},0},
{<<"getopt">>,{pkg,<<"getopt">>,<<"0.8.2">>},0},
{<<"providers">>,{pkg,<<"providers">>,<<"1.4.1">>},0},
- {<<"relx">>,{pkg,<<"relx">>,<<"3.4.0">>},0},
+ {<<"relx">>,{pkg,<<"relx">>,<<"3.5.0">>},0},
{<<"ssl_verify_hostname">>,{pkg,<<"ssl_verify_hostname">>,<<"1.0.5">>},0}].
diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl
index 2d725a4..ca9344b 100644
--- a/src/rebar_prv_install_deps.erl
+++ b/src/rebar_prv_install_deps.erl
@@ -98,6 +98,8 @@ do(State) ->
end.
-spec format_error(any()) -> iolist().
+format_error({dep_app_not_found, AppDir, AppName}) ->
+ io_lib:format("Dependency failure: Application ~s not found at the top level of directory ~s", [AppName, AppDir]);
format_error({load_registry_fail, Dep}) ->
io_lib:format("Error loading registry to resolve version of ~s. Try fixing by running 'rebar3 update'", [Dep]);
format_error({bad_constraint, Name, Constraint}) ->
@@ -358,16 +360,20 @@ fetch_app(AppInfo, AppDir, State) ->
%% So this is the first time for newly downloaded apps that its .app/.app.src data can
%% be read in an parsed.
update_app_info(AppDir, AppInfo) ->
- {ok, Found} = rebar_app_info:discover(AppDir),
- AppDetails = rebar_app_info:app_details(Found),
- Vsn = rebar_app_info:original_vsn(Found),
- Applications = proplists:get_value(applications, AppDetails, []),
- IncludedApplications = proplists:get_value(included_applications, AppDetails, []),
- AppInfo1 = rebar_app_info:original_vsn(rebar_app_info:applications(
- rebar_app_info:app_details(AppInfo, AppDetails),
- IncludedApplications++Applications), Vsn),
- AppInfo2 = copy_app_info(AppInfo, AppInfo1),
- rebar_app_info:valid(AppInfo2, undefined).
+ case rebar_app_info:discover(AppDir) of
+ {ok, Found} ->
+ AppDetails = rebar_app_info:app_details(Found),
+ Vsn = rebar_app_info:original_vsn(Found),
+ Applications = proplists:get_value(applications, AppDetails, []),
+ IncludedApplications = proplists:get_value(included_applications, AppDetails, []),
+ AppInfo1 = rebar_app_info:original_vsn(rebar_app_info:applications(
+ rebar_app_info:app_details(AppInfo, AppDetails),
+ IncludedApplications++Applications), Vsn),
+ AppInfo2 = copy_app_info(AppInfo, AppInfo1),
+ rebar_app_info:valid(AppInfo2, undefined);
+ not_found ->
+ throw(?PRV_ERROR({dep_app_not_found, AppDir, rebar_app_info:name(AppInfo)}))
+ end.
copy_app_info(OldAppInfo, NewAppInfo) ->
Deps = rebar_app_info:deps(OldAppInfo),
diff --git a/src/rebar_prv_packages.erl b/src/rebar_prv_packages.erl
index f5d9e38..5b8ea66 100644
--- a/src/rebar_prv_packages.erl
+++ b/src/rebar_prv_packages.erl
@@ -35,8 +35,12 @@ format_error(load_registry_fail) ->
"Failed to load package regsitry. Try running 'rebar3 update' to fix".
print_packages() ->
- SortedPkgs = ets:foldl(fun({{Pkg, Vsn}, _}, Acc) ->
- orddict:append_list(Pkg, [Vsn], Acc)
+ SortedPkgs = ets:foldl(fun({package_index_version, _}, Acc) ->
+ Acc;
+ ({Pkg, Vsns}, Acc) ->
+ orddict:store(Pkg, Vsns, Acc);
+ (_, Acc) ->
+ Acc
end, orddict:new(), ?PACKAGE_TABLE),
orddict:map(fun(Name, Vsns) ->
@@ -45,7 +49,7 @@ print_packages() ->
,ec_semver:parse(B))
end, Vsns),
VsnStr = join(SortedVsns, <<", ">>),
- io:format("~s:~n Versions: ~s~n~n", [Name, VsnStr])
+ ?CONSOLE("~s:~n Versions: ~s~n", [Name, VsnStr])
end, SortedPkgs).
-spec join([binary()], binary()) -> binary().
diff --git a/src/rebar_prv_upgrade.erl b/src/rebar_prv_upgrade.erl
index 7385cfe..97d1953 100644
--- a/src/rebar_prv_upgrade.erl
+++ b/src/rebar_prv_upgrade.erl
@@ -100,7 +100,8 @@ prepare_locks([Name|Names], Deps, Locks, Unlocks) ->
{_, _, 0} = Lock ->
case rebar_utils:tup_find(AtomName, Deps) of
false ->
- ?PRV_ERROR({unknown_dependency, Name});
+ ?WARN("Dependency ~s has been removed and will not be upgraded", [Name]),
+ prepare_locks(Names, Deps, Locks, Unlocks);
Dep ->
{Source, NewLocks, NewUnlocks} = prepare_lock(Dep, Lock, Locks),
prepare_locks(Names, Deps, NewLocks,
diff --git a/test/rebar_pkg_SUITE.erl b/test/rebar_pkg_SUITE.erl
index b0b7eda..b3201ad 100644
--- a/test/rebar_pkg_SUITE.erl
+++ b/test/rebar_pkg_SUITE.erl
@@ -11,7 +11,7 @@
-define(good_checksum, <<"1C6CE379D191FBAB41B7905075E0BF87CBBE23C77CECE775C5A0B786B2244C35">>).
all() -> [good_uncached, good_cached, badindexchk, badpkg,
- bad_to_good, good_disconnect, bad_disconnect].
+ bad_to_good, good_disconnect, bad_disconnect, pkgs_provider].
init_per_suite(Config) ->
application:start(meck),
@@ -20,6 +20,8 @@ init_per_suite(Config) ->
end_per_suite(_Config) ->
application:stop(meck).
+init_per_testcase(pkgs_provider, Config) ->
+ Config;
init_per_testcase(good_uncached=Name, Config0) ->
Config = [{good_cache, false},
{pkg, {<<"goodpkg">>, <<"1.0.0">>}}
@@ -74,6 +76,8 @@ init_per_testcase(bad_disconnect=Name, Config0) ->
meck:expect(httpc, request, fun(_, _, _, _, _) -> {error, econnrefused} end),
Config.
+end_per_testcase(pkgs_provider, Config) ->
+ Config;
end_per_testcase(_, Config) ->
unmock_config(Config),
Config.
@@ -151,6 +155,12 @@ bad_disconnect(Config) ->
?assertEqual({fetch_fail, Pkg, Vsn},
rebar_pkg_resource:download(Tmp, {pkg, Pkg, Vsn}, State)).
+pkgs_provider(Config) ->
+ Config1 = rebar_test_utils:init_rebar_state(Config),
+ rebar_test_utils:run_and_check(
+ Config1, [], ["pkgs"],
+ {ok, []}
+ ).
%%%%%%%%%%%%%%%
%%% Helpers %%%