Просмотр исходного кода

fix up tarball extraction path and parse goal constraints

pull/3/head
Tristan Sloughter 10 лет назад
Родитель
Сommit
f17812d963
3 измененных файлов: 25 добавлений и 10 удалений
  1. +2
    -2
      src/rebar_ct.erl
  2. +11
    -6
      src/rebar_fetch.erl
  3. +12
    -2
      src/rebar_prv_install_deps.erl

+ 2
- 2
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

+ 11
- 6
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);

+ 12
- 2
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"

Загрузка…
Отмена
Сохранить