Initial "verbs" adjustment

This commit is contained in:
Craig Everett 2019-12-20 19:12:25 +09:00
parent 4e83b63dcc
commit 959902d56f
6 changed files with 37 additions and 22 deletions

View File

@ -382,6 +382,12 @@ start() ->
module => logger_std_h}, module => logger_std_h},
ok = logger:add_handler(default, logger_std_h, LoggerConf), ok = logger:add_handler(default, logger_std_h, LoggerConf),
ok = logger:set_primary_config(level, debug), ok = logger:set_primary_config(level, debug),
% Hacky:
% Load all necessary atoms for binary_to_term(B, [safe]) to work with zx_zsp:meta()
MetaKeys = maps:keys(zx_zsp:new_meta()),
Types = [lib, app, gui, cli],
ok = log(info, "ZSP meta keys: ~w", [MetaKeys]),
ok = log(info, "Available package types: ~w", [Types]),
application:ensure_started(zx). application:ensure_started(zx).

View File

@ -118,7 +118,8 @@ submit2(ZspBin) ->
end. end.
submit3(ZspBin) -> submit3(ZspBin) ->
{ok, #{project_id := {Realm, Name, Version}, key_name := KeyName}} = zx_zsp:meta(ZspBin), {ok, #{package_id := {Realm, Name, Version}, key_name := KeyName}}
= zx_zsp:meta(ZspBin),
UserName = select_auth(Realm), UserName = select_auth(Realm),
case zx_daemon:get_key(private, {Realm, KeyName}) of case zx_daemon:get_key(private, {Realm, KeyName}) of
{ok, DKey} -> {ok, DKey} ->

View File

@ -280,17 +280,22 @@ wait_ok(Socket) ->
dispatch(Socket, ID, Action) -> dispatch(Socket, ID, Action) ->
case Action of case Action of
{list, R} -> send_query(Socket, 3, R); {list, R} -> send_query(Socket, 3, R);
{list, R, N} -> send_query(Socket, 4, {R, N}); {list, R, N} -> send_query(Socket, 4, {R, N});
{list, R, N, V} -> send_query(Socket, 4, {R, N, V}); {list, R, N, V} -> send_query(Socket, 4, {R, N, V});
{latest, R, N} -> send_query(Socket, 5, {R, N}); {latest, R, N} -> send_query(Socket, 5, {R, N});
{latest, R, N, V} -> send_query(Socket, 5, {R, N, V}); {latest, R, N, V} -> send_query(Socket, 5, {R, N, V});
{provides, R, M} -> send_query(Socket, 6, {R, M}); {describe, R, N} -> send_query(Socket, 6, {R, N});
{list_deps, R, N, V} -> send_query(Socket, 7, {R, N, V}); {describe, R, N, V} -> send_query(Socket, 6, {R, N, V});
{list_sysops, R} -> send_query(Socket, 8, R); {tags, R, N} -> send_query(Socket, 7, {R, N});
{fetch, R, N, V} -> fetch(Socket, ID, {R, N, V}); {tags, R, N, V} -> send_query(Socket, 7, {R, N, V});
{keychain, R, K} -> send_query(Socket, 10, {R, K}); {provides, R, M} -> send_query(Socket, 8, {R, M});
Unexpected -> {search, R, String} -> send_query(Socket, 9, {R, String});
{list_deps, R, N, V} -> send_query(Socket, 10, {R, N, V});
{list_sysops, R} -> send_query(Socket, 11, R);
{fetch, R, N, V} -> fetch(Socket, ID, {R, N, V});
{keychain, R, K} -> send_query(Socket, 13, {R, K});
Unexpected ->
Message = "Received unexpected request action. ID: ~tp, Action: ~200tp", Message = "Received unexpected request action. ID: ~tp, Action: ~200tp",
log(warning, Message, [ID, Unexpected]) log(warning, Message, [ID, Unexpected])
end. end.

View File

@ -262,6 +262,7 @@
| {latest, zx:realm(), zx:name(), zx:version()} | {latest, zx:realm(), zx:name(), zx:version()}
| {describe, zx:realm(), zx:name()} | {describe, zx:realm(), zx:name()}
| {provides, zx:realm(), string()} | {provides, zx:realm(), string()}
| {search, zx:realm(), string()}
| {list_deps, zx:realm(), zx:name(), zx:version()} | {list_deps, zx:realm(), zx:name(), zx:version()}
| {list_sysops, zx:realm()} | {list_sysops, zx:realm()}
| {pending, zx:realm(), zx:name()} | {pending, zx:realm(), zx:name()}

View File

@ -248,15 +248,15 @@ initialize_check(P = #project{id = PackageID}) ->
initialize(P#project{id = none}); initialize(P#project{id = none});
maybe -> maybe ->
Message = Message =
"~nHmmm...~n" "~n∑(。・Д・。)???~nHmmm...~n"
"zx_daemon wasn't able to find out (network problem?) whether this " "zx_daemon wasn't able to check whether this package already exists.~n"
"package already exists.~n" "(Network problem?)~n"
"What do?~", "What do?~n",
ok = io:format(Message), ok = io:format(Message),
Options = [{"Continue anyway.", 1}, Options = [{"Continue anyway.", 1},
{"Check again.", 2}, {"Check again.", 2},
{"Abort and do it later.", 3}], {"Abort and do it later.", 3}],
case zx_tty:selet(Options) of case zx_tty:select(Options) of
1 -> zompify(P); 1 -> zompify(P);
2 -> initialize_check(P); 2 -> initialize_check(P);
3 -> ok 3 -> ok
@ -2394,10 +2394,8 @@ ask_description() ->
"This description will appear:~n" "This description will appear:~n"
"- In the project's .app file~n" "- In the project's .app file~n"
"- Be displayed when a user uses the `zx describe [project]` command~n" "- Be displayed when a user uses the `zx describe [project]` command~n"
"- (If this is an end-user GUI application) As the program summary in the GUI~n" "- (GUIs) As the program summary if no project site summary can be found~n"
" program launcher if no HTML summary data is provided on a project site~n" "NOTE: You can change or update this description in subsequent versions.~n",
"(NOTE: You can change or update this description in subsequent package "
"versions.)~n",
String = zx_tty:get_input(Instructions, [], "[ENTER] to leave blank"), String = zx_tty:get_input(Instructions, [], "[ENTER] to leave blank"),
unicode:characters_to_list(String, utf8). unicode:characters_to_list(String, utf8).

View File

@ -32,6 +32,7 @@
a_email := string(), a_email := string(),
copyright := string(), copyright := string(),
c_email := string(), c_email := string(),
license := string(),
ws_url := string(), ws_url := string(),
repo_url := string(), repo_url := string(),
prefix := string(), prefix := string(),
@ -52,6 +53,7 @@ new_meta() ->
a_email => "", a_email => "",
copyright => "", copyright => "",
c_email => "", c_email => "",
license => "",
ws_url => "", ws_url => "",
repo_url => "", repo_url => "",
prefix => "", prefix => "",
@ -99,6 +101,7 @@ pack3(TargetDir, PackageID, Meta, {KeyName, Key}, ZspFile) ->
{ok, [{application, _, AppData}]} = file:consult(AppFile), {ok, [{application, _, AppData}]} = file:consult(AppFile),
Modules = lists:map(fun atom_to_list/1, proplists:get_value(modules, AppData)), Modules = lists:map(fun atom_to_list/1, proplists:get_value(modules, AppData)),
TarGzPath = filename:join(zx_lib:path(tmp), ZspFile ++ ".tgz"), TarGzPath = filename:join(zx_lib:path(tmp), ZspFile ++ ".tgz"),
ok = filelib:ensure_dir(TarGzPath),
ok = erl_tar:create(TarGzPath, Targets, [compressed]), ok = erl_tar:create(TarGzPath, Targets, [compressed]),
{ok, TgzBin} = file:read_file(TarGzPath), {ok, TgzBin} = file:read_file(TarGzPath),
ok = file:delete(TarGzPath), ok = file:delete(TarGzPath),
@ -197,10 +200,11 @@ verify(_) ->
verify2(Sig, Signed = <<MetaSize:24, MetaBin:MetaSize/binary, _/binary>>) -> verify2(Sig, Signed = <<MetaSize:24, MetaBin:MetaSize/binary, _/binary>>) ->
case zx_lib:b_to_ts(MetaBin) of case zx_lib:b_to_ts(MetaBin) of
{ok, {{Realm, _, _}, SigKeyName, _, _, _}} -> {ok, #{package_id := {Realm, _, _}, key_name := SigKeyName}} ->
SigKeyID = {Realm, SigKeyName}, SigKeyID = {Realm, SigKeyName},
verify3(Sig, Signed, SigKeyID); verify3(Sig, Signed, SigKeyID);
error -> error ->
tell(info, "MetaBin: ~p", [MetaBin]),
{error, bad_zsp} {error, bad_zsp}
end; end;
verify2(_, _) -> verify2(_, _) ->