summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2014-09-26 19:51:45 -0500
committerTristan Sloughter <t@crashfast.com>2014-09-26 19:51:45 -0500
commit1549b11b88dca340a1e471775d8387ca94e377e5 (patch)
tree2f125bf12e8be5143bda8d2811d3dd1a5d3b5688 /src
parent3f9ff5a30221919b1ce4f65bbefcebe360c09ecb (diff)
getting closer
Diffstat (limited to 'src')
-rw-r--r--src/rebar_fetch.erl10
-rw-r--r--src/rebar_prv_install_deps.erl37
2 files changed, 27 insertions, 20 deletions
diff --git a/src/rebar_fetch.erl b/src/rebar_fetch.erl
index 6b31f6c..0a90848 100644
--- a/src/rebar_fetch.erl
+++ b/src/rebar_fetch.erl
@@ -49,14 +49,16 @@ lock_source(_AppDir, Source) ->
download_source(AppDir, Source) ->
TmpDir = ec_file:insecure_mkdtemp(),
AppDir1 = ec_cnv:to_list(AppDir),
+ ec_file:mkdir_p(AppDir1),
case download_source_tmp(TmpDir, Source) of
{ok, _} ->
- ec_file:mkdir_p(AppDir1),
ok = ec_file:copy(TmpDir, filename:absname(AppDir1), [recursive]);
{tarball, File} ->
- ok = erl_tar:extract(File, [{cwd,
- (filename:dirname(filename:absname(AppDir1)))}
- ,compressed])
+ ok = erl_tar:extract(File, [{cwd, TmpDir}
+ ,compressed]),
+ BaseName = filename:basename(AppDir1),
+ [FromDir] = filelib:wildcard(filename:join(TmpDir, BaseName++"-*")),
+ ec_file:copy(FromDir, AppDir1, [recursive])
end.
download_source_tmp(TmpDir, {p4, Url}) ->
diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl
index de4be27..8071382 100644
--- a/src/rebar_prv_install_deps.erl
+++ b/src/rebar_prv_install_deps.erl
@@ -74,7 +74,7 @@ do(State) ->
handle_deps(State, Locks)
end,
- Source = ProjectApps ++ rebar_state:get(State1, all_deps),
+ Source = ProjectApps ++ rebar_state:src_deps(State1),
{ok, Sort} = rebar_topo:sort_apps(Source),
{ok, rebar_state:set(State1, deps_to_build, lists:dropwhile(fun is_valid/1, Sort -- ProjectApps))}.
@@ -151,7 +151,7 @@ package_to_app(DepsDir, Packages, Pkg={_, Vsn}) ->
{ok, AppInfo} = rebar_app_info:new(Name, FmtVsn),
AppInfo1 = rebar_app_info:deps(AppInfo, PkgDeps),
AppInfo2 =
- rebar_app_info:dir(AppInfo1, get_deps_dir(DepsDir, <<Name/binary, "-", FmtVsn/binary>>)),
+ rebar_app_info:dir(AppInfo1, get_deps_dir(DepsDir, Name)),
rebar_app_info:source(AppInfo2, Link).
-spec update_src_deps(integer(), rebar_state:t(), boolean()) -> rebar_state:t().
@@ -161,18 +161,23 @@ update_src_deps(Level, State, Update) ->
case lists:foldl(fun(AppInfo, {SrcDepsAcc, BinaryDepsAcc, StateAcc}) ->
Name = rebar_app_info:name(AppInfo),
Locks = rebar_state:get(State, locks, []),
- {_, _, _, DepLevel} = lists:keyfind(Name, 1, Locks),
case Update of
- {true, UpdateName, UpdateLevel} when UpdateLevel < DepLevel
- ; Name =:= UpdateName ->
- case maybe_fetch(AppInfo, true) of
+ {true, UpdateName, UpdateLevel} ->
+ {_, _, _, DepLevel} = lists:keyfind(Name, 1, Locks),
+ case UpdateLevel < DepLevel
+ orelse Name =:= UpdateName of
true ->
- {AppInfo1, NewSrcDeps, NewBinaryDeps} =
- handle_dep(DepsDir, AppInfo),
- AppInfo2 = rebar_app_info:dep_level(AppInfo1, Level),
- {NewSrcDeps ++ SrcDepsAcc
- ,NewBinaryDeps++BinaryDepsAcc
- ,rebar_state:src_apps(StateAcc, AppInfo2)};
+ case maybe_fetch(AppInfo, true) of
+ true ->
+ {AppInfo1, NewSrcDeps, NewBinaryDeps} =
+ handle_dep(DepsDir, AppInfo),
+ AppInfo2 = rebar_app_info:dep_level(AppInfo1, Level),
+ {NewSrcDeps ++ SrcDepsAcc
+ ,NewBinaryDeps++BinaryDepsAcc
+ ,rebar_state:src_apps(StateAcc, AppInfo2)};
+ false ->
+ {SrcDepsAcc, BinaryDepsAcc, State}
+ end;
false ->
{SrcDepsAcc, BinaryDepsAcc, State}
end;
@@ -190,10 +195,10 @@ update_src_deps(Level, State, Update) ->
end
end
end, {[], rebar_state:binary_deps(State), State}, SrcDeps) of
- {NewSrcDeps, NewBinaryDeps, State1} when length(SrcDeps) =:= length(NewSrcDeps) ->
- rebar_state:src_deps(rebar_state:binary_deps(State1, NewBinaryDeps), NewSrcDeps);
- {NewSrcDeps, NewBinaryDeps, State1} ->
- State2 = rebar_state:src_deps(rebar_state:binary_deps(State1, NewBinaryDeps), NewSrcDeps),
+ {[], NewBinaryDeps, State1} ->
+ rebar_state:binary_deps(State1, NewBinaryDeps);
+ {_NewSrcDeps, NewBinaryDeps, State1} ->
+ State2 = rebar_state:binary_deps(State1, NewBinaryDeps),
update_src_deps(Level+1, State2, Update)
end.