From b5c072d0b020a183192f21665305c42b1c3a6890 Mon Sep 17 00:00:00 2001 From: Craig Everett Date: Mon, 23 Dec 2019 10:50:05 +0900 Subject: [PATCH] Better output --- install.escript | 23 ++++++----------------- install_unix | 1 + zomp/lib/otpr/zx/0.4.0/src/zx.erl | 14 ++++++-------- zomp/lib/otpr/zx/0.4.0/src/zx_key.erl | 1 - zomp/lib/otpr/zx/0.4.0/src/zx_local.erl | 19 +++++++++---------- 5 files changed, 22 insertions(+), 36 deletions(-) diff --git a/install.escript b/install.escript index 7181889..22ba60b 100755 --- a/install.escript +++ b/install.escript @@ -38,7 +38,6 @@ unpack(OS, ZompDir) -> add_launcher({unix, linux}, ZompDir) -> add_unix_link(ZompDir), - ok = io:format("Should attempt a FreeDesktop icon addition here.~n"), halt(0); add_launcher({unix, _}, ZompDir) -> add_unix_link(ZompDir), @@ -74,27 +73,17 @@ add_unix_link(ZompDir) -> true -> "A link to ~ts has been created at ~ts.~n" "~ts seems to be in $PATH already.~n" - "You should be able to run any Zomp/ZX program as a normal shell " - "command by typing `zx`, or with an Erlang shell attached by " - "typing `zxh` from anywhere in your system.~n" - "Creating launchers to the link that start specific programs may be " - "conveinent.~n" - "A desktop launcher would need to run the command:~n" - " zx run [some_program]~n" - "Or alternately (if ~~/bin/ is not in your launcher's $PATH):~n" - " ~ts run [some_program]~n"; + "You should be able to run any Zomp/ZX program as a normal shell~n" + "command by typing `zx`, or with an Erlang shell attached by~n" + "typing `zxh` from anywhere in your system.~n"; false -> "A link to ~ts has been created at ~ts. " "~ts seems to be NOT in your $PATH. " - "You will need to add that to $PATH if you want to be able to run " - "zx by simply typing `zx` (or zxh to attach an Erlang shell) from " + "You will need to add that to $PATH if you want to be able to run~n" + "zx by simply typing `zx` (or zxh to attach an Erlang shell) from~n" "anywhere in your system.~n" - "Creating launchers to the link that start specific programs may be " - "conveinent.~n" - "A desktop launcher would need to run the command:~n" - " ~ts run [some_program]~n" end, - io:format(Message, [Target, Link, HomeBin, Target]). + io:format(Message, [Target, Link, HomeBin]). -spec os_cmd(Command :: string()) -> ok. diff --git a/install_unix b/install_unix index 90e94b8..e1378c5 100755 --- a/install_unix +++ b/install_unix @@ -7,6 +7,7 @@ if escript_path=$(command -v escript) if zx_link=$(command -v zx) then echo "zx found in \$PATH at $zx_link. Checking for upgrade." + echo "Running \`zx upgrade\`..." zx upgrade else echo "zx is not yet in \$PATH. Once you have added zx's location to \$PATH run \`zx upgrade\`." diff --git a/zomp/lib/otpr/zx/0.4.0/src/zx.erl b/zomp/lib/otpr/zx/0.4.0/src/zx.erl index a1ade11..bd16e0c 100644 --- a/zomp/lib/otpr/zx/0.4.0/src/zx.erl +++ b/zomp/lib/otpr/zx/0.4.0/src/zx.erl @@ -243,8 +243,10 @@ do(["list", "maintainers", PackageName]) -> do(["list", "sysops", Realm]) -> ok = zx_daemon:connect(), done(zx_local:list_sysops(Realm)); -do(["create", "realmfile"]) -> - done(zx_local:create_realmfile()); +do(["export", "realm"]) -> + done(zx_local:export_realm()); +do(["export", "realm", Realm]) -> + done(zx_local:export_realm(Realm)); do(["install", PackageFile]) -> case filelib:is_regular(PackageFile) of true -> done(zx_daemon:install(PackageFile)); @@ -869,8 +871,6 @@ usage_user() -> " zx upgrade~n" " zx import realm RealmFile~n" " zx drop realm Realm~n" - " zx logpath [Package [1-10]]~n" - " zx set timeout Value~n" " zx add mirror [Address [Port]]~n" " zx drop mirror [Address [Port]]~n~n". @@ -894,7 +894,6 @@ usage_dev() -> " zx review PackageID~n" " zx approve PackageID~n" " zx reject PackageID~n" - " zx sync keys~n" " zx create user~n" " zx create keypair~n" " zx export user [dangerous]~n" @@ -903,13 +902,13 @@ usage_dev() -> " zx list packagers PackageName~n" " zx list maintainers PackageName~n" " zx list sysops Realm~n" - " zx create realmfile~n" + " zx export realm [Realm]~n" " zx install ZSP~n~n". usage_sysop() -> "Sysop Actions:~n" " zx list approved Realm~n" - " zx accept PackageID~n" + " zx accept ZSP~n" " zx add package PackageName~n" " zx add user ZPUF~n" " zx rem user Realm UserName~n" @@ -917,7 +916,6 @@ usage_sysop() -> " zx rem packager PackageName UserName~n" " zx add maintainer PackageName UserName~n" " zx rem maintainer PackageName UserName~n" - " zx add sysop Realm UserName~n" " zx create realm~n" " zx takeover Realm~n" " zx abdicate Realm~n~n". diff --git a/zomp/lib/otpr/zx/0.4.0/src/zx_key.erl b/zomp/lib/otpr/zx/0.4.0/src/zx_key.erl index ab50349..8cbe904 100644 --- a/zomp/lib/otpr/zx/0.4.0/src/zx_key.erl +++ b/zomp/lib/otpr/zx/0.4.0/src/zx_key.erl @@ -60,7 +60,6 @@ generate_rsa2(Owner, PemFile, KeyFile, PubFile) -> Signature = public_key:sign(TestMessage, sha512, Key), case public_key:verify(TestMessage, sha512, Signature, Pub) of true -> - ok = tell(info, "~ts and ~ts agree", [KeyFile, PubFile]), PubHash = crypto:hash(sha512, PubBin), KeyData = {PubHash, {none, PubBin}, {none, KeyBin}}, ok = zx_daemon:register_key(Owner, KeyData), diff --git a/zomp/lib/otpr/zx/0.4.0/src/zx_local.erl b/zomp/lib/otpr/zx/0.4.0/src/zx_local.erl index b07f84d..cf07a6a 100644 --- a/zomp/lib/otpr/zx/0.4.0/src/zx_local.erl +++ b/zomp/lib/otpr/zx/0.4.0/src/zx_local.erl @@ -24,7 +24,7 @@ create_project/0, grow_a_pair/0, grow_a_pair/2, drop_key/1, create_user/0, export_user/1, import_user/1, - create_realm/0, create_realmfile/0, create_realmfile/1]). + create_realm/0, export_realm/0, export_realm/1]). -export([create_user/1, select_private_key/1]). @@ -202,7 +202,7 @@ initialize(P = #project{type = Type, "[ 7] Copyright Holder's Email: ~ts~n" "[ 8] License : ~ts~n" "[ 9] Prefix : ~ts~n" - "[10] AppMod : ~tw~n" + "[10] AppMod : ~ts~n" "[11] Repo URL : ~ts~n" "[12] Website URL : ~ts~n" "[13] Description : ~ts~n" @@ -1822,7 +1822,7 @@ store_realm(#realm_init{realm = Realm, {timestamp, calendar:universal_time()}], RealmConfPath = filename:join(zx_lib:path(etc, Realm), "realm.conf"), ok = zx_lib:write_terms(RealmConfPath, RealmConf), - ok = create_realmfile(Realm), + ok = export_realm(Realm), ok = export_user(zpuf, Realm, UserName), ZPUF = Realm ++ "-" ++ UserName ++ ".zpuf", ZRF = Realm ++ ".zrf", @@ -2062,7 +2062,7 @@ create_user2(U = #user_data{realm = Realm, "3" -> create_user2(U#user_data{realname = none}); "4" -> create_user2(U#user_data{contact_info = none}); "" -> - {ok, KeyHash} = zx_key:generate_rsa(Realm), + {ok, KeyHash} = zx_key:generate_rsa({Realm, UserName}), ok = store_user(U#user_data{keys = [KeyHash]}), UserName; _ -> @@ -2110,7 +2110,6 @@ export_user(Type, Realm, UserName) -> KeyData = lists:foldl(Load, [], Keys), UserFile = Realm ++ "-" ++ UserName ++ Ext, UserData = maps:to_list(UserConf), - ok = tell(info, "UserData: ~p", [UserData]), Bin = term_to_binary({UserData, KeyData}), ok = file:write_file(UserFile, Bin), io:format(Message, [UserFile, Realm]). @@ -2483,16 +2482,16 @@ make_realm_dirs(Realm) -> lists:foreach(Make, Dirs). --spec create_realmfile() -> ok. +-spec export_realm() -> ok. -create_realmfile() -> +export_realm() -> {ok, Realm} = pick_realm(), - create_realmfile(Realm). + export_realm(Realm). --spec create_realmfile(zx:realm()) -> ok. +-spec export_realm(zx:realm()) -> ok. -create_realmfile(Realm) -> +export_realm(Realm) -> {ok, RealmConf} = zx_lib:load_realm_conf(Realm), ok = tell("Realm found, creating realm file..."), KeyName = maps:get(key, RealmConf),