Permalink
Browse files

Add rsync as another option to fetch dependencies

Newly added syntax:

{deps, [ {<depname>, ".*", {rsync, "<rsync_url>"}}, ... ]}

Where rsync_url is any URL accepted by the rsync command.
  • Loading branch information...
1 parent 32ddef7 commit 8d823308021623a73640eedd538069172f87797b @nickva nickva committed with tuncer Apr 25, 2012
Showing with 20 additions and 8 deletions.
  1. +20 −8 src/rebar_deps.erl
View
@@ -385,7 +385,10 @@ download_source(AppDir, {svn, Url, Rev}) ->
ok = filelib:ensure_dir(AppDir),
rebar_utils:sh(?FMT("svn checkout -r ~s ~s ~s",
[Rev, Url, filename:basename(AppDir)]),
- [{cd, filename:dirname(AppDir)}]).
+ [{cd, filename:dirname(AppDir)}]);
+download_source(AppDir, {rsync, Url}) ->
+ ok = filelib:ensure_dir(AppDir),
+ rebar_utils:sh(?FMT("rsync -az --delete ~s/ ~s", [Url, AppDir]), []).
update_source(Dep) ->
%% It's possible when updating a source, that a given dep does not have a
@@ -426,7 +429,10 @@ update_source(AppDir, {svn, _Url, Rev}) ->
update_source(AppDir, {hg, _Url, Rev}) ->
rebar_utils:sh(?FMT("hg pull -u -r ~s", [Rev]), [{cd, AppDir}]);
update_source(AppDir, {bzr, _Url, Rev}) ->
- rebar_utils:sh(?FMT("bzr update -r ~s", [Rev]), [{cd, AppDir}]).
+ rebar_utils:sh(?FMT("bzr update -r ~s", [Rev]), [{cd, AppDir}]);
+update_source(AppDir, {rsync, Url}) ->
+ rebar_utils:sh(?FMT("rsync -az --delete ~s/ ~s",[Url,AppDir]),[]).
+
@@ -439,7 +445,7 @@ source_engine_avail(Source) ->
source_engine_avail(Name, Source).
source_engine_avail(Name, Source)
- when Name == hg; Name == git; Name == svn; Name == bzr ->
+ when Name == hg; Name == git; Name == svn; Name == bzr; Name == rsync ->
case vcs_client_vsn(Name) >= required_vcs_client_vsn(Name) of
true ->
true;
@@ -460,10 +466,11 @@ vcs_client_vsn(Path, VsnArg, VsnRegex) ->
false
end.
-required_vcs_client_vsn(hg) -> {1, 1};
-required_vcs_client_vsn(git) -> {1, 5};
-required_vcs_client_vsn(bzr) -> {2, 0};
-required_vcs_client_vsn(svn) -> {1, 6}.
+required_vcs_client_vsn(hg) -> {1, 1};
+required_vcs_client_vsn(git) -> {1, 5};
+required_vcs_client_vsn(bzr) -> {2, 0};
+required_vcs_client_vsn(svn) -> {1, 6};
+required_vcs_client_vsn(rsync) -> {2, 0}.
vcs_client_vsn(hg) ->
vcs_client_vsn(rebar_utils:find_executable("hg"), " --version",
@@ -476,7 +483,10 @@ vcs_client_vsn(bzr) ->
"Bazaar \\(bzr\\) (\\d+).(\\d+)");
vcs_client_vsn(svn) ->
vcs_client_vsn(rebar_utils:find_executable("svn"), " --version",
- "svn, version (\\d+).(\\d+)").
+ "svn, version (\\d+).(\\d+)");
+vcs_client_vsn(rsync) ->
+ vcs_client_vsn(rebar_utils:find_executable("rsync"), " --version",
+ "rsync version (\\d+).(\\d+)").
has_vcs_dir(git, Dir) ->
filelib:is_dir(filename:join(Dir, ".git"));
@@ -487,6 +497,8 @@ has_vcs_dir(bzr, Dir) ->
has_vcs_dir(svn, Dir) ->
filelib:is_dir(filename:join(Dir, ".svn"))
orelse filelib:is_dir(filename:join(Dir, "_svn"));
+has_vcs_dir(rsync, _) ->
+ true;
has_vcs_dir(_, _) ->
true.

0 comments on commit 8d82330

Please sign in to comment.