소스 검색

move local install/upgrade to 'unstable install/upgrade' and print error if windows

pull/784/head
Tristan Sloughter 9 년 전
부모
커밋
286e832a29
2개의 변경된 파일34개의 추가작업 그리고 20개의 파일을 삭제
  1. +12
    -6
      src/rebar_prv_local_install.erl
  2. +22
    -14
      src/rebar_prv_local_upgrade.erl

+ 12
- 6
src/rebar_prv_local_install.erl 파일 보기

@ -15,7 +15,7 @@
-include_lib("kernel/include/file.hrl").
-define(PROVIDER, install).
-define(NAMESPACE, local).
-define(NAMESPACE, unstable).
-define(DEPS, []).
%% ===================================================================
@ -39,12 +39,18 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
case rebar_state:escript_path(State) of
undefined ->
?INFO("Already running from an unpacked rebar3. Nothing to do...", []),
case os:type() of
{win32, _} ->
?ERROR("Sorry, this feature is not yet available on Windows.", []),
{ok, State};
ScriptPath ->
extract_escript(State, ScriptPath)
_ ->
case rebar_state:escript_path(State) of
undefined ->
?INFO("Already running from an unpacked rebar3. Nothing to do...", []),
{ok, State};
ScriptPath ->
extract_escript(State, ScriptPath)
end
end.
-spec format_error(any()) -> iolist().

+ 22
- 14
src/rebar_prv_local_upgrade.erl 파일 보기

@ -13,7 +13,7 @@
-include_lib("kernel/include/file.hrl").
-define(PROVIDER, upgrade).
-define(NAMESPACE, local).
-define(NAMESPACE, unstable).
-define(DEPS, []).
%% ===================================================================
@ -37,19 +37,24 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
Md5 = case rebar_state:escript_path(State) of
undefined ->
false;
ScriptPath ->
get_md5(ScriptPath)
end,
case maybe_fetch_rebar3(Md5) of
up_to_date ->
?CONSOLE("No upgrade available", []),
case os:type() of
{win32, _} ->
?ERROR("Sorry, this feature is not yet available on Windows.", []),
{ok, State};
{saved, TmpRebar3} ->
rebar_prv_local_install:extract_escript(State, TmpRebar3)
_ ->
Md5 = case rebar_state:escript_path(State) of
undefined ->
false;
ScriptPath ->
get_md5(ScriptPath)
end,
case maybe_fetch_rebar3(Md5) of
{saved, TmpRebar3} ->
rebar_prv_local_install:extract_escript(State, TmpRebar3);
_ ->
{ok, State}
end
end.
-spec format_error(any()) -> iolist().
@ -67,10 +72,13 @@ get_md5(Rebar3Path) ->
maybe_fetch_rebar3(Rebar3Md5) ->
TmpDir = ec_file:insecure_mkdtemp(),
TmpFile = filename:join(TmpDir, "rebar3"),
case rebar_pkg_resource:request("https://s3.amazonaws.com/rebar3/rebar3", Rebar3Md5) of
case rebar_pkg_resource:request("https://s3.amazonaws.com/rebar3/rebar4", Rebar3Md5) of
{ok, Binary, _ETag} ->
file:write_file(TmpFile, Binary),
{saved, TmpFile};
error ->
?ERROR("Unable to fetch latest rebar3 escript. Please try again later.", []);
_ ->
?CONSOLE("No upgrade available", []),
up_to_date
end.

불러오는 중...
취소
저장