diff options
author | Tristan Sloughter <t@crashfast.com> | 2014-11-02 12:09:24 -0600 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2014-11-02 12:09:24 -0600 |
commit | a7c2ecff73f5f9daa200f2c407a60e01d7ab5bef (patch) | |
tree | 05dd461cdaad15629342408f280517d9c561490a | |
parent | d549901de4493a8ac8f6f591e885b11816a340e8 (diff) |
add pkg resource
-rw-r--r-- | src/rebar3.erl | 4 | ||||
-rw-r--r-- | src/rebar_fetch.erl | 11 | ||||
-rw-r--r-- | src/rebar_pkg_resource.erl | 28 | ||||
-rw-r--r-- | src/rebar_prv_install_deps.erl | 2 |
4 files changed, 40 insertions, 5 deletions
diff --git a/src/rebar3.erl b/src/rebar3.erl index 22c08ca..e5d82f9 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -49,10 +49,12 @@ main(Args) -> ok; rebar_abort -> rebar_utils:delayed_halt(1); + {error, rebar_abort} -> + rebar_utils:delayed_halt(1); {error, {Module, Reason}} -> ?ERROR(Module:format_error(Reason, []), []), rebar_utils:delayed_halt(1); - {error, Error} -> + {error, Error} when is_list(Error) -> ?ERROR(Error++"~n", []), rebar_utils:delayed_halt(1); Error -> diff --git a/src/rebar_fetch.erl b/src/rebar_fetch.erl index bba7c1c..a7ae446 100644 --- a/src/rebar_fetch.erl +++ b/src/rebar_fetch.erl @@ -63,6 +63,13 @@ needs_update(AppDir, Source) -> end. get_resource_type({Type, Location, _}) -> + find_resource_module(Type, Location); +get_resource_type({Type, _, _, Location}) -> + find_resource_module(Type, Location); +get_resource_type(_) -> + rebar_pkg_resource. + +find_resource_module(Type, Location) -> case lists:keyfind(Type, 1, ?RESOURCES) of false -> case code:which(Type) of @@ -74,6 +81,4 @@ get_resource_type({Type, Location, _}) -> end; {Type, Module} -> Module - end; -get_resource_type(_) -> - rebar_pkg_resource. + end. diff --git a/src/rebar_pkg_resource.erl b/src/rebar_pkg_resource.erl new file mode 100644 index 0000000..1590458 --- /dev/null +++ b/src/rebar_pkg_resource.erl @@ -0,0 +1,28 @@ +%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*- +%% ex: ts=4 sw=4 et +-module(rebar_pkg_resource). + +-behaviour(rebar_resource). + +-export([lock/2 + ,download/2 + ,needs_update/2]). + +-include("rebar.hrl"). + +lock(_AppDir, Source) -> + Source. + +needs_update(Dir, {pkg, _Name, Vsn, _Url}) -> + [AppInfo] = rebar_app_discover:find_apps([Dir], all), + case rebar_app_info:original_vsn(AppInfo) =:= ec_cnv:to_list(Vsn) of + true -> + false; + false -> + true + end. + +download(Dir, {pkg, _Name, _Vsn, Url}) -> + TmpFile = filename:join(Dir, "package.tar.gz"), + {ok, saved_to_file} = httpc:request(get, {binary_to_list(Url), []}, [], [{stream, TmpFile}]), + {tarball, TmpFile}. diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 1baa9db..9fb1630 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -162,7 +162,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)), - [rebar_app_info:source(AppInfo2, Link)] + [rebar_app_info:source(AppInfo2, {pkg, Name, FmtVsn, Link})] end. -spec update_src_deps(integer(), rebar_state:t(), boolean(), sets:set(binary())) -> |