diff options
author | Tristan Sloughter <t@crashfast.com> | 2014-08-25 21:41:12 -0500 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2014-08-25 21:41:22 -0500 |
commit | f17812d963b34c8157df44a4dee8380a581aa200 (patch) | |
tree | e76b1ec35918aa778b9201ee3693de4da8f6a995 /src | |
parent | f72a38c3b3d409dca529697cb3d3715cbf76a1bf (diff) |
fix up tarball extraction path and parse goal constraints
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_ct.erl | 4 | ||||
-rw-r--r-- | src/rebar_fetch.erl | 17 | ||||
-rw-r--r-- | src/rebar_prv_install_deps.erl | 14 |
3 files changed, 25 insertions, 10 deletions
diff --git a/src/rebar_ct.erl b/src/rebar_ct.erl index abd29cc..b5abeae 100644 --- a/src/rebar_ct.erl +++ b/src/rebar_ct.erl @@ -225,7 +225,7 @@ make_cmd(TestDir, RawLogDir, State) -> %% that are part of the root Erlang install are filtered out to %% avoid duplication Apps = rebar_state:apps_to_build(State), - DepsDir = rebar_prv_deps:get_deps_dir(State), + DepsDir = rebar_prv_install_deps:get_deps_dir(State), DepsDirEbin = filename:join([DepsDir, "*", "ebin"]), AppDirs = [filename:join(rebar_app_info:dir(A), "ebin") || A <- Apps], CodeDirs = [io_lib:format("\"~s\"", [Dir]) || Dir <- [DepsDirEbin | AppDirs]], @@ -311,7 +311,7 @@ get_cover_config(State, Cwd) -> end. collect_glob(State, Cwd, Glob) -> - DepsDir = rebar_prv_deps:get_deps_dir(State), + DepsDir = rebar_prv_install_deps:get_deps_dir(State), CwdParts = filename:split(Cwd), filelib:fold_files(Cwd, Glob, true, fun(F, Acc) -> %% Ignore any specs under the deps/ directory. Do this pulling diff --git a/src/rebar_fetch.erl b/src/rebar_fetch.erl index 09e52a9..83aa0b4 100644 --- a/src/rebar_fetch.erl +++ b/src/rebar_fetch.erl @@ -44,10 +44,16 @@ current_ref(AppDir, {git, _, _}) -> string:strip(os:cmd("git --git-dir='" ++ AppDir ++ "/.git' rev-parse --verify HEAD"), both, $\n). download_source(AppDir, Source) -> - ec_file:mkdir_p(AppDir), TmpDir = ec_file:insecure_mkdtemp(), - download_source_tmp(TmpDir, Source), - ok = ec_file:copy(TmpDir, binary_to_list(filename:absname(AppDir)), [recursive]). + case download_source_tmp(TmpDir, Source) of + ok -> + ec_file:mkdir_p(AppDir), + ok = ec_file:copy(TmpDir, binary_to_list(filename:absname(AppDir)), [recursive]); + {tarball, File} -> + ok = erl_tar:extract(File, [{cwd, + (filename:dirname(filename:absname(binary_to_list(AppDir))))} + ,compressed]) + end. download_source_tmp(TmpDir, {p4, Url}) -> download_source_tmp(TmpDir, {p4, Url, "#head"}); @@ -116,10 +122,9 @@ download_source_tmp(TmpDir, {fossil, Url, Version}) -> []); download_source_tmp(TmpDir, {AppName, AppVersion, Url}) when is_binary(AppName) , is_binary(AppVersion) -> - TmpFile = binary_to_list(filename:join(TmpDir, <<AppName/binary, "-", AppVersion/binary>>)), + TmpFile = binary_to_list(filename:join(TmpDir, <<AppName/binary, "-", AppVersion/binary, ".tar.gz">>)), {ok, saved_to_file} = httpc:request(get, {binary_to_list(Url), []}, [], [{stream, TmpFile}]), - ok = erl_tar:extract(TmpFile, [{cwd, filename:dirname(TmpDir)}, compressed]), - ok. + {tarball, TmpFile}. update_source1(AppDir, Args) when element(1, Args) =:= p4 -> download_source_tmp(AppDir, Args); diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 245dcb2..09032d7 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -165,7 +165,6 @@ handle_src_deps(Deps, Found, Goals) -> C = rebar_config:consult(rebar_app_info:dir(X)), S = rebar_state:new(rebar_state:new(), C, rebar_app_info:dir(X)), {ParsedDeps, NewGoals} = parse_deps(rebar_state:get(S, deps, [])), - %lists:keymerge(2, DepsAcc, ParsedDeps) {ParsedDeps++DepsAcc, NewGoals++GoalsAcc} end, {Deps, Goals}, Found). @@ -198,7 +197,8 @@ download_missing_deps(State, DepsDir, Found, Unbuilt, Deps) -> parse_deps(Deps) -> lists:foldl(fun({Name, Vsn}, {SrcDepsAcc, GoalsAcc}) -> - {SrcDepsAcc, [{ec_cnv:to_binary(Name), ec_cnv:to_binary(Vsn)} | GoalsAcc]}; + {SrcDepsAcc, [parse_goal(ec_cnv:to_binary(Name) + ,ec_cnv:to_binary(Vsn)) | GoalsAcc]}; (Name, {SrcDepsAcc, GoalsAcc}) when is_atom(Name) -> {SrcDepsAcc, [ec_cnv:to_binary(Name) | GoalsAcc]}; (SrcDep, {SrcDepsAcc, GoalsAcc}) -> @@ -206,6 +206,16 @@ parse_deps(Deps) -> {[Dep | SrcDepsAcc], GoalsAcc} end, {[], []}, Deps). +parse_goal(Name, Constraint) -> + case re:run(Constraint, "([^\\d]*)(\\d.*)", [{capture, [1,2], binary}]) of + {match, [<<>>, Vsn]} -> + {Name, Vsn}; + {match, [Op, Vsn]} -> + {Name, Vsn, binary_to_atom(Op, utf8)}; + nomatch -> + fail + end. + info(Description) -> io_lib:format("~s.~n" "~n" |