From ea9b60f4be865f099e8ad67706141480b43a6c3f Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 21 Jun 2015 14:44:36 -0500 Subject: deduplicate parts of package and source dep handling --- src/rebar_prv_install_deps.erl | 40 +++++++++------------------------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 84bf266..cfce1b7 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -224,26 +224,13 @@ update_pkg_deps(Profile, Pkgs, Packages, Upgrade, Seen, State, Locks) -> handle_pkg_dep(Profile, Pkg, Packages, Upgrade, DepsDir, Fetched, Seen, Locks, State) -> IsLock = pkg_locked(Pkg, Locks), AppInfo = package_to_app(DepsDir, Packages, Pkg, IsLock, State), + Deps = rebar_app_info:deps(AppInfo), Level = rebar_app_info:dep_level(AppInfo), {NewSeen, NewState} = maybe_lock(Profile, AppInfo, Seen, State, Level), {_, AppInfo1} = maybe_fetch(AppInfo, Profile, Upgrade, Seen, NewState), - - Profiles = rebar_state:current_profiles(State), - Name = rebar_app_info:name(AppInfo1), - - S1 = rebar_app_info:state(AppInfo1), - S2 = rebar_state:apply_overrides(S1, Name), - - Plugins = rebar_state:get(S2, plugins, []), - S3 = rebar_state:set(S2, {plugins, Profile}, Plugins), - - S4 = rebar_state:apply_profiles(S3, Profiles), - AppInfo2 = rebar_app_info:state(AppInfo1, S4), - - %% Dep may have plugins to install. Find and install here. - S5 = rebar_plugins:install(S4), - AppInfo3 = rebar_app_info:state(AppInfo2, S5), - + {AppInfo2, _, _, _, _} = + handle_dep(NewState, Profile, DepsDir, AppInfo1, Locks, Level), + AppInfo3 = rebar_app_info:deps(AppInfo2, Deps), {[AppInfo3 | Fetched], NewSeen, NewState}. maybe_lock(Profile, AppInfo, Seen, State, Level) -> @@ -282,21 +269,12 @@ package_to_app(DepsDir, Packages, {Name, Vsn, Level}, IsLock, State) -> throw(?PRV_ERROR({missing_package, Name, Vsn})) end; {ok, PkgDeps} -> - {ok, AppInfo} = rebar_app_info:new(Name, Vsn), - AppInfo1 = rebar_app_info:deps(AppInfo, PkgDeps), - AppInfo2 = rebar_app_info:dir(AppInfo1, filename:join([DepsDir, Name])), - AppInfo3 = rebar_app_info:dep_level(AppInfo2, Level), - AppInfo4 = rebar_app_info:is_lock(AppInfo3, IsLock), - - C = rebar_config:consult(rebar_app_info:dir(AppInfo1)), + Source = {pkg, Name, Vsn}, + AppInfo = new_dep(DepsDir, Name, Vsn, Source, IsLock, State), + AppInfo1 = rebar_app_info:dep_level(rebar_app_info:deps(AppInfo, PkgDeps), Level), BaseDir = rebar_state:get(State, base_dir, []), - Overrides = rebar_state:get(State, overrides, []), - S = rebar_state:new(rebar_state:set(rebar_state:new(), base_dir, BaseDir), - C, rebar_app_info:dir(AppInfo1)), - ParentOverrides = rebar_state:overrides(State), - AppInfo5 = rebar_app_info:state(AppInfo4, - rebar_state:overrides(S, ParentOverrides++Overrides)), - rebar_app_info:source(AppInfo5, {pkg, Name, Vsn}) + AppState1 = rebar_state:set(rebar_app_info:state(AppInfo1), base_dir, BaseDir), + rebar_app_info:state(AppInfo1, AppState1) end. -spec update_src_deps(atom(), non_neg_integer(), list(), list(), list(), rebar_state:t(), boolean(), sets:set(binary()), list()) -> {rebar_state:t(), list(), list(), sets:set(binary())}. -- cgit v1.1