From 8e12c8b68ed5c3ad594665f77a67ae2d9960230f Mon Sep 17 00:00:00 2001 From: Bryan Paxton Date: Sun, 9 Dec 2018 18:14:21 -0600 Subject: strip trailing forward slash on recrusive cp for darwin - fixes systests on darwin where previously the recursive cp would fail due to everything being copied after the last forward slash. Specifically, everything in `systest/all_SUITE_data/` would be copied but not `all_suite_data` dir itself which the tests expected. --- src/rebar_file_utils.erl | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl index a51a557..3b4e102 100644 --- a/src/rebar_file_utils.erl +++ b/src/rebar_file_utils.erl @@ -189,16 +189,28 @@ cp_r([], _Dest) -> ok; cp_r(Sources, Dest) -> case os:type() of - {unix, _} -> + {unix, Os} -> EscSources = [rebar_utils:escape_chars(Src) || Src <- Sources], SourceStr = rebar_string:join(EscSources, " "), + % On darwin the following cp command will cp everything inside + % target vs target and everything inside, so we chop the last char + % off if it is a '/' + Source = case {Os == darwin, lists:last(SourceStr) == 47} of + {true, true} -> + string:sub_string(SourceStr, 1, length(SourceStr) - 1); + {true, false} -> + SourceStr; + {false, _} -> + SourceStr + end, + EscSources = [rebar_utils:escape_chars(Src) || Src <- Sources], % ensure destination exists before copying files into it {ok, []} = rebar_utils:sh(?FMT("mkdir -p ~ts", [rebar_utils:escape_chars(Dest)]), [{use_stdout, false}, abort_on_error]), {ok, []} = rebar_utils:sh(?FMT("cp -Rp ~ts \"~ts\"", - [SourceStr, rebar_utils:escape_double_quotes(Dest)]), - [{use_stdout, false}, abort_on_error]), + [Source, rebar_utils:escape_double_quotes(Dest)]), + [{use_stdout, true}, abort_on_error]), ok; {win32, _} -> lists:foreach(fun(Src) -> ok = cp_r_win32(Src,Dest) end, Sources), -- cgit v1.1 From 7a9f88790ea4799d3b6c3ec0a6e43f6827540177 Mon Sep 17 00:00:00 2001 From: Bryan Paxton Date: Mon, 10 Dec 2018 01:57:32 -0600 Subject: Remove dup quotation op --- src/rebar_file_utils.erl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl index 3b4e102..5b6164a 100644 --- a/src/rebar_file_utils.erl +++ b/src/rebar_file_utils.erl @@ -203,7 +203,6 @@ cp_r(Sources, Dest) -> {false, _} -> SourceStr end, - EscSources = [rebar_utils:escape_chars(Src) || Src <- Sources], % ensure destination exists before copying files into it {ok, []} = rebar_utils:sh(?FMT("mkdir -p ~ts", [rebar_utils:escape_chars(Dest)]), -- cgit v1.1