diff options
Diffstat (limited to 'src/rebar_prv_update.erl')
-rw-r--r-- | src/rebar_prv_update.erl | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl index d0ff889..942b386 100644 --- a/src/rebar_prv_update.erl +++ b/src/rebar_prv_update.erl @@ -52,7 +52,8 @@ do(State) -> write_registry(Dict, Graph, State), ok catch - _E:_C -> + _E:C -> + ?DEBUG("Error creating package index: ~p ~p", [C, erlang:get_stacktrace()]), throw(?PRV_ERROR(package_index_write)) end, @@ -71,6 +72,10 @@ write_registry(Dict, {digraph, Edges, Vertices, Neighbors, _}, State) -> ets:tab2file(Neighbors, filename:join(RegistryDir, "neighbors")), file:write_file(filename:join(RegistryDir, "dict"), term_to_binary(Dict)). +is_supported(<<"make">>) -> true; +is_supported(<<"rebar">>) -> true; +is_supported(_) -> false. + hex_to_graph(Filename) -> {ok, T} = ets:file2tab(Filename), Graph = digraph:new(), @@ -82,9 +87,14 @@ hex_to_graph(Filename) -> ok end, ok, T), - Dict1 = ets:foldl(fun({{Pkg, PkgVsn}, [Deps | _]}, Dict) -> - DepsList = update_graph(Pkg, PkgVsn, Deps, T, Graph), - dict:store({Pkg, PkgVsn}, DepsList, Dict); + Dict1 = ets:foldl(fun({{Pkg, PkgVsn}, [Deps, _, BuildTools | _]}, Dict) when is_list(BuildTools) -> + case lists:any(fun is_supported/1, BuildTools) of + true -> + DepsList = update_graph(Pkg, PkgVsn, Deps, T, Graph), + dict:store({Pkg, PkgVsn}, DepsList, Dict); + false -> + Dict + end; (_, Dict) -> Dict end, dict:new(), T), @@ -94,9 +104,13 @@ update_graph(Pkg, PkgVsn, Deps, HexRegistry, Graph) -> lists:foldl(fun([Dep, DepVsn, false, _AppName | _], DepsListAcc) -> case DepVsn of <<"~> ", Vsn/binary>> -> - HighestDepVsn = rebar_packages:find_highest_matching(Dep, Vsn, HexRegistry), - digraph:add_edge(Graph, {Pkg, PkgVsn}, {Dep, HighestDepVsn}), - [{Dep, DepVsn} | DepsListAcc]; + case rebar_packages:find_highest_matching(Dep, Vsn, HexRegistry) of + {ok, HighestDepVsn} -> + digraph:add_edge(Graph, {Pkg, PkgVsn}, {Dep, HighestDepVsn}), + [{Dep, DepVsn} | DepsListAcc]; + none -> + DepsListAcc + end; Vsn -> digraph:add_edge(Graph, {Pkg, PkgVsn}, {Dep, Vsn}), [{Dep, Vsn} | DepsListAcc] |