Nothing
This commit is contained in:
parent
83a7a68844
commit
649a75c2bf
36
src/zx.erl
36
src/zx.erl
@ -3216,39 +3216,3 @@ error_exit(Format, Args, Path, Line) ->
|
|||||||
File = filename:basename(Path),
|
File = filename:basename(Path),
|
||||||
ok = log(error, "~ts:~tp: " ++ Format, [File, Line | Args]),
|
ok = log(error, "~ts:~tp: " ++ Format, [File, Line | Args]),
|
||||||
halt(1).
|
halt(1).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%%% Logger
|
|
||||||
|
|
||||||
-spec log(Level, Format) -> ok
|
|
||||||
when Level :: info
|
|
||||||
| warning
|
|
||||||
| error,
|
|
||||||
Format :: string().
|
|
||||||
%% @private
|
|
||||||
%% @equiv log(Level, Format, [])
|
|
||||||
|
|
||||||
log(Level, Format) ->
|
|
||||||
log(Level, Format, []).
|
|
||||||
|
|
||||||
|
|
||||||
-spec log(Level, Format, Args) -> ok
|
|
||||||
when Level :: info
|
|
||||||
| warning
|
|
||||||
| error,
|
|
||||||
Format :: string(),
|
|
||||||
Args :: [term()].
|
|
||||||
%% @private
|
|
||||||
%% A logging abstraction to hide whatever logging back end is actually in use.
|
|
||||||
%% Format must adhere to Erlang format string rules, and the arity of Args must match
|
|
||||||
%% the provided format.
|
|
||||||
|
|
||||||
log(Level, Format, Args) ->
|
|
||||||
Tag =
|
|
||||||
case Level of
|
|
||||||
info -> "[INFO]";
|
|
||||||
warning -> "[WARNING]";
|
|
||||||
error -> "[ERROR]"
|
|
||||||
end,
|
|
||||||
io:format("~s ~p: " ++ Format ++ "~n", [Tag, self() | Args]).
|
|
||||||
|
|||||||
42
zx_install.escript
Normal file
42
zx_install.escript
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#! /usr/bin/env escript
|
||||||
|
|
||||||
|
%% ZX install script
|
||||||
|
|
||||||
|
-spec main(Argv :: [string()]) -> no_return().
|
||||||
|
|
||||||
|
main(_) ->
|
||||||
|
ZompDir = zomp_dir(),
|
||||||
|
case filelib:is_dir(ZompDir) of
|
||||||
|
false -> unpack(ZompDir);
|
||||||
|
true -> halt(0)
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
-spec unpack(ZompDir :: file:filename()) -> no_return().
|
||||||
|
|
||||||
|
unpack(ZompDir) ->
|
||||||
|
ZompFile = filename:join(ZompDir, "zomp.conf"),
|
||||||
|
ok = filelib:ensure_dir(ZompFile),
|
||||||
|
ok = erl_tar:extract("zx.tgz", [compressed, {cwd, ZompFile}]),
|
||||||
|
halt(0).
|
||||||
|
|
||||||
|
|
||||||
|
-spec zomp_dir() -> file:filename().
|
||||||
|
%% @private
|
||||||
|
%% Check the host OS and return the absolute path to the zomp filesystem root.
|
||||||
|
|
||||||
|
zomp_dir() ->
|
||||||
|
case os:type() of
|
||||||
|
{unix, _} ->
|
||||||
|
Home = os:getenv("HOME"),
|
||||||
|
Dir = ".zomp",
|
||||||
|
filename:join(Home, Dir);
|
||||||
|
{win32, _} ->
|
||||||
|
Drive = os:getenv("HOMEDRIVE"),
|
||||||
|
Path = os:getenv("HOMEPATH"),
|
||||||
|
Dir = "zomp",
|
||||||
|
filename:join([Drive, Path, Dir]);
|
||||||
|
Unknown ->
|
||||||
|
ok = io:format("zx_install: ERROR Unknown host system type: ~tp", [Unknown]),
|
||||||
|
halt(1)
|
||||||
|
end.
|
||||||
Loading…
x
Reference in New Issue
Block a user