From 6388b3025fd2c8db6b72f4ae496b5f195665da4e Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Thu, 10 Sep 2015 15:12:22 -0500 Subject: [PATCH] move local install/upgrade to 'unstable install/upgrade' and print error if windows --- src/rebar_prv_local_install.erl | 18 +++++++++++------ src/rebar_prv_local_upgrade.erl | 36 ++++++++++++++++++++------------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/rebar_prv_local_install.erl b/src/rebar_prv_local_install.erl index e9dcdb994..cc8d85011 100644 --- a/src/rebar_prv_local_install.erl +++ b/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(). diff --git a/src/rebar_prv_local_upgrade.erl b/src/rebar_prv_local_upgrade.erl index 248be97a1..03d1c25c5 100644 --- a/src/rebar_prv_local_upgrade.erl +++ b/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.