diff options
author | Tristan Sloughter <t@crashfast.com> | 2015-09-10 15:12:22 -0500 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2015-09-10 15:16:51 -0500 |
commit | 286e832a29ee502f5debb5a7393e7209e1848cf4 (patch) | |
tree | f2a73d929a2c073696068a6cd68f019480d13bc6 | |
parent | da3d8a69cc6467dcb63348dfa02bc4b98f528ca4 (diff) |
move local install/upgrade to 'unstable install/upgrade' and print error if windows
-rw-r--r-- | src/rebar_prv_local_install.erl | 18 | ||||
-rw-r--r-- | 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 e9dcdb9..6d83fc3 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 248be97..831436e 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. |