瀏覽代碼

add pkg resource

pull/3/head
Tristan Sloughter 10 年之前
父節點
當前提交
a7c2ecff73
共有 4 個文件被更改,包括 40 次插入5 次删除
  1. +3
    -1
      src/rebar3.erl
  2. +8
    -3
      src/rebar_fetch.erl
  3. +28
    -0
      src/rebar_pkg_resource.erl
  4. +1
    -1
      src/rebar_prv_install_deps.erl

+ 3
- 1
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 ->

+ 8
- 3
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.

+ 28
- 0
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}.

+ 1
- 1
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())) ->

Loading…
取消
儲存