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 /src/rebar_pkg_resource.erl | |
parent | d549901de4493a8ac8f6f591e885b11816a340e8 (diff) |
add pkg resource
Diffstat (limited to 'src/rebar_pkg_resource.erl')
-rw-r--r-- | src/rebar_pkg_resource.erl | 28 |
1 files changed, 28 insertions, 0 deletions
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}. |