Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- deps/eini/_build/default/plugins/hex_core/src/hex_api_auth.erl +20 -0
- deps/eini/_build/default/plugins/hex_core/src/hex_api_key.erl +156 -0
- deps/eini/_build/default/plugins/hex_core/src/hex_api_organization.erl +67 -0
- deps/eini/_build/default/plugins/hex_core/src/hex_api_organization_member.erl +113 -0
- deps/eini/_build/default/plugins/hex_core/src/hex_api_package.erl +53 -0
- deps/eini/_build/default/plugins/hex_core/src/hex_api_release.erl +191 -0
- deps/eini/_build/default/plugins/hex_core/src/hex_api_short_url.erl +19 -0
- deps/eini/_build/default/plugins/hex_core/src/hex_core.app.src +12 -0
- deps/eini/_build/default/plugins/hex_core/src/hex_core.hrl +1 -0
- deps/eini/_build/default/plugins/hex_core/src/hex_filename.erl +58 -0
- deps/eini/_build/default/plugins/hex_core/src/hex_licenses.erl +668 -0
- deps/eini/_build/default/plugins/hex_core/src/hex_pb_package.erl +1227 -0
- deps/eini/_build/default/plugins/hex_core/src/hex_pb_signed.erl +593 -0
- deps/eini/_build/default/plugins/hex_core/src/hex_pb_versions.erl +816 -0
- deps/eini/_build/default/plugins/hex_core/src/hex_registry.erl +165 -0
- deps/eini/_build/default/plugins/hex_core/src/hex_safe_binary_to_term.erl +92 -0
- deps/eini/_build/default/plugins/hex_core/src/hex_tarball.erl +717 -0
- deps/eini/_build/default/plugins/hex_core/src/safe_erl_term.xrl +77 -0
- deps/eini/_build/default/plugins/rebar3_hex/LICENSE +193 -0
- deps/eini/_build/default/plugins/rebar3_hex/README.md +196 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex.app +16 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_app.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_build.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_client.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_config.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_cut.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_error.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_file.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_httpc_adapter.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_io.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_key.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_organization.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_owner.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_publish.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_results.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_retire.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_search.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_user.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_version.beam +0 -0
- deps/eini/_build/default/plugins/rebar3_hex/hex_metadata.config +29 -0
- deps/eini/_build/default/plugins/rebar3_hex/rebar.config +52 -0
- deps/eini/_build/default/plugins/rebar3_hex/rebar.lock +11 -0
- deps/eini/_build/default/plugins/rebar3_hex/src/rebar3_hex.app.src +7 -0
- deps/eini/_build/default/plugins/rebar3_hex/src/rebar3_hex.erl +144 -0
- deps/eini/_build/default/plugins/rebar3_hex/src/rebar3_hex.hrl +4 -0
- deps/eini/_build/default/plugins/rebar3_hex/src/rebar3_hex_app.erl +224 -0
- deps/eini/_build/default/plugins/rebar3_hex/src/rebar3_hex_build.erl +646 -0
- deps/eini/_build/default/plugins/rebar3_hex/src/rebar3_hex_client.erl +166 -0
- deps/eini/_build/default/plugins/rebar3_hex/src/rebar3_hex_config.erl +254 -0
deps/eini/_build/default/plugins/hex_core/src/hex_api_auth.erl
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%% @doc
|
| 2 |
+
%% Hex HTTP API - Authentication.
|
| 3 |
+
-module(hex_api_auth).
|
| 4 |
+
-export([test/2]).
|
| 5 |
+
|
| 6 |
+
%% @doc
|
| 7 |
+
%% Test an auth key against a given domain and resource.
|
| 8 |
+
%%
|
| 9 |
+
%% Examples:
|
| 10 |
+
%%
|
| 11 |
+
%% ```
|
| 12 |
+
%% 1> Params = #{domain => <<"repository">>, resource => <<"gustafson_motors">>}.
|
| 13 |
+
%% 2> hex_api_auth:test_key(hex_core:default_config(), Params).
|
| 14 |
+
%% {ok,{204, ..., nil}}
|
| 15 |
+
%% '''
|
| 16 |
+
%% @end
|
| 17 |
+
-spec test(hex_core:config(), map()) -> hex_api:response().
|
| 18 |
+
test(Config, #{domain := Domain, resource := Resource}) ->
|
| 19 |
+
URI = ["auth", "?domain=", Domain, "&resource=", Resource],
|
| 20 |
+
hex_api:get(Config, list_to_binary(URI)).
|
deps/eini/_build/default/plugins/hex_core/src/hex_api_key.erl
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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Lists the user's or organization's API and repository keys.
|
| 18 |
+
%%
|
| 19 |
+
%% Examples:
|
| 20 |
+
%%
|
| 21 |
+
%% ```
|
| 22 |
+
%% > hex_api_key:list(hex_core:default_config()).
|
| 23 |
+
%% {ok, {200, ..., [#{
|
| 24 |
+
%% <<"authing_key">> => true,
|
| 25 |
+
%% <<"inserted_at">> => <<"2019-02-27T11:15:32Z">>,
|
| 26 |
+
%% <<"last_use">> =>
|
| 27 |
+
%% #{<<"ip">> => <<"1.2.3.4">>,
|
| 28 |
+
%% <<"used_at">> => <<"2019-02-27T14:38:54Z">>,
|
| 29 |
+
%% <<"user_agent">> => <<"hex_core/0.5.0 (httpc) (OTP/21) (erts/10.2)">>},
|
| 30 |
+
%% <<"name">> => <<"hex_core">>,
|
| 31 |
+
%% <<"permissions">> => [#{<<"domain">> => <<"api">>,<<"resource">> => <<"read">>}],
|
| 32 |
+
%% <<"revoked_at">> => nil,
|
| 33 |
+
%% <<"updated_at">> => <<"2019-02-27T14:38:54Z">>,
|
| 34 |
+
%% <<"url">> => <<"https://hex.pm/api/keys/test">>},
|
| 35 |
+
%% }]}}
|
| 36 |
+
%% '''
|
| 37 |
+
%% @end
|
| 38 |
+
-spec list(hex_core:config()) -> hex_api:response().
|
| 39 |
+
list(Config) when is_map(Config) ->
|
| 40 |
+
Path = hex_api:build_organization_path(Config, ["keys"]),
|
| 41 |
+
hex_api:get(Config, Path).
|
| 42 |
+
|
| 43 |
+
%% @doc
|
| 44 |
+
%% Gets an API or repository key by name.
|
| 45 |
+
%%
|
| 46 |
+
%% Examples:
|
| 47 |
+
%%
|
| 48 |
+
%% ```
|
| 49 |
+
%% > hex_api_key:get(hex_core:default_config(), <<"test">>).
|
| 50 |
+
%% {ok, {200, ..., #{
|
| 51 |
+
%% <<"authing_key">> => true,
|
| 52 |
+
%% <<"inserted_at">> => <<"2019-02-27T11:15:32Z">>,
|
| 53 |
+
%% <<"last_use">> =>
|
| 54 |
+
%% #{<<"ip">> => <<"1.2.3.4">>,
|
| 55 |
+
%% <<"used_at">> => <<"2019-02-27T14:38:54Z">>,
|
| 56 |
+
%% <<"user_agent">> => <<"hex_core/0.5.0 (httpc) (OTP/21) (erts/10.2)">>},
|
| 57 |
+
%% <<"name">> => <<"hex_core">>,
|
| 58 |
+
%% <<"permissions">> => [#{<<"domain">> => <<"api">>,<<"resource">> => <<"read">>}],
|
| 59 |
+
%% <<"revoked_at">> => nil,
|
| 60 |
+
%% <<"updated_at">> => <<"2019-02-27T14:38:54Z">>,
|
| 61 |
+
%% <<"url">> => <<"https://hex.pm/api/keys/test">>},
|
| 62 |
+
%% }}}
|
| 63 |
+
%% '''
|
| 64 |
+
%% @end
|
| 65 |
+
-spec get(hex_core:config(), binary()) -> hex_api:response().
|
| 66 |
+
get(Config, Name) when is_map(Config) and is_binary(Name) ->
|
| 67 |
+
Path = hex_api:build_organization_path(Config, ["keys", Name]),
|
| 68 |
+
hex_api:get(Config, Path).
|
| 69 |
+
|
| 70 |
+
%% @doc
|
| 71 |
+
%% Adds a new API or repository key.
|
| 72 |
+
%%
|
| 73 |
+
%% A permission is a map of `#{<<"domain">> => Domain, <<"resource"> => Resource}'.
|
| 74 |
+
%%
|
| 75 |
+
%% Valid `Domain' values: `<<"api">> | <<"repository">> | <<"repositories">>'.
|
| 76 |
+
%%
|
| 77 |
+
%% Valid `Resource' values: `<<"read">> | <<"write">>'.
|
| 78 |
+
%%
|
| 79 |
+
%% Examples:
|
| 80 |
+
%%
|
| 81 |
+
%% ```
|
| 82 |
+
%% > hex_api_key:add(hex_core:default_config(), <<"test">>, [...]).
|
| 83 |
+
%% {ok, {200, ..., #{
|
| 84 |
+
%% <<"authing_key">> => true,
|
| 85 |
+
%% <<"inserted_at">> => <<"2019-02-27T11:15:32Z">>,
|
| 86 |
+
%% <<"last_use">> =>
|
| 87 |
+
%% #{<<"ip">> => <<"1.2.3.4">>,
|
| 88 |
+
%% <<"used_at">> => <<"2019-02-27T14:38:54Z">>,
|
| 89 |
+
%% <<"user_agent">> => <<"hex_core/0.5.0 (httpc) (OTP/21) (erts/10.2)">>},
|
| 90 |
+
%% <<"name">> => <<"hex_core">>,
|
| 91 |
+
%% <<"permissions">> => [#{<<"domain">> => <<"api">>,<<"resource">> => <<"read">>}],
|
| 92 |
+
%% <<"revoked_at">> => nil,
|
| 93 |
+
%% <<"updated_at">> => <<"2019-02-27T14:38:54Z">>,
|
| 94 |
+
%% <<"url">> => <<"https://hex.pm/api/keys/test">>},
|
| 95 |
+
%% }}}
|
| 96 |
+
%% '''
|
| 97 |
+
%% @end
|
| 98 |
+
-spec add(hex_core:config(), binary(), [permission()]) -> hex_api:response().
|
| 99 |
+
add(Config, Name, Permissions) when is_map(Config) and is_binary(Name) and is_list(Permissions) ->
|
| 100 |
+
Path = hex_api:build_organization_path(Config, ["keys"]),
|
| 101 |
+
Params = #{<<"name">> => Name, <<"permissions">> => Permissions},
|
| 102 |
+
hex_api:post(Config, Path, Params).
|
| 103 |
+
|
| 104 |
+
%% @doc
|
| 105 |
+
%% Deletes an API or repository key.
|
| 106 |
+
%%
|
| 107 |
+
%% Examples:
|
| 108 |
+
%%
|
| 109 |
+
%% ```
|
| 110 |
+
%% > hex_api_key:delete(hex_core:default_config(), <<"test">>).
|
| 111 |
+
%% {ok, {200, ..., #{
|
| 112 |
+
%% <<"authing_key">> => true,
|
| 113 |
+
%% <<"inserted_at">> => <<"2019-02-27T11:15:32Z">>,
|
| 114 |
+
%% <<"last_use">> =>
|
| 115 |
+
%% #{<<"ip">> => <<"1.2.3.4">>,
|
| 116 |
+
%% <<"used_at">> => <<"2019-02-27T14:38:54Z">>,
|
| 117 |
+
%% <<"user_agent">> => <<"hex_core/0.5.0 (httpc) (OTP/21) (erts/10.2)">>},
|
| 118 |
+
%% <<"name">> => <<"hex_core">>,
|
| 119 |
+
%% <<"permissions">> => [#{<<"domain">> => <<"api">>,<<"resource">> => <<"read">>}],
|
| 120 |
+
%% <<"revoked_at">> => nil,
|
| 121 |
+
%% <<"updated_at">> => <<"2019-02-27T14:38:54Z">>,
|
| 122 |
+
%% <<"url">> => <<"https://hex.pm/api/keys/test">>},
|
| 123 |
+
%% }}}
|
| 124 |
+
%% '''
|
| 125 |
+
%% @end
|
| 126 |
+
-spec delete(hex_core:config(), binary()) -> hex_api:response().
|
| 127 |
+
delete(Config, Name) when is_map(Config) and is_binary(Name) ->
|
| 128 |
+
Path = hex_api:build_organization_path(Config, ["keys", Name]),
|
| 129 |
+
hex_api:delete(Config, Path).
|
| 130 |
+
|
| 131 |
+
%% @doc
|
| 132 |
+
%% Deletes all API and repository keys associated with the account.
|
| 133 |
+
%%
|
| 134 |
+
%% Examples:
|
| 135 |
+
%%
|
| 136 |
+
%% ```
|
| 137 |
+
%% > hex_api_key:delete_all(hex_core:default_config()).
|
| 138 |
+
%% {ok, {200, ..., [#{
|
| 139 |
+
%% <<"authing_key">> => true,
|
| 140 |
+
%% <<"inserted_at">> => <<"2019-02-27T11:15:32Z">>,
|
| 141 |
+
%% <<"last_use">> =>
|
| 142 |
+
%% #{<<"ip">> => <<"1.2.3.4">>,
|
| 143 |
+
%% <<"used_at">> => <<"2019-02-27T14:38:54Z">>,
|
| 144 |
+
%% <<"user_agent">> => <<"hex_core/0.5.0 (httpc) (OTP/21) (erts/10.2)">>},
|
| 145 |
+
%% <<"name">> => <<"hex_core">>,
|
| 146 |
+
%% <<"permissions">> => [#{<<"domain">> => <<"api">>,<<"resource">> => <<"read">>}],
|
| 147 |
+
%% <<"revoked_at">> => nil,
|
| 148 |
+
%% <<"updated_at">> => <<"2019-02-27T14:38:54Z">>,
|
| 149 |
+
%% <<"url">> => <<"https://hex.pm/api/keys/test">>},
|
| 150 |
+
%% }]}}
|
| 151 |
+
%% '''
|
| 152 |
+
%% @end
|
| 153 |
+
-spec delete_all(hex_core:config()) -> hex_api:response().
|
| 154 |
+
delete_all(Config) when is_map(Config) ->
|
| 155 |
+
Path = hex_api:build_organization_path(Config, ["keys"]),
|
| 156 |
+
hex_api:delete(Config, Path).
|
deps/eini/_build/default/plugins/hex_core/src/hex_api_organization.erl
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%% @doc
|
| 2 |
+
%% Hex HTTP API - Organizations.
|
| 3 |
+
-module(hex_api_organization).
|
| 4 |
+
-export([
|
| 5 |
+
get/1,
|
| 6 |
+
list/1,
|
| 7 |
+
update/2
|
| 8 |
+
]).
|
| 9 |
+
|
| 10 |
+
%% @doc
|
| 11 |
+
%% Lists all organizations you are member of.
|
| 12 |
+
%%
|
| 13 |
+
%% Examples:
|
| 14 |
+
%%
|
| 15 |
+
%% ```
|
| 16 |
+
%% > hex_api_organization:list(hex_core:default_config()).
|
| 17 |
+
%% {ok, {200, ..., [#{
|
| 18 |
+
%% <<"billing_active">> => true,
|
| 19 |
+
%% <<"inserted_at">> => <<"2017-08-22T22:19:53Z">>,
|
| 20 |
+
%% <<"name">> => <<"acme">>,
|
| 21 |
+
%% <<"updated_at">> => <<"2019-01-18T08:47:29Z">>}
|
| 22 |
+
%% }]}}
|
| 23 |
+
%% '''
|
| 24 |
+
-spec list(hex_core:config()) -> hex_api:response().
|
| 25 |
+
list(Config) when is_map(Config) ->
|
| 26 |
+
hex_api:get(Config, ["orgs"]).
|
| 27 |
+
|
| 28 |
+
%% @doc
|
| 29 |
+
%% Gets an organzation.
|
| 30 |
+
%%
|
| 31 |
+
%% Examples:
|
| 32 |
+
%%
|
| 33 |
+
%% ```
|
| 34 |
+
%% > hex_api_organization:get(hex_core:default_config()).
|
| 35 |
+
%% {ok, {200, ..., #{
|
| 36 |
+
%% <<"billing_active">> => true,
|
| 37 |
+
%% <<"inserted_at">> => <<"2017-08-22T22:19:53Z">>,
|
| 38 |
+
%% <<"name">> => <<"acme">>,
|
| 39 |
+
%% <<"seats">> => 42,
|
| 40 |
+
%% <<"updated_at">> => <<"2019-01-18T08:47:29Z">>}
|
| 41 |
+
%% }}}
|
| 42 |
+
%% '''
|
| 43 |
+
-spec get(hex_core:config()) -> hex_api:response().
|
| 44 |
+
get(Config) when is_map(Config) ->
|
| 45 |
+
Path = hex_api:build_organization_path(Config, []),
|
| 46 |
+
hex_api:get(Config, Path).
|
| 47 |
+
|
| 48 |
+
%% @doc
|
| 49 |
+
%% Updates the number of seats in an organzation.
|
| 50 |
+
%%
|
| 51 |
+
%% Examples:
|
| 52 |
+
%%
|
| 53 |
+
%% ```
|
| 54 |
+
%% > hex_api_organization:get(hex_core:default_config(), 42).
|
| 55 |
+
%% {ok, {200, ..., #{
|
| 56 |
+
%% <<"billing_active">> => true,
|
| 57 |
+
%% <<"inserted_at">> => <<"2017-08-22T22:19:53Z">>,
|
| 58 |
+
%% <<"name">> => <<"acme">>,
|
| 59 |
+
%% <<"seats">> => 42,
|
| 60 |
+
%% <<"updated_at">> => <<"2019-01-18T08:47:29Z">>}
|
| 61 |
+
%% }}}
|
| 62 |
+
%% '''
|
| 63 |
+
-spec update(hex_core:config(), pos_integer()) -> hex_api:response().
|
| 64 |
+
update(Config, Seats) when is_map(Config) and is_integer(Seats) ->
|
| 65 |
+
Path = hex_api:build_organization_path(Config, []),
|
| 66 |
+
Params = #{<<"seats">> => Seats},
|
| 67 |
+
hex_api:post(Config, Path, Params).
|
deps/eini/_build/default/plugins/hex_core/src/hex_api_organization_member.erl
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%% @doc
|
| 2 |
+
%% Hex HTTP API - Organization Members.
|
| 3 |
+
-module(hex_api_organization_member).
|
| 4 |
+
-export([
|
| 5 |
+
add/3,
|
| 6 |
+
delete/2,
|
| 7 |
+
get/2,
|
| 8 |
+
list/1,
|
| 9 |
+
update/3
|
| 10 |
+
]).
|
| 11 |
+
|
| 12 |
+
-type role() :: admin | write | read.
|
| 13 |
+
|
| 14 |
+
%% @doc
|
| 15 |
+
%% Lists the organization's members.
|
| 16 |
+
%%
|
| 17 |
+
%% Examples:
|
| 18 |
+
%%
|
| 19 |
+
%% ```
|
| 20 |
+
%% > hex_api_organization_member:list(hex_core:default_config(), #{api_organization => <<"acme">>}).
|
| 21 |
+
%% {ok, {200, ..., [#{
|
| 22 |
+
%% <<"email">> => <<"user@example.com">>,
|
| 23 |
+
%% <<"role">> => <<"admin">>,
|
| 24 |
+
%% <<"url">> => <<"https://hex.pm/api/users/user">>,
|
| 25 |
+
%% <<"username">> => <<"user">>
|
| 26 |
+
%% }]}}
|
| 27 |
+
%% '''
|
| 28 |
+
%% @end
|
| 29 |
+
-spec list(hex_core:config()) -> hex_api:response().
|
| 30 |
+
list(Config) when is_map(Config) ->
|
| 31 |
+
Path = hex_api:build_organization_path(Config, ["members"]),
|
| 32 |
+
hex_api:get(Config, Path).
|
| 33 |
+
|
| 34 |
+
%% @doc
|
| 35 |
+
%% Gets an organization member.
|
| 36 |
+
%%
|
| 37 |
+
%% Examples:
|
| 38 |
+
%%
|
| 39 |
+
%% ```
|
| 40 |
+
%% > hex_api_organization_member:get(hex_core:default_config(), #{api_organization => <<"acme">>}, <<"user">>).
|
| 41 |
+
%% {ok, {200, ..., #{
|
| 42 |
+
%% <<"email">> => <<"user@example.com">>,
|
| 43 |
+
%% <<"role">> => <<"admin">>,
|
| 44 |
+
%% <<"url">> => <<"https://hex.pm/api/users/user">>,
|
| 45 |
+
%% <<"username">> => <<"user">>
|
| 46 |
+
%% }}}
|
| 47 |
+
%% '''
|
| 48 |
+
%% @end
|
| 49 |
+
-spec get(hex_core:config(), binary()) -> hex_api:response().
|
| 50 |
+
get(Config, UsernameOrEmail) when is_map(Config) and is_binary(UsernameOrEmail) ->
|
| 51 |
+
Path = hex_api:build_organization_path(Config, ["members", UsernameOrEmail]),
|
| 52 |
+
hex_api:get(Config, Path).
|
| 53 |
+
|
| 54 |
+
%% @doc
|
| 55 |
+
%% Adds an organization member.
|
| 56 |
+
%%
|
| 57 |
+
%% Examples:
|
| 58 |
+
%%
|
| 59 |
+
%% ```
|
| 60 |
+
%% > hex_api_organization_member:add(hex_core:default_config(), #{api_organization => <<"acme">>}, <<"user">>, write).
|
| 61 |
+
%% {ok, {200, ..., #{
|
| 62 |
+
%% <<"email">> => <<"user@example.com">>,
|
| 63 |
+
%% <<"role">> => <<"write">>,
|
| 64 |
+
%% <<"url">> => <<"https://hex.pm/api/users/user">>,
|
| 65 |
+
%% <<"username">> => <<"user">>
|
| 66 |
+
%% }}}
|
| 67 |
+
%% '''
|
| 68 |
+
%% @end
|
| 69 |
+
-spec add(hex_core:config(), binary(), role()) -> hex_api:response().
|
| 70 |
+
add(Config, UsernameOrEmail, Role) when
|
| 71 |
+
is_map(Config) and is_binary(UsernameOrEmail) and is_atom(Role)
|
| 72 |
+
->
|
| 73 |
+
Path = hex_api:build_organization_path(Config, ["members"]),
|
| 74 |
+
Params = #{<<"name">> => UsernameOrEmail, <<"role">> => Role},
|
| 75 |
+
hex_api:post(Config, Path, Params).
|
| 76 |
+
|
| 77 |
+
%% @doc
|
| 78 |
+
%% Updates an organization member's role.
|
| 79 |
+
%%
|
| 80 |
+
%% Examples:
|
| 81 |
+
%%
|
| 82 |
+
%% ```
|
| 83 |
+
%% > hex_api_organization_member:update(hex_core:default_config(), #{api_organization => <<"acme">>}, <<"user">>, read).
|
| 84 |
+
%% {ok, {200, ..., #{
|
| 85 |
+
%% <<"email">> => <<"user@example.com">>,
|
| 86 |
+
%% <<"role">> => <<"read">>,
|
| 87 |
+
%% <<"url">> => <<"https://hex.pm/api/users/user">>,
|
| 88 |
+
%% <<"username">> => <<"user">>
|
| 89 |
+
%% }}}
|
| 90 |
+
%% '''
|
| 91 |
+
%% @end
|
| 92 |
+
-spec update(hex_core:config(), binary(), role()) -> hex_api:response().
|
| 93 |
+
update(Config, UsernameOrEmail, Role) when
|
| 94 |
+
is_map(Config) and is_binary(UsernameOrEmail) and is_atom(Role)
|
| 95 |
+
->
|
| 96 |
+
Path = hex_api:build_organization_path(Config, ["members", UsernameOrEmail]),
|
| 97 |
+
Params = #{<<"role">> => Role},
|
| 98 |
+
hex_api:post(Config, Path, Params).
|
| 99 |
+
|
| 100 |
+
%% @doc
|
| 101 |
+
%% Deletes an organization member.
|
| 102 |
+
%%
|
| 103 |
+
%% Examples:
|
| 104 |
+
%%
|
| 105 |
+
%% ```
|
| 106 |
+
%% > hex_api_organization_member:delete(hex_core:default_config(), #{api_organization => <<"acme">>}, <<"user">>).
|
| 107 |
+
%% {ok, {204, ..., nil}}
|
| 108 |
+
%% '''
|
| 109 |
+
%% @end
|
| 110 |
+
-spec delete(hex_core:config(), binary()) -> hex_api:response().
|
| 111 |
+
delete(Config, UsernameOrEmail) when is_map(Config) and is_binary(UsernameOrEmail) ->
|
| 112 |
+
Path = hex_api:build_organization_path(Config, ["members", UsernameOrEmail]),
|
| 113 |
+
hex_api:delete(Config, Path).
|
deps/eini/_build/default/plugins/hex_core/src/hex_api_package.erl
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%% @doc
|
| 2 |
+
%% Hex HTTP API - Packages.
|
| 3 |
+
-module(hex_api_package).
|
| 4 |
+
-export([get/2, search/3]).
|
| 5 |
+
|
| 6 |
+
%% @doc
|
| 7 |
+
%% Gets a package.
|
| 8 |
+
%%
|
| 9 |
+
%% Examples:
|
| 10 |
+
%%
|
| 11 |
+
%% ```
|
| 12 |
+
%% > hex_api_package:get(hex_core:default_config(), <<"package">>).
|
| 13 |
+
%% {ok, {200, ..., #{
|
| 14 |
+
%% <<"name">> => <<"package1">>,
|
| 15 |
+
%% <<"meta">> => #{
|
| 16 |
+
%% <<"description">> => ...,
|
| 17 |
+
%% <<"licenses">> => ...,
|
| 18 |
+
%% <<"links">> => ...,
|
| 19 |
+
%% <<"maintainers">> => ...
|
| 20 |
+
%% },
|
| 21 |
+
%% ...,
|
| 22 |
+
%% <<"releases">> => [
|
| 23 |
+
%% #{<<"url">> => ..., <<"version">> => <<"0.5.0">>}],
|
| 24 |
+
%% #{<<"url">> => ..., <<"version">> => <<"1.0.0">>}],
|
| 25 |
+
%% ...
|
| 26 |
+
%% ]}}}
|
| 27 |
+
%% '''
|
| 28 |
+
%% @end
|
| 29 |
+
-spec get(hex_core:config(), binary()) -> hex_api:response().
|
| 30 |
+
get(Config, Name) when is_map(Config) and is_binary(Name) ->
|
| 31 |
+
Path = hex_api:build_repository_path(Config, ["packages", Name]),
|
| 32 |
+
hex_api:get(Config, Path).
|
| 33 |
+
|
| 34 |
+
%% @doc
|
| 35 |
+
%% Searches packages.
|
| 36 |
+
%%
|
| 37 |
+
%% Examples:
|
| 38 |
+
%%
|
| 39 |
+
%% ```
|
| 40 |
+
%% > hex_api_package:search(hex_core:default_config(), <<"package">>, [{page, 1}]).
|
| 41 |
+
%% {ok, {200, ..., [
|
| 42 |
+
%% #{<<"name">> => <<"package1">>, ...},
|
| 43 |
+
%% ...
|
| 44 |
+
%% ]}}
|
| 45 |
+
%% '''
|
| 46 |
+
-spec search(hex_core:config(), binary(), [{term(), term()}]) -> hex_api:response().
|
| 47 |
+
search(Config, Query, SearchParams) when
|
| 48 |
+
is_map(Config) and is_binary(Query) and is_list(SearchParams)
|
| 49 |
+
->
|
| 50 |
+
QueryString = hex_api:encode_query_string([{search, Query} | SearchParams]),
|
| 51 |
+
Path = hex_api:join_path_segments(hex_api:build_repository_path(Config, ["packages"])),
|
| 52 |
+
PathQuery = <<Path/binary, "?", QueryString/binary>>,
|
| 53 |
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%% @doc
|
| 2 |
+
%% Hex HTTP API - Releases.
|
| 3 |
+
-module(hex_api_release).
|
| 4 |
+
-export([
|
| 5 |
+
delete/3,
|
| 6 |
+
get/3,
|
| 7 |
+
publish/2,
|
| 8 |
+
publish/3,
|
| 9 |
+
retire/4,
|
| 10 |
+
unretire/3
|
| 11 |
+
]).
|
| 12 |
+
|
| 13 |
+
-export_type([publish_params/0, retirement_params/0]).
|
| 14 |
+
|
| 15 |
+
-type publish_params() :: [{replace, boolean()}].
|
| 16 |
+
|
| 17 |
+
-type retirement_params() :: #{binary() := binary()}.
|
| 18 |
+
%% @doc
|
| 19 |
+
%% Gets a package release.
|
| 20 |
+
%%
|
| 21 |
+
%% Examples:
|
| 22 |
+
%%
|
| 23 |
+
%% ```
|
| 24 |
+
%% > hex_api_release:get(hex_core:default_config(), <<"package">>, <<"1.0.0">>).
|
| 25 |
+
%% {ok, {200, ..., #{
|
| 26 |
+
%% <<"checksum">> => <<"540d210d81f56f17f64309a4896430e727972499b37bd59342dc08d61dff74d8">>,
|
| 27 |
+
%% <<"docs_html_url">> => <<"https://hexdocs.pm/package/1.0.0/">>,
|
| 28 |
+
%% <<"downloads">> => 740,<<"has_docs">> => true,
|
| 29 |
+
%% <<"html_url">> => <<"https://hex.pm/packages/package/1.0.0">>,
|
| 30 |
+
%% <<"inserted_at">> => <<"2014-12-09T18:32:03Z">>,
|
| 31 |
+
%% <<"meta">> =>
|
| 32 |
+
%% #{<<"app">> => <<"package">>,
|
| 33 |
+
%% <<"build_tools">> => [<<"mix">>]},
|
| 34 |
+
%% <<"package_url">> => <<"https://hex.pm/api/packages/package">>,
|
| 35 |
+
%% <<"publisher">> => nil,<<"requirements">> => #{},
|
| 36 |
+
%% <<"retirement">> => nil,
|
| 37 |
+
%% <<"updated_at">> => <<"2019-07-28T21:12:11Z">>,
|
| 38 |
+
%% <<"url">> => <<"https://hex.pm/api/packages/package/releases/1.0.0">>,
|
| 39 |
+
%% <<"version">> => <<"1.0.0">>
|
| 40 |
+
%% }}}
|
| 41 |
+
%% '''
|
| 42 |
+
%% @end
|
| 43 |
+
-spec get(hex_core:config(), binary(), binary()) -> hex_api:response().
|
| 44 |
+
get(Config, Name, Version) when is_map(Config) and is_binary(Name) and is_binary(Version) ->
|
| 45 |
+
Path = hex_api:build_repository_path(Config, ["packages", Name, "releases", Version]),
|
| 46 |
+
hex_api:get(Config, Path).
|
| 47 |
+
|
| 48 |
+
%% @doc
|
| 49 |
+
%% Publishes a new package release.
|
| 50 |
+
%%
|
| 51 |
+
%% Examples:
|
| 52 |
+
%%
|
| 53 |
+
%% ```
|
| 54 |
+
%% > hex_api_release:publish(hex_core:default_config(), Tarball).
|
| 55 |
+
%% {ok, {200, ..., #{
|
| 56 |
+
%% <<"checksum">> => <<"540d210d81f56f17f64309a4896430e727972499b37bd59342dc08d61dff74d8">>,
|
| 57 |
+
%% <<"docs_html_url">> => <<"https://hexdocs.pm/package/1.0.0/">>,
|
| 58 |
+
%% <<"downloads">> => 740,<<"has_docs">> => true,
|
| 59 |
+
%% <<"html_url">> => <<"https://hex.pm/packages/package/1.0.0">>,
|
| 60 |
+
%% <<"inserted_at">> => <<"2014-12-09T18:32:03Z">>,
|
| 61 |
+
%% <<"meta">> =>
|
| 62 |
+
%% #{<<"app">> => <<"package">>,
|
| 63 |
+
%% <<"build_tools">> => [<<"mix">>]},
|
| 64 |
+
%% <<"package_url">> => <<"https://hex.pm/api/packages/package">>,
|
| 65 |
+
%% <<"publisher">> => nil,<<"requirements">> => #{},
|
| 66 |
+
%% <<"retirement">> => nil,
|
| 67 |
+
%% <<"updated_at">> => <<"2019-07-28T21:12:11Z">>,
|
| 68 |
+
%% <<"url">> => <<"https://hex.pm/api/packages/package/releases/1.0.0">>,
|
| 69 |
+
%% <<"version">> => <<"1.0.0">>
|
| 70 |
+
%% }}}
|
| 71 |
+
%% '''
|
| 72 |
+
%% @end
|
| 73 |
+
-spec publish(hex_core:config(), binary()) -> hex_api:response().
|
| 74 |
+
publish(Config, Tarball) -> publish(Config, Tarball, []).
|
| 75 |
+
|
| 76 |
+
%% @doc
|
| 77 |
+
%% Publishes a new package release with query parameters.
|
| 78 |
+
%%
|
| 79 |
+
%% Supported query params :
|
| 80 |
+
%% - replace : boolean
|
| 81 |
+
%%
|
| 82 |
+
%% Examples:
|
| 83 |
+
%%
|
| 84 |
+
%% ```
|
| 85 |
+
%% > hex_api_release:publish(hex_core:default_config(), Tarball, [{replace, true}]).
|
| 86 |
+
%% {ok, {201, ..., #{
|
| 87 |
+
%% <<"checksum">> => <<"540d210d81f56f17f64309a4896430e727972499b37bd59342dc08d61dff74d8">>,
|
| 88 |
+
%% <<"docs_html_url">> => <<"https://hexdocs.pm/package/1.0.0/">>,
|
| 89 |
+
%% <<"downloads">> => 740,<<"has_docs">> => true,
|
| 90 |
+
%% <<"html_url">> => <<"https://hex.pm/packages/package/1.0.0">>,
|
| 91 |
+
%% <<"inserted_at">> => <<"2014-12-09T18:32:03Z">>,
|
| 92 |
+
%% <<"meta">> =>
|
| 93 |
+
%% #{<<"app">> => <<"package">>,
|
| 94 |
+
%% <<"build_tools">> => [<<"mix">>]},
|
| 95 |
+
%% <<"package_url">> => <<"https://hex.pm/api/packages/package">>,
|
| 96 |
+
%% <<"publisher">> => nil,<<"requirements">> => #{},
|
| 97 |
+
%% <<"retirement">> => nil,
|
| 98 |
+
%% <<"updated_at">> => <<"2019-07-28T21:12:11Z">>,
|
| 99 |
+
%% <<"url">> => <<"https://hex.pm/api/packages/package/releases/1.0.0">>,
|
| 100 |
+
%% <<"version">> => <<"1.0.0">>
|
| 101 |
+
%% }}}
|
| 102 |
+
%% '''
|
| 103 |
+
%% @end
|
| 104 |
+
-spec publish(hex_core:config(), binary(), publish_params()) -> hex_api:response().
|
| 105 |
+
publish(Config, Tarball, Params) when
|
| 106 |
+
is_map(Config) andalso is_binary(Tarball) andalso is_list(Params)
|
| 107 |
+
->
|
| 108 |
+
case hex_tarball:unpack(Tarball, memory) of
|
| 109 |
+
{ok, #{metadata := Metadata}} ->
|
| 110 |
+
PackageName = maps:get(<<"name">>, Metadata),
|
| 111 |
+
QueryString = hex_api:encode_query_string([
|
| 112 |
+
{replace, proplists:get_value(replace, Params, false)}
|
| 113 |
+
]),
|
| 114 |
+
Path = hex_api:join_path_segments(
|
| 115 |
+
hex_api:build_repository_path(Config, ["packages", PackageName, "releases"])
|
| 116 |
+
),
|
| 117 |
+
PathWithQuery = <<Path/binary, "?", QueryString/binary>>,
|
| 118 |
+
TarballContentType = "application/octet-stream",
|
| 119 |
+
Config2 = put_header(
|
| 120 |
+
<<"content-length">>, integer_to_binary(byte_size(Tarball)), Config
|
| 121 |
+
),
|
| 122 |
+
Config3 = maybe_put_expect_header(Config2),
|
| 123 |
+
Body = {TarballContentType, Tarball},
|
| 124 |
+
hex_api:post(Config3, PathWithQuery, Body);
|
| 125 |
+
{error, Reason} ->
|
| 126 |
+
{error, {tarball, Reason}}
|
| 127 |
+
end.
|
| 128 |
+
|
| 129 |
+
%% @doc
|
| 130 |
+
%% Deletes a package release.
|
| 131 |
+
%%
|
| 132 |
+
%% Examples:
|
| 133 |
+
%%
|
| 134 |
+
%% ```
|
| 135 |
+
%% > hex_api_release:delete(hex_core:default_config(), <<"package">>, <<"1.0.0">>).
|
| 136 |
+
%% {ok, {204, ..., nil}}
|
| 137 |
+
%% '''
|
| 138 |
+
%% @end
|
| 139 |
+
-spec delete(hex_core:config(), binary(), binary()) -> hex_api:response().
|
| 140 |
+
delete(Config, Name, Version) when is_map(Config) and is_binary(Name) and is_binary(Version) ->
|
| 141 |
+
Path = hex_api:build_repository_path(Config, ["packages", Name, "releases", Version]),
|
| 142 |
+
hex_api:delete(Config, Path).
|
| 143 |
+
|
| 144 |
+
%% @doc
|
| 145 |
+
%% Retires a package release.
|
| 146 |
+
%%
|
| 147 |
+
%% Examples:
|
| 148 |
+
%%
|
| 149 |
+
%% ```
|
| 150 |
+
%% > hex_api_release:retire(hex_core:default_config(), <<"package">>, <<"1.0.0">>, Params).
|
| 151 |
+
%% {ok, {204, ..., nil}}
|
| 152 |
+
%% '''
|
| 153 |
+
%% @end
|
| 154 |
+
-spec retire(hex_core:config(), binary(), binary(), retirement_params()) -> hex_api:response().
|
| 155 |
+
retire(Config, Name, Version, Params) when
|
| 156 |
+
is_map(Config) and is_binary(Name) and is_binary(Version)
|
| 157 |
+
->
|
| 158 |
+
Path = hex_api:build_repository_path(Config, ["packages", Name, "releases", Version, "retire"]),
|
| 159 |
+
hex_api:post(Config, Path, Params).
|
| 160 |
+
|
| 161 |
+
%% @doc
|
| 162 |
+
%% Unretires a package release.
|
| 163 |
+
%%
|
| 164 |
+
%% Examples:
|
| 165 |
+
%%
|
| 166 |
+
%% ```
|
| 167 |
+
%% > hex_api_release:unretire(hex_core:default_config(), <<"package">>, <<"1.0.0">>).
|
| 168 |
+
%% {ok, {204, ..., nil}}
|
| 169 |
+
%% '''
|
| 170 |
+
%% @end
|
| 171 |
+
-spec unretire(hex_core:config(), binary(), binary()) -> hex_api:response().
|
| 172 |
+
unretire(Config, Name, Version) when is_map(Config) and is_binary(Name) and is_binary(Version) ->
|
| 173 |
+
Path = hex_api:build_repository_path(Config, ["packages", Name, "releases", Version, "retire"]),
|
| 174 |
+
hex_api:delete(Config, Path).
|
| 175 |
+
|
| 176 |
+
%%====================================================================
|
| 177 |
+
%% Internal functions
|
| 178 |
+
%%====================================================================
|
| 179 |
+
|
| 180 |
+
%% @private
|
| 181 |
+
put_header(Name, Value, Config) ->
|
| 182 |
+
Headers = maps:get(http_headers, Config, #{}),
|
| 183 |
+
Headers2 = maps:put(Name, Value, Headers),
|
| 184 |
+
maps:put(http_headers, Headers2, Config).
|
| 185 |
+
|
| 186 |
+
%% @private
|
| 187 |
+
maybe_put_expect_header(Config) ->
|
| 188 |
+
case maps:get(send_100_continue, Config, true) of
|
| 189 |
+
true -> put_header(<<"expect">>, <<"100-continue">>, Config);
|
| 190 |
+
false -> Config
|
| 191 |
+
end.
|
deps/eini/_build/default/plugins/hex_core/src/hex_api_short_url.erl
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%% @doc
|
| 2 |
+
%% Hex HTTP API - Short URLs.
|
| 3 |
+
-module(hex_api_short_url).
|
| 4 |
+
-export([create/2]).
|
| 5 |
+
|
| 6 |
+
%% @doc
|
| 7 |
+
%% Creates a short URL.
|
| 8 |
+
%%
|
| 9 |
+
%% Examples:
|
| 10 |
+
%%
|
| 11 |
+
%% ```
|
| 12 |
+
%% > hex_api_short_url:create(hex_core:default_config(), <<"https://hex.pm/packages/example">>).
|
| 13 |
+
%% {ok, {201, ..., #{<<"url">> => <<"https://hex.pm/l/XXXXX">>}}}
|
| 14 |
+
%% '''
|
| 15 |
+
%% @end
|
| 16 |
+
-spec create(hex_core:config(), binary()) -> hex_api:response().
|
| 17 |
+
create(Config, URL) when is_map(Config) and is_binary(URL) ->
|
| 18 |
+
Body = #{<<"url">> => URL},
|
| 19 |
+
hex_api:post(Config, ["short_url"], Body).
|
deps/eini/_build/default/plugins/hex_core/src/hex_core.app.src
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{application,hex_core,
|
| 2 |
+
[{description,"Reference implementation of Hex specifications"},
|
| 3 |
+
{vsn,"0.12.2"},
|
| 4 |
+
{registered,[]},
|
| 5 |
+
{applications,[kernel,stdlib,inets,ssl]},
|
| 6 |
+
{licenses,["Apache-2.0"]},
|
| 7 |
+
{include_paths,["CHANGELOG.md"]},
|
| 8 |
+
{exclude_paths,["src/safe_erl_term.erl"]},
|
| 9 |
+
{links,[{"GitHub","https://github.com/hexpm/hex_core"},
|
| 10 |
+
{"Hex specifications",
|
| 11 |
+
"https://github.com/hexpm/specifications"}]},
|
| 12 |
+
{doc,"doc"}]}.
|
deps/eini/_build/default/plugins/hex_core/src/hex_core.hrl
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
-define(HEX_CORE_VERSION, "0.12.2").
|
deps/eini/_build/default/plugins/hex_core/src/hex_filename.erl
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
% @private
|
| 2 |
+
% Excerpt from https://github.com/erlang/otp/blob/OTP-20.0.1/lib/stdlib/src/filename.erl#L761-L788
|
| 3 |
+
% with modifications for changing local function calls to remote function calls
|
| 4 |
+
% to the `filename` module, for the functions `pathtype/1`, `split/1`, and `join/1`
|
| 5 |
+
%
|
| 6 |
+
% safe_relative_path/1 was not present in earlier OTP releases.
|
| 7 |
+
|
| 8 |
+
%%
|
| 9 |
+
%% %CopyrightBegin%
|
| 10 |
+
%%
|
| 11 |
+
%% Copyright Ericsson AB 1997-2017. All Rights Reserved.
|
| 12 |
+
%%
|
| 13 |
+
%% Licensed under the Apache License, Version 2.0 (the "License");
|
| 14 |
+
%% you may not use this file except in compliance with the License.
|
| 15 |
+
%% You may obtain a copy of the License at
|
| 16 |
+
%%
|
| 17 |
+
%% http://www.apache.org/licenses/LICENSE-2.0
|
| 18 |
+
%%
|
| 19 |
+
%% Unless required by applicable law or agreed to in writing, software
|
| 20 |
+
%% distributed under the License is distributed on an "AS IS" BASIS,
|
| 21 |
+
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 22 |
+
%% See the License for the specific language governing permissions and
|
| 23 |
+
%% limitations under the License.
|
| 24 |
+
%%
|
| 25 |
+
%% %CopyrightEnd%
|
| 26 |
+
%%
|
| 27 |
+
|
| 28 |
+
-module(hex_filename).
|
| 29 |
+
-export([safe_relative_path/1]).
|
| 30 |
+
|
| 31 |
+
safe_relative_path(Path) ->
|
| 32 |
+
case filename:pathtype(Path) of
|
| 33 |
+
relative ->
|
| 34 |
+
Cs0 = filename:split(Path),
|
| 35 |
+
safe_relative_path_1(Cs0, []);
|
| 36 |
+
_ ->
|
| 37 |
+
unsafe
|
| 38 |
+
end.
|
| 39 |
+
|
| 40 |
+
safe_relative_path_1(["." | T], Acc) ->
|
| 41 |
+
safe_relative_path_1(T, Acc);
|
| 42 |
+
safe_relative_path_1([<<".">> | T], Acc) ->
|
| 43 |
+
safe_relative_path_1(T, Acc);
|
| 44 |
+
safe_relative_path_1([".." | T], Acc) ->
|
| 45 |
+
climb(T, Acc);
|
| 46 |
+
safe_relative_path_1([<<"..">> | T], Acc) ->
|
| 47 |
+
climb(T, Acc);
|
| 48 |
+
safe_relative_path_1([H | T], Acc) ->
|
| 49 |
+
safe_relative_path_1(T, [H | Acc]);
|
| 50 |
+
safe_relative_path_1([], []) ->
|
| 51 |
+
[];
|
| 52 |
+
safe_relative_path_1([], Acc) ->
|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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%% @doc
|
| 2 |
+
%% Hex Licenses.
|
| 3 |
+
%% File generated by https://github.com/supersimple/spdx. Do not edit manually.
|
| 4 |
+
|
| 5 |
+
-module(hex_licenses).
|
| 6 |
+
|
| 7 |
+
-export([valid/1]).
|
| 8 |
+
|
| 9 |
+
valid(<<"0BSD">>) -> true;
|
| 10 |
+
valid(<<"3D-Slicer-1.0">>) -> true;
|
| 11 |
+
valid(<<"AAL">>) -> true;
|
| 12 |
+
valid(<<"ADSL">>) -> true;
|
| 13 |
+
valid(<<"AFL-1.1">>) -> true;
|
| 14 |
+
valid(<<"AFL-1.2">>) -> true;
|
| 15 |
+
valid(<<"AFL-2.0">>) -> true;
|
| 16 |
+
valid(<<"AFL-2.1">>) -> true;
|
| 17 |
+
valid(<<"AFL-3.0">>) -> true;
|
| 18 |
+
valid(<<"AGPL-1.0">>) -> true;
|
| 19 |
+
valid(<<"AGPL-1.0-only">>) -> true;
|
| 20 |
+
valid(<<"AGPL-1.0-or-later">>) -> true;
|
| 21 |
+
valid(<<"AGPL-3.0">>) -> true;
|
| 22 |
+
valid(<<"AGPL-3.0-only">>) -> true;
|
| 23 |
+
valid(<<"AGPL-3.0-or-later">>) -> true;
|
| 24 |
+
valid(<<"AMD-newlib">>) -> true;
|
| 25 |
+
valid(<<"AMDPLPA">>) -> true;
|
| 26 |
+
valid(<<"AML">>) -> true;
|
| 27 |
+
valid(<<"AML-glslang">>) -> true;
|
| 28 |
+
valid(<<"AMPAS">>) -> true;
|
| 29 |
+
valid(<<"ANTLR-PD">>) -> true;
|
| 30 |
+
valid(<<"ANTLR-PD-fallback">>) -> true;
|
| 31 |
+
valid(<<"APAFML">>) -> true;
|
| 32 |
+
valid(<<"APL-1.0">>) -> true;
|
| 33 |
+
valid(<<"APSL-1.0">>) -> true;
|
| 34 |
+
valid(<<"APSL-1.1">>) -> true;
|
| 35 |
+
valid(<<"APSL-1.2">>) -> true;
|
| 36 |
+
valid(<<"APSL-2.0">>) -> true;
|
| 37 |
+
valid(<<"ASWF-Digital-Assets-1.0">>) -> true;
|
| 38 |
+
valid(<<"ASWF-Digital-Assets-1.1">>) -> true;
|
| 39 |
+
valid(<<"Abstyles">>) -> true;
|
| 40 |
+
valid(<<"AdaCore-doc">>) -> true;
|
| 41 |
+
valid(<<"Adobe-2006">>) -> true;
|
| 42 |
+
valid(<<"Adobe-Display-PostScript">>) -> true;
|
| 43 |
+
valid(<<"Adobe-Glyph">>) -> true;
|
| 44 |
+
valid(<<"Adobe-Utopia">>) -> true;
|
| 45 |
+
valid(<<"Afmparse">>) -> true;
|
| 46 |
+
valid(<<"Aladdin">>) -> true;
|
| 47 |
+
valid(<<"Apache-1.0">>) -> true;
|
| 48 |
+
valid(<<"Apache-1.1">>) -> true;
|
| 49 |
+
valid(<<"Apache-2.0">>) -> true;
|
| 50 |
+
valid(<<"App-s2p">>) -> true;
|
| 51 |
+
valid(<<"Arphic-1999">>) -> true;
|
| 52 |
+
valid(<<"Artistic-1.0">>) -> true;
|
| 53 |
+
valid(<<"Artistic-1.0-Perl">>) -> true;
|
| 54 |
+
valid(<<"Artistic-1.0-cl8">>) -> true;
|
| 55 |
+
valid(<<"Artistic-2.0">>) -> true;
|
| 56 |
+
valid(<<"BSD-1-Clause">>) -> true;
|
| 57 |
+
valid(<<"BSD-2-Clause">>) -> true;
|
| 58 |
+
valid(<<"BSD-2-Clause-Darwin">>) -> true;
|
| 59 |
+
valid(<<"BSD-2-Clause-FreeBSD">>) -> true;
|
| 60 |
+
valid(<<"BSD-2-Clause-NetBSD">>) -> true;
|
| 61 |
+
valid(<<"BSD-2-Clause-Patent">>) -> true;
|
| 62 |
+
valid(<<"BSD-2-Clause-Views">>) -> true;
|
| 63 |
+
valid(<<"BSD-2-Clause-first-lines">>) -> true;
|
| 64 |
+
valid(<<"BSD-3-Clause">>) -> true;
|
| 65 |
+
valid(<<"BSD-3-Clause-Attribution">>) -> true;
|
| 66 |
+
valid(<<"BSD-3-Clause-Clear">>) -> true;
|
| 67 |
+
valid(<<"BSD-3-Clause-HP">>) -> true;
|
| 68 |
+
valid(<<"BSD-3-Clause-LBNL">>) -> true;
|
| 69 |
+
valid(<<"BSD-3-Clause-Modification">>) -> true;
|
| 70 |
+
valid(<<"BSD-3-Clause-No-Military-License">>) -> true;
|
| 71 |
+
valid(<<"BSD-3-Clause-No-Nuclear-License">>) -> true;
|
| 72 |
+
valid(<<"BSD-3-Clause-No-Nuclear-License-2014">>) -> true;
|
| 73 |
+
valid(<<"BSD-3-Clause-No-Nuclear-Warranty">>) -> true;
|
| 74 |
+
valid(<<"BSD-3-Clause-Open-MPI">>) -> true;
|
| 75 |
+
valid(<<"BSD-3-Clause-Sun">>) -> true;
|
| 76 |
+
valid(<<"BSD-3-Clause-acpica">>) -> true;
|
| 77 |
+
valid(<<"BSD-3-Clause-flex">>) -> true;
|
| 78 |
+
valid(<<"BSD-4-Clause">>) -> true;
|
| 79 |
+
valid(<<"BSD-4-Clause-Shortened">>) -> true;
|
| 80 |
+
valid(<<"BSD-4-Clause-UC">>) -> true;
|
| 81 |
+
valid(<<"BSD-4.3RENO">>) -> true;
|
| 82 |
+
valid(<<"BSD-4.3TAHOE">>) -> true;
|
| 83 |
+
valid(<<"BSD-Advertising-Acknowledgement">>) -> true;
|
| 84 |
+
valid(<<"BSD-Attribution-HPND-disclaimer">>) -> true;
|
| 85 |
+
valid(<<"BSD-Inferno-Nettverk">>) -> true;
|
| 86 |
+
valid(<<"BSD-Protection">>) -> true;
|
| 87 |
+
valid(<<"BSD-Source-Code">>) -> true;
|
| 88 |
+
valid(<<"BSD-Source-beginning-file">>) -> true;
|
| 89 |
+
valid(<<"BSD-Systemics">>) -> true;
|
| 90 |
+
valid(<<"BSD-Systemics-W3Works">>) -> true;
|
| 91 |
+
valid(<<"BSL-1.0">>) -> true;
|
| 92 |
+
valid(<<"BUSL-1.1">>) -> true;
|
| 93 |
+
valid(<<"Baekmuk">>) -> true;
|
| 94 |
+
valid(<<"Bahyph">>) -> true;
|
| 95 |
+
valid(<<"Barr">>) -> true;
|
| 96 |
+
valid(<<"Beerware">>) -> true;
|
| 97 |
+
valid(<<"BitTorrent-1.0">>) -> true;
|
| 98 |
+
valid(<<"BitTorrent-1.1">>) -> true;
|
| 99 |
+
valid(<<"Bitstream-Charter">>) -> true;
|
| 100 |
+
valid(<<"Bitstream-Vera">>) -> true;
|
| 101 |
+
valid(<<"BlueOak-1.0.0">>) -> true;
|
| 102 |
+
valid(<<"Boehm-GC">>) -> true;
|
| 103 |
+
valid(<<"Borceux">>) -> true;
|
| 104 |
+
valid(<<"Brian-Gladman-2-Clause">>) -> true;
|
| 105 |
+
valid(<<"Brian-Gladman-3-Clause">>) -> true;
|
| 106 |
+
valid(<<"C-UDA-1.0">>) -> true;
|
| 107 |
+
valid(<<"CAL-1.0">>) -> true;
|
| 108 |
+
valid(<<"CAL-1.0-Combined-Work-Exception">>) -> true;
|
| 109 |
+
valid(<<"CATOSL-1.1">>) -> true;
|
| 110 |
+
valid(<<"CC-BY-1.0">>) -> true;
|
| 111 |
+
valid(<<"CC-BY-2.0">>) -> true;
|
| 112 |
+
valid(<<"CC-BY-2.5">>) -> true;
|
| 113 |
+
valid(<<"CC-BY-2.5-AU">>) -> true;
|
| 114 |
+
valid(<<"CC-BY-3.0">>) -> true;
|
| 115 |
+
valid(<<"CC-BY-3.0-AT">>) -> true;
|
| 116 |
+
valid(<<"CC-BY-3.0-AU">>) -> true;
|
| 117 |
+
valid(<<"CC-BY-3.0-DE">>) -> true;
|
| 118 |
+
valid(<<"CC-BY-3.0-IGO">>) -> true;
|
| 119 |
+
valid(<<"CC-BY-3.0-NL">>) -> true;
|
| 120 |
+
valid(<<"CC-BY-3.0-US">>) -> true;
|
| 121 |
+
valid(<<"CC-BY-4.0">>) -> true;
|
| 122 |
+
valid(<<"CC-BY-NC-1.0">>) -> true;
|
| 123 |
+
valid(<<"CC-BY-NC-2.0">>) -> true;
|
| 124 |
+
valid(<<"CC-BY-NC-2.5">>) -> true;
|
| 125 |
+
valid(<<"CC-BY-NC-3.0">>) -> true;
|
| 126 |
+
valid(<<"CC-BY-NC-3.0-DE">>) -> true;
|
| 127 |
+
valid(<<"CC-BY-NC-4.0">>) -> true;
|
| 128 |
+
valid(<<"CC-BY-NC-ND-1.0">>) -> true;
|
| 129 |
+
valid(<<"CC-BY-NC-ND-2.0">>) -> true;
|
| 130 |
+
valid(<<"CC-BY-NC-ND-2.5">>) -> true;
|
| 131 |
+
valid(<<"CC-BY-NC-ND-3.0">>) -> true;
|
| 132 |
+
valid(<<"CC-BY-NC-ND-3.0-DE">>) -> true;
|
| 133 |
+
valid(<<"CC-BY-NC-ND-3.0-IGO">>) -> true;
|
| 134 |
+
valid(<<"CC-BY-NC-ND-4.0">>) -> true;
|
| 135 |
+
valid(<<"CC-BY-NC-SA-1.0">>) -> true;
|
| 136 |
+
valid(<<"CC-BY-NC-SA-2.0">>) -> true;
|
| 137 |
+
valid(<<"CC-BY-NC-SA-2.0-DE">>) -> true;
|
| 138 |
+
valid(<<"CC-BY-NC-SA-2.0-FR">>) -> true;
|
| 139 |
+
valid(<<"CC-BY-NC-SA-2.0-UK">>) -> true;
|
| 140 |
+
valid(<<"CC-BY-NC-SA-2.5">>) -> true;
|
| 141 |
+
valid(<<"CC-BY-NC-SA-3.0">>) -> true;
|
| 142 |
+
valid(<<"CC-BY-NC-SA-3.0-DE">>) -> true;
|
| 143 |
+
valid(<<"CC-BY-NC-SA-3.0-IGO">>) -> true;
|
| 144 |
+
valid(<<"CC-BY-NC-SA-4.0">>) -> true;
|
| 145 |
+
valid(<<"CC-BY-ND-1.0">>) -> true;
|
| 146 |
+
valid(<<"CC-BY-ND-2.0">>) -> true;
|
| 147 |
+
valid(<<"CC-BY-ND-2.5">>) -> true;
|
| 148 |
+
valid(<<"CC-BY-ND-3.0">>) -> true;
|
| 149 |
+
valid(<<"CC-BY-ND-3.0-DE">>) -> true;
|
| 150 |
+
valid(<<"CC-BY-ND-4.0">>) -> true;
|
| 151 |
+
valid(<<"CC-BY-SA-1.0">>) -> true;
|
| 152 |
+
valid(<<"CC-BY-SA-2.0">>) -> true;
|
| 153 |
+
valid(<<"CC-BY-SA-2.0-UK">>) -> true;
|
| 154 |
+
valid(<<"CC-BY-SA-2.1-JP">>) -> true;
|
| 155 |
+
valid(<<"CC-BY-SA-2.5">>) -> true;
|
| 156 |
+
valid(<<"CC-BY-SA-3.0">>) -> true;
|
| 157 |
+
valid(<<"CC-BY-SA-3.0-AT">>) -> true;
|
| 158 |
+
valid(<<"CC-BY-SA-3.0-DE">>) -> true;
|
| 159 |
+
valid(<<"CC-BY-SA-3.0-IGO">>) -> true;
|
| 160 |
+
valid(<<"CC-BY-SA-4.0">>) -> true;
|
| 161 |
+
valid(<<"CC-PDDC">>) -> true;
|
| 162 |
+
valid(<<"CC0-1.0">>) -> true;
|
| 163 |
+
valid(<<"CDDL-1.0">>) -> true;
|
| 164 |
+
valid(<<"CDDL-1.1">>) -> true;
|
| 165 |
+
valid(<<"CDL-1.0">>) -> true;
|
| 166 |
+
valid(<<"CDLA-Permissive-1.0">>) -> true;
|
| 167 |
+
valid(<<"CDLA-Permissive-2.0">>) -> true;
|
| 168 |
+
valid(<<"CDLA-Sharing-1.0">>) -> true;
|
| 169 |
+
valid(<<"CECILL-1.0">>) -> true;
|
| 170 |
+
valid(<<"CECILL-1.1">>) -> true;
|
| 171 |
+
valid(<<"CECILL-2.0">>) -> true;
|
| 172 |
+
valid(<<"CECILL-2.1">>) -> true;
|
| 173 |
+
valid(<<"CECILL-B">>) -> true;
|
| 174 |
+
valid(<<"CECILL-C">>) -> true;
|
| 175 |
+
valid(<<"CERN-OHL-1.1">>) -> true;
|
| 176 |
+
valid(<<"CERN-OHL-1.2">>) -> true;
|
| 177 |
+
valid(<<"CERN-OHL-P-2.0">>) -> true;
|
| 178 |
+
valid(<<"CERN-OHL-S-2.0">>) -> true;
|
| 179 |
+
valid(<<"CERN-OHL-W-2.0">>) -> true;
|
| 180 |
+
valid(<<"CFITSIO">>) -> true;
|
| 181 |
+
valid(<<"CMU-Mach">>) -> true;
|
| 182 |
+
valid(<<"CMU-Mach-nodoc">>) -> true;
|
| 183 |
+
valid(<<"CNRI-Jython">>) -> true;
|
| 184 |
+
valid(<<"CNRI-Python">>) -> true;
|
| 185 |
+
valid(<<"CNRI-Python-GPL-Compatible">>) -> true;
|
| 186 |
+
valid(<<"COIL-1.0">>) -> true;
|
| 187 |
+
valid(<<"CPAL-1.0">>) -> true;
|
| 188 |
+
valid(<<"CPL-1.0">>) -> true;
|
| 189 |
+
valid(<<"CPOL-1.02">>) -> true;
|
| 190 |
+
valid(<<"CUA-OPL-1.0">>) -> true;
|
| 191 |
+
valid(<<"Caldera">>) -> true;
|
| 192 |
+
valid(<<"Caldera-no-preamble">>) -> true;
|
| 193 |
+
valid(<<"Catharon">>) -> true;
|
| 194 |
+
valid(<<"ClArtistic">>) -> true;
|
| 195 |
+
valid(<<"Clips">>) -> true;
|
| 196 |
+
valid(<<"Community-Spec-1.0">>) -> true;
|
| 197 |
+
valid(<<"Condor-1.1">>) -> true;
|
| 198 |
+
valid(<<"Cornell-Lossless-JPEG">>) -> true;
|
| 199 |
+
valid(<<"Cronyx">>) -> true;
|
| 200 |
+
valid(<<"Crossword">>) -> true;
|
| 201 |
+
valid(<<"CrystalStacker">>) -> true;
|
| 202 |
+
valid(<<"Cube">>) -> true;
|
| 203 |
+
valid(<<"D-FSL-1.0">>) -> true;
|
| 204 |
+
valid(<<"DEC-3-Clause">>) -> true;
|
| 205 |
+
valid(<<"DL-DE-BY-2.0">>) -> true;
|
| 206 |
+
valid(<<"DL-DE-ZERO-2.0">>) -> true;
|
| 207 |
+
valid(<<"DOC">>) -> true;
|
| 208 |
+
valid(<<"DRL-1.0">>) -> true;
|
| 209 |
+
valid(<<"DRL-1.1">>) -> true;
|
| 210 |
+
valid(<<"DSDP">>) -> true;
|
| 211 |
+
valid(<<"Dotseqn">>) -> true;
|
| 212 |
+
valid(<<"ECL-1.0">>) -> true;
|
| 213 |
+
valid(<<"ECL-2.0">>) -> true;
|
| 214 |
+
valid(<<"EFL-1.0">>) -> true;
|
| 215 |
+
valid(<<"EFL-2.0">>) -> true;
|
| 216 |
+
valid(<<"EPICS">>) -> true;
|
| 217 |
+
valid(<<"EPL-1.0">>) -> true;
|
| 218 |
+
valid(<<"EPL-2.0">>) -> true;
|
| 219 |
+
valid(<<"EUDatagrid">>) -> true;
|
| 220 |
+
valid(<<"EUPL-1.0">>) -> true;
|
| 221 |
+
valid(<<"EUPL-1.1">>) -> true;
|
| 222 |
+
valid(<<"EUPL-1.2">>) -> true;
|
| 223 |
+
valid(<<"Elastic-2.0">>) -> true;
|
| 224 |
+
valid(<<"Entessa">>) -> true;
|
| 225 |
+
valid(<<"ErlPL-1.1">>) -> true;
|
| 226 |
+
valid(<<"Eurosym">>) -> true;
|
| 227 |
+
valid(<<"FBM">>) -> true;
|
| 228 |
+
valid(<<"FDK-AAC">>) -> true;
|
| 229 |
+
valid(<<"FSFAP">>) -> true;
|
| 230 |
+
valid(<<"FSFAP-no-warranty-disclaimer">>) -> true;
|
| 231 |
+
valid(<<"FSFUL">>) -> true;
|
| 232 |
+
valid(<<"FSFULLR">>) -> true;
|
| 233 |
+
valid(<<"FSFULLRWD">>) -> true;
|
| 234 |
+
valid(<<"FTL">>) -> true;
|
| 235 |
+
valid(<<"Fair">>) -> true;
|
| 236 |
+
valid(<<"Ferguson-Twofish">>) -> true;
|
| 237 |
+
valid(<<"Frameworx-1.0">>) -> true;
|
| 238 |
+
valid(<<"FreeBSD-DOC">>) -> true;
|
| 239 |
+
valid(<<"FreeImage">>) -> true;
|
| 240 |
+
valid(<<"Furuseth">>) -> true;
|
| 241 |
+
valid(<<"GCR-docs">>) -> true;
|
| 242 |
+
valid(<<"GD">>) -> true;
|
| 243 |
+
valid(<<"GFDL-1.1">>) -> true;
|
| 244 |
+
valid(<<"GFDL-1.1-invariants-only">>) -> true;
|
| 245 |
+
valid(<<"GFDL-1.1-invariants-or-later">>) -> true;
|
| 246 |
+
valid(<<"GFDL-1.1-no-invariants-only">>) -> true;
|
| 247 |
+
valid(<<"GFDL-1.1-no-invariants-or-later">>) -> true;
|
| 248 |
+
valid(<<"GFDL-1.1-only">>) -> true;
|
| 249 |
+
valid(<<"GFDL-1.1-or-later">>) -> true;
|
| 250 |
+
valid(<<"GFDL-1.2">>) -> true;
|
| 251 |
+
valid(<<"GFDL-1.2-invariants-only">>) -> true;
|
| 252 |
+
valid(<<"GFDL-1.2-invariants-or-later">>) -> true;
|
| 253 |
+
valid(<<"GFDL-1.2-no-invariants-only">>) -> true;
|
| 254 |
+
valid(<<"GFDL-1.2-no-invariants-or-later">>) -> true;
|
| 255 |
+
valid(<<"GFDL-1.2-only">>) -> true;
|
| 256 |
+
valid(<<"GFDL-1.2-or-later">>) -> true;
|
| 257 |
+
valid(<<"GFDL-1.3">>) -> true;
|
| 258 |
+
valid(<<"GFDL-1.3-invariants-only">>) -> true;
|
| 259 |
+
valid(<<"GFDL-1.3-invariants-or-later">>) -> true;
|
| 260 |
+
valid(<<"GFDL-1.3-no-invariants-only">>) -> true;
|
| 261 |
+
valid(<<"GFDL-1.3-no-invariants-or-later">>) -> true;
|
| 262 |
+
valid(<<"GFDL-1.3-only">>) -> true;
|
| 263 |
+
valid(<<"GFDL-1.3-or-later">>) -> true;
|
| 264 |
+
valid(<<"GL2PS">>) -> true;
|
| 265 |
+
valid(<<"GLWTPL">>) -> true;
|
| 266 |
+
valid(<<"GPL-1.0">>) -> true;
|
| 267 |
+
valid(<<"GPL-1.0+">>) -> true;
|
| 268 |
+
valid(<<"GPL-1.0-only">>) -> true;
|
| 269 |
+
valid(<<"GPL-1.0-or-later">>) -> true;
|
| 270 |
+
valid(<<"GPL-2.0">>) -> true;
|
| 271 |
+
valid(<<"GPL-2.0+">>) -> true;
|
| 272 |
+
valid(<<"GPL-2.0-only">>) -> true;
|
| 273 |
+
valid(<<"GPL-2.0-or-later">>) -> true;
|
| 274 |
+
valid(<<"GPL-2.0-with-GCC-exception">>) -> true;
|
| 275 |
+
valid(<<"GPL-2.0-with-autoconf-exception">>) -> true;
|
| 276 |
+
valid(<<"GPL-2.0-with-bison-exception">>) -> true;
|
| 277 |
+
valid(<<"GPL-2.0-with-classpath-exception">>) -> true;
|
| 278 |
+
valid(<<"GPL-2.0-with-font-exception">>) -> true;
|
| 279 |
+
valid(<<"GPL-3.0">>) -> true;
|
| 280 |
+
valid(<<"GPL-3.0+">>) -> true;
|
| 281 |
+
valid(<<"GPL-3.0-only">>) -> true;
|
| 282 |
+
valid(<<"GPL-3.0-or-later">>) -> true;
|
| 283 |
+
valid(<<"GPL-3.0-with-GCC-exception">>) -> true;
|
| 284 |
+
valid(<<"GPL-3.0-with-autoconf-exception">>) -> true;
|
| 285 |
+
valid(<<"Giftware">>) -> true;
|
| 286 |
+
valid(<<"Glide">>) -> true;
|
| 287 |
+
valid(<<"Glulxe">>) -> true;
|
| 288 |
+
valid(<<"Graphics-Gems">>) -> true;
|
| 289 |
+
valid(<<"Gutmann">>) -> true;
|
| 290 |
+
valid(<<"HP-1986">>) -> true;
|
| 291 |
+
valid(<<"HP-1989">>) -> true;
|
| 292 |
+
valid(<<"HPND">>) -> true;
|
| 293 |
+
valid(<<"HPND-DEC">>) -> true;
|
| 294 |
+
valid(<<"HPND-Fenneberg-Livingston">>) -> true;
|
| 295 |
+
valid(<<"HPND-INRIA-IMAG">>) -> true;
|
| 296 |
+
valid(<<"HPND-Intel">>) -> true;
|
| 297 |
+
valid(<<"HPND-Kevlin-Henney">>) -> true;
|
| 298 |
+
valid(<<"HPND-MIT-disclaimer">>) -> true;
|
| 299 |
+
valid(<<"HPND-Markus-Kuhn">>) -> true;
|
| 300 |
+
valid(<<"HPND-Pbmplus">>) -> true;
|
| 301 |
+
valid(<<"HPND-UC">>) -> true;
|
| 302 |
+
valid(<<"HPND-UC-export-US">>) -> true;
|
| 303 |
+
valid(<<"HPND-doc">>) -> true;
|
| 304 |
+
valid(<<"HPND-doc-sell">>) -> true;
|
| 305 |
+
valid(<<"HPND-export-US">>) -> true;
|
| 306 |
+
valid(<<"HPND-export-US-acknowledgement">>) -> true;
|
| 307 |
+
valid(<<"HPND-export-US-modify">>) -> true;
|
| 308 |
+
valid(<<"HPND-export2-US">>) -> true;
|
| 309 |
+
valid(<<"HPND-merchantability-variant">>) -> true;
|
| 310 |
+
valid(<<"HPND-sell-MIT-disclaimer-xserver">>) -> true;
|
| 311 |
+
valid(<<"HPND-sell-regexpr">>) -> true;
|
| 312 |
+
valid(<<"HPND-sell-variant">>) -> true;
|
| 313 |
+
valid(<<"HPND-sell-variant-MIT-disclaimer">>) -> true;
|
| 314 |
+
valid(<<"HPND-sell-variant-MIT-disclaimer-rev">>) -> true;
|
| 315 |
+
valid(<<"HTMLTIDY">>) -> true;
|
| 316 |
+
valid(<<"HaskellReport">>) -> true;
|
| 317 |
+
valid(<<"Hippocratic-2.1">>) -> true;
|
| 318 |
+
valid(<<"IBM-pibs">>) -> true;
|
| 319 |
+
valid(<<"ICU">>) -> true;
|
| 320 |
+
valid(<<"IEC-Code-Components-EULA">>) -> true;
|
| 321 |
+
valid(<<"IJG">>) -> true;
|
| 322 |
+
valid(<<"IJG-short">>) -> true;
|
| 323 |
+
valid(<<"IPA">>) -> true;
|
| 324 |
+
valid(<<"IPL-1.0">>) -> true;
|
| 325 |
+
valid(<<"ISC">>) -> true;
|
| 326 |
+
valid(<<"ISC-Veillard">>) -> true;
|
| 327 |
+
valid(<<"ImageMagick">>) -> true;
|
| 328 |
+
valid(<<"Imlib2">>) -> true;
|
| 329 |
+
valid(<<"Info-ZIP">>) -> true;
|
| 330 |
+
valid(<<"Inner-Net-2.0">>) -> true;
|
| 331 |
+
valid(<<"Intel">>) -> true;
|
| 332 |
+
valid(<<"Intel-ACPI">>) -> true;
|
| 333 |
+
valid(<<"Interbase-1.0">>) -> true;
|
| 334 |
+
valid(<<"JPL-image">>) -> true;
|
| 335 |
+
valid(<<"JPNIC">>) -> true;
|
| 336 |
+
valid(<<"JSON">>) -> true;
|
| 337 |
+
valid(<<"Jam">>) -> true;
|
| 338 |
+
valid(<<"JasPer-2.0">>) -> true;
|
| 339 |
+
valid(<<"Kastrup">>) -> true;
|
| 340 |
+
valid(<<"Kazlib">>) -> true;
|
| 341 |
+
valid(<<"Knuth-CTAN">>) -> true;
|
| 342 |
+
valid(<<"LAL-1.2">>) -> true;
|
| 343 |
+
valid(<<"LAL-1.3">>) -> true;
|
| 344 |
+
valid(<<"LGPL-2.0">>) -> true;
|
| 345 |
+
valid(<<"LGPL-2.0+">>) -> true;
|
| 346 |
+
valid(<<"LGPL-2.0-only">>) -> true;
|
| 347 |
+
valid(<<"LGPL-2.0-or-later">>) -> true;
|
| 348 |
+
valid(<<"LGPL-2.1">>) -> true;
|
| 349 |
+
valid(<<"LGPL-2.1+">>) -> true;
|
| 350 |
+
valid(<<"LGPL-2.1-only">>) -> true;
|
| 351 |
+
valid(<<"LGPL-2.1-or-later">>) -> true;
|
| 352 |
+
valid(<<"LGPL-3.0">>) -> true;
|
| 353 |
+
valid(<<"LGPL-3.0+">>) -> true;
|
| 354 |
+
valid(<<"LGPL-3.0-only">>) -> true;
|
| 355 |
+
valid(<<"LGPL-3.0-or-later">>) -> true;
|
| 356 |
+
valid(<<"LGPLLR">>) -> true;
|
| 357 |
+
valid(<<"LOOP">>) -> true;
|
| 358 |
+
valid(<<"LPD-document">>) -> true;
|
| 359 |
+
valid(<<"LPL-1.0">>) -> true;
|
| 360 |
+
valid(<<"LPL-1.02">>) -> true;
|
| 361 |
+
valid(<<"LPPL-1.0">>) -> true;
|
| 362 |
+
valid(<<"LPPL-1.1">>) -> true;
|
| 363 |
+
valid(<<"LPPL-1.2">>) -> true;
|
| 364 |
+
valid(<<"LPPL-1.3a">>) -> true;
|
| 365 |
+
valid(<<"LPPL-1.3c">>) -> true;
|
| 366 |
+
valid(<<"LZMA-SDK-9.11-to-9.20">>) -> true;
|
| 367 |
+
valid(<<"LZMA-SDK-9.22">>) -> true;
|
| 368 |
+
valid(<<"Latex2e">>) -> true;
|
| 369 |
+
valid(<<"Latex2e-translated-notice">>) -> true;
|
| 370 |
+
valid(<<"Leptonica">>) -> true;
|
| 371 |
+
valid(<<"LiLiQ-P-1.1">>) -> true;
|
| 372 |
+
valid(<<"LiLiQ-R-1.1">>) -> true;
|
| 373 |
+
valid(<<"LiLiQ-Rplus-1.1">>) -> true;
|
| 374 |
+
valid(<<"Libpng">>) -> true;
|
| 375 |
+
valid(<<"Linux-OpenIB">>) -> true;
|
| 376 |
+
valid(<<"Linux-man-pages-1-para">>) -> true;
|
| 377 |
+
valid(<<"Linux-man-pages-copyleft">>) -> true;
|
| 378 |
+
valid(<<"Linux-man-pages-copyleft-2-para">>) -> true;
|
| 379 |
+
valid(<<"Linux-man-pages-copyleft-var">>) -> true;
|
| 380 |
+
valid(<<"Lucida-Bitmap-Fonts">>) -> true;
|
| 381 |
+
valid(<<"MIT">>) -> true;
|
| 382 |
+
valid(<<"MIT-0">>) -> true;
|
| 383 |
+
valid(<<"MIT-CMU">>) -> true;
|
| 384 |
+
valid(<<"MIT-Festival">>) -> true;
|
| 385 |
+
valid(<<"MIT-Khronos-old">>) -> true;
|
| 386 |
+
valid(<<"MIT-Modern-Variant">>) -> true;
|
| 387 |
+
valid(<<"MIT-Wu">>) -> true;
|
| 388 |
+
valid(<<"MIT-advertising">>) -> true;
|
| 389 |
+
valid(<<"MIT-enna">>) -> true;
|
| 390 |
+
valid(<<"MIT-feh">>) -> true;
|
| 391 |
+
valid(<<"MIT-open-group">>) -> true;
|
| 392 |
+
valid(<<"MIT-testregex">>) -> true;
|
| 393 |
+
valid(<<"MITNFA">>) -> true;
|
| 394 |
+
valid(<<"MMIXware">>) -> true;
|
| 395 |
+
valid(<<"MPEG-SSG">>) -> true;
|
| 396 |
+
valid(<<"MPL-1.0">>) -> true;
|
| 397 |
+
valid(<<"MPL-1.1">>) -> true;
|
| 398 |
+
valid(<<"MPL-2.0">>) -> true;
|
| 399 |
+
valid(<<"MPL-2.0-no-copyleft-exception">>) -> true;
|
| 400 |
+
valid(<<"MS-LPL">>) -> true;
|
| 401 |
+
valid(<<"MS-PL">>) -> true;
|
| 402 |
+
valid(<<"MS-RL">>) -> true;
|
| 403 |
+
valid(<<"MTLL">>) -> true;
|
| 404 |
+
valid(<<"Mackerras-3-Clause">>) -> true;
|
| 405 |
+
valid(<<"Mackerras-3-Clause-acknowledgment">>) -> true;
|
| 406 |
+
valid(<<"MakeIndex">>) -> true;
|
| 407 |
+
valid(<<"Martin-Birgmeier">>) -> true;
|
| 408 |
+
valid(<<"McPhee-slideshow">>) -> true;
|
| 409 |
+
valid(<<"Minpack">>) -> true;
|
| 410 |
+
valid(<<"MirOS">>) -> true;
|
| 411 |
+
valid(<<"Motosoto">>) -> true;
|
| 412 |
+
valid(<<"MulanPSL-1.0">>) -> true;
|
| 413 |
+
valid(<<"MulanPSL-2.0">>) -> true;
|
| 414 |
+
valid(<<"Multics">>) -> true;
|
| 415 |
+
valid(<<"Mup">>) -> true;
|
| 416 |
+
valid(<<"NAIST-2003">>) -> true;
|
| 417 |
+
valid(<<"NASA-1.3">>) -> true;
|
| 418 |
+
valid(<<"NBPL-1.0">>) -> true;
|
| 419 |
+
valid(<<"NCBI-PD">>) -> true;
|
| 420 |
+
valid(<<"NCGL-UK-2.0">>) -> true;
|
| 421 |
+
valid(<<"NCL">>) -> true;
|
| 422 |
+
valid(<<"NCSA">>) -> true;
|
| 423 |
+
valid(<<"NGPL">>) -> true;
|
| 424 |
+
valid(<<"NICTA-1.0">>) -> true;
|
| 425 |
+
valid(<<"NIST-PD">>) -> true;
|
| 426 |
+
valid(<<"NIST-PD-fallback">>) -> true;
|
| 427 |
+
valid(<<"NIST-Software">>) -> true;
|
| 428 |
+
valid(<<"NLOD-1.0">>) -> true;
|
| 429 |
+
valid(<<"NLOD-2.0">>) -> true;
|
| 430 |
+
valid(<<"NLPL">>) -> true;
|
| 431 |
+
valid(<<"NOSL">>) -> true;
|
| 432 |
+
valid(<<"NPL-1.0">>) -> true;
|
| 433 |
+
valid(<<"NPL-1.1">>) -> true;
|
| 434 |
+
valid(<<"NPOSL-3.0">>) -> true;
|
| 435 |
+
valid(<<"NRL">>) -> true;
|
| 436 |
+
valid(<<"NTP">>) -> true;
|
| 437 |
+
valid(<<"NTP-0">>) -> true;
|
| 438 |
+
valid(<<"Naumen">>) -> true;
|
| 439 |
+
valid(<<"Net-SNMP">>) -> true;
|
| 440 |
+
valid(<<"NetCDF">>) -> true;
|
| 441 |
+
valid(<<"Newsletr">>) -> true;
|
| 442 |
+
valid(<<"Nokia">>) -> true;
|
| 443 |
+
valid(<<"Noweb">>) -> true;
|
| 444 |
+
valid(<<"Nunit">>) -> true;
|
| 445 |
+
valid(<<"O-UDA-1.0">>) -> true;
|
| 446 |
+
valid(<<"OAR">>) -> true;
|
| 447 |
+
valid(<<"OCCT-PL">>) -> true;
|
| 448 |
+
valid(<<"OCLC-2.0">>) -> true;
|
| 449 |
+
valid(<<"ODC-By-1.0">>) -> true;
|
| 450 |
+
valid(<<"ODbL-1.0">>) -> true;
|
| 451 |
+
valid(<<"OFFIS">>) -> true;
|
| 452 |
+
valid(<<"OFL-1.0">>) -> true;
|
| 453 |
+
valid(<<"OFL-1.0-RFN">>) -> true;
|
| 454 |
+
valid(<<"OFL-1.0-no-RFN">>) -> true;
|
| 455 |
+
valid(<<"OFL-1.1">>) -> true;
|
| 456 |
+
valid(<<"OFL-1.1-RFN">>) -> true;
|
| 457 |
+
valid(<<"OFL-1.1-no-RFN">>) -> true;
|
| 458 |
+
valid(<<"OGC-1.0">>) -> true;
|
| 459 |
+
valid(<<"OGDL-Taiwan-1.0">>) -> true;
|
| 460 |
+
valid(<<"OGL-Canada-2.0">>) -> true;
|
| 461 |
+
valid(<<"OGL-UK-1.0">>) -> true;
|
| 462 |
+
valid(<<"OGL-UK-2.0">>) -> true;
|
| 463 |
+
valid(<<"OGL-UK-3.0">>) -> true;
|
| 464 |
+
valid(<<"OGTSL">>) -> true;
|
| 465 |
+
valid(<<"OLDAP-1.1">>) -> true;
|
| 466 |
+
valid(<<"OLDAP-1.2">>) -> true;
|
| 467 |
+
valid(<<"OLDAP-1.3">>) -> true;
|
| 468 |
+
valid(<<"OLDAP-1.4">>) -> true;
|
| 469 |
+
valid(<<"OLDAP-2.0">>) -> true;
|
| 470 |
+
valid(<<"OLDAP-2.0.1">>) -> true;
|
| 471 |
+
valid(<<"OLDAP-2.1">>) -> true;
|
| 472 |
+
valid(<<"OLDAP-2.2">>) -> true;
|
| 473 |
+
valid(<<"OLDAP-2.2.1">>) -> true;
|
| 474 |
+
valid(<<"OLDAP-2.2.2">>) -> true;
|
| 475 |
+
valid(<<"OLDAP-2.3">>) -> true;
|
| 476 |
+
valid(<<"OLDAP-2.4">>) -> true;
|
| 477 |
+
valid(<<"OLDAP-2.5">>) -> true;
|
| 478 |
+
valid(<<"OLDAP-2.6">>) -> true;
|
| 479 |
+
valid(<<"OLDAP-2.7">>) -> true;
|
| 480 |
+
valid(<<"OLDAP-2.8">>) -> true;
|
| 481 |
+
valid(<<"OLFL-1.3">>) -> true;
|
| 482 |
+
valid(<<"OML">>) -> true;
|
| 483 |
+
valid(<<"OPL-1.0">>) -> true;
|
| 484 |
+
valid(<<"OPL-UK-3.0">>) -> true;
|
| 485 |
+
valid(<<"OPUBL-1.0">>) -> true;
|
| 486 |
+
valid(<<"OSET-PL-2.1">>) -> true;
|
| 487 |
+
valid(<<"OSL-1.0">>) -> true;
|
| 488 |
+
valid(<<"OSL-1.1">>) -> true;
|
| 489 |
+
valid(<<"OSL-2.0">>) -> true;
|
| 490 |
+
valid(<<"OSL-2.1">>) -> true;
|
| 491 |
+
valid(<<"OSL-3.0">>) -> true;
|
| 492 |
+
valid(<<"OpenPBS-2.3">>) -> true;
|
| 493 |
+
valid(<<"OpenSSL">>) -> true;
|
| 494 |
+
valid(<<"OpenSSL-standalone">>) -> true;
|
| 495 |
+
valid(<<"OpenVision">>) -> true;
|
| 496 |
+
valid(<<"PADL">>) -> true;
|
| 497 |
+
valid(<<"PDDL-1.0">>) -> true;
|
| 498 |
+
valid(<<"PHP-3.0">>) -> true;
|
| 499 |
+
valid(<<"PHP-3.01">>) -> true;
|
| 500 |
+
valid(<<"PPL">>) -> true;
|
| 501 |
+
valid(<<"PSF-2.0">>) -> true;
|
| 502 |
+
valid(<<"Parity-6.0.0">>) -> true;
|
| 503 |
+
valid(<<"Parity-7.0.0">>) -> true;
|
| 504 |
+
valid(<<"Pixar">>) -> true;
|
| 505 |
+
valid(<<"Plexus">>) -> true;
|
| 506 |
+
valid(<<"PolyForm-Noncommercial-1.0.0">>) -> true;
|
| 507 |
+
valid(<<"PolyForm-Small-Business-1.0.0">>) -> true;
|
| 508 |
+
valid(<<"PostgreSQL">>) -> true;
|
| 509 |
+
valid(<<"Python-2.0">>) -> true;
|
| 510 |
+
valid(<<"Python-2.0.1">>) -> true;
|
| 511 |
+
valid(<<"QPL-1.0">>) -> true;
|
| 512 |
+
valid(<<"QPL-1.0-INRIA-2004">>) -> true;
|
| 513 |
+
valid(<<"Qhull">>) -> true;
|
| 514 |
+
valid(<<"RHeCos-1.1">>) -> true;
|
| 515 |
+
valid(<<"RPL-1.1">>) -> true;
|
| 516 |
+
valid(<<"RPL-1.5">>) -> true;
|
| 517 |
+
valid(<<"RPSL-1.0">>) -> true;
|
| 518 |
+
valid(<<"RSA-MD">>) -> true;
|
| 519 |
+
valid(<<"RSCPL">>) -> true;
|
| 520 |
+
valid(<<"Rdisc">>) -> true;
|
| 521 |
+
valid(<<"Ruby">>) -> true;
|
| 522 |
+
valid(<<"SAX-PD">>) -> true;
|
| 523 |
+
valid(<<"SAX-PD-2.0">>) -> true;
|
| 524 |
+
valid(<<"SCEA">>) -> true;
|
| 525 |
+
valid(<<"SGI-B-1.0">>) -> true;
|
| 526 |
+
valid(<<"SGI-B-1.1">>) -> true;
|
| 527 |
+
valid(<<"SGI-B-2.0">>) -> true;
|
| 528 |
+
valid(<<"SGI-OpenGL">>) -> true;
|
| 529 |
+
valid(<<"SGP4">>) -> true;
|
| 530 |
+
valid(<<"SHL-0.5">>) -> true;
|
| 531 |
+
valid(<<"SHL-0.51">>) -> true;
|
| 532 |
+
valid(<<"SISSL">>) -> true;
|
| 533 |
+
valid(<<"SISSL-1.2">>) -> true;
|
| 534 |
+
valid(<<"SL">>) -> true;
|
| 535 |
+
valid(<<"SMLNJ">>) -> true;
|
| 536 |
+
valid(<<"SMPPL">>) -> true;
|
| 537 |
+
valid(<<"SNIA">>) -> true;
|
| 538 |
+
valid(<<"SPL-1.0">>) -> true;
|
| 539 |
+
valid(<<"SSH-OpenSSH">>) -> true;
|
| 540 |
+
valid(<<"SSH-short">>) -> true;
|
| 541 |
+
valid(<<"SSLeay-standalone">>) -> true;
|
| 542 |
+
valid(<<"SSPL-1.0">>) -> true;
|
| 543 |
+
valid(<<"SWL">>) -> true;
|
| 544 |
+
valid(<<"Saxpath">>) -> true;
|
| 545 |
+
valid(<<"SchemeReport">>) -> true;
|
| 546 |
+
valid(<<"Sendmail">>) -> true;
|
| 547 |
+
valid(<<"Sendmail-8.23">>) -> true;
|
| 548 |
+
valid(<<"SimPL-2.0">>) -> true;
|
| 549 |
+
valid(<<"Sleepycat">>) -> true;
|
| 550 |
+
valid(<<"Soundex">>) -> true;
|
| 551 |
+
valid(<<"Spencer-86">>) -> true;
|
| 552 |
+
valid(<<"Spencer-94">>) -> true;
|
| 553 |
+
valid(<<"Spencer-99">>) -> true;
|
| 554 |
+
valid(<<"StandardML-NJ">>) -> true;
|
| 555 |
+
valid(<<"SugarCRM-1.1.3">>) -> true;
|
| 556 |
+
valid(<<"Sun-PPP">>) -> true;
|
| 557 |
+
valid(<<"Sun-PPP-2000">>) -> true;
|
| 558 |
+
valid(<<"SunPro">>) -> true;
|
| 559 |
+
valid(<<"Symlinks">>) -> true;
|
| 560 |
+
valid(<<"TAPR-OHL-1.0">>) -> true;
|
| 561 |
+
valid(<<"TCL">>) -> true;
|
| 562 |
+
valid(<<"TCP-wrappers">>) -> true;
|
| 563 |
+
valid(<<"TGPPL-1.0">>) -> true;
|
| 564 |
+
valid(<<"TMate">>) -> true;
|
| 565 |
+
valid(<<"TORQUE-1.1">>) -> true;
|
| 566 |
+
valid(<<"TOSL">>) -> true;
|
| 567 |
+
valid(<<"TPDL">>) -> true;
|
| 568 |
+
valid(<<"TPL-1.0">>) -> true;
|
| 569 |
+
valid(<<"TTWL">>) -> true;
|
| 570 |
+
valid(<<"TTYP0">>) -> true;
|
| 571 |
+
valid(<<"TU-Berlin-1.0">>) -> true;
|
| 572 |
+
valid(<<"TU-Berlin-2.0">>) -> true;
|
| 573 |
+
valid(<<"TermReadKey">>) -> true;
|
| 574 |
+
valid(<<"UCAR">>) -> true;
|
| 575 |
+
valid(<<"UCL-1.0">>) -> true;
|
| 576 |
+
valid(<<"UMich-Merit">>) -> true;
|
| 577 |
+
valid(<<"UPL-1.0">>) -> true;
|
| 578 |
+
valid(<<"URT-RLE">>) -> true;
|
| 579 |
+
valid(<<"Unicode-3.0">>) -> true;
|
| 580 |
+
valid(<<"Unicode-DFS-2015">>) -> true;
|
| 581 |
+
valid(<<"Unicode-DFS-2016">>) -> true;
|
| 582 |
+
valid(<<"Unicode-TOU">>) -> true;
|
| 583 |
+
valid(<<"UnixCrypt">>) -> true;
|
| 584 |
+
valid(<<"Unlicense">>) -> true;
|
| 585 |
+
valid(<<"VOSTROM">>) -> true;
|
| 586 |
+
valid(<<"VSL-1.0">>) -> true;
|
| 587 |
+
valid(<<"Vim">>) -> true;
|
| 588 |
+
valid(<<"W3C">>) -> true;
|
| 589 |
+
valid(<<"W3C-19980720">>) -> true;
|
| 590 |
+
valid(<<"W3C-20150513">>) -> true;
|
| 591 |
+
valid(<<"WTFPL">>) -> true;
|
| 592 |
+
valid(<<"Watcom-1.0">>) -> true;
|
| 593 |
+
valid(<<"Widget-Workshop">>) -> true;
|
| 594 |
+
valid(<<"Wsuipa">>) -> true;
|
| 595 |
+
valid(<<"X11">>) -> true;
|
| 596 |
+
valid(<<"X11-distribute-modifications-variant">>) -> true;
|
| 597 |
+
valid(<<"XFree86-1.1">>) -> true;
|
| 598 |
+
valid(<<"XSkat">>) -> true;
|
| 599 |
+
valid(<<"Xdebug-1.03">>) -> true;
|
| 600 |
+
valid(<<"Xerox">>) -> true;
|
| 601 |
+
valid(<<"Xfig">>) -> true;
|
| 602 |
+
valid(<<"Xnet">>) -> true;
|
| 603 |
+
valid(<<"YPL-1.0">>) -> true;
|
| 604 |
+
valid(<<"YPL-1.1">>) -> true;
|
| 605 |
+
valid(<<"ZPL-1.1">>) -> true;
|
| 606 |
+
valid(<<"ZPL-2.0">>) -> true;
|
| 607 |
+
valid(<<"ZPL-2.1">>) -> true;
|
| 608 |
+
valid(<<"Zed">>) -> true;
|
| 609 |
+
valid(<<"Zeeff">>) -> true;
|
| 610 |
+
valid(<<"Zend-2.0">>) -> true;
|
| 611 |
+
valid(<<"Zimbra-1.3">>) -> true;
|
| 612 |
+
valid(<<"Zimbra-1.4">>) -> true;
|
| 613 |
+
valid(<<"Zlib">>) -> true;
|
| 614 |
+
valid(<<"any-OSI">>) -> true;
|
| 615 |
+
valid(<<"bcrypt-Solar-Designer">>) -> true;
|
| 616 |
+
valid(<<"blessing">>) -> true;
|
| 617 |
+
valid(<<"bzip2-1.0.5">>) -> true;
|
| 618 |
+
valid(<<"bzip2-1.0.6">>) -> true;
|
| 619 |
+
valid(<<"check-cvs">>) -> true;
|
| 620 |
+
valid(<<"checkmk">>) -> true;
|
| 621 |
+
valid(<<"copyleft-next-0.3.0">>) -> true;
|
| 622 |
+
valid(<<"copyleft-next-0.3.1">>) -> true;
|
| 623 |
+
valid(<<"curl">>) -> true;
|
| 624 |
+
valid(<<"cve-tou">>) -> true;
|
| 625 |
+
valid(<<"diffmark">>) -> true;
|
| 626 |
+
valid(<<"dtoa">>) -> true;
|
| 627 |
+
valid(<<"dvipdfm">>) -> true;
|
| 628 |
+
valid(<<"eCos-2.0">>) -> true;
|
| 629 |
+
valid(<<"eGenix">>) -> true;
|
| 630 |
+
valid(<<"etalab-2.0">>) -> true;
|
| 631 |
+
valid(<<"fwlw">>) -> true;
|
| 632 |
+
valid(<<"gSOAP-1.3b">>) -> true;
|
| 633 |
+
valid(<<"gnuplot">>) -> true;
|
| 634 |
+
valid(<<"gtkbook">>) -> true;
|
| 635 |
+
valid(<<"hdparm">>) -> true;
|
| 636 |
+
valid(<<"iMatix">>) -> true;
|
| 637 |
+
valid(<<"libpng-2.0">>) -> true;
|
| 638 |
+
valid(<<"libselinux-1.0">>) -> true;
|
| 639 |
+
valid(<<"libtiff">>) -> true;
|
| 640 |
+
valid(<<"libutil-David-Nugent">>) -> true;
|
| 641 |
+
valid(<<"lsof">>) -> true;
|
| 642 |
+
valid(<<"magaz">>) -> true;
|
| 643 |
+
valid(<<"mailprio">>) -> true;
|
| 644 |
+
valid(<<"metamail">>) -> true;
|
| 645 |
+
valid(<<"mpi-permissive">>) -> true;
|
| 646 |
+
valid(<<"mpich2">>) -> true;
|
| 647 |
+
valid(<<"mplus">>) -> true;
|
| 648 |
+
valid(<<"pkgconf">>) -> true;
|
| 649 |
+
valid(<<"pnmstitch">>) -> true;
|
| 650 |
+
valid(<<"psfrag">>) -> true;
|
| 651 |
+
valid(<<"psutils">>) -> true;
|
| 652 |
+
valid(<<"python-ldap">>) -> true;
|
| 653 |
+
valid(<<"radvd">>) -> true;
|
| 654 |
+
valid(<<"snprintf">>) -> true;
|
| 655 |
+
valid(<<"softSurfer">>) -> true;
|
| 656 |
+
valid(<<"ssh-keyscan">>) -> true;
|
| 657 |
+
valid(<<"swrule">>) -> true;
|
| 658 |
+
valid(<<"threeparttable">>) -> true;
|
| 659 |
+
valid(<<"ulem">>) -> true;
|
| 660 |
+
valid(<<"w3m">>) -> true;
|
| 661 |
+
valid(<<"wxWindows">>) -> true;
|
| 662 |
+
valid(<<"xinetd">>) -> true;
|
| 663 |
+
valid(<<"xkeyboard-config-Zinoviev">>) -> true;
|
| 664 |
+
valid(<<"xlock">>) -> true;
|
| 665 |
+
valid(<<"xpp">>) -> true;
|
| 666 |
+
valid(<<"xzoom">>) -> true;
|
| 667 |
+
valid(<<"zlib-acknowledgement">>) -> true;
|
| 668 |
+
valid(_) -> false.
|
deps/eini/_build/default/plugins/hex_core/src/hex_pb_package.erl
ADDED
|
@@ -0,0 +1,1227 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%% -*- coding: utf-8 -*-
|
| 2 |
+
%% % this file is @generated
|
| 3 |
+
%% @private
|
| 4 |
+
%% Automatically generated, do not edit
|
| 5 |
+
%% Generated by gpb_compile version 4.21.1
|
| 6 |
+
%% Version source: file
|
| 7 |
+
-module(hex_pb_package).
|
| 8 |
+
|
| 9 |
+
-export([encode_msg/2, encode_msg/3]).
|
| 10 |
+
-export([decode_msg/2, decode_msg/3]).
|
| 11 |
+
-export([merge_msgs/3, merge_msgs/4]).
|
| 12 |
+
-export([verify_msg/2, verify_msg/3]).
|
| 13 |
+
-export([get_msg_defs/0]).
|
| 14 |
+
-export([get_msg_names/0]).
|
| 15 |
+
-export([get_group_names/0]).
|
| 16 |
+
-export([get_msg_or_group_names/0]).
|
| 17 |
+
-export([get_enum_names/0]).
|
| 18 |
+
-export([find_msg_def/1, fetch_msg_def/1]).
|
| 19 |
+
-export([find_enum_def/1, fetch_enum_def/1]).
|
| 20 |
+
-export([enum_symbol_by_value/2, enum_value_by_symbol/2]).
|
| 21 |
+
-export([enum_symbol_by_value_RetirementReason/1, enum_value_by_symbol_RetirementReason/1]).
|
| 22 |
+
-export([get_service_names/0]).
|
| 23 |
+
-export([get_service_def/1]).
|
| 24 |
+
-export([get_rpc_names/1]).
|
| 25 |
+
-export([find_rpc_def/2, fetch_rpc_def/2]).
|
| 26 |
+
-export([fqbin_to_service_name/1]).
|
| 27 |
+
-export([service_name_to_fqbin/1]).
|
| 28 |
+
-export([fqbins_to_service_and_rpc_name/2]).
|
| 29 |
+
-export([service_and_rpc_name_to_fqbins/2]).
|
| 30 |
+
-export([fqbin_to_msg_name/1]).
|
| 31 |
+
-export([msg_name_to_fqbin/1]).
|
| 32 |
+
-export([fqbin_to_enum_name/1]).
|
| 33 |
+
-export([enum_name_to_fqbin/1]).
|
| 34 |
+
-export([get_package_name/0]).
|
| 35 |
+
-export([uses_packages/0]).
|
| 36 |
+
-export([source_basename/0]).
|
| 37 |
+
-export([get_all_source_basenames/0]).
|
| 38 |
+
-export([get_all_proto_names/0]).
|
| 39 |
+
-export([get_msg_containment/1]).
|
| 40 |
+
-export([get_pkg_containment/1]).
|
| 41 |
+
-export([get_service_containment/1]).
|
| 42 |
+
-export([get_rpc_containment/1]).
|
| 43 |
+
-export([get_enum_containment/1]).
|
| 44 |
+
-export([get_proto_by_msg_name_as_fqbin/1]).
|
| 45 |
+
-export([get_proto_by_service_name_as_fqbin/1]).
|
| 46 |
+
-export([get_proto_by_enum_name_as_fqbin/1]).
|
| 47 |
+
-export([get_protos_by_pkg_name_as_fqbin/1]).
|
| 48 |
+
-export([gpb_version_as_string/0, gpb_version_as_list/0]).
|
| 49 |
+
-export([gpb_version_source/0]).
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
%% enumerated types
|
| 53 |
+
-type 'RetirementReason'() :: 'RETIRED_OTHER' | 'RETIRED_INVALID' | 'RETIRED_SECURITY' | 'RETIRED_DEPRECATED' | 'RETIRED_RENAMED'.
|
| 54 |
+
-export_type(['RetirementReason'/0]).
|
| 55 |
+
|
| 56 |
+
%% message types
|
| 57 |
+
-type 'Package'() ::
|
| 58 |
+
#{releases => ['Release'()], % = 1, repeated
|
| 59 |
+
name => unicode:chardata(), % = 2, required
|
| 60 |
+
repository => unicode:chardata() % = 3, required
|
| 61 |
+
}.
|
| 62 |
+
|
| 63 |
+
-type 'Release'() ::
|
| 64 |
+
#{version => unicode:chardata(), % = 1, required
|
| 65 |
+
inner_checksum => iodata(), % = 2, required
|
| 66 |
+
dependencies => ['Dependency'()], % = 3, repeated
|
| 67 |
+
retired => 'RetirementStatus'(), % = 4, optional
|
| 68 |
+
outer_checksum => iodata() % = 5, optional
|
| 69 |
+
}.
|
| 70 |
+
|
| 71 |
+
-type 'RetirementStatus'() ::
|
| 72 |
+
#{reason => 'RETIRED_OTHER' | 'RETIRED_INVALID' | 'RETIRED_SECURITY' | 'RETIRED_DEPRECATED' | 'RETIRED_RENAMED' | integer(), % = 1, required, enum RetirementReason
|
| 73 |
+
message => unicode:chardata() % = 2, optional
|
| 74 |
+
}.
|
| 75 |
+
|
| 76 |
+
-type 'Dependency'() ::
|
| 77 |
+
#{package => unicode:chardata(), % = 1, required
|
| 78 |
+
requirement => unicode:chardata(), % = 2, required
|
| 79 |
+
optional => boolean() | 0 | 1, % = 3, optional
|
| 80 |
+
app => unicode:chardata(), % = 4, optional
|
| 81 |
+
repository => unicode:chardata() % = 5, optional
|
| 82 |
+
}.
|
| 83 |
+
|
| 84 |
+
-export_type(['Package'/0, 'Release'/0, 'RetirementStatus'/0, 'Dependency'/0]).
|
| 85 |
+
-type '$msg_name'() :: 'Package' | 'Release' | 'RetirementStatus' | 'Dependency'.
|
| 86 |
+
-type '$msg'() :: 'Package'() | 'Release'() | 'RetirementStatus'() | 'Dependency'().
|
| 87 |
+
-export_type(['$msg_name'/0, '$msg'/0]).
|
| 88 |
+
|
| 89 |
+
-if(?OTP_RELEASE >= 24).
|
| 90 |
+
-dialyzer({no_underspecs, encode_msg/2}).
|
| 91 |
+
-endif.
|
| 92 |
+
-spec encode_msg('$msg'(), '$msg_name'()) -> binary().
|
| 93 |
+
encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []).
|
| 94 |
+
|
| 95 |
+
-if(?OTP_RELEASE >= 24).
|
| 96 |
+
-dialyzer({no_underspecs, encode_msg/3}).
|
| 97 |
+
-endif.
|
| 98 |
+
-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary().
|
| 99 |
+
encode_msg(Msg, MsgName, Opts) ->
|
| 100 |
+
verify_msg(Msg, MsgName, Opts),
|
| 101 |
+
TrUserData = proplists:get_value(user_data, Opts),
|
| 102 |
+
case MsgName of
|
| 103 |
+
'Package' -> encode_msg_Package(id(Msg, TrUserData), TrUserData);
|
| 104 |
+
'Release' -> encode_msg_Release(id(Msg, TrUserData), TrUserData);
|
| 105 |
+
'RetirementStatus' -> encode_msg_RetirementStatus(id(Msg, TrUserData), TrUserData);
|
| 106 |
+
'Dependency' -> encode_msg_Dependency(id(Msg, TrUserData), TrUserData)
|
| 107 |
+
end.
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
encode_msg_Package(Msg, TrUserData) -> encode_msg_Package(Msg, <<>>, TrUserData).
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
encode_msg_Package(#{name := F2, repository := F3} = M, Bin, TrUserData) ->
|
| 114 |
+
B1 = case M of
|
| 115 |
+
#{releases := F1} ->
|
| 116 |
+
TrF1 = id(F1, TrUserData),
|
| 117 |
+
if TrF1 == [] -> Bin;
|
| 118 |
+
true -> e_field_Package_releases(TrF1, Bin, TrUserData)
|
| 119 |
+
end;
|
| 120 |
+
_ -> Bin
|
| 121 |
+
end,
|
| 122 |
+
B2 = begin TrF2 = id(F2, TrUserData), e_type_string(TrF2, <<B1/binary, 18>>, TrUserData) end,
|
| 123 |
+
begin TrF3 = id(F3, TrUserData), e_type_string(TrF3, <<B2/binary, 26>>, TrUserData) end.
|
| 124 |
+
|
| 125 |
+
encode_msg_Release(Msg, TrUserData) -> encode_msg_Release(Msg, <<>>, TrUserData).
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
encode_msg_Release(#{version := F1, inner_checksum := F2} = M, Bin, TrUserData) ->
|
| 129 |
+
B1 = begin TrF1 = id(F1, TrUserData), e_type_string(TrF1, <<Bin/binary, 10>>, TrUserData) end,
|
| 130 |
+
B2 = begin TrF2 = id(F2, TrUserData), e_type_bytes(TrF2, <<B1/binary, 18>>, TrUserData) end,
|
| 131 |
+
B3 = case M of
|
| 132 |
+
#{dependencies := F3} ->
|
| 133 |
+
TrF3 = id(F3, TrUserData),
|
| 134 |
+
if TrF3 == [] -> B2;
|
| 135 |
+
true -> e_field_Release_dependencies(TrF3, B2, TrUserData)
|
| 136 |
+
end;
|
| 137 |
+
_ -> B2
|
| 138 |
+
end,
|
| 139 |
+
B4 = case M of
|
| 140 |
+
#{retired := F4} -> begin TrF4 = id(F4, TrUserData), e_mfield_Release_retired(TrF4, <<B3/binary, 34>>, TrUserData) end;
|
| 141 |
+
_ -> B3
|
| 142 |
+
end,
|
| 143 |
+
case M of
|
| 144 |
+
#{outer_checksum := F5} -> begin TrF5 = id(F5, TrUserData), e_type_bytes(TrF5, <<B4/binary, 42>>, TrUserData) end;
|
| 145 |
+
_ -> B4
|
| 146 |
+
end.
|
| 147 |
+
|
| 148 |
+
encode_msg_RetirementStatus(Msg, TrUserData) -> encode_msg_RetirementStatus(Msg, <<>>, TrUserData).
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
encode_msg_RetirementStatus(#{reason := F1} = M, Bin, TrUserData) ->
|
| 152 |
+
B1 = begin TrF1 = id(F1, TrUserData), e_enum_RetirementReason(TrF1, <<Bin/binary, 8>>, TrUserData) end,
|
| 153 |
+
case M of
|
| 154 |
+
#{message := F2} -> begin TrF2 = id(F2, TrUserData), e_type_string(TrF2, <<B1/binary, 18>>, TrUserData) end;
|
| 155 |
+
_ -> B1
|
| 156 |
+
end.
|
| 157 |
+
|
| 158 |
+
encode_msg_Dependency(Msg, TrUserData) -> encode_msg_Dependency(Msg, <<>>, TrUserData).
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
encode_msg_Dependency(#{package := F1, requirement := F2} = M, Bin, TrUserData) ->
|
| 162 |
+
B1 = begin TrF1 = id(F1, TrUserData), e_type_string(TrF1, <<Bin/binary, 10>>, TrUserData) end,
|
| 163 |
+
B2 = begin TrF2 = id(F2, TrUserData), e_type_string(TrF2, <<B1/binary, 18>>, TrUserData) end,
|
| 164 |
+
B3 = case M of
|
| 165 |
+
#{optional := F3} -> begin TrF3 = id(F3, TrUserData), e_type_bool(TrF3, <<B2/binary, 24>>, TrUserData) end;
|
| 166 |
+
_ -> B2
|
| 167 |
+
end,
|
| 168 |
+
B4 = case M of
|
| 169 |
+
#{app := F4} -> begin TrF4 = id(F4, TrUserData), e_type_string(TrF4, <<B3/binary, 34>>, TrUserData) end;
|
| 170 |
+
_ -> B3
|
| 171 |
+
end,
|
| 172 |
+
case M of
|
| 173 |
+
#{repository := F5} -> begin TrF5 = id(F5, TrUserData), e_type_string(TrF5, <<B4/binary, 42>>, TrUserData) end;
|
| 174 |
+
_ -> B4
|
| 175 |
+
end.
|
| 176 |
+
|
| 177 |
+
e_mfield_Package_releases(Msg, Bin, TrUserData) ->
|
| 178 |
+
SubBin = encode_msg_Release(Msg, <<>>, TrUserData),
|
| 179 |
+
Bin2 = e_varint(byte_size(SubBin), Bin),
|
| 180 |
+
<<Bin2/binary, SubBin/binary>>.
|
| 181 |
+
|
| 182 |
+
e_field_Package_releases([Elem | Rest], Bin, TrUserData) ->
|
| 183 |
+
Bin2 = <<Bin/binary, 10>>,
|
| 184 |
+
Bin3 = e_mfield_Package_releases(id(Elem, TrUserData), Bin2, TrUserData),
|
| 185 |
+
e_field_Package_releases(Rest, Bin3, TrUserData);
|
| 186 |
+
e_field_Package_releases([], Bin, _TrUserData) -> Bin.
|
| 187 |
+
|
| 188 |
+
e_mfield_Release_dependencies(Msg, Bin, TrUserData) ->
|
| 189 |
+
SubBin = encode_msg_Dependency(Msg, <<>>, TrUserData),
|
| 190 |
+
Bin2 = e_varint(byte_size(SubBin), Bin),
|
| 191 |
+
<<Bin2/binary, SubBin/binary>>.
|
| 192 |
+
|
| 193 |
+
e_field_Release_dependencies([Elem | Rest], Bin, TrUserData) ->
|
| 194 |
+
Bin2 = <<Bin/binary, 26>>,
|
| 195 |
+
Bin3 = e_mfield_Release_dependencies(id(Elem, TrUserData), Bin2, TrUserData),
|
| 196 |
+
e_field_Release_dependencies(Rest, Bin3, TrUserData);
|
| 197 |
+
e_field_Release_dependencies([], Bin, _TrUserData) -> Bin.
|
| 198 |
+
|
| 199 |
+
e_mfield_Release_retired(Msg, Bin, TrUserData) ->
|
| 200 |
+
SubBin = encode_msg_RetirementStatus(Msg, <<>>, TrUserData),
|
| 201 |
+
Bin2 = e_varint(byte_size(SubBin), Bin),
|
| 202 |
+
<<Bin2/binary, SubBin/binary>>.
|
| 203 |
+
|
| 204 |
+
e_enum_RetirementReason('RETIRED_OTHER', Bin, _TrUserData) -> <<Bin/binary, 0>>;
|
| 205 |
+
e_enum_RetirementReason('RETIRED_INVALID', Bin, _TrUserData) -> <<Bin/binary, 1>>;
|
| 206 |
+
e_enum_RetirementReason('RETIRED_SECURITY', Bin, _TrUserData) -> <<Bin/binary, 2>>;
|
| 207 |
+
e_enum_RetirementReason('RETIRED_DEPRECATED', Bin, _TrUserData) -> <<Bin/binary, 3>>;
|
| 208 |
+
e_enum_RetirementReason('RETIRED_RENAMED', Bin, _TrUserData) -> <<Bin/binary, 4>>;
|
| 209 |
+
e_enum_RetirementReason(V, Bin, _TrUserData) -> e_varint(V, Bin).
|
| 210 |
+
|
| 211 |
+
-compile({nowarn_unused_function,e_type_sint/3}).
|
| 212 |
+
e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin);
|
| 213 |
+
e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin).
|
| 214 |
+
|
| 215 |
+
-compile({nowarn_unused_function,e_type_int32/3}).
|
| 216 |
+
e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <<Bin/binary, Value>>;
|
| 217 |
+
e_type_int32(Value, Bin, _TrUserData) ->
|
| 218 |
+
<<N:64/unsigned-native>> = <<Value:64/signed-native>>,
|
| 219 |
+
e_varint(N, Bin).
|
| 220 |
+
|
| 221 |
+
-compile({nowarn_unused_function,e_type_int64/3}).
|
| 222 |
+
e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <<Bin/binary, Value>>;
|
| 223 |
+
e_type_int64(Value, Bin, _TrUserData) ->
|
| 224 |
+
<<N:64/unsigned-native>> = <<Value:64/signed-native>>,
|
| 225 |
+
e_varint(N, Bin).
|
| 226 |
+
|
| 227 |
+
-compile({nowarn_unused_function,e_type_bool/3}).
|
| 228 |
+
e_type_bool(true, Bin, _TrUserData) -> <<Bin/binary, 1>>;
|
| 229 |
+
e_type_bool(false, Bin, _TrUserData) -> <<Bin/binary, 0>>;
|
| 230 |
+
e_type_bool(1, Bin, _TrUserData) -> <<Bin/binary, 1>>;
|
| 231 |
+
e_type_bool(0, Bin, _TrUserData) -> <<Bin/binary, 0>>.
|
| 232 |
+
|
| 233 |
+
-compile({nowarn_unused_function,e_type_string/3}).
|
| 234 |
+
e_type_string(S, Bin, _TrUserData) ->
|
| 235 |
+
Utf8 = unicode:characters_to_binary(S),
|
| 236 |
+
Bin2 = e_varint(byte_size(Utf8), Bin),
|
| 237 |
+
<<Bin2/binary, Utf8/binary>>.
|
| 238 |
+
|
| 239 |
+
-compile({nowarn_unused_function,e_type_bytes/3}).
|
| 240 |
+
e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) ->
|
| 241 |
+
Bin2 = e_varint(byte_size(Bytes), Bin),
|
| 242 |
+
<<Bin2/binary, Bytes/binary>>;
|
| 243 |
+
e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) ->
|
| 244 |
+
BytesBin = iolist_to_binary(Bytes),
|
| 245 |
+
Bin2 = e_varint(byte_size(BytesBin), Bin),
|
| 246 |
+
<<Bin2/binary, BytesBin/binary>>.
|
| 247 |
+
|
| 248 |
+
-compile({nowarn_unused_function,e_type_fixed32/3}).
|
| 249 |
+
e_type_fixed32(Value, Bin, _TrUserData) -> <<Bin/binary, Value:32/little>>.
|
| 250 |
+
|
| 251 |
+
-compile({nowarn_unused_function,e_type_sfixed32/3}).
|
| 252 |
+
e_type_sfixed32(Value, Bin, _TrUserData) -> <<Bin/binary, Value:32/little-signed>>.
|
| 253 |
+
|
| 254 |
+
-compile({nowarn_unused_function,e_type_fixed64/3}).
|
| 255 |
+
e_type_fixed64(Value, Bin, _TrUserData) -> <<Bin/binary, Value:64/little>>.
|
| 256 |
+
|
| 257 |
+
-compile({nowarn_unused_function,e_type_sfixed64/3}).
|
| 258 |
+
e_type_sfixed64(Value, Bin, _TrUserData) -> <<Bin/binary, Value:64/little-signed>>.
|
| 259 |
+
|
| 260 |
+
-compile({nowarn_unused_function,e_type_float/3}).
|
| 261 |
+
e_type_float(V, Bin, _) when is_number(V) -> <<Bin/binary, V:32/little-float>>;
|
| 262 |
+
e_type_float(infinity, Bin, _) -> <<Bin/binary, 0:16, 128, 127>>;
|
| 263 |
+
e_type_float('-infinity', Bin, _) -> <<Bin/binary, 0:16, 128, 255>>;
|
| 264 |
+
e_type_float(nan, Bin, _) -> <<Bin/binary, 0:16, 192, 127>>.
|
| 265 |
+
|
| 266 |
+
-compile({nowarn_unused_function,e_type_double/3}).
|
| 267 |
+
e_type_double(V, Bin, _) when is_number(V) -> <<Bin/binary, V:64/little-float>>;
|
| 268 |
+
e_type_double(infinity, Bin, _) -> <<Bin/binary, 0:48, 240, 127>>;
|
| 269 |
+
e_type_double('-infinity', Bin, _) -> <<Bin/binary, 0:48, 240, 255>>;
|
| 270 |
+
e_type_double(nan, Bin, _) -> <<Bin/binary, 0:48, 248, 127>>.
|
| 271 |
+
|
| 272 |
+
-compile({nowarn_unused_function,e_unknown_elems/2}).
|
| 273 |
+
e_unknown_elems([Elem | Rest], Bin) ->
|
| 274 |
+
BinR = case Elem of
|
| 275 |
+
{varint, FNum, N} ->
|
| 276 |
+
BinF = e_varint(FNum bsl 3, Bin),
|
| 277 |
+
e_varint(N, BinF);
|
| 278 |
+
{length_delimited, FNum, Data} ->
|
| 279 |
+
BinF = e_varint(FNum bsl 3 bor 2, Bin),
|
| 280 |
+
BinL = e_varint(byte_size(Data), BinF),
|
| 281 |
+
<<BinL/binary, Data/binary>>;
|
| 282 |
+
{group, FNum, GroupFields} ->
|
| 283 |
+
Bin1 = e_varint(FNum bsl 3 bor 3, Bin),
|
| 284 |
+
Bin2 = e_unknown_elems(GroupFields, Bin1),
|
| 285 |
+
e_varint(FNum bsl 3 bor 4, Bin2);
|
| 286 |
+
{fixed32, FNum, V} ->
|
| 287 |
+
BinF = e_varint(FNum bsl 3 bor 5, Bin),
|
| 288 |
+
<<BinF/binary, V:32/little>>;
|
| 289 |
+
{fixed64, FNum, V} ->
|
| 290 |
+
BinF = e_varint(FNum bsl 3 bor 1, Bin),
|
| 291 |
+
<<BinF/binary, V:64/little>>
|
| 292 |
+
end,
|
| 293 |
+
e_unknown_elems(Rest, BinR);
|
| 294 |
+
e_unknown_elems([], Bin) -> Bin.
|
| 295 |
+
|
| 296 |
+
-compile({nowarn_unused_function,e_varint/3}).
|
| 297 |
+
e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin).
|
| 298 |
+
|
| 299 |
+
-compile({nowarn_unused_function,e_varint/2}).
|
| 300 |
+
e_varint(N, Bin) when N =< 127 -> <<Bin/binary, N>>;
|
| 301 |
+
e_varint(N, Bin) ->
|
| 302 |
+
Bin2 = <<Bin/binary, (N band 127 bor 128)>>,
|
| 303 |
+
e_varint(N bsr 7, Bin2).
|
| 304 |
+
|
| 305 |
+
|
| 306 |
+
decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []).
|
| 307 |
+
|
| 308 |
+
decode_msg(Bin, MsgName, Opts) when is_binary(Bin) ->
|
| 309 |
+
TrUserData = proplists:get_value(user_data, Opts),
|
| 310 |
+
decode_msg_1_catch(Bin, MsgName, TrUserData).
|
| 311 |
+
|
| 312 |
+
-ifdef('OTP_RELEASE').
|
| 313 |
+
decode_msg_1_catch(Bin, MsgName, TrUserData) ->
|
| 314 |
+
try decode_msg_2_doit(MsgName, Bin, TrUserData)
|
| 315 |
+
catch
|
| 316 |
+
error:{gpb_error,_}=Reason:StackTrace ->
|
| 317 |
+
erlang:raise(error, Reason, StackTrace);
|
| 318 |
+
Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}})
|
| 319 |
+
end.
|
| 320 |
+
-else.
|
| 321 |
+
decode_msg_1_catch(Bin, MsgName, TrUserData) ->
|
| 322 |
+
try decode_msg_2_doit(MsgName, Bin, TrUserData)
|
| 323 |
+
catch
|
| 324 |
+
error:{gpb_error,_}=Reason ->
|
| 325 |
+
erlang:raise(error, Reason,
|
| 326 |
+
erlang:get_stacktrace());
|
| 327 |
+
Class:Reason ->
|
| 328 |
+
StackTrace = erlang:get_stacktrace(),
|
| 329 |
+
error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}})
|
| 330 |
+
end.
|
| 331 |
+
-endif.
|
| 332 |
+
|
| 333 |
+
decode_msg_2_doit('Package', Bin, TrUserData) -> id(decode_msg_Package(Bin, TrUserData), TrUserData);
|
| 334 |
+
decode_msg_2_doit('Release', Bin, TrUserData) -> id(decode_msg_Release(Bin, TrUserData), TrUserData);
|
| 335 |
+
decode_msg_2_doit('RetirementStatus', Bin, TrUserData) -> id(decode_msg_RetirementStatus(Bin, TrUserData), TrUserData);
|
| 336 |
+
decode_msg_2_doit('Dependency', Bin, TrUserData) -> id(decode_msg_Dependency(Bin, TrUserData), TrUserData).
|
| 337 |
+
|
| 338 |
+
|
| 339 |
+
|
| 340 |
+
decode_msg_Package(Bin, TrUserData) -> dfp_read_field_def_Package(Bin, 0, 0, 0, id([], TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), TrUserData).
|
| 341 |
+
|
| 342 |
+
dfp_read_field_def_Package(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_Package_releases(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
|
| 343 |
+
dfp_read_field_def_Package(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_Package_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
|
| 344 |
+
dfp_read_field_def_Package(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_Package_repository(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
|
| 345 |
+
dfp_read_field_def_Package(<<>>, 0, 0, _, R1, F@_2, F@_3, TrUserData) ->
|
| 346 |
+
S1 = #{name => F@_2, repository => F@_3},
|
| 347 |
+
if R1 == '$undef' -> S1;
|
| 348 |
+
true -> S1#{releases => lists_reverse(R1, TrUserData)}
|
| 349 |
+
end;
|
| 350 |
+
dfp_read_field_def_Package(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_Package(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
|
| 351 |
+
|
| 352 |
+
dg_read_field_def_Package(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_Package(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
| 353 |
+
dg_read_field_def_Package(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) ->
|
| 354 |
+
Key = X bsl N + Acc,
|
| 355 |
+
case Key of
|
| 356 |
+
10 -> d_field_Package_releases(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
|
| 357 |
+
18 -> d_field_Package_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
|
| 358 |
+
26 -> d_field_Package_repository(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
|
| 359 |
+
_ ->
|
| 360 |
+
case Key band 7 of
|
| 361 |
+
0 -> skip_varint_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
|
| 362 |
+
1 -> skip_64_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
|
| 363 |
+
2 -> skip_length_delimited_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
|
| 364 |
+
3 -> skip_group_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
|
| 365 |
+
5 -> skip_32_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData)
|
| 366 |
+
end
|
| 367 |
+
end;
|
| 368 |
+
dg_read_field_def_Package(<<>>, 0, 0, _, R1, F@_2, F@_3, TrUserData) ->
|
| 369 |
+
S1 = #{name => F@_2, repository => F@_3},
|
| 370 |
+
if R1 == '$undef' -> S1;
|
| 371 |
+
true -> S1#{releases => lists_reverse(R1, TrUserData)}
|
| 372 |
+
end.
|
| 373 |
+
|
| 374 |
+
d_field_Package_releases(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_Package_releases(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
| 375 |
+
d_field_Package_releases(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, F@_3, TrUserData) ->
|
| 376 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bs:Len/binary, Rest2/binary>> = Rest, {id(decode_msg_Release(Bs, TrUserData), TrUserData), Rest2} end,
|
| 377 |
+
dfp_read_field_def_Package(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), F@_2, F@_3, TrUserData).
|
| 378 |
+
|
| 379 |
+
d_field_Package_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_Package_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
| 380 |
+
d_field_Package_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) ->
|
| 381 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
| 382 |
+
dfp_read_field_def_Package(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData).
|
| 383 |
+
|
| 384 |
+
d_field_Package_repository(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_Package_repository(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
| 385 |
+
d_field_Package_repository(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) ->
|
| 386 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
| 387 |
+
dfp_read_field_def_Package(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData).
|
| 388 |
+
|
| 389 |
+
skip_varint_Package(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_Package(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
|
| 390 |
+
skip_varint_Package(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_Package(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
|
| 391 |
+
|
| 392 |
+
skip_length_delimited_Package(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_Package(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
| 393 |
+
skip_length_delimited_Package(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) ->
|
| 394 |
+
Length = X bsl N + Acc,
|
| 395 |
+
<<_:Length/binary, Rest2/binary>> = Rest,
|
| 396 |
+
dfp_read_field_def_Package(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData).
|
| 397 |
+
|
| 398 |
+
skip_group_Package(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) ->
|
| 399 |
+
{_, Rest} = read_group(Bin, FNum),
|
| 400 |
+
dfp_read_field_def_Package(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData).
|
| 401 |
+
|
| 402 |
+
skip_32_Package(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_Package(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
|
| 403 |
+
|
| 404 |
+
skip_64_Package(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_Package(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
|
| 405 |
+
|
| 406 |
+
decode_msg_Release(Bin, TrUserData) -> dfp_read_field_def_Release(Bin, 0, 0, 0, id('$undef', TrUserData), id('$undef', TrUserData), id([], TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), TrUserData).
|
| 407 |
+
|
| 408 |
+
dfp_read_field_def_Release(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Release_version(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 409 |
+
dfp_read_field_def_Release(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Release_inner_checksum(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 410 |
+
dfp_read_field_def_Release(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Release_dependencies(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 411 |
+
dfp_read_field_def_Release(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Release_retired(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 412 |
+
dfp_read_field_def_Release(<<42, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Release_outer_checksum(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 413 |
+
dfp_read_field_def_Release(<<>>, 0, 0, _, F@_1, F@_2, R1, F@_4, F@_5, TrUserData) ->
|
| 414 |
+
S1 = #{version => F@_1, inner_checksum => F@_2},
|
| 415 |
+
S2 = if R1 == '$undef' -> S1;
|
| 416 |
+
true -> S1#{dependencies => lists_reverse(R1, TrUserData)}
|
| 417 |
+
end,
|
| 418 |
+
S3 = if F@_4 == '$undef' -> S2;
|
| 419 |
+
true -> S2#{retired => F@_4}
|
| 420 |
+
end,
|
| 421 |
+
if F@_5 == '$undef' -> S3;
|
| 422 |
+
true -> S3#{outer_checksum => F@_5}
|
| 423 |
+
end;
|
| 424 |
+
dfp_read_field_def_Release(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> dg_read_field_def_Release(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData).
|
| 425 |
+
|
| 426 |
+
dg_read_field_def_Release(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 32 - 7 -> dg_read_field_def_Release(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 427 |
+
dg_read_field_def_Release(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) ->
|
| 428 |
+
Key = X bsl N + Acc,
|
| 429 |
+
case Key of
|
| 430 |
+
10 -> d_field_Release_version(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 431 |
+
18 -> d_field_Release_inner_checksum(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 432 |
+
26 -> d_field_Release_dependencies(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 433 |
+
34 -> d_field_Release_retired(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 434 |
+
42 -> d_field_Release_outer_checksum(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 435 |
+
_ ->
|
| 436 |
+
case Key band 7 of
|
| 437 |
+
0 -> skip_varint_Release(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 438 |
+
1 -> skip_64_Release(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 439 |
+
2 -> skip_length_delimited_Release(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 440 |
+
3 -> skip_group_Release(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 441 |
+
5 -> skip_32_Release(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData)
|
| 442 |
+
end
|
| 443 |
+
end;
|
| 444 |
+
dg_read_field_def_Release(<<>>, 0, 0, _, F@_1, F@_2, R1, F@_4, F@_5, TrUserData) ->
|
| 445 |
+
S1 = #{version => F@_1, inner_checksum => F@_2},
|
| 446 |
+
S2 = if R1 == '$undef' -> S1;
|
| 447 |
+
true -> S1#{dependencies => lists_reverse(R1, TrUserData)}
|
| 448 |
+
end,
|
| 449 |
+
S3 = if F@_4 == '$undef' -> S2;
|
| 450 |
+
true -> S2#{retired => F@_4}
|
| 451 |
+
end,
|
| 452 |
+
if F@_5 == '$undef' -> S3;
|
| 453 |
+
true -> S3#{outer_checksum => F@_5}
|
| 454 |
+
end.
|
| 455 |
+
|
| 456 |
+
d_field_Release_version(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Release_version(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 457 |
+
d_field_Release_version(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, F@_5, TrUserData) ->
|
| 458 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
| 459 |
+
dfp_read_field_def_Release(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, F@_5, TrUserData).
|
| 460 |
+
|
| 461 |
+
d_field_Release_inner_checksum(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Release_inner_checksum(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 462 |
+
d_field_Release_inner_checksum(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, F@_5, TrUserData) ->
|
| 463 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
| 464 |
+
dfp_read_field_def_Release(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, F@_5, TrUserData).
|
| 465 |
+
|
| 466 |
+
d_field_Release_dependencies(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Release_dependencies(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 467 |
+
d_field_Release_dependencies(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, Prev, F@_4, F@_5, TrUserData) ->
|
| 468 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bs:Len/binary, Rest2/binary>> = Rest, {id(decode_msg_Dependency(Bs, TrUserData), TrUserData), Rest2} end,
|
| 469 |
+
dfp_read_field_def_Release(RestF, 0, 0, F, F@_1, F@_2, cons(NewFValue, Prev, TrUserData), F@_4, F@_5, TrUserData).
|
| 470 |
+
|
| 471 |
+
d_field_Release_retired(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Release_retired(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 472 |
+
d_field_Release_retired(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, Prev, F@_5, TrUserData) ->
|
| 473 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bs:Len/binary, Rest2/binary>> = Rest, {id(decode_msg_RetirementStatus(Bs, TrUserData), TrUserData), Rest2} end,
|
| 474 |
+
dfp_read_field_def_Release(RestF,
|
| 475 |
+
0,
|
| 476 |
+
0,
|
| 477 |
+
F,
|
| 478 |
+
F@_1,
|
| 479 |
+
F@_2,
|
| 480 |
+
F@_3,
|
| 481 |
+
if Prev == '$undef' -> NewFValue;
|
| 482 |
+
true -> merge_msg_RetirementStatus(Prev, NewFValue, TrUserData)
|
| 483 |
+
end,
|
| 484 |
+
F@_5,
|
| 485 |
+
TrUserData).
|
| 486 |
+
|
| 487 |
+
d_field_Release_outer_checksum(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Release_outer_checksum(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 488 |
+
d_field_Release_outer_checksum(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, _, TrUserData) ->
|
| 489 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
| 490 |
+
dfp_read_field_def_Release(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, NewFValue, TrUserData).
|
| 491 |
+
|
| 492 |
+
skip_varint_Release(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> skip_varint_Release(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 493 |
+
skip_varint_Release(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> dfp_read_field_def_Release(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData).
|
| 494 |
+
|
| 495 |
+
skip_length_delimited_Release(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> skip_length_delimited_Release(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 496 |
+
skip_length_delimited_Release(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) ->
|
| 497 |
+
Length = X bsl N + Acc,
|
| 498 |
+
<<_:Length/binary, Rest2/binary>> = Rest,
|
| 499 |
+
dfp_read_field_def_Release(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData).
|
| 500 |
+
|
| 501 |
+
skip_group_Release(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) ->
|
| 502 |
+
{_, Rest} = read_group(Bin, FNum),
|
| 503 |
+
dfp_read_field_def_Release(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData).
|
| 504 |
+
|
| 505 |
+
skip_32_Release(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> dfp_read_field_def_Release(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData).
|
| 506 |
+
|
| 507 |
+
skip_64_Release(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> dfp_read_field_def_Release(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData).
|
| 508 |
+
|
| 509 |
+
decode_msg_RetirementStatus(Bin, TrUserData) -> dfp_read_field_def_RetirementStatus(Bin, 0, 0, 0, id('$undef', TrUserData), id('$undef', TrUserData), TrUserData).
|
| 510 |
+
|
| 511 |
+
dfp_read_field_def_RetirementStatus(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_RetirementStatus_reason(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData);
|
| 512 |
+
dfp_read_field_def_RetirementStatus(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_RetirementStatus_message(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData);
|
| 513 |
+
dfp_read_field_def_RetirementStatus(<<>>, 0, 0, _, F@_1, F@_2, _) ->
|
| 514 |
+
S1 = #{reason => F@_1},
|
| 515 |
+
if F@_2 == '$undef' -> S1;
|
| 516 |
+
true -> S1#{message => F@_2}
|
| 517 |
+
end;
|
| 518 |
+
dfp_read_field_def_RetirementStatus(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_RetirementStatus(Other, Z1, Z2, F, F@_1, F@_2, TrUserData).
|
| 519 |
+
|
| 520 |
+
dg_read_field_def_RetirementStatus(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_RetirementStatus(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData);
|
| 521 |
+
dg_read_field_def_RetirementStatus(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) ->
|
| 522 |
+
Key = X bsl N + Acc,
|
| 523 |
+
case Key of
|
| 524 |
+
8 -> d_field_RetirementStatus_reason(Rest, 0, 0, 0, F@_1, F@_2, TrUserData);
|
| 525 |
+
18 -> d_field_RetirementStatus_message(Rest, 0, 0, 0, F@_1, F@_2, TrUserData);
|
| 526 |
+
_ ->
|
| 527 |
+
case Key band 7 of
|
| 528 |
+
0 -> skip_varint_RetirementStatus(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData);
|
| 529 |
+
1 -> skip_64_RetirementStatus(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData);
|
| 530 |
+
2 -> skip_length_delimited_RetirementStatus(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData);
|
| 531 |
+
3 -> skip_group_RetirementStatus(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData);
|
| 532 |
+
5 -> skip_32_RetirementStatus(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData)
|
| 533 |
+
end
|
| 534 |
+
end;
|
| 535 |
+
dg_read_field_def_RetirementStatus(<<>>, 0, 0, _, F@_1, F@_2, _) ->
|
| 536 |
+
S1 = #{reason => F@_1},
|
| 537 |
+
if F@_2 == '$undef' -> S1;
|
| 538 |
+
true -> S1#{message => F@_2}
|
| 539 |
+
end.
|
| 540 |
+
|
| 541 |
+
d_field_RetirementStatus_reason(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_RetirementStatus_reason(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData);
|
| 542 |
+
d_field_RetirementStatus_reason(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) ->
|
| 543 |
+
{NewFValue, RestF} = {id(d_enum_RetirementReason(begin <<Res:32/signed-native>> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end), TrUserData), Rest},
|
| 544 |
+
dfp_read_field_def_RetirementStatus(RestF, 0, 0, F, NewFValue, F@_2, TrUserData).
|
| 545 |
+
|
| 546 |
+
d_field_RetirementStatus_message(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_RetirementStatus_message(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData);
|
| 547 |
+
d_field_RetirementStatus_message(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) ->
|
| 548 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
| 549 |
+
dfp_read_field_def_RetirementStatus(RestF, 0, 0, F, F@_1, NewFValue, TrUserData).
|
| 550 |
+
|
| 551 |
+
skip_varint_RetirementStatus(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_RetirementStatus(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData);
|
| 552 |
+
skip_varint_RetirementStatus(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_RetirementStatus(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData).
|
| 553 |
+
|
| 554 |
+
skip_length_delimited_RetirementStatus(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_RetirementStatus(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData);
|
| 555 |
+
skip_length_delimited_RetirementStatus(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) ->
|
| 556 |
+
Length = X bsl N + Acc,
|
| 557 |
+
<<_:Length/binary, Rest2/binary>> = Rest,
|
| 558 |
+
dfp_read_field_def_RetirementStatus(Rest2, 0, 0, F, F@_1, F@_2, TrUserData).
|
| 559 |
+
|
| 560 |
+
skip_group_RetirementStatus(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) ->
|
| 561 |
+
{_, Rest} = read_group(Bin, FNum),
|
| 562 |
+
dfp_read_field_def_RetirementStatus(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData).
|
| 563 |
+
|
| 564 |
+
skip_32_RetirementStatus(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_RetirementStatus(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData).
|
| 565 |
+
|
| 566 |
+
skip_64_RetirementStatus(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_RetirementStatus(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData).
|
| 567 |
+
|
| 568 |
+
decode_msg_Dependency(Bin, TrUserData) -> dfp_read_field_def_Dependency(Bin, 0, 0, 0, id('$undef', TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), TrUserData).
|
| 569 |
+
|
| 570 |
+
dfp_read_field_def_Dependency(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Dependency_package(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 571 |
+
dfp_read_field_def_Dependency(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Dependency_requirement(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 572 |
+
dfp_read_field_def_Dependency(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Dependency_optional(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 573 |
+
dfp_read_field_def_Dependency(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Dependency_app(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 574 |
+
dfp_read_field_def_Dependency(<<42, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Dependency_repository(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 575 |
+
dfp_read_field_def_Dependency(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, F@_5, _) ->
|
| 576 |
+
S1 = #{package => F@_1, requirement => F@_2},
|
| 577 |
+
S2 = if F@_3 == '$undef' -> S1;
|
| 578 |
+
true -> S1#{optional => F@_3}
|
| 579 |
+
end,
|
| 580 |
+
S3 = if F@_4 == '$undef' -> S2;
|
| 581 |
+
true -> S2#{app => F@_4}
|
| 582 |
+
end,
|
| 583 |
+
if F@_5 == '$undef' -> S3;
|
| 584 |
+
true -> S3#{repository => F@_5}
|
| 585 |
+
end;
|
| 586 |
+
dfp_read_field_def_Dependency(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> dg_read_field_def_Dependency(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData).
|
| 587 |
+
|
| 588 |
+
dg_read_field_def_Dependency(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 32 - 7 -> dg_read_field_def_Dependency(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 589 |
+
dg_read_field_def_Dependency(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) ->
|
| 590 |
+
Key = X bsl N + Acc,
|
| 591 |
+
case Key of
|
| 592 |
+
10 -> d_field_Dependency_package(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 593 |
+
18 -> d_field_Dependency_requirement(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 594 |
+
24 -> d_field_Dependency_optional(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 595 |
+
34 -> d_field_Dependency_app(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 596 |
+
42 -> d_field_Dependency_repository(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 597 |
+
_ ->
|
| 598 |
+
case Key band 7 of
|
| 599 |
+
0 -> skip_varint_Dependency(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 600 |
+
1 -> skip_64_Dependency(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 601 |
+
2 -> skip_length_delimited_Dependency(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 602 |
+
3 -> skip_group_Dependency(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 603 |
+
5 -> skip_32_Dependency(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData)
|
| 604 |
+
end
|
| 605 |
+
end;
|
| 606 |
+
dg_read_field_def_Dependency(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, F@_5, _) ->
|
| 607 |
+
S1 = #{package => F@_1, requirement => F@_2},
|
| 608 |
+
S2 = if F@_3 == '$undef' -> S1;
|
| 609 |
+
true -> S1#{optional => F@_3}
|
| 610 |
+
end,
|
| 611 |
+
S3 = if F@_4 == '$undef' -> S2;
|
| 612 |
+
true -> S2#{app => F@_4}
|
| 613 |
+
end,
|
| 614 |
+
if F@_5 == '$undef' -> S3;
|
| 615 |
+
true -> S3#{repository => F@_5}
|
| 616 |
+
end.
|
| 617 |
+
|
| 618 |
+
d_field_Dependency_package(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Dependency_package(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 619 |
+
d_field_Dependency_package(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, F@_5, TrUserData) ->
|
| 620 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
| 621 |
+
dfp_read_field_def_Dependency(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, F@_5, TrUserData).
|
| 622 |
+
|
| 623 |
+
d_field_Dependency_requirement(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Dependency_requirement(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 624 |
+
d_field_Dependency_requirement(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, F@_5, TrUserData) ->
|
| 625 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
| 626 |
+
dfp_read_field_def_Dependency(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, F@_5, TrUserData).
|
| 627 |
+
|
| 628 |
+
d_field_Dependency_optional(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Dependency_optional(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 629 |
+
d_field_Dependency_optional(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, F@_5, TrUserData) ->
|
| 630 |
+
{NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest},
|
| 631 |
+
dfp_read_field_def_Dependency(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, F@_5, TrUserData).
|
| 632 |
+
|
| 633 |
+
d_field_Dependency_app(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Dependency_app(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 634 |
+
d_field_Dependency_app(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, F@_5, TrUserData) ->
|
| 635 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
| 636 |
+
dfp_read_field_def_Dependency(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, F@_5, TrUserData).
|
| 637 |
+
|
| 638 |
+
d_field_Dependency_repository(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Dependency_repository(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 639 |
+
d_field_Dependency_repository(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, _, TrUserData) ->
|
| 640 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
| 641 |
+
dfp_read_field_def_Dependency(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, NewFValue, TrUserData).
|
| 642 |
+
|
| 643 |
+
skip_varint_Dependency(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> skip_varint_Dependency(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 644 |
+
skip_varint_Dependency(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> dfp_read_field_def_Dependency(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData).
|
| 645 |
+
|
| 646 |
+
skip_length_delimited_Dependency(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> skip_length_delimited_Dependency(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
|
| 647 |
+
skip_length_delimited_Dependency(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) ->
|
| 648 |
+
Length = X bsl N + Acc,
|
| 649 |
+
<<_:Length/binary, Rest2/binary>> = Rest,
|
| 650 |
+
dfp_read_field_def_Dependency(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData).
|
| 651 |
+
|
| 652 |
+
skip_group_Dependency(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) ->
|
| 653 |
+
{_, Rest} = read_group(Bin, FNum),
|
| 654 |
+
dfp_read_field_def_Dependency(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData).
|
| 655 |
+
|
| 656 |
+
skip_32_Dependency(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> dfp_read_field_def_Dependency(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData).
|
| 657 |
+
|
| 658 |
+
skip_64_Dependency(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> dfp_read_field_def_Dependency(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData).
|
| 659 |
+
|
| 660 |
+
d_enum_RetirementReason(0) -> 'RETIRED_OTHER';
|
| 661 |
+
d_enum_RetirementReason(1) -> 'RETIRED_INVALID';
|
| 662 |
+
d_enum_RetirementReason(2) -> 'RETIRED_SECURITY';
|
| 663 |
+
d_enum_RetirementReason(3) -> 'RETIRED_DEPRECATED';
|
| 664 |
+
d_enum_RetirementReason(4) -> 'RETIRED_RENAMED';
|
| 665 |
+
d_enum_RetirementReason(V) -> V.
|
| 666 |
+
|
| 667 |
+
read_group(Bin, FieldNum) ->
|
| 668 |
+
{NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum),
|
| 669 |
+
<<Group:NumBytes/binary, _:EndTagLen/binary, Rest/binary>> = Bin,
|
| 670 |
+
{Group, Rest}.
|
| 671 |
+
|
| 672 |
+
%% Like skipping over fields, but record the total length,
|
| 673 |
+
%% Each field is <(FieldNum bsl 3) bor FieldType> ++ <FieldValue>
|
| 674 |
+
%% Record the length because varints may be non-optimally encoded.
|
| 675 |
+
%%
|
| 676 |
+
%% Groups can be nested, but assume the same FieldNum cannot be nested
|
| 677 |
+
%% because group field numbers are shared with the rest of the fields
|
| 678 |
+
%% numbers. Thus we can search just for an group-end with the same
|
| 679 |
+
%% field number.
|
| 680 |
+
%%
|
| 681 |
+
%% (The only time the same group field number could occur would
|
| 682 |
+
%% be in a nested sub message, but then it would be inside a
|
| 683 |
+
%% length-delimited entry, which we skip-read by length.)
|
| 684 |
+
read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum)
|
| 685 |
+
when N < (32-7) ->
|
| 686 |
+
read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum);
|
| 687 |
+
read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen,
|
| 688 |
+
FieldNum) ->
|
| 689 |
+
Key = X bsl N + Acc,
|
| 690 |
+
TagLen1 = TagLen + 1,
|
| 691 |
+
case {Key bsr 3, Key band 7} of
|
| 692 |
+
{FieldNum, 4} -> % 4 = group_end
|
| 693 |
+
{NumBytes, TagLen1};
|
| 694 |
+
{_, 0} -> % 0 = varint
|
| 695 |
+
read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum);
|
| 696 |
+
{_, 1} -> % 1 = bits64
|
| 697 |
+
<<_:64, Tl2/binary>> = Tl,
|
| 698 |
+
read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum);
|
| 699 |
+
{_, 2} -> % 2 = length_delimited
|
| 700 |
+
read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum);
|
| 701 |
+
{_, 3} -> % 3 = group_start
|
| 702 |
+
read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum);
|
| 703 |
+
{_, 4} -> % 4 = group_end
|
| 704 |
+
read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum);
|
| 705 |
+
{_, 5} -> % 5 = bits32
|
| 706 |
+
<<_:32, Tl2/binary>> = Tl,
|
| 707 |
+
read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum)
|
| 708 |
+
end.
|
| 709 |
+
|
| 710 |
+
read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum)
|
| 711 |
+
when N < (64-7) ->
|
| 712 |
+
read_gr_vi(Tl, N+7, NumBytes+1, FieldNum);
|
| 713 |
+
read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) ->
|
| 714 |
+
read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum).
|
| 715 |
+
|
| 716 |
+
read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum)
|
| 717 |
+
when N < (64-7) ->
|
| 718 |
+
read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum);
|
| 719 |
+
read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) ->
|
| 720 |
+
Len = X bsl N + Acc,
|
| 721 |
+
NumBytes1 = NumBytes + 1,
|
| 722 |
+
<<_:Len/binary, Tl2/binary>> = Tl,
|
| 723 |
+
read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum).
|
| 724 |
+
|
| 725 |
+
merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []).
|
| 726 |
+
|
| 727 |
+
merge_msgs(Prev, New, MsgName, Opts) ->
|
| 728 |
+
TrUserData = proplists:get_value(user_data, Opts),
|
| 729 |
+
case MsgName of
|
| 730 |
+
'Package' -> merge_msg_Package(Prev, New, TrUserData);
|
| 731 |
+
'Release' -> merge_msg_Release(Prev, New, TrUserData);
|
| 732 |
+
'RetirementStatus' -> merge_msg_RetirementStatus(Prev, New, TrUserData);
|
| 733 |
+
'Dependency' -> merge_msg_Dependency(Prev, New, TrUserData)
|
| 734 |
+
end.
|
| 735 |
+
|
| 736 |
+
-compile({nowarn_unused_function,merge_msg_Package/3}).
|
| 737 |
+
merge_msg_Package(#{} = PMsg, #{name := NFname, repository := NFrepository} = NMsg, TrUserData) ->
|
| 738 |
+
S1 = #{name => NFname, repository => NFrepository},
|
| 739 |
+
case {PMsg, NMsg} of
|
| 740 |
+
{#{releases := PFreleases}, #{releases := NFreleases}} -> S1#{releases => 'erlang_++'(PFreleases, NFreleases, TrUserData)};
|
| 741 |
+
{_, #{releases := NFreleases}} -> S1#{releases => NFreleases};
|
| 742 |
+
{#{releases := PFreleases}, _} -> S1#{releases => PFreleases};
|
| 743 |
+
{_, _} -> S1
|
| 744 |
+
end.
|
| 745 |
+
|
| 746 |
+
-compile({nowarn_unused_function,merge_msg_Release/3}).
|
| 747 |
+
merge_msg_Release(#{} = PMsg, #{version := NFversion, inner_checksum := NFinner_checksum} = NMsg, TrUserData) ->
|
| 748 |
+
S1 = #{version => NFversion, inner_checksum => NFinner_checksum},
|
| 749 |
+
S2 = case {PMsg, NMsg} of
|
| 750 |
+
{#{dependencies := PFdependencies}, #{dependencies := NFdependencies}} -> S1#{dependencies => 'erlang_++'(PFdependencies, NFdependencies, TrUserData)};
|
| 751 |
+
{_, #{dependencies := NFdependencies}} -> S1#{dependencies => NFdependencies};
|
| 752 |
+
{#{dependencies := PFdependencies}, _} -> S1#{dependencies => PFdependencies};
|
| 753 |
+
{_, _} -> S1
|
| 754 |
+
end,
|
| 755 |
+
S3 = case {PMsg, NMsg} of
|
| 756 |
+
{#{retired := PFretired}, #{retired := NFretired}} -> S2#{retired => merge_msg_RetirementStatus(PFretired, NFretired, TrUserData)};
|
| 757 |
+
{_, #{retired := NFretired}} -> S2#{retired => NFretired};
|
| 758 |
+
{#{retired := PFretired}, _} -> S2#{retired => PFretired};
|
| 759 |
+
{_, _} -> S2
|
| 760 |
+
end,
|
| 761 |
+
case {PMsg, NMsg} of
|
| 762 |
+
{_, #{outer_checksum := NFouter_checksum}} -> S3#{outer_checksum => NFouter_checksum};
|
| 763 |
+
{#{outer_checksum := PFouter_checksum}, _} -> S3#{outer_checksum => PFouter_checksum};
|
| 764 |
+
_ -> S3
|
| 765 |
+
end.
|
| 766 |
+
|
| 767 |
+
-compile({nowarn_unused_function,merge_msg_RetirementStatus/3}).
|
| 768 |
+
merge_msg_RetirementStatus(#{} = PMsg, #{reason := NFreason} = NMsg, _) ->
|
| 769 |
+
S1 = #{reason => NFreason},
|
| 770 |
+
case {PMsg, NMsg} of
|
| 771 |
+
{_, #{message := NFmessage}} -> S1#{message => NFmessage};
|
| 772 |
+
{#{message := PFmessage}, _} -> S1#{message => PFmessage};
|
| 773 |
+
_ -> S1
|
| 774 |
+
end.
|
| 775 |
+
|
| 776 |
+
-compile({nowarn_unused_function,merge_msg_Dependency/3}).
|
| 777 |
+
merge_msg_Dependency(#{} = PMsg, #{package := NFpackage, requirement := NFrequirement} = NMsg, _) ->
|
| 778 |
+
S1 = #{package => NFpackage, requirement => NFrequirement},
|
| 779 |
+
S2 = case {PMsg, NMsg} of
|
| 780 |
+
{_, #{optional := NFoptional}} -> S1#{optional => NFoptional};
|
| 781 |
+
{#{optional := PFoptional}, _} -> S1#{optional => PFoptional};
|
| 782 |
+
_ -> S1
|
| 783 |
+
end,
|
| 784 |
+
S3 = case {PMsg, NMsg} of
|
| 785 |
+
{_, #{app := NFapp}} -> S2#{app => NFapp};
|
| 786 |
+
{#{app := PFapp}, _} -> S2#{app => PFapp};
|
| 787 |
+
_ -> S2
|
| 788 |
+
end,
|
| 789 |
+
case {PMsg, NMsg} of
|
| 790 |
+
{_, #{repository := NFrepository}} -> S3#{repository => NFrepository};
|
| 791 |
+
{#{repository := PFrepository}, _} -> S3#{repository => PFrepository};
|
| 792 |
+
_ -> S3
|
| 793 |
+
end.
|
| 794 |
+
|
| 795 |
+
|
| 796 |
+
verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []).
|
| 797 |
+
|
| 798 |
+
verify_msg(Msg, MsgName, Opts) ->
|
| 799 |
+
TrUserData = proplists:get_value(user_data, Opts),
|
| 800 |
+
case MsgName of
|
| 801 |
+
'Package' -> v_msg_Package(Msg, [MsgName], TrUserData);
|
| 802 |
+
'Release' -> v_msg_Release(Msg, [MsgName], TrUserData);
|
| 803 |
+
'RetirementStatus' -> v_msg_RetirementStatus(Msg, [MsgName], TrUserData);
|
| 804 |
+
'Dependency' -> v_msg_Dependency(Msg, [MsgName], TrUserData);
|
| 805 |
+
_ -> mk_type_error(not_a_known_message, Msg, [])
|
| 806 |
+
end.
|
| 807 |
+
|
| 808 |
+
|
| 809 |
+
-compile({nowarn_unused_function,v_msg_Package/3}).
|
| 810 |
+
-dialyzer({nowarn_function,v_msg_Package/3}).
|
| 811 |
+
v_msg_Package(#{name := F2, repository := F3} = M, Path, TrUserData) ->
|
| 812 |
+
case M of
|
| 813 |
+
#{releases := F1} ->
|
| 814 |
+
if is_list(F1) ->
|
| 815 |
+
_ = [v_submsg_Release(Elem, [releases | Path], TrUserData) || Elem <- F1],
|
| 816 |
+
ok;
|
| 817 |
+
true -> mk_type_error({invalid_list_of, {msg, 'Release'}}, F1, [releases | Path])
|
| 818 |
+
end;
|
| 819 |
+
_ -> ok
|
| 820 |
+
end,
|
| 821 |
+
v_type_string(F2, [name | Path], TrUserData),
|
| 822 |
+
v_type_string(F3, [repository | Path], TrUserData),
|
| 823 |
+
lists:foreach(fun (releases) -> ok;
|
| 824 |
+
(name) -> ok;
|
| 825 |
+
(repository) -> ok;
|
| 826 |
+
(OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path)
|
| 827 |
+
end,
|
| 828 |
+
maps:keys(M)),
|
| 829 |
+
ok;
|
| 830 |
+
v_msg_Package(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [name, repository] -- maps:keys(M), 'Package'}, M, Path);
|
| 831 |
+
v_msg_Package(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Package'}, X, Path).
|
| 832 |
+
|
| 833 |
+
-compile({nowarn_unused_function,v_submsg_Release/3}).
|
| 834 |
+
-dialyzer({nowarn_function,v_submsg_Release/3}).
|
| 835 |
+
v_submsg_Release(Msg, Path, TrUserData) -> v_msg_Release(Msg, Path, TrUserData).
|
| 836 |
+
|
| 837 |
+
-compile({nowarn_unused_function,v_msg_Release/3}).
|
| 838 |
+
-dialyzer({nowarn_function,v_msg_Release/3}).
|
| 839 |
+
v_msg_Release(#{version := F1, inner_checksum := F2} = M, Path, TrUserData) ->
|
| 840 |
+
v_type_string(F1, [version | Path], TrUserData),
|
| 841 |
+
v_type_bytes(F2, [inner_checksum | Path], TrUserData),
|
| 842 |
+
case M of
|
| 843 |
+
#{dependencies := F3} ->
|
| 844 |
+
if is_list(F3) ->
|
| 845 |
+
_ = [v_submsg_Dependency(Elem, [dependencies | Path], TrUserData) || Elem <- F3],
|
| 846 |
+
ok;
|
| 847 |
+
true -> mk_type_error({invalid_list_of, {msg, 'Dependency'}}, F3, [dependencies | Path])
|
| 848 |
+
end;
|
| 849 |
+
_ -> ok
|
| 850 |
+
end,
|
| 851 |
+
case M of
|
| 852 |
+
#{retired := F4} -> v_submsg_RetirementStatus(F4, [retired | Path], TrUserData);
|
| 853 |
+
_ -> ok
|
| 854 |
+
end,
|
| 855 |
+
case M of
|
| 856 |
+
#{outer_checksum := F5} -> v_type_bytes(F5, [outer_checksum | Path], TrUserData);
|
| 857 |
+
_ -> ok
|
| 858 |
+
end,
|
| 859 |
+
lists:foreach(fun (version) -> ok;
|
| 860 |
+
(inner_checksum) -> ok;
|
| 861 |
+
(dependencies) -> ok;
|
| 862 |
+
(retired) -> ok;
|
| 863 |
+
(outer_checksum) -> ok;
|
| 864 |
+
(OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path)
|
| 865 |
+
end,
|
| 866 |
+
maps:keys(M)),
|
| 867 |
+
ok;
|
| 868 |
+
v_msg_Release(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [version, inner_checksum] -- maps:keys(M), 'Release'}, M, Path);
|
| 869 |
+
v_msg_Release(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Release'}, X, Path).
|
| 870 |
+
|
| 871 |
+
-compile({nowarn_unused_function,v_submsg_RetirementStatus/3}).
|
| 872 |
+
-dialyzer({nowarn_function,v_submsg_RetirementStatus/3}).
|
| 873 |
+
v_submsg_RetirementStatus(Msg, Path, TrUserData) -> v_msg_RetirementStatus(Msg, Path, TrUserData).
|
| 874 |
+
|
| 875 |
+
-compile({nowarn_unused_function,v_msg_RetirementStatus/3}).
|
| 876 |
+
-dialyzer({nowarn_function,v_msg_RetirementStatus/3}).
|
| 877 |
+
v_msg_RetirementStatus(#{reason := F1} = M, Path, TrUserData) ->
|
| 878 |
+
v_enum_RetirementReason(F1, [reason | Path], TrUserData),
|
| 879 |
+
case M of
|
| 880 |
+
#{message := F2} -> v_type_string(F2, [message | Path], TrUserData);
|
| 881 |
+
_ -> ok
|
| 882 |
+
end,
|
| 883 |
+
lists:foreach(fun (reason) -> ok;
|
| 884 |
+
(message) -> ok;
|
| 885 |
+
(OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path)
|
| 886 |
+
end,
|
| 887 |
+
maps:keys(M)),
|
| 888 |
+
ok;
|
| 889 |
+
v_msg_RetirementStatus(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [reason] -- maps:keys(M), 'RetirementStatus'}, M, Path);
|
| 890 |
+
v_msg_RetirementStatus(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'RetirementStatus'}, X, Path).
|
| 891 |
+
|
| 892 |
+
-compile({nowarn_unused_function,v_submsg_Dependency/3}).
|
| 893 |
+
-dialyzer({nowarn_function,v_submsg_Dependency/3}).
|
| 894 |
+
v_submsg_Dependency(Msg, Path, TrUserData) -> v_msg_Dependency(Msg, Path, TrUserData).
|
| 895 |
+
|
| 896 |
+
-compile({nowarn_unused_function,v_msg_Dependency/3}).
|
| 897 |
+
-dialyzer({nowarn_function,v_msg_Dependency/3}).
|
| 898 |
+
v_msg_Dependency(#{package := F1, requirement := F2} = M, Path, TrUserData) ->
|
| 899 |
+
v_type_string(F1, [package | Path], TrUserData),
|
| 900 |
+
v_type_string(F2, [requirement | Path], TrUserData),
|
| 901 |
+
case M of
|
| 902 |
+
#{optional := F3} -> v_type_bool(F3, [optional | Path], TrUserData);
|
| 903 |
+
_ -> ok
|
| 904 |
+
end,
|
| 905 |
+
case M of
|
| 906 |
+
#{app := F4} -> v_type_string(F4, [app | Path], TrUserData);
|
| 907 |
+
_ -> ok
|
| 908 |
+
end,
|
| 909 |
+
case M of
|
| 910 |
+
#{repository := F5} -> v_type_string(F5, [repository | Path], TrUserData);
|
| 911 |
+
_ -> ok
|
| 912 |
+
end,
|
| 913 |
+
lists:foreach(fun (package) -> ok;
|
| 914 |
+
(requirement) -> ok;
|
| 915 |
+
(optional) -> ok;
|
| 916 |
+
(app) -> ok;
|
| 917 |
+
(repository) -> ok;
|
| 918 |
+
(OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path)
|
| 919 |
+
end,
|
| 920 |
+
maps:keys(M)),
|
| 921 |
+
ok;
|
| 922 |
+
v_msg_Dependency(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [package, requirement] -- maps:keys(M), 'Dependency'}, M, Path);
|
| 923 |
+
v_msg_Dependency(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Dependency'}, X, Path).
|
| 924 |
+
|
| 925 |
+
-compile({nowarn_unused_function,v_enum_RetirementReason/3}).
|
| 926 |
+
-dialyzer({nowarn_function,v_enum_RetirementReason/3}).
|
| 927 |
+
v_enum_RetirementReason('RETIRED_OTHER', _Path, _TrUserData) -> ok;
|
| 928 |
+
v_enum_RetirementReason('RETIRED_INVALID', _Path, _TrUserData) -> ok;
|
| 929 |
+
v_enum_RetirementReason('RETIRED_SECURITY', _Path, _TrUserData) -> ok;
|
| 930 |
+
v_enum_RetirementReason('RETIRED_DEPRECATED', _Path, _TrUserData) -> ok;
|
| 931 |
+
v_enum_RetirementReason('RETIRED_RENAMED', _Path, _TrUserData) -> ok;
|
| 932 |
+
v_enum_RetirementReason(V, _Path, _TrUserData) when -2147483648 =< V, V =< 2147483647, is_integer(V) -> ok;
|
| 933 |
+
v_enum_RetirementReason(X, Path, _TrUserData) -> mk_type_error({invalid_enum, 'RetirementReason'}, X, Path).
|
| 934 |
+
|
| 935 |
+
-compile({nowarn_unused_function,v_type_bool/3}).
|
| 936 |
+
-dialyzer({nowarn_function,v_type_bool/3}).
|
| 937 |
+
v_type_bool(false, _Path, _TrUserData) -> ok;
|
| 938 |
+
v_type_bool(true, _Path, _TrUserData) -> ok;
|
| 939 |
+
v_type_bool(0, _Path, _TrUserData) -> ok;
|
| 940 |
+
v_type_bool(1, _Path, _TrUserData) -> ok;
|
| 941 |
+
v_type_bool(X, Path, _TrUserData) -> mk_type_error(bad_boolean_value, X, Path).
|
| 942 |
+
|
| 943 |
+
-compile({nowarn_unused_function,v_type_string/3}).
|
| 944 |
+
-dialyzer({nowarn_function,v_type_string/3}).
|
| 945 |
+
v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) ->
|
| 946 |
+
try unicode:characters_to_binary(S) of
|
| 947 |
+
B when is_binary(B) -> ok;
|
| 948 |
+
{error, _, _} -> mk_type_error(bad_unicode_string, S, Path)
|
| 949 |
+
catch
|
| 950 |
+
error:badarg -> mk_type_error(bad_unicode_string, S, Path)
|
| 951 |
+
end;
|
| 952 |
+
v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path).
|
| 953 |
+
|
| 954 |
+
-compile({nowarn_unused_function,v_type_bytes/3}).
|
| 955 |
+
-dialyzer({nowarn_function,v_type_bytes/3}).
|
| 956 |
+
v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> ok;
|
| 957 |
+
v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> ok;
|
| 958 |
+
v_type_bytes(X, Path, _TrUserData) -> mk_type_error(bad_binary_value, X, Path).
|
| 959 |
+
|
| 960 |
+
-compile({nowarn_unused_function,mk_type_error/3}).
|
| 961 |
+
-spec mk_type_error(_, _, list()) -> no_return().
|
| 962 |
+
mk_type_error(Error, ValueSeen, Path) ->
|
| 963 |
+
Path2 = prettify_path(Path),
|
| 964 |
+
erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}).
|
| 965 |
+
|
| 966 |
+
|
| 967 |
+
-compile({nowarn_unused_function,prettify_path/1}).
|
| 968 |
+
-dialyzer({nowarn_function,prettify_path/1}).
|
| 969 |
+
prettify_path([]) -> top_level;
|
| 970 |
+
prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))).
|
| 971 |
+
|
| 972 |
+
|
| 973 |
+
-compile({nowarn_unused_function,id/2}).
|
| 974 |
+
-compile({inline,id/2}).
|
| 975 |
+
id(X, _TrUserData) -> X.
|
| 976 |
+
|
| 977 |
+
-compile({nowarn_unused_function,v_ok/3}).
|
| 978 |
+
-compile({inline,v_ok/3}).
|
| 979 |
+
v_ok(_Value, _Path, _TrUserData) -> ok.
|
| 980 |
+
|
| 981 |
+
-compile({nowarn_unused_function,m_overwrite/3}).
|
| 982 |
+
-compile({inline,m_overwrite/3}).
|
| 983 |
+
m_overwrite(_Prev, New, _TrUserData) -> New.
|
| 984 |
+
|
| 985 |
+
-compile({nowarn_unused_function,cons/3}).
|
| 986 |
+
-compile({inline,cons/3}).
|
| 987 |
+
cons(Elem, Acc, _TrUserData) -> [Elem | Acc].
|
| 988 |
+
|
| 989 |
+
-compile({nowarn_unused_function,lists_reverse/2}).
|
| 990 |
+
-compile({inline,lists_reverse/2}).
|
| 991 |
+
'lists_reverse'(L, _TrUserData) -> lists:reverse(L).
|
| 992 |
+
-compile({nowarn_unused_function,'erlang_++'/3}).
|
| 993 |
+
-compile({inline,'erlang_++'/3}).
|
| 994 |
+
'erlang_++'(A, B, _TrUserData) -> A ++ B.
|
| 995 |
+
|
| 996 |
+
|
| 997 |
+
get_msg_defs() ->
|
| 998 |
+
[{{enum, 'RetirementReason'}, [{'RETIRED_OTHER', 0}, {'RETIRED_INVALID', 1}, {'RETIRED_SECURITY', 2}, {'RETIRED_DEPRECATED', 3}, {'RETIRED_RENAMED', 4}]},
|
| 999 |
+
{{msg, 'Package'},
|
| 1000 |
+
[#{name => releases, fnum => 1, rnum => 2, type => {msg, 'Release'}, occurrence => repeated, opts => []},
|
| 1001 |
+
#{name => name, fnum => 2, rnum => 3, type => string, occurrence => required, opts => []},
|
| 1002 |
+
#{name => repository, fnum => 3, rnum => 4, type => string, occurrence => required, opts => []}]},
|
| 1003 |
+
{{msg, 'Release'},
|
| 1004 |
+
[#{name => version, fnum => 1, rnum => 2, type => string, occurrence => required, opts => []},
|
| 1005 |
+
#{name => inner_checksum, fnum => 2, rnum => 3, type => bytes, occurrence => required, opts => []},
|
| 1006 |
+
#{name => dependencies, fnum => 3, rnum => 4, type => {msg, 'Dependency'}, occurrence => repeated, opts => []},
|
| 1007 |
+
#{name => retired, fnum => 4, rnum => 5, type => {msg, 'RetirementStatus'}, occurrence => optional, opts => []},
|
| 1008 |
+
#{name => outer_checksum, fnum => 5, rnum => 6, type => bytes, occurrence => optional, opts => []}]},
|
| 1009 |
+
{{msg, 'RetirementStatus'}, [#{name => reason, fnum => 1, rnum => 2, type => {enum, 'RetirementReason'}, occurrence => required, opts => []}, #{name => message, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]},
|
| 1010 |
+
{{msg, 'Dependency'},
|
| 1011 |
+
[#{name => package, fnum => 1, rnum => 2, type => string, occurrence => required, opts => []},
|
| 1012 |
+
#{name => requirement, fnum => 2, rnum => 3, type => string, occurrence => required, opts => []},
|
| 1013 |
+
#{name => optional, fnum => 3, rnum => 4, type => bool, occurrence => optional, opts => []},
|
| 1014 |
+
#{name => app, fnum => 4, rnum => 5, type => string, occurrence => optional, opts => []},
|
| 1015 |
+
#{name => repository, fnum => 5, rnum => 6, type => string, occurrence => optional, opts => []}]}].
|
| 1016 |
+
|
| 1017 |
+
|
| 1018 |
+
get_msg_names() -> ['Package', 'Release', 'RetirementStatus', 'Dependency'].
|
| 1019 |
+
|
| 1020 |
+
|
| 1021 |
+
get_group_names() -> [].
|
| 1022 |
+
|
| 1023 |
+
|
| 1024 |
+
get_msg_or_group_names() -> ['Package', 'Release', 'RetirementStatus', 'Dependency'].
|
| 1025 |
+
|
| 1026 |
+
|
| 1027 |
+
get_enum_names() -> ['RetirementReason'].
|
| 1028 |
+
|
| 1029 |
+
|
| 1030 |
+
fetch_msg_def(MsgName) ->
|
| 1031 |
+
case find_msg_def(MsgName) of
|
| 1032 |
+
Fs when is_list(Fs) -> Fs;
|
| 1033 |
+
error -> erlang:error({no_such_msg, MsgName})
|
| 1034 |
+
end.
|
| 1035 |
+
|
| 1036 |
+
|
| 1037 |
+
fetch_enum_def(EnumName) ->
|
| 1038 |
+
case find_enum_def(EnumName) of
|
| 1039 |
+
Es when is_list(Es) -> Es;
|
| 1040 |
+
error -> erlang:error({no_such_enum, EnumName})
|
| 1041 |
+
end.
|
| 1042 |
+
|
| 1043 |
+
|
| 1044 |
+
find_msg_def('Package') ->
|
| 1045 |
+
[#{name => releases, fnum => 1, rnum => 2, type => {msg, 'Release'}, occurrence => repeated, opts => []},
|
| 1046 |
+
#{name => name, fnum => 2, rnum => 3, type => string, occurrence => required, opts => []},
|
| 1047 |
+
#{name => repository, fnum => 3, rnum => 4, type => string, occurrence => required, opts => []}];
|
| 1048 |
+
find_msg_def('Release') ->
|
| 1049 |
+
[#{name => version, fnum => 1, rnum => 2, type => string, occurrence => required, opts => []},
|
| 1050 |
+
#{name => inner_checksum, fnum => 2, rnum => 3, type => bytes, occurrence => required, opts => []},
|
| 1051 |
+
#{name => dependencies, fnum => 3, rnum => 4, type => {msg, 'Dependency'}, occurrence => repeated, opts => []},
|
| 1052 |
+
#{name => retired, fnum => 4, rnum => 5, type => {msg, 'RetirementStatus'}, occurrence => optional, opts => []},
|
| 1053 |
+
#{name => outer_checksum, fnum => 5, rnum => 6, type => bytes, occurrence => optional, opts => []}];
|
| 1054 |
+
find_msg_def('RetirementStatus') -> [#{name => reason, fnum => 1, rnum => 2, type => {enum, 'RetirementReason'}, occurrence => required, opts => []}, #{name => message, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}];
|
| 1055 |
+
find_msg_def('Dependency') ->
|
| 1056 |
+
[#{name => package, fnum => 1, rnum => 2, type => string, occurrence => required, opts => []},
|
| 1057 |
+
#{name => requirement, fnum => 2, rnum => 3, type => string, occurrence => required, opts => []},
|
| 1058 |
+
#{name => optional, fnum => 3, rnum => 4, type => bool, occurrence => optional, opts => []},
|
| 1059 |
+
#{name => app, fnum => 4, rnum => 5, type => string, occurrence => optional, opts => []},
|
| 1060 |
+
#{name => repository, fnum => 5, rnum => 6, type => string, occurrence => optional, opts => []}];
|
| 1061 |
+
find_msg_def(_) -> error.
|
| 1062 |
+
|
| 1063 |
+
|
| 1064 |
+
find_enum_def('RetirementReason') -> [{'RETIRED_OTHER', 0}, {'RETIRED_INVALID', 1}, {'RETIRED_SECURITY', 2}, {'RETIRED_DEPRECATED', 3}, {'RETIRED_RENAMED', 4}];
|
| 1065 |
+
find_enum_def(_) -> error.
|
| 1066 |
+
|
| 1067 |
+
|
| 1068 |
+
enum_symbol_by_value('RetirementReason', Value) -> enum_symbol_by_value_RetirementReason(Value).
|
| 1069 |
+
|
| 1070 |
+
|
| 1071 |
+
enum_value_by_symbol('RetirementReason', Sym) -> enum_value_by_symbol_RetirementReason(Sym).
|
| 1072 |
+
|
| 1073 |
+
|
| 1074 |
+
enum_symbol_by_value_RetirementReason(0) -> 'RETIRED_OTHER';
|
| 1075 |
+
enum_symbol_by_value_RetirementReason(1) -> 'RETIRED_INVALID';
|
| 1076 |
+
enum_symbol_by_value_RetirementReason(2) -> 'RETIRED_SECURITY';
|
| 1077 |
+
enum_symbol_by_value_RetirementReason(3) -> 'RETIRED_DEPRECATED';
|
| 1078 |
+
enum_symbol_by_value_RetirementReason(4) -> 'RETIRED_RENAMED'.
|
| 1079 |
+
|
| 1080 |
+
|
| 1081 |
+
enum_value_by_symbol_RetirementReason('RETIRED_OTHER') -> 0;
|
| 1082 |
+
enum_value_by_symbol_RetirementReason('RETIRED_INVALID') -> 1;
|
| 1083 |
+
enum_value_by_symbol_RetirementReason('RETIRED_SECURITY') -> 2;
|
| 1084 |
+
enum_value_by_symbol_RetirementReason('RETIRED_DEPRECATED') -> 3;
|
| 1085 |
+
enum_value_by_symbol_RetirementReason('RETIRED_RENAMED') -> 4.
|
| 1086 |
+
|
| 1087 |
+
|
| 1088 |
+
get_service_names() -> [].
|
| 1089 |
+
|
| 1090 |
+
|
| 1091 |
+
get_service_def(_) -> error.
|
| 1092 |
+
|
| 1093 |
+
|
| 1094 |
+
get_rpc_names(_) -> error.
|
| 1095 |
+
|
| 1096 |
+
|
| 1097 |
+
find_rpc_def(_, _) -> error.
|
| 1098 |
+
|
| 1099 |
+
|
| 1100 |
+
|
| 1101 |
+
-spec fetch_rpc_def(_, _) -> no_return().
|
| 1102 |
+
fetch_rpc_def(ServiceName, RpcName) -> erlang:error({no_such_rpc, ServiceName, RpcName}).
|
| 1103 |
+
|
| 1104 |
+
|
| 1105 |
+
%% Convert a a fully qualified (ie with package name) service name
|
| 1106 |
+
%% as a binary to a service name as an atom.
|
| 1107 |
+
-spec fqbin_to_service_name(_) -> no_return().
|
| 1108 |
+
fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}).
|
| 1109 |
+
|
| 1110 |
+
|
| 1111 |
+
%% Convert a service name as an atom to a fully qualified
|
| 1112 |
+
%% (ie with package name) name as a binary.
|
| 1113 |
+
-spec service_name_to_fqbin(_) -> no_return().
|
| 1114 |
+
service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}).
|
| 1115 |
+
|
| 1116 |
+
|
| 1117 |
+
%% Convert a a fully qualified (ie with package name) service name
|
| 1118 |
+
%% and an rpc name, both as binaries to a service name and an rpc
|
| 1119 |
+
%% name, as atoms.
|
| 1120 |
+
-spec fqbins_to_service_and_rpc_name(_, _) -> no_return().
|
| 1121 |
+
fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}).
|
| 1122 |
+
|
| 1123 |
+
|
| 1124 |
+
%% Convert a service name and an rpc name, both as atoms,
|
| 1125 |
+
%% to a fully qualified (ie with package name) service name and
|
| 1126 |
+
%% an rpc name as binaries.
|
| 1127 |
+
-spec service_and_rpc_name_to_fqbins(_, _) -> no_return().
|
| 1128 |
+
service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}).
|
| 1129 |
+
|
| 1130 |
+
|
| 1131 |
+
fqbin_to_msg_name(<<"Package">>) -> 'Package';
|
| 1132 |
+
fqbin_to_msg_name(<<"Release">>) -> 'Release';
|
| 1133 |
+
fqbin_to_msg_name(<<"RetirementStatus">>) -> 'RetirementStatus';
|
| 1134 |
+
fqbin_to_msg_name(<<"Dependency">>) -> 'Dependency';
|
| 1135 |
+
fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}).
|
| 1136 |
+
|
| 1137 |
+
|
| 1138 |
+
msg_name_to_fqbin('Package') -> <<"Package">>;
|
| 1139 |
+
msg_name_to_fqbin('Release') -> <<"Release">>;
|
| 1140 |
+
msg_name_to_fqbin('RetirementStatus') -> <<"RetirementStatus">>;
|
| 1141 |
+
msg_name_to_fqbin('Dependency') -> <<"Dependency">>;
|
| 1142 |
+
msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}).
|
| 1143 |
+
|
| 1144 |
+
|
| 1145 |
+
fqbin_to_enum_name(<<"RetirementReason">>) -> 'RetirementReason';
|
| 1146 |
+
fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}).
|
| 1147 |
+
|
| 1148 |
+
|
| 1149 |
+
enum_name_to_fqbin('RetirementReason') -> <<"RetirementReason">>;
|
| 1150 |
+
enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}).
|
| 1151 |
+
|
| 1152 |
+
|
| 1153 |
+
get_package_name() -> undefined.
|
| 1154 |
+
|
| 1155 |
+
|
| 1156 |
+
%% Whether or not the message names
|
| 1157 |
+
%% are prepended with package name or not.
|
| 1158 |
+
uses_packages() -> false.
|
| 1159 |
+
|
| 1160 |
+
|
| 1161 |
+
source_basename() -> "hex_pb_package.proto".
|
| 1162 |
+
|
| 1163 |
+
|
| 1164 |
+
%% Retrieve all proto file names, also imported ones.
|
| 1165 |
+
%% The order is top-down. The first element is always the main
|
| 1166 |
+
%% source file. The files are returned with extension,
|
| 1167 |
+
%% see get_all_proto_names/0 for a version that returns
|
| 1168 |
+
%% the basenames sans extension
|
| 1169 |
+
get_all_source_basenames() -> ["hex_pb_package.proto"].
|
| 1170 |
+
|
| 1171 |
+
|
| 1172 |
+
%% Retrieve all proto file names, also imported ones.
|
| 1173 |
+
%% The order is top-down. The first element is always the main
|
| 1174 |
+
%% source file. The files are returned sans .proto extension,
|
| 1175 |
+
%% to make it easier to use them with the various get_xyz_containment
|
| 1176 |
+
%% functions.
|
| 1177 |
+
get_all_proto_names() -> ["hex_pb_package"].
|
| 1178 |
+
|
| 1179 |
+
|
| 1180 |
+
get_msg_containment("hex_pb_package") -> ['Dependency', 'Package', 'Release', 'RetirementStatus'];
|
| 1181 |
+
get_msg_containment(P) -> error({gpb_error, {badproto, P}}).
|
| 1182 |
+
|
| 1183 |
+
|
| 1184 |
+
get_pkg_containment("hex_pb_package") -> undefined;
|
| 1185 |
+
get_pkg_containment(P) -> error({gpb_error, {badproto, P}}).
|
| 1186 |
+
|
| 1187 |
+
|
| 1188 |
+
get_service_containment("hex_pb_package") -> [];
|
| 1189 |
+
get_service_containment(P) -> error({gpb_error, {badproto, P}}).
|
| 1190 |
+
|
| 1191 |
+
|
| 1192 |
+
get_rpc_containment("hex_pb_package") -> [];
|
| 1193 |
+
get_rpc_containment(P) -> error({gpb_error, {badproto, P}}).
|
| 1194 |
+
|
| 1195 |
+
|
| 1196 |
+
get_enum_containment("hex_pb_package") -> ['RetirementReason'];
|
| 1197 |
+
get_enum_containment(P) -> error({gpb_error, {badproto, P}}).
|
| 1198 |
+
|
| 1199 |
+
|
| 1200 |
+
get_proto_by_msg_name_as_fqbin(<<"RetirementStatus">>) -> "hex_pb_package";
|
| 1201 |
+
get_proto_by_msg_name_as_fqbin(<<"Release">>) -> "hex_pb_package";
|
| 1202 |
+
get_proto_by_msg_name_as_fqbin(<<"Package">>) -> "hex_pb_package";
|
| 1203 |
+
get_proto_by_msg_name_as_fqbin(<<"Dependency">>) -> "hex_pb_package";
|
| 1204 |
+
get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}).
|
| 1205 |
+
|
| 1206 |
+
|
| 1207 |
+
-spec get_proto_by_service_name_as_fqbin(_) -> no_return().
|
| 1208 |
+
get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}).
|
| 1209 |
+
|
| 1210 |
+
|
| 1211 |
+
get_proto_by_enum_name_as_fqbin(<<"RetirementReason">>) -> "hex_pb_package";
|
| 1212 |
+
get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}).
|
| 1213 |
+
|
| 1214 |
+
|
| 1215 |
+
-spec get_protos_by_pkg_name_as_fqbin(_) -> no_return().
|
| 1216 |
+
get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}).
|
| 1217 |
+
|
| 1218 |
+
|
| 1219 |
+
|
| 1220 |
+
gpb_version_as_string() ->
|
| 1221 |
+
"4.21.1".
|
| 1222 |
+
|
| 1223 |
+
gpb_version_as_list() ->
|
| 1224 |
+
[4,21,1].
|
| 1225 |
+
|
| 1226 |
+
gpb_version_source() ->
|
| 1227 |
+
"file".
|
deps/eini/_build/default/plugins/hex_core/src/hex_pb_signed.erl
ADDED
|
@@ -0,0 +1,593 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%% -*- coding: utf-8 -*-
|
| 2 |
+
%% % this file is @generated
|
| 3 |
+
%% @private
|
| 4 |
+
%% Automatically generated, do not edit
|
| 5 |
+
%% Generated by gpb_compile version 4.21.1
|
| 6 |
+
%% Version source: file
|
| 7 |
+
-module(hex_pb_signed).
|
| 8 |
+
|
| 9 |
+
-export([encode_msg/2, encode_msg/3]).
|
| 10 |
+
-export([decode_msg/2, decode_msg/3]).
|
| 11 |
+
-export([merge_msgs/3, merge_msgs/4]).
|
| 12 |
+
-export([verify_msg/2, verify_msg/3]).
|
| 13 |
+
-export([get_msg_defs/0]).
|
| 14 |
+
-export([get_msg_names/0]).
|
| 15 |
+
-export([get_group_names/0]).
|
| 16 |
+
-export([get_msg_or_group_names/0]).
|
| 17 |
+
-export([get_enum_names/0]).
|
| 18 |
+
-export([find_msg_def/1, fetch_msg_def/1]).
|
| 19 |
+
-export([find_enum_def/1, fetch_enum_def/1]).
|
| 20 |
+
-export([enum_symbol_by_value/2, enum_value_by_symbol/2]).
|
| 21 |
+
-export([get_service_names/0]).
|
| 22 |
+
-export([get_service_def/1]).
|
| 23 |
+
-export([get_rpc_names/1]).
|
| 24 |
+
-export([find_rpc_def/2, fetch_rpc_def/2]).
|
| 25 |
+
-export([fqbin_to_service_name/1]).
|
| 26 |
+
-export([service_name_to_fqbin/1]).
|
| 27 |
+
-export([fqbins_to_service_and_rpc_name/2]).
|
| 28 |
+
-export([service_and_rpc_name_to_fqbins/2]).
|
| 29 |
+
-export([fqbin_to_msg_name/1]).
|
| 30 |
+
-export([msg_name_to_fqbin/1]).
|
| 31 |
+
-export([fqbin_to_enum_name/1]).
|
| 32 |
+
-export([enum_name_to_fqbin/1]).
|
| 33 |
+
-export([get_package_name/0]).
|
| 34 |
+
-export([uses_packages/0]).
|
| 35 |
+
-export([source_basename/0]).
|
| 36 |
+
-export([get_all_source_basenames/0]).
|
| 37 |
+
-export([get_all_proto_names/0]).
|
| 38 |
+
-export([get_msg_containment/1]).
|
| 39 |
+
-export([get_pkg_containment/1]).
|
| 40 |
+
-export([get_service_containment/1]).
|
| 41 |
+
-export([get_rpc_containment/1]).
|
| 42 |
+
-export([get_enum_containment/1]).
|
| 43 |
+
-export([get_proto_by_msg_name_as_fqbin/1]).
|
| 44 |
+
-export([get_proto_by_service_name_as_fqbin/1]).
|
| 45 |
+
-export([get_proto_by_enum_name_as_fqbin/1]).
|
| 46 |
+
-export([get_protos_by_pkg_name_as_fqbin/1]).
|
| 47 |
+
-export([gpb_version_as_string/0, gpb_version_as_list/0]).
|
| 48 |
+
-export([gpb_version_source/0]).
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
%% enumerated types
|
| 52 |
+
|
| 53 |
+
-export_type([]).
|
| 54 |
+
|
| 55 |
+
%% message types
|
| 56 |
+
-type 'Signed'() ::
|
| 57 |
+
#{payload => iodata(), % = 1, required
|
| 58 |
+
signature => iodata() % = 2, optional
|
| 59 |
+
}.
|
| 60 |
+
|
| 61 |
+
-export_type(['Signed'/0]).
|
| 62 |
+
-type '$msg_name'() :: 'Signed'.
|
| 63 |
+
-type '$msg'() :: 'Signed'().
|
| 64 |
+
-export_type(['$msg_name'/0, '$msg'/0]).
|
| 65 |
+
|
| 66 |
+
-if(?OTP_RELEASE >= 24).
|
| 67 |
+
-dialyzer({no_underspecs, encode_msg/2}).
|
| 68 |
+
-endif.
|
| 69 |
+
-spec encode_msg('$msg'(), '$msg_name'()) -> binary().
|
| 70 |
+
encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []).
|
| 71 |
+
|
| 72 |
+
-if(?OTP_RELEASE >= 24).
|
| 73 |
+
-dialyzer({no_underspecs, encode_msg/3}).
|
| 74 |
+
-endif.
|
| 75 |
+
-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary().
|
| 76 |
+
encode_msg(Msg, MsgName, Opts) ->
|
| 77 |
+
verify_msg(Msg, MsgName, Opts),
|
| 78 |
+
TrUserData = proplists:get_value(user_data, Opts),
|
| 79 |
+
case MsgName of 'Signed' -> encode_msg_Signed(id(Msg, TrUserData), TrUserData) end.
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
encode_msg_Signed(Msg, TrUserData) -> encode_msg_Signed(Msg, <<>>, TrUserData).
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
encode_msg_Signed(#{payload := F1} = M, Bin, TrUserData) ->
|
| 86 |
+
B1 = begin TrF1 = id(F1, TrUserData), e_type_bytes(TrF1, <<Bin/binary, 10>>, TrUserData) end,
|
| 87 |
+
case M of
|
| 88 |
+
#{signature := F2} -> begin TrF2 = id(F2, TrUserData), e_type_bytes(TrF2, <<B1/binary, 18>>, TrUserData) end;
|
| 89 |
+
_ -> B1
|
| 90 |
+
end.
|
| 91 |
+
|
| 92 |
+
-compile({nowarn_unused_function,e_type_sint/3}).
|
| 93 |
+
e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin);
|
| 94 |
+
e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin).
|
| 95 |
+
|
| 96 |
+
-compile({nowarn_unused_function,e_type_int32/3}).
|
| 97 |
+
e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <<Bin/binary, Value>>;
|
| 98 |
+
e_type_int32(Value, Bin, _TrUserData) ->
|
| 99 |
+
<<N:64/unsigned-native>> = <<Value:64/signed-native>>,
|
| 100 |
+
e_varint(N, Bin).
|
| 101 |
+
|
| 102 |
+
-compile({nowarn_unused_function,e_type_int64/3}).
|
| 103 |
+
e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <<Bin/binary, Value>>;
|
| 104 |
+
e_type_int64(Value, Bin, _TrUserData) ->
|
| 105 |
+
<<N:64/unsigned-native>> = <<Value:64/signed-native>>,
|
| 106 |
+
e_varint(N, Bin).
|
| 107 |
+
|
| 108 |
+
-compile({nowarn_unused_function,e_type_bool/3}).
|
| 109 |
+
e_type_bool(true, Bin, _TrUserData) -> <<Bin/binary, 1>>;
|
| 110 |
+
e_type_bool(false, Bin, _TrUserData) -> <<Bin/binary, 0>>;
|
| 111 |
+
e_type_bool(1, Bin, _TrUserData) -> <<Bin/binary, 1>>;
|
| 112 |
+
e_type_bool(0, Bin, _TrUserData) -> <<Bin/binary, 0>>.
|
| 113 |
+
|
| 114 |
+
-compile({nowarn_unused_function,e_type_string/3}).
|
| 115 |
+
e_type_string(S, Bin, _TrUserData) ->
|
| 116 |
+
Utf8 = unicode:characters_to_binary(S),
|
| 117 |
+
Bin2 = e_varint(byte_size(Utf8), Bin),
|
| 118 |
+
<<Bin2/binary, Utf8/binary>>.
|
| 119 |
+
|
| 120 |
+
-compile({nowarn_unused_function,e_type_bytes/3}).
|
| 121 |
+
e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) ->
|
| 122 |
+
Bin2 = e_varint(byte_size(Bytes), Bin),
|
| 123 |
+
<<Bin2/binary, Bytes/binary>>;
|
| 124 |
+
e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) ->
|
| 125 |
+
BytesBin = iolist_to_binary(Bytes),
|
| 126 |
+
Bin2 = e_varint(byte_size(BytesBin), Bin),
|
| 127 |
+
<<Bin2/binary, BytesBin/binary>>.
|
| 128 |
+
|
| 129 |
+
-compile({nowarn_unused_function,e_type_fixed32/3}).
|
| 130 |
+
e_type_fixed32(Value, Bin, _TrUserData) -> <<Bin/binary, Value:32/little>>.
|
| 131 |
+
|
| 132 |
+
-compile({nowarn_unused_function,e_type_sfixed32/3}).
|
| 133 |
+
e_type_sfixed32(Value, Bin, _TrUserData) -> <<Bin/binary, Value:32/little-signed>>.
|
| 134 |
+
|
| 135 |
+
-compile({nowarn_unused_function,e_type_fixed64/3}).
|
| 136 |
+
e_type_fixed64(Value, Bin, _TrUserData) -> <<Bin/binary, Value:64/little>>.
|
| 137 |
+
|
| 138 |
+
-compile({nowarn_unused_function,e_type_sfixed64/3}).
|
| 139 |
+
e_type_sfixed64(Value, Bin, _TrUserData) -> <<Bin/binary, Value:64/little-signed>>.
|
| 140 |
+
|
| 141 |
+
-compile({nowarn_unused_function,e_type_float/3}).
|
| 142 |
+
e_type_float(V, Bin, _) when is_number(V) -> <<Bin/binary, V:32/little-float>>;
|
| 143 |
+
e_type_float(infinity, Bin, _) -> <<Bin/binary, 0:16, 128, 127>>;
|
| 144 |
+
e_type_float('-infinity', Bin, _) -> <<Bin/binary, 0:16, 128, 255>>;
|
| 145 |
+
e_type_float(nan, Bin, _) -> <<Bin/binary, 0:16, 192, 127>>.
|
| 146 |
+
|
| 147 |
+
-compile({nowarn_unused_function,e_type_double/3}).
|
| 148 |
+
e_type_double(V, Bin, _) when is_number(V) -> <<Bin/binary, V:64/little-float>>;
|
| 149 |
+
e_type_double(infinity, Bin, _) -> <<Bin/binary, 0:48, 240, 127>>;
|
| 150 |
+
e_type_double('-infinity', Bin, _) -> <<Bin/binary, 0:48, 240, 255>>;
|
| 151 |
+
e_type_double(nan, Bin, _) -> <<Bin/binary, 0:48, 248, 127>>.
|
| 152 |
+
|
| 153 |
+
-compile({nowarn_unused_function,e_unknown_elems/2}).
|
| 154 |
+
e_unknown_elems([Elem | Rest], Bin) ->
|
| 155 |
+
BinR = case Elem of
|
| 156 |
+
{varint, FNum, N} ->
|
| 157 |
+
BinF = e_varint(FNum bsl 3, Bin),
|
| 158 |
+
e_varint(N, BinF);
|
| 159 |
+
{length_delimited, FNum, Data} ->
|
| 160 |
+
BinF = e_varint(FNum bsl 3 bor 2, Bin),
|
| 161 |
+
BinL = e_varint(byte_size(Data), BinF),
|
| 162 |
+
<<BinL/binary, Data/binary>>;
|
| 163 |
+
{group, FNum, GroupFields} ->
|
| 164 |
+
Bin1 = e_varint(FNum bsl 3 bor 3, Bin),
|
| 165 |
+
Bin2 = e_unknown_elems(GroupFields, Bin1),
|
| 166 |
+
e_varint(FNum bsl 3 bor 4, Bin2);
|
| 167 |
+
{fixed32, FNum, V} ->
|
| 168 |
+
BinF = e_varint(FNum bsl 3 bor 5, Bin),
|
| 169 |
+
<<BinF/binary, V:32/little>>;
|
| 170 |
+
{fixed64, FNum, V} ->
|
| 171 |
+
BinF = e_varint(FNum bsl 3 bor 1, Bin),
|
| 172 |
+
<<BinF/binary, V:64/little>>
|
| 173 |
+
end,
|
| 174 |
+
e_unknown_elems(Rest, BinR);
|
| 175 |
+
e_unknown_elems([], Bin) -> Bin.
|
| 176 |
+
|
| 177 |
+
-compile({nowarn_unused_function,e_varint/3}).
|
| 178 |
+
e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin).
|
| 179 |
+
|
| 180 |
+
-compile({nowarn_unused_function,e_varint/2}).
|
| 181 |
+
e_varint(N, Bin) when N =< 127 -> <<Bin/binary, N>>;
|
| 182 |
+
e_varint(N, Bin) ->
|
| 183 |
+
Bin2 = <<Bin/binary, (N band 127 bor 128)>>,
|
| 184 |
+
e_varint(N bsr 7, Bin2).
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []).
|
| 188 |
+
|
| 189 |
+
decode_msg(Bin, MsgName, Opts) when is_binary(Bin) ->
|
| 190 |
+
TrUserData = proplists:get_value(user_data, Opts),
|
| 191 |
+
decode_msg_1_catch(Bin, MsgName, TrUserData).
|
| 192 |
+
|
| 193 |
+
-ifdef('OTP_RELEASE').
|
| 194 |
+
decode_msg_1_catch(Bin, MsgName, TrUserData) ->
|
| 195 |
+
try decode_msg_2_doit(MsgName, Bin, TrUserData)
|
| 196 |
+
catch
|
| 197 |
+
error:{gpb_error,_}=Reason:StackTrace ->
|
| 198 |
+
erlang:raise(error, Reason, StackTrace);
|
| 199 |
+
Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}})
|
| 200 |
+
end.
|
| 201 |
+
-else.
|
| 202 |
+
decode_msg_1_catch(Bin, MsgName, TrUserData) ->
|
| 203 |
+
try decode_msg_2_doit(MsgName, Bin, TrUserData)
|
| 204 |
+
catch
|
| 205 |
+
error:{gpb_error,_}=Reason ->
|
| 206 |
+
erlang:raise(error, Reason,
|
| 207 |
+
erlang:get_stacktrace());
|
| 208 |
+
Class:Reason ->
|
| 209 |
+
StackTrace = erlang:get_stacktrace(),
|
| 210 |
+
error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}})
|
| 211 |
+
end.
|
| 212 |
+
-endif.
|
| 213 |
+
|
| 214 |
+
decode_msg_2_doit('Signed', Bin, TrUserData) -> id(decode_msg_Signed(Bin, TrUserData), TrUserData).
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
decode_msg_Signed(Bin, TrUserData) -> dfp_read_field_def_Signed(Bin, 0, 0, 0, id('$undef', TrUserData), id('$undef', TrUserData), TrUserData).
|
| 219 |
+
|
| 220 |
+
dfp_read_field_def_Signed(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_Signed_payload(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData);
|
| 221 |
+
dfp_read_field_def_Signed(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_Signed_signature(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData);
|
| 222 |
+
dfp_read_field_def_Signed(<<>>, 0, 0, _, F@_1, F@_2, _) ->
|
| 223 |
+
S1 = #{payload => F@_1},
|
| 224 |
+
if F@_2 == '$undef' -> S1;
|
| 225 |
+
true -> S1#{signature => F@_2}
|
| 226 |
+
end;
|
| 227 |
+
dfp_read_field_def_Signed(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_Signed(Other, Z1, Z2, F, F@_1, F@_2, TrUserData).
|
| 228 |
+
|
| 229 |
+
dg_read_field_def_Signed(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_Signed(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData);
|
| 230 |
+
dg_read_field_def_Signed(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) ->
|
| 231 |
+
Key = X bsl N + Acc,
|
| 232 |
+
case Key of
|
| 233 |
+
10 -> d_field_Signed_payload(Rest, 0, 0, 0, F@_1, F@_2, TrUserData);
|
| 234 |
+
18 -> d_field_Signed_signature(Rest, 0, 0, 0, F@_1, F@_2, TrUserData);
|
| 235 |
+
_ ->
|
| 236 |
+
case Key band 7 of
|
| 237 |
+
0 -> skip_varint_Signed(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData);
|
| 238 |
+
1 -> skip_64_Signed(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData);
|
| 239 |
+
2 -> skip_length_delimited_Signed(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData);
|
| 240 |
+
3 -> skip_group_Signed(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData);
|
| 241 |
+
5 -> skip_32_Signed(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData)
|
| 242 |
+
end
|
| 243 |
+
end;
|
| 244 |
+
dg_read_field_def_Signed(<<>>, 0, 0, _, F@_1, F@_2, _) ->
|
| 245 |
+
S1 = #{payload => F@_1},
|
| 246 |
+
if F@_2 == '$undef' -> S1;
|
| 247 |
+
true -> S1#{signature => F@_2}
|
| 248 |
+
end.
|
| 249 |
+
|
| 250 |
+
d_field_Signed_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_Signed_payload(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData);
|
| 251 |
+
d_field_Signed_payload(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) ->
|
| 252 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
| 253 |
+
dfp_read_field_def_Signed(RestF, 0, 0, F, NewFValue, F@_2, TrUserData).
|
| 254 |
+
|
| 255 |
+
d_field_Signed_signature(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_Signed_signature(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData);
|
| 256 |
+
d_field_Signed_signature(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) ->
|
| 257 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
| 258 |
+
dfp_read_field_def_Signed(RestF, 0, 0, F, F@_1, NewFValue, TrUserData).
|
| 259 |
+
|
| 260 |
+
skip_varint_Signed(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_Signed(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData);
|
| 261 |
+
skip_varint_Signed(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Signed(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData).
|
| 262 |
+
|
| 263 |
+
skip_length_delimited_Signed(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_Signed(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData);
|
| 264 |
+
skip_length_delimited_Signed(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) ->
|
| 265 |
+
Length = X bsl N + Acc,
|
| 266 |
+
<<_:Length/binary, Rest2/binary>> = Rest,
|
| 267 |
+
dfp_read_field_def_Signed(Rest2, 0, 0, F, F@_1, F@_2, TrUserData).
|
| 268 |
+
|
| 269 |
+
skip_group_Signed(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) ->
|
| 270 |
+
{_, Rest} = read_group(Bin, FNum),
|
| 271 |
+
dfp_read_field_def_Signed(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData).
|
| 272 |
+
|
| 273 |
+
skip_32_Signed(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Signed(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData).
|
| 274 |
+
|
| 275 |
+
skip_64_Signed(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Signed(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData).
|
| 276 |
+
|
| 277 |
+
read_group(Bin, FieldNum) ->
|
| 278 |
+
{NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum),
|
| 279 |
+
<<Group:NumBytes/binary, _:EndTagLen/binary, Rest/binary>> = Bin,
|
| 280 |
+
{Group, Rest}.
|
| 281 |
+
|
| 282 |
+
%% Like skipping over fields, but record the total length,
|
| 283 |
+
%% Each field is <(FieldNum bsl 3) bor FieldType> ++ <FieldValue>
|
| 284 |
+
%% Record the length because varints may be non-optimally encoded.
|
| 285 |
+
%%
|
| 286 |
+
%% Groups can be nested, but assume the same FieldNum cannot be nested
|
| 287 |
+
%% because group field numbers are shared with the rest of the fields
|
| 288 |
+
%% numbers. Thus we can search just for an group-end with the same
|
| 289 |
+
%% field number.
|
| 290 |
+
%%
|
| 291 |
+
%% (The only time the same group field number could occur would
|
| 292 |
+
%% be in a nested sub message, but then it would be inside a
|
| 293 |
+
%% length-delimited entry, which we skip-read by length.)
|
| 294 |
+
read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum)
|
| 295 |
+
when N < (32-7) ->
|
| 296 |
+
read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum);
|
| 297 |
+
read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen,
|
| 298 |
+
FieldNum) ->
|
| 299 |
+
Key = X bsl N + Acc,
|
| 300 |
+
TagLen1 = TagLen + 1,
|
| 301 |
+
case {Key bsr 3, Key band 7} of
|
| 302 |
+
{FieldNum, 4} -> % 4 = group_end
|
| 303 |
+
{NumBytes, TagLen1};
|
| 304 |
+
{_, 0} -> % 0 = varint
|
| 305 |
+
read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum);
|
| 306 |
+
{_, 1} -> % 1 = bits64
|
| 307 |
+
<<_:64, Tl2/binary>> = Tl,
|
| 308 |
+
read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum);
|
| 309 |
+
{_, 2} -> % 2 = length_delimited
|
| 310 |
+
read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum);
|
| 311 |
+
{_, 3} -> % 3 = group_start
|
| 312 |
+
read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum);
|
| 313 |
+
{_, 4} -> % 4 = group_end
|
| 314 |
+
read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum);
|
| 315 |
+
{_, 5} -> % 5 = bits32
|
| 316 |
+
<<_:32, Tl2/binary>> = Tl,
|
| 317 |
+
read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum)
|
| 318 |
+
end.
|
| 319 |
+
|
| 320 |
+
read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum)
|
| 321 |
+
when N < (64-7) ->
|
| 322 |
+
read_gr_vi(Tl, N+7, NumBytes+1, FieldNum);
|
| 323 |
+
read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) ->
|
| 324 |
+
read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum).
|
| 325 |
+
|
| 326 |
+
read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum)
|
| 327 |
+
when N < (64-7) ->
|
| 328 |
+
read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum);
|
| 329 |
+
read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) ->
|
| 330 |
+
Len = X bsl N + Acc,
|
| 331 |
+
NumBytes1 = NumBytes + 1,
|
| 332 |
+
<<_:Len/binary, Tl2/binary>> = Tl,
|
| 333 |
+
read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum).
|
| 334 |
+
|
| 335 |
+
merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []).
|
| 336 |
+
|
| 337 |
+
merge_msgs(Prev, New, MsgName, Opts) ->
|
| 338 |
+
TrUserData = proplists:get_value(user_data, Opts),
|
| 339 |
+
case MsgName of 'Signed' -> merge_msg_Signed(Prev, New, TrUserData) end.
|
| 340 |
+
|
| 341 |
+
-compile({nowarn_unused_function,merge_msg_Signed/3}).
|
| 342 |
+
merge_msg_Signed(#{} = PMsg, #{payload := NFpayload} = NMsg, _) ->
|
| 343 |
+
S1 = #{payload => NFpayload},
|
| 344 |
+
case {PMsg, NMsg} of
|
| 345 |
+
{_, #{signature := NFsignature}} -> S1#{signature => NFsignature};
|
| 346 |
+
{#{signature := PFsignature}, _} -> S1#{signature => PFsignature};
|
| 347 |
+
_ -> S1
|
| 348 |
+
end.
|
| 349 |
+
|
| 350 |
+
|
| 351 |
+
verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []).
|
| 352 |
+
|
| 353 |
+
verify_msg(Msg, MsgName, Opts) ->
|
| 354 |
+
TrUserData = proplists:get_value(user_data, Opts),
|
| 355 |
+
case MsgName of
|
| 356 |
+
'Signed' -> v_msg_Signed(Msg, [MsgName], TrUserData);
|
| 357 |
+
_ -> mk_type_error(not_a_known_message, Msg, [])
|
| 358 |
+
end.
|
| 359 |
+
|
| 360 |
+
|
| 361 |
+
-compile({nowarn_unused_function,v_msg_Signed/3}).
|
| 362 |
+
-dialyzer({nowarn_function,v_msg_Signed/3}).
|
| 363 |
+
v_msg_Signed(#{payload := F1} = M, Path, TrUserData) ->
|
| 364 |
+
v_type_bytes(F1, [payload | Path], TrUserData),
|
| 365 |
+
case M of
|
| 366 |
+
#{signature := F2} -> v_type_bytes(F2, [signature | Path], TrUserData);
|
| 367 |
+
_ -> ok
|
| 368 |
+
end,
|
| 369 |
+
lists:foreach(fun (payload) -> ok;
|
| 370 |
+
(signature) -> ok;
|
| 371 |
+
(OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path)
|
| 372 |
+
end,
|
| 373 |
+
maps:keys(M)),
|
| 374 |
+
ok;
|
| 375 |
+
v_msg_Signed(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [payload] -- maps:keys(M), 'Signed'}, M, Path);
|
| 376 |
+
v_msg_Signed(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Signed'}, X, Path).
|
| 377 |
+
|
| 378 |
+
-compile({nowarn_unused_function,v_type_bytes/3}).
|
| 379 |
+
-dialyzer({nowarn_function,v_type_bytes/3}).
|
| 380 |
+
v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> ok;
|
| 381 |
+
v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> ok;
|
| 382 |
+
v_type_bytes(X, Path, _TrUserData) -> mk_type_error(bad_binary_value, X, Path).
|
| 383 |
+
|
| 384 |
+
-compile({nowarn_unused_function,mk_type_error/3}).
|
| 385 |
+
-spec mk_type_error(_, _, list()) -> no_return().
|
| 386 |
+
mk_type_error(Error, ValueSeen, Path) ->
|
| 387 |
+
Path2 = prettify_path(Path),
|
| 388 |
+
erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}).
|
| 389 |
+
|
| 390 |
+
|
| 391 |
+
-compile({nowarn_unused_function,prettify_path/1}).
|
| 392 |
+
-dialyzer({nowarn_function,prettify_path/1}).
|
| 393 |
+
prettify_path([]) -> top_level;
|
| 394 |
+
prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))).
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
-compile({nowarn_unused_function,id/2}).
|
| 398 |
+
-compile({inline,id/2}).
|
| 399 |
+
id(X, _TrUserData) -> X.
|
| 400 |
+
|
| 401 |
+
-compile({nowarn_unused_function,v_ok/3}).
|
| 402 |
+
-compile({inline,v_ok/3}).
|
| 403 |
+
v_ok(_Value, _Path, _TrUserData) -> ok.
|
| 404 |
+
|
| 405 |
+
-compile({nowarn_unused_function,m_overwrite/3}).
|
| 406 |
+
-compile({inline,m_overwrite/3}).
|
| 407 |
+
m_overwrite(_Prev, New, _TrUserData) -> New.
|
| 408 |
+
|
| 409 |
+
-compile({nowarn_unused_function,cons/3}).
|
| 410 |
+
-compile({inline,cons/3}).
|
| 411 |
+
cons(Elem, Acc, _TrUserData) -> [Elem | Acc].
|
| 412 |
+
|
| 413 |
+
-compile({nowarn_unused_function,lists_reverse/2}).
|
| 414 |
+
-compile({inline,lists_reverse/2}).
|
| 415 |
+
'lists_reverse'(L, _TrUserData) -> lists:reverse(L).
|
| 416 |
+
-compile({nowarn_unused_function,'erlang_++'/3}).
|
| 417 |
+
-compile({inline,'erlang_++'/3}).
|
| 418 |
+
'erlang_++'(A, B, _TrUserData) -> A ++ B.
|
| 419 |
+
|
| 420 |
+
|
| 421 |
+
get_msg_defs() -> [{{msg, 'Signed'}, [#{name => payload, fnum => 1, rnum => 2, type => bytes, occurrence => required, opts => []}, #{name => signature, fnum => 2, rnum => 3, type => bytes, occurrence => optional, opts => []}]}].
|
| 422 |
+
|
| 423 |
+
|
| 424 |
+
get_msg_names() -> ['Signed'].
|
| 425 |
+
|
| 426 |
+
|
| 427 |
+
get_group_names() -> [].
|
| 428 |
+
|
| 429 |
+
|
| 430 |
+
get_msg_or_group_names() -> ['Signed'].
|
| 431 |
+
|
| 432 |
+
|
| 433 |
+
get_enum_names() -> [].
|
| 434 |
+
|
| 435 |
+
|
| 436 |
+
fetch_msg_def(MsgName) ->
|
| 437 |
+
case find_msg_def(MsgName) of
|
| 438 |
+
Fs when is_list(Fs) -> Fs;
|
| 439 |
+
error -> erlang:error({no_such_msg, MsgName})
|
| 440 |
+
end.
|
| 441 |
+
|
| 442 |
+
|
| 443 |
+
-spec fetch_enum_def(_) -> no_return().
|
| 444 |
+
fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}).
|
| 445 |
+
|
| 446 |
+
|
| 447 |
+
find_msg_def('Signed') -> [#{name => payload, fnum => 1, rnum => 2, type => bytes, occurrence => required, opts => []}, #{name => signature, fnum => 2, rnum => 3, type => bytes, occurrence => optional, opts => []}];
|
| 448 |
+
find_msg_def(_) -> error.
|
| 449 |
+
|
| 450 |
+
|
| 451 |
+
find_enum_def(_) -> error.
|
| 452 |
+
|
| 453 |
+
|
| 454 |
+
-spec enum_symbol_by_value(_, _) -> no_return().
|
| 455 |
+
enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}).
|
| 456 |
+
|
| 457 |
+
|
| 458 |
+
-spec enum_value_by_symbol(_, _) -> no_return().
|
| 459 |
+
enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}).
|
| 460 |
+
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
get_service_names() -> [].
|
| 464 |
+
|
| 465 |
+
|
| 466 |
+
get_service_def(_) -> error.
|
| 467 |
+
|
| 468 |
+
|
| 469 |
+
get_rpc_names(_) -> error.
|
| 470 |
+
|
| 471 |
+
|
| 472 |
+
find_rpc_def(_, _) -> error.
|
| 473 |
+
|
| 474 |
+
|
| 475 |
+
|
| 476 |
+
-spec fetch_rpc_def(_, _) -> no_return().
|
| 477 |
+
fetch_rpc_def(ServiceName, RpcName) -> erlang:error({no_such_rpc, ServiceName, RpcName}).
|
| 478 |
+
|
| 479 |
+
|
| 480 |
+
%% Convert a a fully qualified (ie with package name) service name
|
| 481 |
+
%% as a binary to a service name as an atom.
|
| 482 |
+
-spec fqbin_to_service_name(_) -> no_return().
|
| 483 |
+
fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}).
|
| 484 |
+
|
| 485 |
+
|
| 486 |
+
%% Convert a service name as an atom to a fully qualified
|
| 487 |
+
%% (ie with package name) name as a binary.
|
| 488 |
+
-spec service_name_to_fqbin(_) -> no_return().
|
| 489 |
+
service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}).
|
| 490 |
+
|
| 491 |
+
|
| 492 |
+
%% Convert a a fully qualified (ie with package name) service name
|
| 493 |
+
%% and an rpc name, both as binaries to a service name and an rpc
|
| 494 |
+
%% name, as atoms.
|
| 495 |
+
-spec fqbins_to_service_and_rpc_name(_, _) -> no_return().
|
| 496 |
+
fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}).
|
| 497 |
+
|
| 498 |
+
|
| 499 |
+
%% Convert a service name and an rpc name, both as atoms,
|
| 500 |
+
%% to a fully qualified (ie with package name) service name and
|
| 501 |
+
%% an rpc name as binaries.
|
| 502 |
+
-spec service_and_rpc_name_to_fqbins(_, _) -> no_return().
|
| 503 |
+
service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}).
|
| 504 |
+
|
| 505 |
+
|
| 506 |
+
fqbin_to_msg_name(<<"Signed">>) -> 'Signed';
|
| 507 |
+
fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}).
|
| 508 |
+
|
| 509 |
+
|
| 510 |
+
msg_name_to_fqbin('Signed') -> <<"Signed">>;
|
| 511 |
+
msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}).
|
| 512 |
+
|
| 513 |
+
|
| 514 |
+
-spec fqbin_to_enum_name(_) -> no_return().
|
| 515 |
+
fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}).
|
| 516 |
+
|
| 517 |
+
|
| 518 |
+
-spec enum_name_to_fqbin(_) -> no_return().
|
| 519 |
+
enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}).
|
| 520 |
+
|
| 521 |
+
|
| 522 |
+
get_package_name() -> undefined.
|
| 523 |
+
|
| 524 |
+
|
| 525 |
+
%% Whether or not the message names
|
| 526 |
+
%% are prepended with package name or not.
|
| 527 |
+
uses_packages() -> false.
|
| 528 |
+
|
| 529 |
+
|
| 530 |
+
source_basename() -> "hex_pb_signed.proto".
|
| 531 |
+
|
| 532 |
+
|
| 533 |
+
%% Retrieve all proto file names, also imported ones.
|
| 534 |
+
%% The order is top-down. The first element is always the main
|
| 535 |
+
%% source file. The files are returned with extension,
|
| 536 |
+
%% see get_all_proto_names/0 for a version that returns
|
| 537 |
+
%% the basenames sans extension
|
| 538 |
+
get_all_source_basenames() -> ["hex_pb_signed.proto"].
|
| 539 |
+
|
| 540 |
+
|
| 541 |
+
%% Retrieve all proto file names, also imported ones.
|
| 542 |
+
%% The order is top-down. The first element is always the main
|
| 543 |
+
%% source file. The files are returned sans .proto extension,
|
| 544 |
+
%% to make it easier to use them with the various get_xyz_containment
|
| 545 |
+
%% functions.
|
| 546 |
+
get_all_proto_names() -> ["hex_pb_signed"].
|
| 547 |
+
|
| 548 |
+
|
| 549 |
+
get_msg_containment("hex_pb_signed") -> ['Signed'];
|
| 550 |
+
get_msg_containment(P) -> error({gpb_error, {badproto, P}}).
|
| 551 |
+
|
| 552 |
+
|
| 553 |
+
get_pkg_containment("hex_pb_signed") -> undefined;
|
| 554 |
+
get_pkg_containment(P) -> error({gpb_error, {badproto, P}}).
|
| 555 |
+
|
| 556 |
+
|
| 557 |
+
get_service_containment("hex_pb_signed") -> [];
|
| 558 |
+
get_service_containment(P) -> error({gpb_error, {badproto, P}}).
|
| 559 |
+
|
| 560 |
+
|
| 561 |
+
get_rpc_containment("hex_pb_signed") -> [];
|
| 562 |
+
get_rpc_containment(P) -> error({gpb_error, {badproto, P}}).
|
| 563 |
+
|
| 564 |
+
|
| 565 |
+
get_enum_containment("hex_pb_signed") -> [];
|
| 566 |
+
get_enum_containment(P) -> error({gpb_error, {badproto, P}}).
|
| 567 |
+
|
| 568 |
+
|
| 569 |
+
get_proto_by_msg_name_as_fqbin(<<"Signed">>) -> "hex_pb_signed";
|
| 570 |
+
get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}).
|
| 571 |
+
|
| 572 |
+
|
| 573 |
+
-spec get_proto_by_service_name_as_fqbin(_) -> no_return().
|
| 574 |
+
get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}).
|
| 575 |
+
|
| 576 |
+
|
| 577 |
+
-spec get_proto_by_enum_name_as_fqbin(_) -> no_return().
|
| 578 |
+
get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}).
|
| 579 |
+
|
| 580 |
+
|
| 581 |
+
-spec get_protos_by_pkg_name_as_fqbin(_) -> no_return().
|
| 582 |
+
get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}).
|
| 583 |
+
|
| 584 |
+
|
| 585 |
+
|
| 586 |
+
gpb_version_as_string() ->
|
| 587 |
+
"4.21.1".
|
| 588 |
+
|
| 589 |
+
gpb_version_as_list() ->
|
| 590 |
+
[4,21,1].
|
| 591 |
+
|
| 592 |
+
gpb_version_source() ->
|
| 593 |
+
"file".
|
deps/eini/_build/default/plugins/hex_core/src/hex_pb_versions.erl
ADDED
|
@@ -0,0 +1,816 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%% -*- coding: utf-8 -*-
|
| 2 |
+
%% % this file is @generated
|
| 3 |
+
%% @private
|
| 4 |
+
%% Automatically generated, do not edit
|
| 5 |
+
%% Generated by gpb_compile version 4.21.1
|
| 6 |
+
%% Version source: file
|
| 7 |
+
-module(hex_pb_versions).
|
| 8 |
+
|
| 9 |
+
-export([encode_msg/2, encode_msg/3]).
|
| 10 |
+
-export([decode_msg/2, decode_msg/3]).
|
| 11 |
+
-export([merge_msgs/3, merge_msgs/4]).
|
| 12 |
+
-export([verify_msg/2, verify_msg/3]).
|
| 13 |
+
-export([get_msg_defs/0]).
|
| 14 |
+
-export([get_msg_names/0]).
|
| 15 |
+
-export([get_group_names/0]).
|
| 16 |
+
-export([get_msg_or_group_names/0]).
|
| 17 |
+
-export([get_enum_names/0]).
|
| 18 |
+
-export([find_msg_def/1, fetch_msg_def/1]).
|
| 19 |
+
-export([find_enum_def/1, fetch_enum_def/1]).
|
| 20 |
+
-export([enum_symbol_by_value/2, enum_value_by_symbol/2]).
|
| 21 |
+
-export([get_service_names/0]).
|
| 22 |
+
-export([get_service_def/1]).
|
| 23 |
+
-export([get_rpc_names/1]).
|
| 24 |
+
-export([find_rpc_def/2, fetch_rpc_def/2]).
|
| 25 |
+
-export([fqbin_to_service_name/1]).
|
| 26 |
+
-export([service_name_to_fqbin/1]).
|
| 27 |
+
-export([fqbins_to_service_and_rpc_name/2]).
|
| 28 |
+
-export([service_and_rpc_name_to_fqbins/2]).
|
| 29 |
+
-export([fqbin_to_msg_name/1]).
|
| 30 |
+
-export([msg_name_to_fqbin/1]).
|
| 31 |
+
-export([fqbin_to_enum_name/1]).
|
| 32 |
+
-export([enum_name_to_fqbin/1]).
|
| 33 |
+
-export([get_package_name/0]).
|
| 34 |
+
-export([uses_packages/0]).
|
| 35 |
+
-export([source_basename/0]).
|
| 36 |
+
-export([get_all_source_basenames/0]).
|
| 37 |
+
-export([get_all_proto_names/0]).
|
| 38 |
+
-export([get_msg_containment/1]).
|
| 39 |
+
-export([get_pkg_containment/1]).
|
| 40 |
+
-export([get_service_containment/1]).
|
| 41 |
+
-export([get_rpc_containment/1]).
|
| 42 |
+
-export([get_enum_containment/1]).
|
| 43 |
+
-export([get_proto_by_msg_name_as_fqbin/1]).
|
| 44 |
+
-export([get_proto_by_service_name_as_fqbin/1]).
|
| 45 |
+
-export([get_proto_by_enum_name_as_fqbin/1]).
|
| 46 |
+
-export([get_protos_by_pkg_name_as_fqbin/1]).
|
| 47 |
+
-export([gpb_version_as_string/0, gpb_version_as_list/0]).
|
| 48 |
+
-export([gpb_version_source/0]).
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
%% enumerated types
|
| 52 |
+
|
| 53 |
+
-export_type([]).
|
| 54 |
+
|
| 55 |
+
%% message types
|
| 56 |
+
-type 'Versions'() ::
|
| 57 |
+
#{packages => ['Package'()], % = 1, repeated
|
| 58 |
+
repository => unicode:chardata() % = 2, required
|
| 59 |
+
}.
|
| 60 |
+
|
| 61 |
+
-type 'Package'() ::
|
| 62 |
+
#{name => unicode:chardata(), % = 1, required
|
| 63 |
+
versions => [unicode:chardata()], % = 2, repeated
|
| 64 |
+
retired => [integer()] % = 3, repeated, 32 bits
|
| 65 |
+
}.
|
| 66 |
+
|
| 67 |
+
-export_type(['Versions'/0, 'Package'/0]).
|
| 68 |
+
-type '$msg_name'() :: 'Versions' | 'Package'.
|
| 69 |
+
-type '$msg'() :: 'Versions'() | 'Package'().
|
| 70 |
+
-export_type(['$msg_name'/0, '$msg'/0]).
|
| 71 |
+
|
| 72 |
+
-if(?OTP_RELEASE >= 24).
|
| 73 |
+
-dialyzer({no_underspecs, encode_msg/2}).
|
| 74 |
+
-endif.
|
| 75 |
+
-spec encode_msg('$msg'(), '$msg_name'()) -> binary().
|
| 76 |
+
encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []).
|
| 77 |
+
|
| 78 |
+
-if(?OTP_RELEASE >= 24).
|
| 79 |
+
-dialyzer({no_underspecs, encode_msg/3}).
|
| 80 |
+
-endif.
|
| 81 |
+
-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary().
|
| 82 |
+
encode_msg(Msg, MsgName, Opts) ->
|
| 83 |
+
verify_msg(Msg, MsgName, Opts),
|
| 84 |
+
TrUserData = proplists:get_value(user_data, Opts),
|
| 85 |
+
case MsgName of
|
| 86 |
+
'Versions' -> encode_msg_Versions(id(Msg, TrUserData), TrUserData);
|
| 87 |
+
'Package' -> encode_msg_Package(id(Msg, TrUserData), TrUserData)
|
| 88 |
+
end.
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
encode_msg_Versions(Msg, TrUserData) -> encode_msg_Versions(Msg, <<>>, TrUserData).
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
encode_msg_Versions(#{repository := F2} = M, Bin, TrUserData) ->
|
| 95 |
+
B1 = case M of
|
| 96 |
+
#{packages := F1} ->
|
| 97 |
+
TrF1 = id(F1, TrUserData),
|
| 98 |
+
if TrF1 == [] -> Bin;
|
| 99 |
+
true -> e_field_Versions_packages(TrF1, Bin, TrUserData)
|
| 100 |
+
end;
|
| 101 |
+
_ -> Bin
|
| 102 |
+
end,
|
| 103 |
+
begin TrF2 = id(F2, TrUserData), e_type_string(TrF2, <<B1/binary, 18>>, TrUserData) end.
|
| 104 |
+
|
| 105 |
+
encode_msg_Package(Msg, TrUserData) -> encode_msg_Package(Msg, <<>>, TrUserData).
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
encode_msg_Package(#{name := F1} = M, Bin, TrUserData) ->
|
| 109 |
+
B1 = begin TrF1 = id(F1, TrUserData), e_type_string(TrF1, <<Bin/binary, 10>>, TrUserData) end,
|
| 110 |
+
B2 = case M of
|
| 111 |
+
#{versions := F2} ->
|
| 112 |
+
TrF2 = id(F2, TrUserData),
|
| 113 |
+
if TrF2 == [] -> B1;
|
| 114 |
+
true -> e_field_Package_versions(TrF2, B1, TrUserData)
|
| 115 |
+
end;
|
| 116 |
+
_ -> B1
|
| 117 |
+
end,
|
| 118 |
+
case M of
|
| 119 |
+
#{retired := F3} ->
|
| 120 |
+
TrF3 = id(F3, TrUserData),
|
| 121 |
+
if TrF3 == [] -> B2;
|
| 122 |
+
true -> e_field_Package_retired(TrF3, B2, TrUserData)
|
| 123 |
+
end;
|
| 124 |
+
_ -> B2
|
| 125 |
+
end.
|
| 126 |
+
|
| 127 |
+
e_mfield_Versions_packages(Msg, Bin, TrUserData) ->
|
| 128 |
+
SubBin = encode_msg_Package(Msg, <<>>, TrUserData),
|
| 129 |
+
Bin2 = e_varint(byte_size(SubBin), Bin),
|
| 130 |
+
<<Bin2/binary, SubBin/binary>>.
|
| 131 |
+
|
| 132 |
+
e_field_Versions_packages([Elem | Rest], Bin, TrUserData) ->
|
| 133 |
+
Bin2 = <<Bin/binary, 10>>,
|
| 134 |
+
Bin3 = e_mfield_Versions_packages(id(Elem, TrUserData), Bin2, TrUserData),
|
| 135 |
+
e_field_Versions_packages(Rest, Bin3, TrUserData);
|
| 136 |
+
e_field_Versions_packages([], Bin, _TrUserData) -> Bin.
|
| 137 |
+
|
| 138 |
+
e_field_Package_versions([Elem | Rest], Bin, TrUserData) ->
|
| 139 |
+
Bin2 = <<Bin/binary, 18>>,
|
| 140 |
+
Bin3 = e_type_string(id(Elem, TrUserData), Bin2, TrUserData),
|
| 141 |
+
e_field_Package_versions(Rest, Bin3, TrUserData);
|
| 142 |
+
e_field_Package_versions([], Bin, _TrUserData) -> Bin.
|
| 143 |
+
|
| 144 |
+
e_field_Package_retired(Elems, Bin, TrUserData) when Elems =/= [] ->
|
| 145 |
+
SubBin = e_pfield_Package_retired(Elems, <<>>, TrUserData),
|
| 146 |
+
Bin2 = <<Bin/binary, 26>>,
|
| 147 |
+
Bin3 = e_varint(byte_size(SubBin), Bin2),
|
| 148 |
+
<<Bin3/binary, SubBin/binary>>;
|
| 149 |
+
e_field_Package_retired([], Bin, _TrUserData) -> Bin.
|
| 150 |
+
|
| 151 |
+
e_pfield_Package_retired([Value | Rest], Bin, TrUserData) ->
|
| 152 |
+
Bin2 = e_type_int32(id(Value, TrUserData), Bin, TrUserData),
|
| 153 |
+
e_pfield_Package_retired(Rest, Bin2, TrUserData);
|
| 154 |
+
e_pfield_Package_retired([], Bin, _TrUserData) -> Bin.
|
| 155 |
+
|
| 156 |
+
-compile({nowarn_unused_function,e_type_sint/3}).
|
| 157 |
+
e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin);
|
| 158 |
+
e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin).
|
| 159 |
+
|
| 160 |
+
-compile({nowarn_unused_function,e_type_int32/3}).
|
| 161 |
+
e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <<Bin/binary, Value>>;
|
| 162 |
+
e_type_int32(Value, Bin, _TrUserData) ->
|
| 163 |
+
<<N:64/unsigned-native>> = <<Value:64/signed-native>>,
|
| 164 |
+
e_varint(N, Bin).
|
| 165 |
+
|
| 166 |
+
-compile({nowarn_unused_function,e_type_int64/3}).
|
| 167 |
+
e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <<Bin/binary, Value>>;
|
| 168 |
+
e_type_int64(Value, Bin, _TrUserData) ->
|
| 169 |
+
<<N:64/unsigned-native>> = <<Value:64/signed-native>>,
|
| 170 |
+
e_varint(N, Bin).
|
| 171 |
+
|
| 172 |
+
-compile({nowarn_unused_function,e_type_bool/3}).
|
| 173 |
+
e_type_bool(true, Bin, _TrUserData) -> <<Bin/binary, 1>>;
|
| 174 |
+
e_type_bool(false, Bin, _TrUserData) -> <<Bin/binary, 0>>;
|
| 175 |
+
e_type_bool(1, Bin, _TrUserData) -> <<Bin/binary, 1>>;
|
| 176 |
+
e_type_bool(0, Bin, _TrUserData) -> <<Bin/binary, 0>>.
|
| 177 |
+
|
| 178 |
+
-compile({nowarn_unused_function,e_type_string/3}).
|
| 179 |
+
e_type_string(S, Bin, _TrUserData) ->
|
| 180 |
+
Utf8 = unicode:characters_to_binary(S),
|
| 181 |
+
Bin2 = e_varint(byte_size(Utf8), Bin),
|
| 182 |
+
<<Bin2/binary, Utf8/binary>>.
|
| 183 |
+
|
| 184 |
+
-compile({nowarn_unused_function,e_type_bytes/3}).
|
| 185 |
+
e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) ->
|
| 186 |
+
Bin2 = e_varint(byte_size(Bytes), Bin),
|
| 187 |
+
<<Bin2/binary, Bytes/binary>>;
|
| 188 |
+
e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) ->
|
| 189 |
+
BytesBin = iolist_to_binary(Bytes),
|
| 190 |
+
Bin2 = e_varint(byte_size(BytesBin), Bin),
|
| 191 |
+
<<Bin2/binary, BytesBin/binary>>.
|
| 192 |
+
|
| 193 |
+
-compile({nowarn_unused_function,e_type_fixed32/3}).
|
| 194 |
+
e_type_fixed32(Value, Bin, _TrUserData) -> <<Bin/binary, Value:32/little>>.
|
| 195 |
+
|
| 196 |
+
-compile({nowarn_unused_function,e_type_sfixed32/3}).
|
| 197 |
+
e_type_sfixed32(Value, Bin, _TrUserData) -> <<Bin/binary, Value:32/little-signed>>.
|
| 198 |
+
|
| 199 |
+
-compile({nowarn_unused_function,e_type_fixed64/3}).
|
| 200 |
+
e_type_fixed64(Value, Bin, _TrUserData) -> <<Bin/binary, Value:64/little>>.
|
| 201 |
+
|
| 202 |
+
-compile({nowarn_unused_function,e_type_sfixed64/3}).
|
| 203 |
+
e_type_sfixed64(Value, Bin, _TrUserData) -> <<Bin/binary, Value:64/little-signed>>.
|
| 204 |
+
|
| 205 |
+
-compile({nowarn_unused_function,e_type_float/3}).
|
| 206 |
+
e_type_float(V, Bin, _) when is_number(V) -> <<Bin/binary, V:32/little-float>>;
|
| 207 |
+
e_type_float(infinity, Bin, _) -> <<Bin/binary, 0:16, 128, 127>>;
|
| 208 |
+
e_type_float('-infinity', Bin, _) -> <<Bin/binary, 0:16, 128, 255>>;
|
| 209 |
+
e_type_float(nan, Bin, _) -> <<Bin/binary, 0:16, 192, 127>>.
|
| 210 |
+
|
| 211 |
+
-compile({nowarn_unused_function,e_type_double/3}).
|
| 212 |
+
e_type_double(V, Bin, _) when is_number(V) -> <<Bin/binary, V:64/little-float>>;
|
| 213 |
+
e_type_double(infinity, Bin, _) -> <<Bin/binary, 0:48, 240, 127>>;
|
| 214 |
+
e_type_double('-infinity', Bin, _) -> <<Bin/binary, 0:48, 240, 255>>;
|
| 215 |
+
e_type_double(nan, Bin, _) -> <<Bin/binary, 0:48, 248, 127>>.
|
| 216 |
+
|
| 217 |
+
-compile({nowarn_unused_function,e_unknown_elems/2}).
|
| 218 |
+
e_unknown_elems([Elem | Rest], Bin) ->
|
| 219 |
+
BinR = case Elem of
|
| 220 |
+
{varint, FNum, N} ->
|
| 221 |
+
BinF = e_varint(FNum bsl 3, Bin),
|
| 222 |
+
e_varint(N, BinF);
|
| 223 |
+
{length_delimited, FNum, Data} ->
|
| 224 |
+
BinF = e_varint(FNum bsl 3 bor 2, Bin),
|
| 225 |
+
BinL = e_varint(byte_size(Data), BinF),
|
| 226 |
+
<<BinL/binary, Data/binary>>;
|
| 227 |
+
{group, FNum, GroupFields} ->
|
| 228 |
+
Bin1 = e_varint(FNum bsl 3 bor 3, Bin),
|
| 229 |
+
Bin2 = e_unknown_elems(GroupFields, Bin1),
|
| 230 |
+
e_varint(FNum bsl 3 bor 4, Bin2);
|
| 231 |
+
{fixed32, FNum, V} ->
|
| 232 |
+
BinF = e_varint(FNum bsl 3 bor 5, Bin),
|
| 233 |
+
<<BinF/binary, V:32/little>>;
|
| 234 |
+
{fixed64, FNum, V} ->
|
| 235 |
+
BinF = e_varint(FNum bsl 3 bor 1, Bin),
|
| 236 |
+
<<BinF/binary, V:64/little>>
|
| 237 |
+
end,
|
| 238 |
+
e_unknown_elems(Rest, BinR);
|
| 239 |
+
e_unknown_elems([], Bin) -> Bin.
|
| 240 |
+
|
| 241 |
+
-compile({nowarn_unused_function,e_varint/3}).
|
| 242 |
+
e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin).
|
| 243 |
+
|
| 244 |
+
-compile({nowarn_unused_function,e_varint/2}).
|
| 245 |
+
e_varint(N, Bin) when N =< 127 -> <<Bin/binary, N>>;
|
| 246 |
+
e_varint(N, Bin) ->
|
| 247 |
+
Bin2 = <<Bin/binary, (N band 127 bor 128)>>,
|
| 248 |
+
e_varint(N bsr 7, Bin2).
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []).
|
| 252 |
+
|
| 253 |
+
decode_msg(Bin, MsgName, Opts) when is_binary(Bin) ->
|
| 254 |
+
TrUserData = proplists:get_value(user_data, Opts),
|
| 255 |
+
decode_msg_1_catch(Bin, MsgName, TrUserData).
|
| 256 |
+
|
| 257 |
+
-ifdef('OTP_RELEASE').
|
| 258 |
+
decode_msg_1_catch(Bin, MsgName, TrUserData) ->
|
| 259 |
+
try decode_msg_2_doit(MsgName, Bin, TrUserData)
|
| 260 |
+
catch
|
| 261 |
+
error:{gpb_error,_}=Reason:StackTrace ->
|
| 262 |
+
erlang:raise(error, Reason, StackTrace);
|
| 263 |
+
Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}})
|
| 264 |
+
end.
|
| 265 |
+
-else.
|
| 266 |
+
decode_msg_1_catch(Bin, MsgName, TrUserData) ->
|
| 267 |
+
try decode_msg_2_doit(MsgName, Bin, TrUserData)
|
| 268 |
+
catch
|
| 269 |
+
error:{gpb_error,_}=Reason ->
|
| 270 |
+
erlang:raise(error, Reason,
|
| 271 |
+
erlang:get_stacktrace());
|
| 272 |
+
Class:Reason ->
|
| 273 |
+
StackTrace = erlang:get_stacktrace(),
|
| 274 |
+
error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}})
|
| 275 |
+
end.
|
| 276 |
+
-endif.
|
| 277 |
+
|
| 278 |
+
decode_msg_2_doit('Versions', Bin, TrUserData) -> id(decode_msg_Versions(Bin, TrUserData), TrUserData);
|
| 279 |
+
decode_msg_2_doit('Package', Bin, TrUserData) -> id(decode_msg_Package(Bin, TrUserData), TrUserData).
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
|
| 283 |
+
decode_msg_Versions(Bin, TrUserData) -> dfp_read_field_def_Versions(Bin, 0, 0, 0, id([], TrUserData), id('$undef', TrUserData), TrUserData).
|
| 284 |
+
|
| 285 |
+
dfp_read_field_def_Versions(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_Versions_packages(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData);
|
| 286 |
+
dfp_read_field_def_Versions(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_Versions_repository(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData);
|
| 287 |
+
dfp_read_field_def_Versions(<<>>, 0, 0, _, R1, F@_2, TrUserData) ->
|
| 288 |
+
S1 = #{repository => F@_2},
|
| 289 |
+
if R1 == '$undef' -> S1;
|
| 290 |
+
true -> S1#{packages => lists_reverse(R1, TrUserData)}
|
| 291 |
+
end;
|
| 292 |
+
dfp_read_field_def_Versions(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_Versions(Other, Z1, Z2, F, F@_1, F@_2, TrUserData).
|
| 293 |
+
|
| 294 |
+
dg_read_field_def_Versions(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_Versions(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData);
|
| 295 |
+
dg_read_field_def_Versions(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) ->
|
| 296 |
+
Key = X bsl N + Acc,
|
| 297 |
+
case Key of
|
| 298 |
+
10 -> d_field_Versions_packages(Rest, 0, 0, 0, F@_1, F@_2, TrUserData);
|
| 299 |
+
18 -> d_field_Versions_repository(Rest, 0, 0, 0, F@_1, F@_2, TrUserData);
|
| 300 |
+
_ ->
|
| 301 |
+
case Key band 7 of
|
| 302 |
+
0 -> skip_varint_Versions(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData);
|
| 303 |
+
1 -> skip_64_Versions(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData);
|
| 304 |
+
2 -> skip_length_delimited_Versions(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData);
|
| 305 |
+
3 -> skip_group_Versions(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData);
|
| 306 |
+
5 -> skip_32_Versions(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData)
|
| 307 |
+
end
|
| 308 |
+
end;
|
| 309 |
+
dg_read_field_def_Versions(<<>>, 0, 0, _, R1, F@_2, TrUserData) ->
|
| 310 |
+
S1 = #{repository => F@_2},
|
| 311 |
+
if R1 == '$undef' -> S1;
|
| 312 |
+
true -> S1#{packages => lists_reverse(R1, TrUserData)}
|
| 313 |
+
end.
|
| 314 |
+
|
| 315 |
+
d_field_Versions_packages(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_Versions_packages(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData);
|
| 316 |
+
d_field_Versions_packages(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) ->
|
| 317 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bs:Len/binary, Rest2/binary>> = Rest, {id(decode_msg_Package(Bs, TrUserData), TrUserData), Rest2} end,
|
| 318 |
+
dfp_read_field_def_Versions(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), F@_2, TrUserData).
|
| 319 |
+
|
| 320 |
+
d_field_Versions_repository(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_Versions_repository(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData);
|
| 321 |
+
d_field_Versions_repository(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) ->
|
| 322 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
| 323 |
+
dfp_read_field_def_Versions(RestF, 0, 0, F, F@_1, NewFValue, TrUserData).
|
| 324 |
+
|
| 325 |
+
skip_varint_Versions(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_Versions(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData);
|
| 326 |
+
skip_varint_Versions(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Versions(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData).
|
| 327 |
+
|
| 328 |
+
skip_length_delimited_Versions(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_Versions(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData);
|
| 329 |
+
skip_length_delimited_Versions(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) ->
|
| 330 |
+
Length = X bsl N + Acc,
|
| 331 |
+
<<_:Length/binary, Rest2/binary>> = Rest,
|
| 332 |
+
dfp_read_field_def_Versions(Rest2, 0, 0, F, F@_1, F@_2, TrUserData).
|
| 333 |
+
|
| 334 |
+
skip_group_Versions(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) ->
|
| 335 |
+
{_, Rest} = read_group(Bin, FNum),
|
| 336 |
+
dfp_read_field_def_Versions(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData).
|
| 337 |
+
|
| 338 |
+
skip_32_Versions(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Versions(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData).
|
| 339 |
+
|
| 340 |
+
skip_64_Versions(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Versions(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData).
|
| 341 |
+
|
| 342 |
+
decode_msg_Package(Bin, TrUserData) -> dfp_read_field_def_Package(Bin, 0, 0, 0, id('$undef', TrUserData), id([], TrUserData), id([], TrUserData), TrUserData).
|
| 343 |
+
|
| 344 |
+
dfp_read_field_def_Package(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_Package_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
|
| 345 |
+
dfp_read_field_def_Package(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_Package_versions(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
|
| 346 |
+
dfp_read_field_def_Package(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_pfield_Package_retired(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
|
| 347 |
+
dfp_read_field_def_Package(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_Package_retired(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
|
| 348 |
+
dfp_read_field_def_Package(<<>>, 0, 0, _, F@_1, R1, R2, TrUserData) -> #{name => F@_1, versions => lists_reverse(R1, TrUserData), retired => lists_reverse(R2, TrUserData)};
|
| 349 |
+
dfp_read_field_def_Package(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_Package(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
|
| 350 |
+
|
| 351 |
+
dg_read_field_def_Package(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_Package(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
| 352 |
+
dg_read_field_def_Package(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) ->
|
| 353 |
+
Key = X bsl N + Acc,
|
| 354 |
+
case Key of
|
| 355 |
+
10 -> d_field_Package_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
|
| 356 |
+
18 -> d_field_Package_versions(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
|
| 357 |
+
26 -> d_pfield_Package_retired(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
|
| 358 |
+
24 -> d_field_Package_retired(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
|
| 359 |
+
_ ->
|
| 360 |
+
case Key band 7 of
|
| 361 |
+
0 -> skip_varint_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
|
| 362 |
+
1 -> skip_64_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
|
| 363 |
+
2 -> skip_length_delimited_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
|
| 364 |
+
3 -> skip_group_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
|
| 365 |
+
5 -> skip_32_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData)
|
| 366 |
+
end
|
| 367 |
+
end;
|
| 368 |
+
dg_read_field_def_Package(<<>>, 0, 0, _, F@_1, R1, R2, TrUserData) -> #{name => F@_1, versions => lists_reverse(R1, TrUserData), retired => lists_reverse(R2, TrUserData)}.
|
| 369 |
+
|
| 370 |
+
d_field_Package_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_Package_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
| 371 |
+
d_field_Package_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) ->
|
| 372 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
| 373 |
+
dfp_read_field_def_Package(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData).
|
| 374 |
+
|
| 375 |
+
d_field_Package_versions(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_Package_versions(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
| 376 |
+
d_field_Package_versions(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, Prev, F@_3, TrUserData) ->
|
| 377 |
+
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
| 378 |
+
dfp_read_field_def_Package(RestF, 0, 0, F, F@_1, cons(NewFValue, Prev, TrUserData), F@_3, TrUserData).
|
| 379 |
+
|
| 380 |
+
d_field_Package_retired(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_Package_retired(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
| 381 |
+
d_field_Package_retired(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, Prev, TrUserData) ->
|
| 382 |
+
{NewFValue, RestF} = {begin <<Res:32/signed-native>> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest},
|
| 383 |
+
dfp_read_field_def_Package(RestF, 0, 0, F, F@_1, F@_2, cons(NewFValue, Prev, TrUserData), TrUserData).
|
| 384 |
+
|
| 385 |
+
d_pfield_Package_retired(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_pfield_Package_retired(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
| 386 |
+
d_pfield_Package_retired(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, E, TrUserData) ->
|
| 387 |
+
Len = X bsl N + Acc,
|
| 388 |
+
<<PackedBytes:Len/binary, Rest2/binary>> = Rest,
|
| 389 |
+
NewSeq = d_packed_field_Package_retired(PackedBytes, 0, 0, F, E, TrUserData),
|
| 390 |
+
dfp_read_field_def_Package(Rest2, 0, 0, F, F@_1, F@_2, NewSeq, TrUserData).
|
| 391 |
+
|
| 392 |
+
d_packed_field_Package_retired(<<1:1, X:7, Rest/binary>>, N, Acc, F, AccSeq, TrUserData) when N < 57 -> d_packed_field_Package_retired(Rest, N + 7, X bsl N + Acc, F, AccSeq, TrUserData);
|
| 393 |
+
d_packed_field_Package_retired(<<0:1, X:7, Rest/binary>>, N, Acc, F, AccSeq, TrUserData) ->
|
| 394 |
+
{NewFValue, RestF} = {begin <<Res:32/signed-native>> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest},
|
| 395 |
+
d_packed_field_Package_retired(RestF, 0, 0, F, [NewFValue | AccSeq], TrUserData);
|
| 396 |
+
d_packed_field_Package_retired(<<>>, 0, 0, _, AccSeq, _) -> AccSeq.
|
| 397 |
+
|
| 398 |
+
skip_varint_Package(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_Package(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
|
| 399 |
+
skip_varint_Package(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_Package(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
|
| 400 |
+
|
| 401 |
+
skip_length_delimited_Package(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_Package(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
| 402 |
+
skip_length_delimited_Package(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) ->
|
| 403 |
+
Length = X bsl N + Acc,
|
| 404 |
+
<<_:Length/binary, Rest2/binary>> = Rest,
|
| 405 |
+
dfp_read_field_def_Package(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData).
|
| 406 |
+
|
| 407 |
+
skip_group_Package(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) ->
|
| 408 |
+
{_, Rest} = read_group(Bin, FNum),
|
| 409 |
+
dfp_read_field_def_Package(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData).
|
| 410 |
+
|
| 411 |
+
skip_32_Package(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_Package(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
|
| 412 |
+
|
| 413 |
+
skip_64_Package(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_Package(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
|
| 414 |
+
|
| 415 |
+
read_group(Bin, FieldNum) ->
|
| 416 |
+
{NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum),
|
| 417 |
+
<<Group:NumBytes/binary, _:EndTagLen/binary, Rest/binary>> = Bin,
|
| 418 |
+
{Group, Rest}.
|
| 419 |
+
|
| 420 |
+
%% Like skipping over fields, but record the total length,
|
| 421 |
+
%% Each field is <(FieldNum bsl 3) bor FieldType> ++ <FieldValue>
|
| 422 |
+
%% Record the length because varints may be non-optimally encoded.
|
| 423 |
+
%%
|
| 424 |
+
%% Groups can be nested, but assume the same FieldNum cannot be nested
|
| 425 |
+
%% because group field numbers are shared with the rest of the fields
|
| 426 |
+
%% numbers. Thus we can search just for an group-end with the same
|
| 427 |
+
%% field number.
|
| 428 |
+
%%
|
| 429 |
+
%% (The only time the same group field number could occur would
|
| 430 |
+
%% be in a nested sub message, but then it would be inside a
|
| 431 |
+
%% length-delimited entry, which we skip-read by length.)
|
| 432 |
+
read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum)
|
| 433 |
+
when N < (32-7) ->
|
| 434 |
+
read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum);
|
| 435 |
+
read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen,
|
| 436 |
+
FieldNum) ->
|
| 437 |
+
Key = X bsl N + Acc,
|
| 438 |
+
TagLen1 = TagLen + 1,
|
| 439 |
+
case {Key bsr 3, Key band 7} of
|
| 440 |
+
{FieldNum, 4} -> % 4 = group_end
|
| 441 |
+
{NumBytes, TagLen1};
|
| 442 |
+
{_, 0} -> % 0 = varint
|
| 443 |
+
read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum);
|
| 444 |
+
{_, 1} -> % 1 = bits64
|
| 445 |
+
<<_:64, Tl2/binary>> = Tl,
|
| 446 |
+
read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum);
|
| 447 |
+
{_, 2} -> % 2 = length_delimited
|
| 448 |
+
read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum);
|
| 449 |
+
{_, 3} -> % 3 = group_start
|
| 450 |
+
read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum);
|
| 451 |
+
{_, 4} -> % 4 = group_end
|
| 452 |
+
read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum);
|
| 453 |
+
{_, 5} -> % 5 = bits32
|
| 454 |
+
<<_:32, Tl2/binary>> = Tl,
|
| 455 |
+
read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum)
|
| 456 |
+
end.
|
| 457 |
+
|
| 458 |
+
read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum)
|
| 459 |
+
when N < (64-7) ->
|
| 460 |
+
read_gr_vi(Tl, N+7, NumBytes+1, FieldNum);
|
| 461 |
+
read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) ->
|
| 462 |
+
read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum).
|
| 463 |
+
|
| 464 |
+
read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum)
|
| 465 |
+
when N < (64-7) ->
|
| 466 |
+
read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum);
|
| 467 |
+
read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) ->
|
| 468 |
+
Len = X bsl N + Acc,
|
| 469 |
+
NumBytes1 = NumBytes + 1,
|
| 470 |
+
<<_:Len/binary, Tl2/binary>> = Tl,
|
| 471 |
+
read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum).
|
| 472 |
+
|
| 473 |
+
merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []).
|
| 474 |
+
|
| 475 |
+
merge_msgs(Prev, New, MsgName, Opts) ->
|
| 476 |
+
TrUserData = proplists:get_value(user_data, Opts),
|
| 477 |
+
case MsgName of
|
| 478 |
+
'Versions' -> merge_msg_Versions(Prev, New, TrUserData);
|
| 479 |
+
'Package' -> merge_msg_Package(Prev, New, TrUserData)
|
| 480 |
+
end.
|
| 481 |
+
|
| 482 |
+
-compile({nowarn_unused_function,merge_msg_Versions/3}).
|
| 483 |
+
merge_msg_Versions(#{} = PMsg, #{repository := NFrepository} = NMsg, TrUserData) ->
|
| 484 |
+
S1 = #{repository => NFrepository},
|
| 485 |
+
case {PMsg, NMsg} of
|
| 486 |
+
{#{packages := PFpackages}, #{packages := NFpackages}} -> S1#{packages => 'erlang_++'(PFpackages, NFpackages, TrUserData)};
|
| 487 |
+
{_, #{packages := NFpackages}} -> S1#{packages => NFpackages};
|
| 488 |
+
{#{packages := PFpackages}, _} -> S1#{packages => PFpackages};
|
| 489 |
+
{_, _} -> S1
|
| 490 |
+
end.
|
| 491 |
+
|
| 492 |
+
-compile({nowarn_unused_function,merge_msg_Package/3}).
|
| 493 |
+
merge_msg_Package(#{} = PMsg, #{name := NFname} = NMsg, TrUserData) ->
|
| 494 |
+
S1 = #{name => NFname},
|
| 495 |
+
S2 = case {PMsg, NMsg} of
|
| 496 |
+
{#{versions := PFversions}, #{versions := NFversions}} -> S1#{versions => 'erlang_++'(PFversions, NFversions, TrUserData)};
|
| 497 |
+
{_, #{versions := NFversions}} -> S1#{versions => NFversions};
|
| 498 |
+
{#{versions := PFversions}, _} -> S1#{versions => PFversions};
|
| 499 |
+
{_, _} -> S1
|
| 500 |
+
end,
|
| 501 |
+
case {PMsg, NMsg} of
|
| 502 |
+
{#{retired := PFretired}, #{retired := NFretired}} -> S2#{retired => 'erlang_++'(PFretired, NFretired, TrUserData)};
|
| 503 |
+
{_, #{retired := NFretired}} -> S2#{retired => NFretired};
|
| 504 |
+
{#{retired := PFretired}, _} -> S2#{retired => PFretired};
|
| 505 |
+
{_, _} -> S2
|
| 506 |
+
end.
|
| 507 |
+
|
| 508 |
+
|
| 509 |
+
verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []).
|
| 510 |
+
|
| 511 |
+
verify_msg(Msg, MsgName, Opts) ->
|
| 512 |
+
TrUserData = proplists:get_value(user_data, Opts),
|
| 513 |
+
case MsgName of
|
| 514 |
+
'Versions' -> v_msg_Versions(Msg, [MsgName], TrUserData);
|
| 515 |
+
'Package' -> v_msg_Package(Msg, [MsgName], TrUserData);
|
| 516 |
+
_ -> mk_type_error(not_a_known_message, Msg, [])
|
| 517 |
+
end.
|
| 518 |
+
|
| 519 |
+
|
| 520 |
+
-compile({nowarn_unused_function,v_msg_Versions/3}).
|
| 521 |
+
-dialyzer({nowarn_function,v_msg_Versions/3}).
|
| 522 |
+
v_msg_Versions(#{repository := F2} = M, Path, TrUserData) ->
|
| 523 |
+
case M of
|
| 524 |
+
#{packages := F1} ->
|
| 525 |
+
if is_list(F1) ->
|
| 526 |
+
_ = [v_submsg_Package(Elem, [packages | Path], TrUserData) || Elem <- F1],
|
| 527 |
+
ok;
|
| 528 |
+
true -> mk_type_error({invalid_list_of, {msg, 'Package'}}, F1, [packages | Path])
|
| 529 |
+
end;
|
| 530 |
+
_ -> ok
|
| 531 |
+
end,
|
| 532 |
+
v_type_string(F2, [repository | Path], TrUserData),
|
| 533 |
+
lists:foreach(fun (packages) -> ok;
|
| 534 |
+
(repository) -> ok;
|
| 535 |
+
(OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path)
|
| 536 |
+
end,
|
| 537 |
+
maps:keys(M)),
|
| 538 |
+
ok;
|
| 539 |
+
v_msg_Versions(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [repository] -- maps:keys(M), 'Versions'}, M, Path);
|
| 540 |
+
v_msg_Versions(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Versions'}, X, Path).
|
| 541 |
+
|
| 542 |
+
-compile({nowarn_unused_function,v_submsg_Package/3}).
|
| 543 |
+
-dialyzer({nowarn_function,v_submsg_Package/3}).
|
| 544 |
+
v_submsg_Package(Msg, Path, TrUserData) -> v_msg_Package(Msg, Path, TrUserData).
|
| 545 |
+
|
| 546 |
+
-compile({nowarn_unused_function,v_msg_Package/3}).
|
| 547 |
+
-dialyzer({nowarn_function,v_msg_Package/3}).
|
| 548 |
+
v_msg_Package(#{name := F1} = M, Path, TrUserData) ->
|
| 549 |
+
v_type_string(F1, [name | Path], TrUserData),
|
| 550 |
+
case M of
|
| 551 |
+
#{versions := F2} ->
|
| 552 |
+
if is_list(F2) ->
|
| 553 |
+
_ = [v_type_string(Elem, [versions | Path], TrUserData) || Elem <- F2],
|
| 554 |
+
ok;
|
| 555 |
+
true -> mk_type_error({invalid_list_of, string}, F2, [versions | Path])
|
| 556 |
+
end;
|
| 557 |
+
_ -> ok
|
| 558 |
+
end,
|
| 559 |
+
case M of
|
| 560 |
+
#{retired := F3} ->
|
| 561 |
+
if is_list(F3) ->
|
| 562 |
+
_ = [v_type_int32(Elem, [retired | Path], TrUserData) || Elem <- F3],
|
| 563 |
+
ok;
|
| 564 |
+
true -> mk_type_error({invalid_list_of, int32}, F3, [retired | Path])
|
| 565 |
+
end;
|
| 566 |
+
_ -> ok
|
| 567 |
+
end,
|
| 568 |
+
lists:foreach(fun (name) -> ok;
|
| 569 |
+
(versions) -> ok;
|
| 570 |
+
(retired) -> ok;
|
| 571 |
+
(OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path)
|
| 572 |
+
end,
|
| 573 |
+
maps:keys(M)),
|
| 574 |
+
ok;
|
| 575 |
+
v_msg_Package(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [name] -- maps:keys(M), 'Package'}, M, Path);
|
| 576 |
+
v_msg_Package(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Package'}, X, Path).
|
| 577 |
+
|
| 578 |
+
-compile({nowarn_unused_function,v_type_int32/3}).
|
| 579 |
+
-dialyzer({nowarn_function,v_type_int32/3}).
|
| 580 |
+
v_type_int32(N, _Path, _TrUserData) when is_integer(N), -2147483648 =< N, N =< 2147483647 -> ok;
|
| 581 |
+
v_type_int32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int32, signed, 32}, N, Path);
|
| 582 |
+
v_type_int32(X, Path, _TrUserData) -> mk_type_error({bad_integer, int32, signed, 32}, X, Path).
|
| 583 |
+
|
| 584 |
+
-compile({nowarn_unused_function,v_type_string/3}).
|
| 585 |
+
-dialyzer({nowarn_function,v_type_string/3}).
|
| 586 |
+
v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) ->
|
| 587 |
+
try unicode:characters_to_binary(S) of
|
| 588 |
+
B when is_binary(B) -> ok;
|
| 589 |
+
{error, _, _} -> mk_type_error(bad_unicode_string, S, Path)
|
| 590 |
+
catch
|
| 591 |
+
error:badarg -> mk_type_error(bad_unicode_string, S, Path)
|
| 592 |
+
end;
|
| 593 |
+
v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path).
|
| 594 |
+
|
| 595 |
+
-compile({nowarn_unused_function,mk_type_error/3}).
|
| 596 |
+
-spec mk_type_error(_, _, list()) -> no_return().
|
| 597 |
+
mk_type_error(Error, ValueSeen, Path) ->
|
| 598 |
+
Path2 = prettify_path(Path),
|
| 599 |
+
erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}).
|
| 600 |
+
|
| 601 |
+
|
| 602 |
+
-compile({nowarn_unused_function,prettify_path/1}).
|
| 603 |
+
-dialyzer({nowarn_function,prettify_path/1}).
|
| 604 |
+
prettify_path([]) -> top_level;
|
| 605 |
+
prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))).
|
| 606 |
+
|
| 607 |
+
|
| 608 |
+
-compile({nowarn_unused_function,id/2}).
|
| 609 |
+
-compile({inline,id/2}).
|
| 610 |
+
id(X, _TrUserData) -> X.
|
| 611 |
+
|
| 612 |
+
-compile({nowarn_unused_function,v_ok/3}).
|
| 613 |
+
-compile({inline,v_ok/3}).
|
| 614 |
+
v_ok(_Value, _Path, _TrUserData) -> ok.
|
| 615 |
+
|
| 616 |
+
-compile({nowarn_unused_function,m_overwrite/3}).
|
| 617 |
+
-compile({inline,m_overwrite/3}).
|
| 618 |
+
m_overwrite(_Prev, New, _TrUserData) -> New.
|
| 619 |
+
|
| 620 |
+
-compile({nowarn_unused_function,cons/3}).
|
| 621 |
+
-compile({inline,cons/3}).
|
| 622 |
+
cons(Elem, Acc, _TrUserData) -> [Elem | Acc].
|
| 623 |
+
|
| 624 |
+
-compile({nowarn_unused_function,lists_reverse/2}).
|
| 625 |
+
-compile({inline,lists_reverse/2}).
|
| 626 |
+
'lists_reverse'(L, _TrUserData) -> lists:reverse(L).
|
| 627 |
+
-compile({nowarn_unused_function,'erlang_++'/3}).
|
| 628 |
+
-compile({inline,'erlang_++'/3}).
|
| 629 |
+
'erlang_++'(A, B, _TrUserData) -> A ++ B.
|
| 630 |
+
|
| 631 |
+
|
| 632 |
+
get_msg_defs() ->
|
| 633 |
+
[{{msg, 'Versions'}, [#{name => packages, fnum => 1, rnum => 2, type => {msg, 'Package'}, occurrence => repeated, opts => []}, #{name => repository, fnum => 2, rnum => 3, type => string, occurrence => required, opts => []}]},
|
| 634 |
+
{{msg, 'Package'},
|
| 635 |
+
[#{name => name, fnum => 1, rnum => 2, type => string, occurrence => required, opts => []},
|
| 636 |
+
#{name => versions, fnum => 2, rnum => 3, type => string, occurrence => repeated, opts => []},
|
| 637 |
+
#{name => retired, fnum => 3, rnum => 4, type => int32, occurrence => repeated, opts => [packed]}]}].
|
| 638 |
+
|
| 639 |
+
|
| 640 |
+
get_msg_names() -> ['Versions', 'Package'].
|
| 641 |
+
|
| 642 |
+
|
| 643 |
+
get_group_names() -> [].
|
| 644 |
+
|
| 645 |
+
|
| 646 |
+
get_msg_or_group_names() -> ['Versions', 'Package'].
|
| 647 |
+
|
| 648 |
+
|
| 649 |
+
get_enum_names() -> [].
|
| 650 |
+
|
| 651 |
+
|
| 652 |
+
fetch_msg_def(MsgName) ->
|
| 653 |
+
case find_msg_def(MsgName) of
|
| 654 |
+
Fs when is_list(Fs) -> Fs;
|
| 655 |
+
error -> erlang:error({no_such_msg, MsgName})
|
| 656 |
+
end.
|
| 657 |
+
|
| 658 |
+
|
| 659 |
+
-spec fetch_enum_def(_) -> no_return().
|
| 660 |
+
fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}).
|
| 661 |
+
|
| 662 |
+
|
| 663 |
+
find_msg_def('Versions') -> [#{name => packages, fnum => 1, rnum => 2, type => {msg, 'Package'}, occurrence => repeated, opts => []}, #{name => repository, fnum => 2, rnum => 3, type => string, occurrence => required, opts => []}];
|
| 664 |
+
find_msg_def('Package') ->
|
| 665 |
+
[#{name => name, fnum => 1, rnum => 2, type => string, occurrence => required, opts => []},
|
| 666 |
+
#{name => versions, fnum => 2, rnum => 3, type => string, occurrence => repeated, opts => []},
|
| 667 |
+
#{name => retired, fnum => 3, rnum => 4, type => int32, occurrence => repeated, opts => [packed]}];
|
| 668 |
+
find_msg_def(_) -> error.
|
| 669 |
+
|
| 670 |
+
|
| 671 |
+
find_enum_def(_) -> error.
|
| 672 |
+
|
| 673 |
+
|
| 674 |
+
-spec enum_symbol_by_value(_, _) -> no_return().
|
| 675 |
+
enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}).
|
| 676 |
+
|
| 677 |
+
|
| 678 |
+
-spec enum_value_by_symbol(_, _) -> no_return().
|
| 679 |
+
enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}).
|
| 680 |
+
|
| 681 |
+
|
| 682 |
+
|
| 683 |
+
get_service_names() -> [].
|
| 684 |
+
|
| 685 |
+
|
| 686 |
+
get_service_def(_) -> error.
|
| 687 |
+
|
| 688 |
+
|
| 689 |
+
get_rpc_names(_) -> error.
|
| 690 |
+
|
| 691 |
+
|
| 692 |
+
find_rpc_def(_, _) -> error.
|
| 693 |
+
|
| 694 |
+
|
| 695 |
+
|
| 696 |
+
-spec fetch_rpc_def(_, _) -> no_return().
|
| 697 |
+
fetch_rpc_def(ServiceName, RpcName) -> erlang:error({no_such_rpc, ServiceName, RpcName}).
|
| 698 |
+
|
| 699 |
+
|
| 700 |
+
%% Convert a a fully qualified (ie with package name) service name
|
| 701 |
+
%% as a binary to a service name as an atom.
|
| 702 |
+
-spec fqbin_to_service_name(_) -> no_return().
|
| 703 |
+
fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}).
|
| 704 |
+
|
| 705 |
+
|
| 706 |
+
%% Convert a service name as an atom to a fully qualified
|
| 707 |
+
%% (ie with package name) name as a binary.
|
| 708 |
+
-spec service_name_to_fqbin(_) -> no_return().
|
| 709 |
+
service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}).
|
| 710 |
+
|
| 711 |
+
|
| 712 |
+
%% Convert a a fully qualified (ie with package name) service name
|
| 713 |
+
%% and an rpc name, both as binaries to a service name and an rpc
|
| 714 |
+
%% name, as atoms.
|
| 715 |
+
-spec fqbins_to_service_and_rpc_name(_, _) -> no_return().
|
| 716 |
+
fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}).
|
| 717 |
+
|
| 718 |
+
|
| 719 |
+
%% Convert a service name and an rpc name, both as atoms,
|
| 720 |
+
%% to a fully qualified (ie with package name) service name and
|
| 721 |
+
%% an rpc name as binaries.
|
| 722 |
+
-spec service_and_rpc_name_to_fqbins(_, _) -> no_return().
|
| 723 |
+
service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}).
|
| 724 |
+
|
| 725 |
+
|
| 726 |
+
fqbin_to_msg_name(<<"Versions">>) -> 'Versions';
|
| 727 |
+
fqbin_to_msg_name(<<"Package">>) -> 'Package';
|
| 728 |
+
fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}).
|
| 729 |
+
|
| 730 |
+
|
| 731 |
+
msg_name_to_fqbin('Versions') -> <<"Versions">>;
|
| 732 |
+
msg_name_to_fqbin('Package') -> <<"Package">>;
|
| 733 |
+
msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}).
|
| 734 |
+
|
| 735 |
+
|
| 736 |
+
-spec fqbin_to_enum_name(_) -> no_return().
|
| 737 |
+
fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}).
|
| 738 |
+
|
| 739 |
+
|
| 740 |
+
-spec enum_name_to_fqbin(_) -> no_return().
|
| 741 |
+
enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}).
|
| 742 |
+
|
| 743 |
+
|
| 744 |
+
get_package_name() -> undefined.
|
| 745 |
+
|
| 746 |
+
|
| 747 |
+
%% Whether or not the message names
|
| 748 |
+
%% are prepended with package name or not.
|
| 749 |
+
uses_packages() -> false.
|
| 750 |
+
|
| 751 |
+
|
| 752 |
+
source_basename() -> "hex_pb_versions.proto".
|
| 753 |
+
|
| 754 |
+
|
| 755 |
+
%% Retrieve all proto file names, also imported ones.
|
| 756 |
+
%% The order is top-down. The first element is always the main
|
| 757 |
+
%% source file. The files are returned with extension,
|
| 758 |
+
%% see get_all_proto_names/0 for a version that returns
|
| 759 |
+
%% the basenames sans extension
|
| 760 |
+
get_all_source_basenames() -> ["hex_pb_versions.proto"].
|
| 761 |
+
|
| 762 |
+
|
| 763 |
+
%% Retrieve all proto file names, also imported ones.
|
| 764 |
+
%% The order is top-down. The first element is always the main
|
| 765 |
+
%% source file. The files are returned sans .proto extension,
|
| 766 |
+
%% to make it easier to use them with the various get_xyz_containment
|
| 767 |
+
%% functions.
|
| 768 |
+
get_all_proto_names() -> ["hex_pb_versions"].
|
| 769 |
+
|
| 770 |
+
|
| 771 |
+
get_msg_containment("hex_pb_versions") -> ['Package', 'Versions'];
|
| 772 |
+
get_msg_containment(P) -> error({gpb_error, {badproto, P}}).
|
| 773 |
+
|
| 774 |
+
|
| 775 |
+
get_pkg_containment("hex_pb_versions") -> undefined;
|
| 776 |
+
get_pkg_containment(P) -> error({gpb_error, {badproto, P}}).
|
| 777 |
+
|
| 778 |
+
|
| 779 |
+
get_service_containment("hex_pb_versions") -> [];
|
| 780 |
+
get_service_containment(P) -> error({gpb_error, {badproto, P}}).
|
| 781 |
+
|
| 782 |
+
|
| 783 |
+
get_rpc_containment("hex_pb_versions") -> [];
|
| 784 |
+
get_rpc_containment(P) -> error({gpb_error, {badproto, P}}).
|
| 785 |
+
|
| 786 |
+
|
| 787 |
+
get_enum_containment("hex_pb_versions") -> [];
|
| 788 |
+
get_enum_containment(P) -> error({gpb_error, {badproto, P}}).
|
| 789 |
+
|
| 790 |
+
|
| 791 |
+
get_proto_by_msg_name_as_fqbin(<<"Versions">>) -> "hex_pb_versions";
|
| 792 |
+
get_proto_by_msg_name_as_fqbin(<<"Package">>) -> "hex_pb_versions";
|
| 793 |
+
get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}).
|
| 794 |
+
|
| 795 |
+
|
| 796 |
+
-spec get_proto_by_service_name_as_fqbin(_) -> no_return().
|
| 797 |
+
get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}).
|
| 798 |
+
|
| 799 |
+
|
| 800 |
+
-spec get_proto_by_enum_name_as_fqbin(_) -> no_return().
|
| 801 |
+
get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}).
|
| 802 |
+
|
| 803 |
+
|
| 804 |
+
-spec get_protos_by_pkg_name_as_fqbin(_) -> no_return().
|
| 805 |
+
get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}).
|
| 806 |
+
|
| 807 |
+
|
| 808 |
+
|
| 809 |
+
gpb_version_as_string() ->
|
| 810 |
+
"4.21.1".
|
| 811 |
+
|
| 812 |
+
gpb_version_as_list() ->
|
| 813 |
+
[4,21,1].
|
| 814 |
+
|
| 815 |
+
gpb_version_source() ->
|
| 816 |
+
"file".
|
deps/eini/_build/default/plugins/hex_core/src/hex_registry.erl
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%% @doc
|
| 2 |
+
%% Functions for encoding and decoding Hex registries.
|
| 3 |
+
-module(hex_registry).
|
| 4 |
+
-export([
|
| 5 |
+
encode_names/1,
|
| 6 |
+
decode_names/2,
|
| 7 |
+
build_names/2,
|
| 8 |
+
unpack_names/3,
|
| 9 |
+
encode_versions/1,
|
| 10 |
+
decode_versions/2,
|
| 11 |
+
build_versions/2,
|
| 12 |
+
unpack_versions/3,
|
| 13 |
+
encode_package/1,
|
| 14 |
+
decode_package/3,
|
| 15 |
+
build_package/2,
|
| 16 |
+
unpack_package/4,
|
| 17 |
+
sign_protobuf/2,
|
| 18 |
+
decode_signed/1,
|
| 19 |
+
decode_and_verify_signed/2,
|
| 20 |
+
sign/2,
|
| 21 |
+
verify/3
|
| 22 |
+
]).
|
| 23 |
+
-include_lib("public_key/include/public_key.hrl").
|
| 24 |
+
|
| 25 |
+
-type private_key() :: #'RSAPrivateKey'{} | binary().
|
| 26 |
+
-type public_key() :: #'RSAPublicKey'{} | binary().
|
| 27 |
+
|
| 28 |
+
%%====================================================================
|
| 29 |
+
%% API functions
|
| 30 |
+
%%====================================================================
|
| 31 |
+
|
| 32 |
+
%% @doc
|
| 33 |
+
%% Builds names resource.
|
| 34 |
+
build_names(Names, PrivateKey) ->
|
| 35 |
+
Payload = encode_names(Names),
|
| 36 |
+
zlib:gzip(sign_protobuf(Payload, PrivateKey)).
|
| 37 |
+
|
| 38 |
+
%% @doc
|
| 39 |
+
%% Unpacks names resource.
|
| 40 |
+
unpack_names(Payload, Repository, PublicKey) ->
|
| 41 |
+
case decode_and_verify_signed(zlib:gunzip(Payload), PublicKey) of
|
| 42 |
+
{ok, Names} -> decode_names(Names, Repository);
|
| 43 |
+
Other -> Other
|
| 44 |
+
end.
|
| 45 |
+
|
| 46 |
+
%% @private
|
| 47 |
+
encode_names(Names) ->
|
| 48 |
+
hex_pb_names:encode_msg(Names, 'Names').
|
| 49 |
+
|
| 50 |
+
%% @private
|
| 51 |
+
decode_names(Payload, no_verify) ->
|
| 52 |
+
{ok, hex_pb_names:decode_msg(Payload, 'Names')};
|
| 53 |
+
decode_names(Payload, Repository) ->
|
| 54 |
+
case hex_pb_names:decode_msg(Payload, 'Names') of
|
| 55 |
+
#{repository := Repository, packages := _Packages} = Result ->
|
| 56 |
+
{ok, Result};
|
| 57 |
+
_ ->
|
| 58 |
+
{error, bad_repo_name}
|
| 59 |
+
end.
|
| 60 |
+
|
| 61 |
+
%% @doc
|
| 62 |
+
%% Builds versions resource.
|
| 63 |
+
build_versions(Versions, PrivateKey) ->
|
| 64 |
+
Payload = encode_versions(Versions),
|
| 65 |
+
zlib:gzip(sign_protobuf(Payload, PrivateKey)).
|
| 66 |
+
|
| 67 |
+
%% @doc
|
| 68 |
+
%% Unpacks versions resource.
|
| 69 |
+
unpack_versions(Payload, Repository, PublicKey) ->
|
| 70 |
+
case decode_and_verify_signed(zlib:gunzip(Payload), PublicKey) of
|
| 71 |
+
{ok, Versions} -> decode_versions(Versions, Repository);
|
| 72 |
+
Other -> Other
|
| 73 |
+
end.
|
| 74 |
+
|
| 75 |
+
%% @private
|
| 76 |
+
encode_versions(Versions) ->
|
| 77 |
+
hex_pb_versions:encode_msg(Versions, 'Versions').
|
| 78 |
+
|
| 79 |
+
%% @private
|
| 80 |
+
decode_versions(Payload, no_verify) ->
|
| 81 |
+
{ok, hex_pb_versions:decode_msg(Payload, 'Versions')};
|
| 82 |
+
decode_versions(Payload, Repository) ->
|
| 83 |
+
case hex_pb_versions:decode_msg(Payload, 'Versions') of
|
| 84 |
+
#{repository := Repository, packages := _Packages} = Result ->
|
| 85 |
+
{ok, Result};
|
| 86 |
+
_ ->
|
| 87 |
+
{error, bad_repo_name}
|
| 88 |
+
end.
|
| 89 |
+
|
| 90 |
+
%% @doc
|
| 91 |
+
%% Builds package resource.
|
| 92 |
+
build_package(Package, PrivateKey) ->
|
| 93 |
+
Payload = encode_package(Package),
|
| 94 |
+
zlib:gzip(sign_protobuf(Payload, PrivateKey)).
|
| 95 |
+
|
| 96 |
+
%% @doc
|
| 97 |
+
%% Unpacks package resource.
|
| 98 |
+
unpack_package(Payload, Repository, Name, PublicKey) ->
|
| 99 |
+
case decode_and_verify_signed(zlib:gunzip(Payload), PublicKey) of
|
| 100 |
+
{ok, Package} -> decode_package(Package, Repository, Name);
|
| 101 |
+
Other -> Other
|
| 102 |
+
end.
|
| 103 |
+
|
| 104 |
+
%% @private
|
| 105 |
+
encode_package(Package) ->
|
| 106 |
+
hex_pb_package:encode_msg(Package, 'Package').
|
| 107 |
+
|
| 108 |
+
%% @private
|
| 109 |
+
decode_package(Payload, no_verify, no_verify) ->
|
| 110 |
+
{ok, hex_pb_package:decode_msg(Payload, 'Package')};
|
| 111 |
+
decode_package(Payload, Repository, Package) ->
|
| 112 |
+
case hex_pb_package:decode_msg(Payload, 'Package') of
|
| 113 |
+
#{repository := Repository, name := Package, releases := _Releases} = Result ->
|
| 114 |
+
{ok, Result};
|
| 115 |
+
_ ->
|
| 116 |
+
{error, bad_repo_name}
|
| 117 |
+
end.
|
| 118 |
+
|
| 119 |
+
%% @private
|
| 120 |
+
sign_protobuf(Payload, PrivateKey) ->
|
| 121 |
+
Signature = sign(Payload, PrivateKey),
|
| 122 |
+
hex_pb_signed:encode_msg(#{payload => Payload, signature => Signature}, 'Signed').
|
| 123 |
+
|
| 124 |
+
%% @private
|
| 125 |
+
decode_signed(Signed) ->
|
| 126 |
+
hex_pb_signed:decode_msg(Signed, 'Signed').
|
| 127 |
+
|
| 128 |
+
%% @private
|
| 129 |
+
-spec decode_and_verify_signed(binary(), public_key()) -> {ok, binary()} | {error, term()}.
|
| 130 |
+
decode_and_verify_signed(Signed, PublicKey) ->
|
| 131 |
+
#{payload := Payload, signature := Signature} = decode_signed(Signed),
|
| 132 |
+
case verify(Payload, Signature, PublicKey) of
|
| 133 |
+
true -> {ok, Payload};
|
| 134 |
+
false -> {error, bad_signature};
|
| 135 |
+
{error, Reason} -> {error, Reason}
|
| 136 |
+
end.
|
| 137 |
+
|
| 138 |
+
%% @private
|
| 139 |
+
-spec sign(binary(), private_key()) -> binary().
|
| 140 |
+
sign(Binary, PrivateKey) ->
|
| 141 |
+
{ok, RSAPrivateKey} = key(PrivateKey),
|
| 142 |
+
public_key:sign(Binary, sha512, RSAPrivateKey).
|
| 143 |
+
|
| 144 |
+
%% @private
|
| 145 |
+
-spec verify(binary(), binary(), public_key()) -> boolean() | {error, term()}.
|
| 146 |
+
verify(Binary, Signature, PublicKey) ->
|
| 147 |
+
case key(PublicKey) of
|
| 148 |
+
{ok, RSAPublicKey} -> public_key:verify(Binary, sha512, Signature, RSAPublicKey);
|
| 149 |
+
{error, Reason} -> {error, Reason}
|
| 150 |
+
end.
|
| 151 |
+
|
| 152 |
+
%%====================================================================
|
| 153 |
+
%% Internal functions
|
| 154 |
+
%%====================================================================
|
| 155 |
+
|
| 156 |
+
%% @private
|
| 157 |
+
key(#'RSAPublicKey'{} = Key) ->
|
| 158 |
+
{ok, Key};
|
| 159 |
+
key(#'RSAPrivateKey'{} = Key) ->
|
| 160 |
+
{ok, Key};
|
| 161 |
+
key(Binary) when is_binary(Binary) ->
|
| 162 |
+
case public_key:pem_decode(Binary) of
|
| 163 |
+
[Entry | _] -> {ok, public_key:pem_entry_decode(Entry)};
|
| 164 |
+
_ -> {error, bad_key}
|
| 165 |
+
end.
|
deps/eini/_build/default/plugins/hex_core/src/hex_safe_binary_to_term.erl
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%% @hidden
|
| 2 |
+
%% Safe deserialization of Erlang terms from binary.
|
| 3 |
+
%%
|
| 4 |
+
%% This module provides a restricted version of `binary_to_term/1' that:
|
| 5 |
+
%% - Uses the `safe' option to prevent creation of new atoms (DoS protection)
|
| 6 |
+
%% - Validates that the term contains no executable code (RCE protection)
|
| 7 |
+
%%
|
| 8 |
+
%% Inspired by Plug.Crypto's non_executable_binary_to_term:
|
| 9 |
+
%% https://github.com/elixir-plug/plug_crypto/blob/c326c3c743b18cf5f4b12735d06dd90c72dcd779/lib/plug/crypto.ex
|
| 10 |
+
-module(hex_safe_binary_to_term).
|
| 11 |
+
|
| 12 |
+
-export([safe_binary_to_term/1]).
|
| 13 |
+
|
| 14 |
+
-type unsafe_term() :: function() | port().
|
| 15 |
+
-type error_reason() :: invalid_term | {unsafe_term, unsafe_term()}.
|
| 16 |
+
|
| 17 |
+
-spec safe_binary_to_term(binary()) -> {ok, term()} | {error, error_reason()}.
|
| 18 |
+
safe_binary_to_term(Binary) when is_binary(Binary) ->
|
| 19 |
+
try binary_to_term(Binary, [safe]) of
|
| 20 |
+
Term ->
|
| 21 |
+
case validate_term(Term) of
|
| 22 |
+
ok -> {ok, Term};
|
| 23 |
+
{error, _} = Error -> Error
|
| 24 |
+
end
|
| 25 |
+
catch
|
| 26 |
+
error:badarg ->
|
| 27 |
+
{error, invalid_term}
|
| 28 |
+
end.
|
| 29 |
+
|
| 30 |
+
-spec validate_term(term()) -> ok | {error, {unsafe_term, term()}}.
|
| 31 |
+
validate_term(Term) when is_list(Term) ->
|
| 32 |
+
validate_list(Term);
|
| 33 |
+
validate_term(Term) when is_tuple(Term) ->
|
| 34 |
+
validate_tuple(Term, tuple_size(Term));
|
| 35 |
+
validate_term(Term) when is_map(Term) ->
|
| 36 |
+
validate_map(Term);
|
| 37 |
+
validate_term(Term) when
|
| 38 |
+
is_atom(Term);
|
| 39 |
+
is_number(Term);
|
| 40 |
+
is_bitstring(Term);
|
| 41 |
+
is_pid(Term);
|
| 42 |
+
is_reference(Term)
|
| 43 |
+
->
|
| 44 |
+
ok;
|
| 45 |
+
validate_term(Term) ->
|
| 46 |
+
{error, {unsafe_term, Term}}.
|
| 47 |
+
|
| 48 |
+
-spec validate_list(list()) -> ok | {error, {unsafe_term, term()}}.
|
| 49 |
+
validate_list([]) ->
|
| 50 |
+
ok;
|
| 51 |
+
validate_list([H | T]) when is_list(T) ->
|
| 52 |
+
case validate_term(H) of
|
| 53 |
+
ok -> validate_list(T);
|
| 54 |
+
Error -> Error
|
| 55 |
+
end;
|
| 56 |
+
validate_list([H | T]) ->
|
| 57 |
+
%% Improper list
|
| 58 |
+
case validate_term(H) of
|
| 59 |
+
ok -> validate_term(T);
|
| 60 |
+
Error -> Error
|
| 61 |
+
end.
|
| 62 |
+
|
| 63 |
+
-spec validate_tuple(tuple(), non_neg_integer()) -> ok | {error, {unsafe_term, term()}}.
|
| 64 |
+
validate_tuple(_Tuple, 0) ->
|
| 65 |
+
ok;
|
| 66 |
+
validate_tuple(Tuple, N) ->
|
| 67 |
+
case validate_term(element(N, Tuple)) of
|
| 68 |
+
ok -> validate_tuple(Tuple, N - 1);
|
| 69 |
+
Error -> Error
|
| 70 |
+
end.
|
| 71 |
+
|
| 72 |
+
-spec validate_map(map()) -> ok | {error, {unsafe_term, term()}}.
|
| 73 |
+
validate_map(Map) ->
|
| 74 |
+
try
|
| 75 |
+
maps:fold(
|
| 76 |
+
fun(Key, Value, ok) ->
|
| 77 |
+
case validate_term(Key) of
|
| 78 |
+
ok ->
|
| 79 |
+
case validate_term(Value) of
|
| 80 |
+
ok -> ok;
|
| 81 |
+
Error -> throw(Error)
|
| 82 |
+
end;
|
| 83 |
+
Error ->
|
| 84 |
+
throw(Error)
|
| 85 |
+
end
|
| 86 |
+
end,
|
| 87 |
+
ok,
|
| 88 |
+
Map
|
| 89 |
+
)
|
| 90 |
+
catch
|
| 91 |
+
throw:{error, _} = Error -> Error
|
| 92 |
+
end.
|
deps/eini/_build/default/plugins/hex_core/src/hex_tarball.erl
ADDED
|
@@ -0,0 +1,717 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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docs/1, create_docs/2,
|
| 7 |
+
unpack/2, unpack/3,
|
| 8 |
+
unpack_docs/2, unpack_docs/3,
|
| 9 |
+
format_checksum/1,
|
| 10 |
+
format_error/1
|
| 11 |
+
]).
|
| 12 |
+
-ifdef(TEST).
|
| 13 |
+
-export([do_decode_metadata/1, gzip/1, normalize_requirements/1]).
|
| 14 |
+
-endif.
|
| 15 |
+
-define(VERSION, <<"3">>).
|
| 16 |
+
-define(BUILD_TOOL_FILES, [
|
| 17 |
+
{<<"mix.exs">>, <<"mix">>},
|
| 18 |
+
{<<"rebar.config">>, <<"rebar3">>},
|
| 19 |
+
{<<"rebar">>, <<"rebar3">>},
|
| 20 |
+
{<<"Makefile">>, <<"make">>},
|
| 21 |
+
{<<"Makefile.win">>, <<"make">>}
|
| 22 |
+
]).
|
| 23 |
+
-include_lib("kernel/include/file.hrl").
|
| 24 |
+
|
| 25 |
+
-type checksum() :: binary().
|
| 26 |
+
-type contents() :: #{filename() => binary()}.
|
| 27 |
+
-type filename() :: string().
|
| 28 |
+
-type files() :: [{filename(), filename() | binary()}].
|
| 29 |
+
-type metadata() :: map().
|
| 30 |
+
-type tarball() :: binary().
|
| 31 |
+
|
| 32 |
+
%%====================================================================
|
| 33 |
+
%% API functions
|
| 34 |
+
%%====================================================================
|
| 35 |
+
|
| 36 |
+
%% @doc
|
| 37 |
+
%% Creates a package tarball.
|
| 38 |
+
%%
|
| 39 |
+
%% Returns the binary of the tarball the "inner checksum" and "outer checksum".
|
| 40 |
+
%% The inner checksum is deprecated in favor of the outer checksum.
|
| 41 |
+
%%
|
| 42 |
+
%% Examples:
|
| 43 |
+
%%
|
| 44 |
+
%% ```
|
| 45 |
+
%% > Metadata = #{<<"name">> => <<"foo">>, <<"version">> => <<"1.0.0">>},
|
| 46 |
+
%% > Files = [{"src/foo.erl", <<"-module(foo).">>}],
|
| 47 |
+
%% > hex_tarball:create(Metadata, Files).
|
| 48 |
+
%% {ok, #{tarball => <<86,69,...>>,
|
| 49 |
+
%% outer_checksum => <<40,32,...>>,
|
| 50 |
+
%% inner_checksum => <<178,12,...>>}}
|
| 51 |
+
%% '''
|
| 52 |
+
%% @end
|
| 53 |
+
-spec create(metadata(), files(), hex_core:config()) ->
|
| 54 |
+
{ok, #{
|
| 55 |
+
tarball => tarball(),
|
| 56 |
+
outer_checksum => checksum(),
|
| 57 |
+
inner_checksum => tarball()
|
| 58 |
+
}}
|
| 59 |
+
| {error, term()}.
|
| 60 |
+
create(Metadata, Files, Config) ->
|
| 61 |
+
#{
|
| 62 |
+
tarball_max_size := TarballMaxSize,
|
| 63 |
+
tarball_max_uncompressed_size := TarballMaxUncompressedSize
|
| 64 |
+
} = Config,
|
| 65 |
+
|
| 66 |
+
MetadataBinary = encode_metadata(Metadata),
|
| 67 |
+
ContentsTarball = create_memory_tarball(Files),
|
| 68 |
+
ContentsTarballCompressed = gzip(ContentsTarball),
|
| 69 |
+
InnerChecksum = inner_checksum(?VERSION, MetadataBinary, ContentsTarballCompressed),
|
| 70 |
+
InnerChecksumBase16 = encode_base16(InnerChecksum),
|
| 71 |
+
TarballMaxSize = maps:get(tarball_max_size, Config),
|
| 72 |
+
TarballMaxUncompressedSize = maps:get(tarball_max_uncompressed_size, Config),
|
| 73 |
+
|
| 74 |
+
OuterFiles = [
|
| 75 |
+
{"VERSION", ?VERSION},
|
| 76 |
+
{"CHECKSUM", InnerChecksumBase16},
|
| 77 |
+
{"metadata.config", MetadataBinary},
|
| 78 |
+
{"contents.tar.gz", ContentsTarballCompressed}
|
| 79 |
+
],
|
| 80 |
+
|
| 81 |
+
case valid_size(ContentsTarball, TarballMaxUncompressedSize) of
|
| 82 |
+
true ->
|
| 83 |
+
Tarball = create_memory_tarball(OuterFiles),
|
| 84 |
+
OuterChecksum = checksum(Tarball),
|
| 85 |
+
|
| 86 |
+
case valid_size(Tarball, TarballMaxSize) of
|
| 87 |
+
true ->
|
| 88 |
+
{ok, #{
|
| 89 |
+
tarball => Tarball,
|
| 90 |
+
outer_checksum => OuterChecksum,
|
| 91 |
+
inner_checksum => InnerChecksum
|
| 92 |
+
}};
|
| 93 |
+
false ->
|
| 94 |
+
{error, {tarball, {too_big_compressed, TarballMaxSize}}}
|
| 95 |
+
end;
|
| 96 |
+
false ->
|
| 97 |
+
{error, {tarball, {too_big_uncompressed, TarballMaxUncompressedSize}}}
|
| 98 |
+
end.
|
| 99 |
+
|
| 100 |
+
-spec create(metadata(), files()) ->
|
| 101 |
+
{ok, #{
|
| 102 |
+
tarball => tarball(),
|
| 103 |
+
outer_checksum => checksum(),
|
| 104 |
+
inner_checksum => tarball()
|
| 105 |
+
}}
|
| 106 |
+
| {error, term()}.
|
| 107 |
+
create(Metadata, Files) ->
|
| 108 |
+
create(Metadata, Files, hex_core:default_config()).
|
| 109 |
+
|
| 110 |
+
%% @doc
|
| 111 |
+
%% Creates a docs tarball.
|
| 112 |
+
%%
|
| 113 |
+
%% Examples:
|
| 114 |
+
%%
|
| 115 |
+
%% ```
|
| 116 |
+
%% > Files = [{"doc/index.html", <<"Docs">>}],
|
| 117 |
+
%% > hex_tarball:create_docs(Files).
|
| 118 |
+
%% {ok, <<86,69,...>>}
|
| 119 |
+
%% '''
|
| 120 |
+
%% @end
|
| 121 |
+
-spec create_docs(files(), hex_core:config()) -> {ok, tarball()} | {error, term()}.
|
| 122 |
+
create_docs(Files, Config) ->
|
| 123 |
+
#{
|
| 124 |
+
docs_tarball_max_size := TarballMaxSize,
|
| 125 |
+
docs_tarball_max_uncompressed_size := TarballMaxUncompressedSize
|
| 126 |
+
} = Config,
|
| 127 |
+
|
| 128 |
+
UncompressedTarball = create_memory_tarball(Files),
|
| 129 |
+
|
| 130 |
+
case valid_size(UncompressedTarball, TarballMaxUncompressedSize) of
|
| 131 |
+
true ->
|
| 132 |
+
Tarball = gzip(UncompressedTarball),
|
| 133 |
+
|
| 134 |
+
case valid_size(Tarball, TarballMaxSize) of
|
| 135 |
+
true ->
|
| 136 |
+
{ok, Tarball};
|
| 137 |
+
false ->
|
| 138 |
+
{error, {tarball, {too_big_compressed, TarballMaxSize}}}
|
| 139 |
+
end;
|
| 140 |
+
false ->
|
| 141 |
+
{error, {tarball, {too_big_uncompressed, TarballMaxUncompressedSize}}}
|
| 142 |
+
end.
|
| 143 |
+
|
| 144 |
+
-spec create_docs(files()) -> {ok, tarball()} | {error, term()}.
|
| 145 |
+
create_docs(Files) ->
|
| 146 |
+
create_docs(Files, hex_core:default_config()).
|
| 147 |
+
|
| 148 |
+
%% @doc
|
| 149 |
+
%% Unpacks a package tarball.
|
| 150 |
+
%%
|
| 151 |
+
%% Remember to verify the outer tarball checksum against the registry checksum
|
| 152 |
+
%% returned from `hex_repo:get_package(Config, Package)'.
|
| 153 |
+
%%
|
| 154 |
+
%% Examples:
|
| 155 |
+
%%
|
| 156 |
+
%% ```
|
| 157 |
+
%% > hex_tarball:unpack(Tarball, memory).
|
| 158 |
+
%% {ok,#{outer_checksum => <<...>>,
|
| 159 |
+
%% contents => [{"src/foo.erl",<<"-module(foo).">>}],
|
| 160 |
+
%% metadata => #{<<"name">> => <<"foo">>, ...}}}
|
| 161 |
+
%%
|
| 162 |
+
%% > hex_tarball:unpack(Tarball, "path/to/unpack").
|
| 163 |
+
%% {ok,#{outer_checksum => <<...>>,
|
| 164 |
+
%% metadata => #{<<"name">> => <<"foo">>, ...}}}
|
| 165 |
+
%% '''
|
| 166 |
+
-spec unpack
|
| 167 |
+
(tarball(), memory, hex_core:config()) ->
|
| 168 |
+
{ok, #{
|
| 169 |
+
outer_checksum => checksum(),
|
| 170 |
+
inner_checksum => checksum(),
|
| 171 |
+
metadata => metadata(),
|
| 172 |
+
contents => contents()
|
| 173 |
+
}}
|
| 174 |
+
| {error, term()};
|
| 175 |
+
(tarball(), filename(), hex_core:config()) ->
|
| 176 |
+
{ok, #{
|
| 177 |
+
outer_checksum => checksum(),
|
| 178 |
+
inner_checksum => checksum(),
|
| 179 |
+
metadata => metadata()
|
| 180 |
+
}}
|
| 181 |
+
| {error, term()}.
|
| 182 |
+
unpack(Tarball, Output, Config) ->
|
| 183 |
+
case valid_size(Tarball, maps:get(tarball_max_size, Config)) of
|
| 184 |
+
true ->
|
| 185 |
+
case hex_erl_tar:extract({binary, Tarball}, [memory]) of
|
| 186 |
+
{ok, []} ->
|
| 187 |
+
{error, {tarball, empty}};
|
| 188 |
+
{ok, FileList} ->
|
| 189 |
+
OuterChecksum = crypto:hash(sha256, Tarball),
|
| 190 |
+
do_unpack(maps:from_list(FileList), OuterChecksum, Output);
|
| 191 |
+
{error, Reason} ->
|
| 192 |
+
{error, {tarball, Reason}}
|
| 193 |
+
end;
|
| 194 |
+
false ->
|
| 195 |
+
{error, {tarball, too_big}}
|
| 196 |
+
end.
|
| 197 |
+
|
| 198 |
+
%% @doc
|
| 199 |
+
%% Unpacks a package tarball.
|
| 200 |
+
%%
|
| 201 |
+
%% @see unpack/3
|
| 202 |
+
-spec unpack
|
| 203 |
+
(tarball(), memory) ->
|
| 204 |
+
{ok, #{
|
| 205 |
+
outer_checksum => checksum(),
|
| 206 |
+
inner_checksum => checksum(),
|
| 207 |
+
metadata => metadata(),
|
| 208 |
+
contents => contents()
|
| 209 |
+
}}
|
| 210 |
+
| {error, term()};
|
| 211 |
+
(tarball(), filename()) ->
|
| 212 |
+
{ok, #{
|
| 213 |
+
outer_checksum => checksum(),
|
| 214 |
+
inner_checksum => checksum(),
|
| 215 |
+
metadata => metadata()
|
| 216 |
+
}}
|
| 217 |
+
| {error, term()}.
|
| 218 |
+
unpack(Tarball, Output) ->
|
| 219 |
+
unpack(Tarball, Output, hex_core:default_config()).
|
| 220 |
+
|
| 221 |
+
%% @doc
|
| 222 |
+
%% Unpacks a documentation tarball.
|
| 223 |
+
%%
|
| 224 |
+
%% Examples:
|
| 225 |
+
%%
|
| 226 |
+
%% ```
|
| 227 |
+
%% > hex_tarball:unpack_docs(Tarball, memory).
|
| 228 |
+
%% {ok, [{"index.html", <<"<!doctype>">>}, ...]}
|
| 229 |
+
%%
|
| 230 |
+
%% > hex_tarball:unpack_docs(Tarball, "path/to/unpack").
|
| 231 |
+
%% ok
|
| 232 |
+
%% '''
|
| 233 |
+
-spec unpack_docs
|
| 234 |
+
(tarball(), memory, hex_core:config()) -> {ok, contents()} | {error, term()};
|
| 235 |
+
(tarball(), filename(), hex_core:config()) -> ok | {error, term()}.
|
| 236 |
+
unpack_docs(Tarball, Output, Config) ->
|
| 237 |
+
case valid_size(Tarball, maps:get(docs_tarball_max_size, Config)) of
|
| 238 |
+
true ->
|
| 239 |
+
unpack_tarball(Tarball, Output);
|
| 240 |
+
false ->
|
| 241 |
+
{error, {tarball, too_big}}
|
| 242 |
+
end.
|
| 243 |
+
|
| 244 |
+
-spec unpack_docs
|
| 245 |
+
(tarball(), memory) -> {ok, contents()} | {error, term()};
|
| 246 |
+
(tarball(), filename()) -> ok | {error, term()}.
|
| 247 |
+
unpack_docs(Tarball, Output) ->
|
| 248 |
+
unpack_docs(Tarball, Output, hex_core:default_config()).
|
| 249 |
+
|
| 250 |
+
%% @doc
|
| 251 |
+
%% Returns base16-encoded representation of checksum.
|
| 252 |
+
-spec format_checksum(checksum()) -> binary().
|
| 253 |
+
format_checksum(Checksum) ->
|
| 254 |
+
encode_base16(Checksum).
|
| 255 |
+
|
| 256 |
+
%% @doc
|
| 257 |
+
%% Converts an error reason term to a human-readable error message string.
|
| 258 |
+
-spec format_error(term()) -> string().
|
| 259 |
+
format_error({tarball, empty}) ->
|
| 260 |
+
"empty tarball";
|
| 261 |
+
format_error({tarball, {too_big_uncompressed, Size}}) ->
|
| 262 |
+
io_lib:format("package exceeds max uncompressed size ~w ~s", [format_byte_size(Size), "MB"]);
|
| 263 |
+
format_error({tarball, {too_big_compressed, Size}}) ->
|
| 264 |
+
io_lib:format("package exceeds max compressed size ~w ~s", [format_byte_size(Size), "MB"]);
|
| 265 |
+
format_error({tarball, {missing_files, Files}}) ->
|
| 266 |
+
io_lib:format("missing files: ~p", [Files]);
|
| 267 |
+
format_error({tarball, {bad_version, Vsn}}) ->
|
| 268 |
+
io_lib:format("unsupported version: ~p", [Vsn]);
|
| 269 |
+
format_error({tarball, invalid_checksum}) ->
|
| 270 |
+
"invalid tarball checksum";
|
| 271 |
+
format_error({tarball, Reason}) ->
|
| 272 |
+
"tarball error, " ++ hex_erl_tar:format_error(Reason);
|
| 273 |
+
format_error({inner_tarball, Reason}) ->
|
| 274 |
+
"inner tarball error, " ++ hex_erl_tar:format_error(Reason);
|
| 275 |
+
format_error({metadata, invalid_terms}) ->
|
| 276 |
+
"error reading package metadata: invalid terms";
|
| 277 |
+
format_error({metadata, not_key_value}) ->
|
| 278 |
+
"error reading package metadata: not in key-value format";
|
| 279 |
+
format_error({metadata, Reason}) ->
|
| 280 |
+
"error reading package metadata" ++ safe_erl_term:format_error(Reason);
|
| 281 |
+
format_error({checksum_mismatch, ExpectedChecksum, ActualChecksum}) ->
|
| 282 |
+
io_lib:format(
|
| 283 |
+
"tarball checksum mismatch~n~n" ++
|
| 284 |
+
"Expected (base16-encoded): ~s~n" ++
|
| 285 |
+
"Actual (base16-encoded): ~s",
|
| 286 |
+
[encode_base16(ExpectedChecksum), encode_base16(ActualChecksum)]
|
| 287 |
+
).
|
| 288 |
+
|
| 289 |
+
format_byte_size(Size) ->
|
| 290 |
+
Size / 1000000.
|
| 291 |
+
|
| 292 |
+
%%====================================================================
|
| 293 |
+
%% Internal functions
|
| 294 |
+
%%====================================================================
|
| 295 |
+
|
| 296 |
+
%% @private
|
| 297 |
+
inner_checksum(Version, MetadataBinary, ContentsBinary) ->
|
| 298 |
+
Blob = <<Version/binary, MetadataBinary/binary, ContentsBinary/binary>>,
|
| 299 |
+
crypto:hash(sha256, Blob).
|
| 300 |
+
|
| 301 |
+
%% @private
|
| 302 |
+
checksum(ContentsBinary) when is_binary(ContentsBinary) ->
|
| 303 |
+
crypto:hash(sha256, ContentsBinary).
|
| 304 |
+
|
| 305 |
+
%% @private
|
| 306 |
+
encode_metadata(Meta) ->
|
| 307 |
+
Data = lists:map(
|
| 308 |
+
fun(MetaPair) ->
|
| 309 |
+
String = io_lib_pretty:print(binarify(MetaPair), [{encoding, utf8}]),
|
| 310 |
+
unicode:characters_to_binary([String, ".\n"])
|
| 311 |
+
end,
|
| 312 |
+
maps:to_list(Meta)
|
| 313 |
+
),
|
| 314 |
+
iolist_to_binary(Data).
|
| 315 |
+
|
| 316 |
+
%% @private
|
| 317 |
+
do_unpack(Files, OuterChecksum, Output) ->
|
| 318 |
+
State = #{
|
| 319 |
+
inner_checksum => undefined,
|
| 320 |
+
outer_checksum => OuterChecksum,
|
| 321 |
+
contents => undefined,
|
| 322 |
+
files => Files,
|
| 323 |
+
metadata => undefined,
|
| 324 |
+
output => Output
|
| 325 |
+
},
|
| 326 |
+
State1 = check_files(State),
|
| 327 |
+
State2 = check_version(State1),
|
| 328 |
+
State3 = check_inner_checksum(State2),
|
| 329 |
+
State4 = decode_metadata(State3),
|
| 330 |
+
finish_unpack(State4).
|
| 331 |
+
|
| 332 |
+
%% @private
|
| 333 |
+
finish_unpack({error, _} = Error) ->
|
| 334 |
+
Error;
|
| 335 |
+
finish_unpack(#{
|
| 336 |
+
metadata := Metadata,
|
| 337 |
+
files := Files,
|
| 338 |
+
inner_checksum := InnerChecksum,
|
| 339 |
+
outer_checksum := OuterChecksum,
|
| 340 |
+
output := Output
|
| 341 |
+
}) ->
|
| 342 |
+
_ = maps:get("VERSION", Files),
|
| 343 |
+
ContentsBinary = maps:get("contents.tar.gz", Files),
|
| 344 |
+
|
| 345 |
+
case Output of
|
| 346 |
+
memory -> ok;
|
| 347 |
+
_ -> filelib:ensure_dir(filename:join(Output, "*"))
|
| 348 |
+
end,
|
| 349 |
+
|
| 350 |
+
case unpack_tarball(ContentsBinary, Output) of
|
| 351 |
+
ok ->
|
| 352 |
+
copy_metadata_config(Output, maps:get("metadata.config", Files)),
|
| 353 |
+
{ok, #{
|
| 354 |
+
inner_checksum => InnerChecksum,
|
| 355 |
+
outer_checksum => OuterChecksum,
|
| 356 |
+
metadata => Metadata
|
| 357 |
+
}};
|
| 358 |
+
{ok, Contents} ->
|
| 359 |
+
{ok, #{
|
| 360 |
+
inner_checksum => InnerChecksum,
|
| 361 |
+
outer_checksum => OuterChecksum,
|
| 362 |
+
metadata => Metadata,
|
| 363 |
+
contents => Contents
|
| 364 |
+
}};
|
| 365 |
+
{error, Reason} ->
|
| 366 |
+
{error, {inner_tarball, Reason}}
|
| 367 |
+
end.
|
| 368 |
+
|
| 369 |
+
%% @private
|
| 370 |
+
copy_metadata_config(Output, MetadataBinary) ->
|
| 371 |
+
ok = file:write_file(filename:join(Output, "hex_metadata.config"), MetadataBinary).
|
| 372 |
+
|
| 373 |
+
%% @private
|
| 374 |
+
check_files(#{files := Files} = State) ->
|
| 375 |
+
RequiredFiles = ["VERSION", "CHECKSUM", "metadata.config", "contents.tar.gz"],
|
| 376 |
+
case diff_keys(Files, RequiredFiles, []) of
|
| 377 |
+
ok ->
|
| 378 |
+
State;
|
| 379 |
+
{error, {missing_keys, Keys}} ->
|
| 380 |
+
{error, {tarball, {missing_files, Keys}}}
|
| 381 |
+
end.
|
| 382 |
+
|
| 383 |
+
%% @private
|
| 384 |
+
check_version({error, _} = Error) ->
|
| 385 |
+
Error;
|
| 386 |
+
check_version(#{files := Files} = State) ->
|
| 387 |
+
case maps:get("VERSION", Files) of
|
| 388 |
+
<<"3">> ->
|
| 389 |
+
State;
|
| 390 |
+
Version ->
|
| 391 |
+
{error, {tarball, {bad_version, Version}}}
|
| 392 |
+
end.
|
| 393 |
+
|
| 394 |
+
%% @private
|
| 395 |
+
% Note: This checksum is deprecated
|
| 396 |
+
check_inner_checksum({error, _} = Error) ->
|
| 397 |
+
Error;
|
| 398 |
+
check_inner_checksum(#{files := Files} = State) ->
|
| 399 |
+
ChecksumBase16 = maps:get("CHECKSUM", Files),
|
| 400 |
+
ExpectedChecksum = decode_base16(ChecksumBase16),
|
| 401 |
+
|
| 402 |
+
Version = maps:get("VERSION", Files),
|
| 403 |
+
MetadataBinary = maps:get("metadata.config", Files),
|
| 404 |
+
ContentsBinary = maps:get("contents.tar.gz", Files),
|
| 405 |
+
ActualChecksum = inner_checksum(Version, MetadataBinary, ContentsBinary),
|
| 406 |
+
|
| 407 |
+
if
|
| 408 |
+
byte_size(ExpectedChecksum) /= 32 ->
|
| 409 |
+
{error, {tarball, invalid_inner_checksum}};
|
| 410 |
+
ExpectedChecksum == ActualChecksum ->
|
| 411 |
+
maps:put(inner_checksum, ExpectedChecksum, State);
|
| 412 |
+
true ->
|
| 413 |
+
{error, {tarball, {inner_checksum_mismatch, ExpectedChecksum, ActualChecksum}}}
|
| 414 |
+
end.
|
| 415 |
+
|
| 416 |
+
%% @private
|
| 417 |
+
decode_metadata({error, _} = Error) ->
|
| 418 |
+
Error;
|
| 419 |
+
decode_metadata(#{files := #{"metadata.config" := Binary}} = State) when is_binary(Binary) ->
|
| 420 |
+
case do_decode_metadata(Binary) of
|
| 421 |
+
#{} = Metadata -> maps:put(metadata, normalize_metadata(Metadata), State);
|
| 422 |
+
Other -> Other
|
| 423 |
+
end.
|
| 424 |
+
|
| 425 |
+
%% @private
|
| 426 |
+
do_decode_metadata(Binary) when is_binary(Binary) ->
|
| 427 |
+
{ok, String} = characters_to_list(Binary),
|
| 428 |
+
|
| 429 |
+
case safe_erl_term:string(String) of
|
| 430 |
+
{ok, Tokens, _Line} ->
|
| 431 |
+
try
|
| 432 |
+
Terms = safe_erl_term:terms(Tokens),
|
| 433 |
+
maps:from_list(Terms)
|
| 434 |
+
catch
|
| 435 |
+
error:function_clause ->
|
| 436 |
+
{error, {metadata, invalid_terms}};
|
| 437 |
+
error:badarg ->
|
| 438 |
+
{error, {metadata, not_key_value}}
|
| 439 |
+
end;
|
| 440 |
+
{error, {_Line, safe_erl_term, Reason}, _Line2} ->
|
| 441 |
+
{error, {metadata, Reason}}
|
| 442 |
+
end.
|
| 443 |
+
|
| 444 |
+
%% @private
|
| 445 |
+
characters_to_list(Binary) ->
|
| 446 |
+
case unicode:characters_to_list(Binary) of
|
| 447 |
+
List when is_list(List) ->
|
| 448 |
+
{ok, List};
|
| 449 |
+
{error, _, _} ->
|
| 450 |
+
case unicode:characters_to_list(Binary, latin1) of
|
| 451 |
+
List when is_list(List) -> {ok, List};
|
| 452 |
+
Other -> Other
|
| 453 |
+
end
|
| 454 |
+
end.
|
| 455 |
+
|
| 456 |
+
%% @private
|
| 457 |
+
normalize_metadata(Metadata1) ->
|
| 458 |
+
Metadata2 = maybe_update_with(<<"requirements">>, fun normalize_requirements/1, Metadata1),
|
| 459 |
+
Metadata3 = maybe_update_with(<<"links">>, fun try_into_map/1, Metadata2),
|
| 460 |
+
Metadata4 = maybe_update_with(<<"extra">>, fun try_into_nested_map/1, Metadata3),
|
| 461 |
+
guess_build_tools(Metadata4).
|
| 462 |
+
|
| 463 |
+
%% @private
|
| 464 |
+
normalize_requirements(Requirements) ->
|
| 465 |
+
case is_list(Requirements) andalso (Requirements /= []) andalso is_list(hd(Requirements)) of
|
| 466 |
+
true ->
|
| 467 |
+
maps:from_list(lists:map(fun normalize_legacy_requirement/1, Requirements));
|
| 468 |
+
false ->
|
| 469 |
+
try_into_map(fun normalize_normal_requirement/1, Requirements)
|
| 470 |
+
end.
|
| 471 |
+
|
| 472 |
+
%% @private
|
| 473 |
+
normalize_normal_requirement({Name, Requirement}) ->
|
| 474 |
+
{Name, try_into_map(Requirement)}.
|
| 475 |
+
|
| 476 |
+
%% @private
|
| 477 |
+
normalize_legacy_requirement(Requirement) ->
|
| 478 |
+
Map = maps:from_list(Requirement),
|
| 479 |
+
Name = maps:get(<<"name">>, Map),
|
| 480 |
+
{Name, maps:without([<<"name">>], Map)}.
|
| 481 |
+
|
| 482 |
+
%% @private
|
| 483 |
+
guess_build_tools(#{<<"build_tools">> := BuildTools} = Metadata) when is_list(BuildTools) ->
|
| 484 |
+
Metadata;
|
| 485 |
+
guess_build_tools(#{<<"files">> := Filenames} = Metadata) ->
|
| 486 |
+
BaseFiles = [
|
| 487 |
+
Filename
|
| 488 |
+
|| Filename <- Filenames, filename:dirname(binary_to_list(Filename)) == "."
|
| 489 |
+
],
|
| 490 |
+
BuildTools = lists:usort([
|
| 491 |
+
Tool
|
| 492 |
+
|| {Filename, Tool} <- ?BUILD_TOOL_FILES, lists:member(Filename, BaseFiles)
|
| 493 |
+
]),
|
| 494 |
+
Metadata#{<<"build_tools">> => BuildTools};
|
| 495 |
+
guess_build_tools(Metadata) ->
|
| 496 |
+
Metadata.
|
| 497 |
+
|
| 498 |
+
%%====================================================================
|
| 499 |
+
%% Tar Helpers
|
| 500 |
+
%%====================================================================
|
| 501 |
+
|
| 502 |
+
%% @private
|
| 503 |
+
unpack_tarball(ContentsBinary, memory) ->
|
| 504 |
+
hex_erl_tar:extract({binary, ContentsBinary}, [memory, compressed]);
|
| 505 |
+
unpack_tarball(ContentsBinary, Output) ->
|
| 506 |
+
filelib:ensure_dir(filename:join(Output, "*")),
|
| 507 |
+
case hex_erl_tar:extract({binary, ContentsBinary}, [{cwd, Output}, compressed]) of
|
| 508 |
+
ok ->
|
| 509 |
+
[
|
| 510 |
+
try_updating_mtime(filename:join(Output, Path))
|
| 511 |
+
|| Path <- filelib:wildcard("**", Output)
|
| 512 |
+
],
|
| 513 |
+
ok;
|
| 514 |
+
Other ->
|
| 515 |
+
Other
|
| 516 |
+
end.
|
| 517 |
+
|
| 518 |
+
%% @private
|
| 519 |
+
%% let it silently fail for bad symlinks
|
| 520 |
+
try_updating_mtime(Path) ->
|
| 521 |
+
Time = calendar:universal_time(),
|
| 522 |
+
_ = file:write_file_info(Path, #file_info{mtime = Time}, [{time, universal}]),
|
| 523 |
+
ok.
|
| 524 |
+
|
| 525 |
+
%% @private
|
| 526 |
+
create_memory_tarball(Files) ->
|
| 527 |
+
Path = tmp_path(),
|
| 528 |
+
{ok, Tar} = hex_erl_tar:open(Path, [write]),
|
| 529 |
+
|
| 530 |
+
try
|
| 531 |
+
add_files(Tar, Files)
|
| 532 |
+
after
|
| 533 |
+
ok = hex_erl_tar:close(Tar)
|
| 534 |
+
end,
|
| 535 |
+
{ok, Tarball} = file:read_file(Path),
|
| 536 |
+
ok = file:delete(Path),
|
| 537 |
+
Tarball.
|
| 538 |
+
|
| 539 |
+
%% @private
|
| 540 |
+
tmp_path() ->
|
| 541 |
+
"tmp_" ++ binary_to_list(encode_base16(crypto:strong_rand_bytes(32))).
|
| 542 |
+
|
| 543 |
+
%% @private
|
| 544 |
+
add_files(Tar, Files) when is_list(Files) ->
|
| 545 |
+
lists:map(fun(File) -> add_file(Tar, File) end, Files).
|
| 546 |
+
|
| 547 |
+
%% @private
|
| 548 |
+
add_file(Tar, {Filename, Contents}) when is_list(Filename) and is_binary(Contents) ->
|
| 549 |
+
ok = hex_erl_tar:add(Tar, Contents, Filename, tar_opts());
|
| 550 |
+
add_file(Tar, Filename) when is_list(Filename) ->
|
| 551 |
+
add_file(Tar, {Filename, Filename});
|
| 552 |
+
add_file(Tar, {Filename, AbsFilename}) when is_list(Filename), is_list(AbsFilename) ->
|
| 553 |
+
{ok, FileInfo} = file:read_link_info(AbsFilename, []),
|
| 554 |
+
|
| 555 |
+
case FileInfo#file_info.type of
|
| 556 |
+
symlink ->
|
| 557 |
+
ok = hex_erl_tar:add(Tar, {Filename, AbsFilename}, tar_opts());
|
| 558 |
+
directory ->
|
| 559 |
+
case file:list_dir(AbsFilename) of
|
| 560 |
+
{ok, []} ->
|
| 561 |
+
hex_erl_tar:add(Tar, {Filename, AbsFilename}, tar_opts());
|
| 562 |
+
{ok, _} ->
|
| 563 |
+
ok
|
| 564 |
+
end;
|
| 565 |
+
_ ->
|
| 566 |
+
Mode = FileInfo#file_info.mode,
|
| 567 |
+
{ok, Contents} = file:read_file(AbsFilename),
|
| 568 |
+
ok = hex_erl_tar:add(Tar, Contents, Filename, Mode, tar_opts())
|
| 569 |
+
end.
|
| 570 |
+
|
| 571 |
+
%% @private
|
| 572 |
+
tar_opts() ->
|
| 573 |
+
NixEpoch = calendar:datetime_to_gregorian_seconds({{1970, 1, 1}, {0, 0, 0}}),
|
| 574 |
+
Y2kEpoch = calendar:datetime_to_gregorian_seconds({{2000, 1, 1}, {0, 0, 0}}),
|
| 575 |
+
Epoch = Y2kEpoch - NixEpoch,
|
| 576 |
+
[{atime, Epoch}, {mtime, Epoch}, {ctime, Epoch}, {uid, 0}, {gid, 0}].
|
| 577 |
+
|
| 578 |
+
%% @private
|
| 579 |
+
%% Reproducible gzip by not setting mtime and OS
|
| 580 |
+
%%
|
| 581 |
+
%% From https://tools.ietf.org/html/rfc1952
|
| 582 |
+
%%
|
| 583 |
+
%% +---+---+---+---+---+---+---+---+---+---+
|
| 584 |
+
%% |ID1|ID2|CM |FLG| MTIME |XFL|OS | (more-->)
|
| 585 |
+
%% +---+---+---+---+---+---+---+---+---+---+
|
| 586 |
+
%%
|
| 587 |
+
%% +=======================+
|
| 588 |
+
%% |...compressed blocks...| (more-->)
|
| 589 |
+
%% +=======================+
|
| 590 |
+
%%
|
| 591 |
+
%% +---+---+---+---+---+---+---+---+
|
| 592 |
+
%% | CRC32 | ISIZE |
|
| 593 |
+
%% +---+---+---+---+---+---+---+---+
|
| 594 |
+
gzip(Uncompressed) ->
|
| 595 |
+
Compressed = gzip_no_header(Uncompressed),
|
| 596 |
+
Header = <<31, 139, 8, 0, 0, 0, 0, 0, 0, 0>>,
|
| 597 |
+
Crc = erlang:crc32(Uncompressed),
|
| 598 |
+
Size = byte_size(Uncompressed),
|
| 599 |
+
Trailer = <<Crc:32/little, Size:32/little>>,
|
| 600 |
+
iolist_to_binary([Header, Compressed, Trailer]).
|
| 601 |
+
|
| 602 |
+
%% @private
|
| 603 |
+
gzip_no_header(Uncompressed) ->
|
| 604 |
+
Zstream = zlib:open(),
|
| 605 |
+
|
| 606 |
+
try
|
| 607 |
+
zlib:deflateInit(Zstream, default, deflated, -15, 8, default),
|
| 608 |
+
Compressed = zlib:deflate(Zstream, Uncompressed, finish),
|
| 609 |
+
zlib:deflateEnd(Zstream),
|
| 610 |
+
iolist_to_binary(Compressed)
|
| 611 |
+
after
|
| 612 |
+
zlib:close(Zstream)
|
| 613 |
+
end.
|
| 614 |
+
|
| 615 |
+
%%====================================================================
|
| 616 |
+
%% Helpers
|
| 617 |
+
%%====================================================================
|
| 618 |
+
|
| 619 |
+
%% @private
|
| 620 |
+
valid_size(Binary, infinity) when is_binary(Binary) ->
|
| 621 |
+
true;
|
| 622 |
+
valid_size(Binary, Limit) when is_binary(Binary) and is_integer(Limit) ->
|
| 623 |
+
byte_size(Binary) =< Limit.
|
| 624 |
+
|
| 625 |
+
%% @private
|
| 626 |
+
binarify(Binary) when is_binary(Binary) -> Binary;
|
| 627 |
+
binarify(Number) when is_number(Number) -> Number;
|
| 628 |
+
binarify(Atom) when Atom == undefined orelse is_boolean(Atom) -> Atom;
|
| 629 |
+
binarify(Atom) when is_atom(Atom) -> atom_to_binary(Atom, utf8);
|
| 630 |
+
binarify(List) when is_list(List) ->
|
| 631 |
+
[binarify(E) || E <- List];
|
| 632 |
+
binarify({Key, Value}) ->
|
| 633 |
+
{binarify(Key), binarify(Value)};
|
| 634 |
+
binarify(Map) when is_map(Map) ->
|
| 635 |
+
List = maps:to_list(Map),
|
| 636 |
+
lists:map(fun({K, V}) -> binarify({K, V}) end, List).
|
| 637 |
+
|
| 638 |
+
%% @private
|
| 639 |
+
diff_keys(Map, RequiredKeys, OptionalKeys) ->
|
| 640 |
+
Keys = maps:keys(Map),
|
| 641 |
+
MissingKeys = RequiredKeys -- Keys,
|
| 642 |
+
UnknownKeys = Keys -- (RequiredKeys ++ OptionalKeys),
|
| 643 |
+
|
| 644 |
+
case {MissingKeys, UnknownKeys} of
|
| 645 |
+
{[], []} ->
|
| 646 |
+
ok;
|
| 647 |
+
% Server should validate this but clients should not
|
| 648 |
+
% {_, [_ | _]} ->
|
| 649 |
+
% {error, {unknown_keys, UnknownKeys}};
|
| 650 |
+
|
| 651 |
+
_ ->
|
| 652 |
+
{error, {missing_keys, MissingKeys}}
|
| 653 |
+
end.
|
| 654 |
+
|
| 655 |
+
%% @private
|
| 656 |
+
maybe_update_with(Key, Fun, Map) ->
|
| 657 |
+
case maps:find(Key, Map) of
|
| 658 |
+
{ok, Value} -> maps:put(Key, Fun(Value), Map);
|
| 659 |
+
error -> Map
|
| 660 |
+
end.
|
| 661 |
+
|
| 662 |
+
%% @private
|
| 663 |
+
try_into_map(List) ->
|
| 664 |
+
try_into_map(fun(X) -> X end, List).
|
| 665 |
+
|
| 666 |
+
%% @private
|
| 667 |
+
try_into_map(Fun, Input) ->
|
| 668 |
+
case has_map_shape(Input) of
|
| 669 |
+
true -> maps:from_list(lists:map(Fun, Input));
|
| 670 |
+
false -> Input
|
| 671 |
+
end.
|
| 672 |
+
|
| 673 |
+
%% @private
|
| 674 |
+
try_into_nested_map(List) ->
|
| 675 |
+
try_into_nested_map(fun(X) -> X end, List).
|
| 676 |
+
|
| 677 |
+
%% @private
|
| 678 |
+
try_into_nested_map(Fun, Input) ->
|
| 679 |
+
case has_map_shape(Input) of
|
| 680 |
+
true ->
|
| 681 |
+
maps:from_list(
|
| 682 |
+
lists:map(
|
| 683 |
+
fun({Key, Value}) ->
|
| 684 |
+
Fun({Key, try_into_nested_map(Fun, Value)})
|
| 685 |
+
end,
|
| 686 |
+
Input
|
| 687 |
+
)
|
| 688 |
+
);
|
| 689 |
+
false ->
|
| 690 |
+
Input
|
| 691 |
+
end.
|
| 692 |
+
|
| 693 |
+
%% @private
|
| 694 |
+
has_map_shape(Input) ->
|
| 695 |
+
is_list(Input) andalso
|
| 696 |
+
lists:all(fun(E) -> is_tuple(E) andalso (tuple_size(E) == 2) end, Input).
|
| 697 |
+
|
| 698 |
+
%% @private
|
| 699 |
+
encode_base16(Binary) ->
|
| 700 |
+
<<X:256/big-unsigned-integer>> = Binary,
|
| 701 |
+
String = string:to_upper(lists:flatten(io_lib:format("~64.16.0b", [X]))),
|
| 702 |
+
list_to_binary(String).
|
| 703 |
+
|
| 704 |
+
%% Based on https://github.com/goj/base16/blob/master/src/base16.erl
|
| 705 |
+
%% (C) 2012, Erlang Solutions Ltd.
|
| 706 |
+
|
| 707 |
+
%% @private
|
| 708 |
+
decode_base16(Base16) ->
|
| 709 |
+
<<<<(unhex(H) bsl 4 + unhex(L))>> || <<H, L>> <= Base16>>.
|
| 710 |
+
|
| 711 |
+
%% @private
|
| 712 |
+
unhex(D) when $0 =< D andalso D =< $9 ->
|
| 713 |
+
D - $0;
|
| 714 |
+
unhex(D) when $a =< D andalso D =< $f ->
|
| 715 |
+
10 + D - $a;
|
| 716 |
+
unhex(D) when $A =< D andalso D =< $F ->
|
| 717 |
+
10 + D - $A.
|
deps/eini/_build/default/plugins/hex_core/src/safe_erl_term.xrl
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%%% Author : Robert Virding
|
| 2 |
+
%%% Purpose : Token definitions for Erlang.
|
| 3 |
+
|
| 4 |
+
Definitions.
|
| 5 |
+
|
| 6 |
+
D = [0-9]
|
| 7 |
+
U = [A-Z]
|
| 8 |
+
L = [a-z]
|
| 9 |
+
A = ({U}|{L}|{D}|_|@)
|
| 10 |
+
WS = ([\000-\s])
|
| 11 |
+
|
| 12 |
+
Rules.
|
| 13 |
+
|
| 14 |
+
{L}{A}* : tokenize_atom(TokenChars, TokenLine).
|
| 15 |
+
'(\\\^.|\\.|[^'])*' : tokenize_atom(escape(unquote(TokenChars, TokenLen)), TokenLine).
|
| 16 |
+
"(\\\^.|\\.|[^"])*" : {token, {string, TokenLine, escape(unquote(TokenChars, TokenLen))}}.
|
| 17 |
+
{D}+ : {token, {integer, TokenLine, list_to_integer(TokenChars)}}.
|
| 18 |
+
[\#\[\]}{,+-] : {token, {list_to_atom(TokenChars), TokenLine}}.
|
| 19 |
+
(<<|>>|=>) : {token, {list_to_atom(TokenChars), TokenLine}}.
|
| 20 |
+
\. : {token, {dot, TokenLine}}.
|
| 21 |
+
/ : {token, {'/', TokenLine}}.
|
| 22 |
+
{WS}+ : skip_token.
|
| 23 |
+
|
| 24 |
+
Erlang code.
|
| 25 |
+
|
| 26 |
+
-export([terms/1]).
|
| 27 |
+
|
| 28 |
+
terms(Tokens) ->
|
| 29 |
+
terms(Tokens, []).
|
| 30 |
+
|
| 31 |
+
terms([{dot, _} = H], Buffer) ->
|
| 32 |
+
[buffer_to_term([H|Buffer])];
|
| 33 |
+
terms([{dot, _} = H|T], Buffer) ->
|
| 34 |
+
[buffer_to_term([H|Buffer])|terms(T, [])];
|
| 35 |
+
terms([H|T], Buffer) ->
|
| 36 |
+
terms(T, [H|Buffer]).
|
| 37 |
+
|
| 38 |
+
buffer_to_term(Buffer) ->
|
| 39 |
+
{ok, Term} = erl_parse:parse_term(lists:reverse(Buffer)),
|
| 40 |
+
Term.
|
| 41 |
+
|
| 42 |
+
unquote(TokenChars, TokenLen) ->
|
| 43 |
+
lists:sublist(TokenChars, 2, TokenLen - 2).
|
| 44 |
+
|
| 45 |
+
tokenize_atom(TokenChars, TokenLine) ->
|
| 46 |
+
try list_to_existing_atom(TokenChars) of
|
| 47 |
+
Atom -> {token, {atom, TokenLine, Atom}}
|
| 48 |
+
catch
|
| 49 |
+
error:badarg -> {error, "illegal atom " ++ TokenChars}
|
| 50 |
+
end.
|
| 51 |
+
|
| 52 |
+
escape([$\\|Cs]) ->
|
| 53 |
+
do_escape(Cs);
|
| 54 |
+
escape([C|Cs]) ->
|
| 55 |
+
[C|escape(Cs)];
|
| 56 |
+
escape([]) -> [].
|
| 57 |
+
|
| 58 |
+
do_escape([O1,O2,O3|S]) when
|
| 59 |
+
O1 >= $0, O1 =< $7, O2 >= $0, O2 =< $7, O3 >= $0, O3 =< $7 ->
|
| 60 |
+
[(O1*8 + O2)*8 + O3 - 73*$0|escape(S)];
|
| 61 |
+
do_escape([$^,C|Cs]) ->
|
| 62 |
+
[C band 31|escape(Cs)];
|
| 63 |
+
do_escape([C|Cs]) when C >= $\000, C =< $\s ->
|
| 64 |
+
escape(Cs);
|
| 65 |
+
do_escape([C|Cs]) ->
|
| 66 |
+
[escape_char(C)|escape(Cs)].
|
| 67 |
+
|
| 68 |
+
escape_char($n) -> $\n; %\n = LF
|
| 69 |
+
escape_char($r) -> $\r; %\r = CR
|
| 70 |
+
escape_char($t) -> $\t; %\t = TAB
|
| 71 |
+
escape_char($v) -> $\v; %\v = VT
|
| 72 |
+
escape_char($b) -> $\b; %\b = BS
|
| 73 |
+
escape_char($f) -> $\f; %\f = FF
|
| 74 |
+
escape_char($e) -> $\e; %\e = ESC
|
| 75 |
+
escape_char($s) -> $\s; %\s = SPC
|
| 76 |
+
escape_char($d) -> $\d; %\d = DEL
|
| 77 |
+
escape_char(C) -> C.
|
deps/eini/_build/default/plugins/rebar3_hex/LICENSE
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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2004
|
| 6 |
+
http://www.apache.org/licenses/
|
| 7 |
+
|
| 8 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 9 |
+
|
| 10 |
+
1. Definitions.
|
| 11 |
+
|
| 12 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 13 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 14 |
+
|
| 15 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 16 |
+
the copyright owner that is granting the License.
|
| 17 |
+
|
| 18 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 19 |
+
other entities that control, are controlled by, or are under common
|
| 20 |
+
control with that entity. For the purposes of this definition,
|
| 21 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 22 |
+
direction or management of such entity, whether by contract or
|
| 23 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 24 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 25 |
+
|
| 26 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 27 |
+
exercising permissions granted by this License.
|
| 28 |
+
|
| 29 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 30 |
+
including but not limited to software source code, documentation
|
| 31 |
+
source, and configuration files.
|
| 32 |
+
|
| 33 |
+
"Object" form shall mean any form resulting from mechanical
|
| 34 |
+
transformation or translation of a Source form, including but
|
| 35 |
+
not limited to compiled object code, generated documentation,
|
| 36 |
+
and conversions to other media types.
|
| 37 |
+
|
| 38 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 39 |
+
Object form, made available under the License, as indicated by a
|
| 40 |
+
copyright notice that is included in or attached to the work
|
| 41 |
+
(an example is provided in the Appendix below).
|
| 42 |
+
|
| 43 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 44 |
+
form, that is based on (or derived from) the Work and for which the
|
| 45 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 46 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 47 |
+
of this License, Derivative Works shall not include works that remain
|
| 48 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 49 |
+
the Work and Derivative Works thereof.
|
| 50 |
+
|
| 51 |
+
"Contribution" shall mean any work of authorship, including
|
| 52 |
+
the original version of the Work and any modifications or additions
|
| 53 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 54 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 55 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 56 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 57 |
+
means any form of electronic, verbal, or written communication sent
|
| 58 |
+
to the Licensor or its representatives, including but not limited to
|
| 59 |
+
communication on electronic mailing lists, source code control systems,
|
| 60 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 61 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 62 |
+
excluding communication that is conspicuously marked or otherwise
|
| 63 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 64 |
+
|
| 65 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 66 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 67 |
+
subsequently incorporated within the Work.
|
| 68 |
+
|
| 69 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 70 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 71 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 72 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 73 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 74 |
+
Work and such Derivative Works in Source or Object form.
|
| 75 |
+
|
| 76 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 77 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 78 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 79 |
+
(except as stated in this section) patent license to make, have made,
|
| 80 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 81 |
+
where such license applies only to those patent claims licensable
|
| 82 |
+
by such Contributor that are necessarily infringed by their
|
| 83 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 84 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 85 |
+
institute patent litigation against any entity (including a
|
| 86 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 87 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 88 |
+
or contributory patent infringement, then any patent licenses
|
| 89 |
+
granted to You under this License for that Work shall terminate
|
| 90 |
+
as of the date such litigation is filed.
|
| 91 |
+
|
| 92 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 93 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 94 |
+
modifications, and in Source or Object form, provided that You
|
| 95 |
+
meet the following conditions:
|
| 96 |
+
|
| 97 |
+
(a) You must give any other recipients of the Work or
|
| 98 |
+
Derivative Works a copy of this License; and
|
| 99 |
+
|
| 100 |
+
(b) You must cause any modified files to carry prominent notices
|
| 101 |
+
stating that You changed the files; and
|
| 102 |
+
|
| 103 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 104 |
+
that You distribute, all copyright, patent, trademark, and
|
| 105 |
+
attribution notices from the Source form of the Work,
|
| 106 |
+
excluding those notices that do not pertain to any part of
|
| 107 |
+
the Derivative Works; and
|
| 108 |
+
|
| 109 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 110 |
+
distribution, then any Derivative Works that You distribute must
|
| 111 |
+
include a readable copy of the attribution notices contained
|
| 112 |
+
within such NOTICE file, excluding those notices that do not
|
| 113 |
+
pertain to any part of the Derivative Works, in at least one
|
| 114 |
+
of the following places: within a NOTICE text file distributed
|
| 115 |
+
as part of the Derivative Works; within the Source form or
|
| 116 |
+
documentation, if provided along with the Derivative Works; or,
|
| 117 |
+
within a display generated by the Derivative Works, if and
|
| 118 |
+
wherever such third-party notices normally appear. The contents
|
| 119 |
+
of the NOTICE file are for informational purposes only and
|
| 120 |
+
do not modify the License. You may add Your own attribution
|
| 121 |
+
notices within Derivative Works that You distribute, alongside
|
| 122 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 123 |
+
that such additional attribution notices cannot be construed
|
| 124 |
+
as modifying the License.
|
| 125 |
+
|
| 126 |
+
You may add Your own copyright statement to Your modifications and
|
| 127 |
+
may provide additional or different license terms and conditions
|
| 128 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 129 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 130 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 131 |
+
the conditions stated in this License.
|
| 132 |
+
|
| 133 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 134 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 135 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 136 |
+
this License, without any additional terms or conditions.
|
| 137 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 138 |
+
the terms of any separate license agreement you may have executed
|
| 139 |
+
with Licensor regarding such Contributions.
|
| 140 |
+
|
| 141 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 142 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 143 |
+
except as required for reasonable and customary use in describing the
|
| 144 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 145 |
+
|
| 146 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 147 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 148 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 149 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 150 |
+
implied, including, without limitation, any warranties or conditions
|
| 151 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 152 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 153 |
+
appropriateness of using or redistributing the Work and assume any
|
| 154 |
+
risks associated with Your exercise of permissions under this License.
|
| 155 |
+
|
| 156 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 157 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 158 |
+
unless required by applicable law (such as deliberate and grossly
|
| 159 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 160 |
+
liable to You for damages, including any direct, indirect, special,
|
| 161 |
+
incidental, or consequential damages of any character arising as a
|
| 162 |
+
result of this License or out of the use or inability to use the
|
| 163 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 164 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 165 |
+
other commercial damages or losses), even if such Contributor
|
| 166 |
+
has been advised of the possibility of such damages.
|
| 167 |
+
|
| 168 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 169 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 170 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 171 |
+
or other liability obligations and/or rights consistent with this
|
| 172 |
+
License. However, in accepting such obligations, You may act only
|
| 173 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 174 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 175 |
+
defend, and hold each Contributor harmless for any liability
|
| 176 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 177 |
+
of your accepting any such warranty or additional liability.
|
| 178 |
+
|
| 179 |
+
END OF TERMS AND CONDITIONS
|
| 180 |
+
|
| 181 |
+
Copyright (c) 2015, Tristan Sloughter <t@crashfast.com>.
|
| 182 |
+
|
| 183 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 184 |
+
you may not use this file except in compliance with the License.
|
| 185 |
+
You may obtain a copy of the License at
|
| 186 |
+
|
| 187 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 188 |
+
|
| 189 |
+
Unless required by applicable law or agreed to in writing, software
|
| 190 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 191 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 192 |
+
See the License for the specific language governing permissions and
|
| 193 |
+
limitations under the License.
|
deps/eini/_build/default/plugins/rebar3_hex/README.md
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# rebar3_hex
|
| 2 |
+
|
| 3 |
+
[](https://github.com/erlef/rebar3_hex/actions/workflows/ci.yml)
|
| 4 |
+
[](https://hex.pm/packages/rebar3_hex)
|
| 5 |
+
[](https://hexdocs.pm/rebar3_hex)
|
| 6 |
+
[](http://www.erlang.org)
|
| 7 |
+
|
| 8 |
+
rebar3_hex is a plugin for [Rebar3](https://www.rebar3.org/) that bundles providers to interact with [Hex](https://hex.pm/).
|
| 9 |
+
|
| 10 |
+
> 💡 **rebar3_hex is a tool for package authors**
|
| 11 |
+
> If your Erlang project is not meant to be published on Hex, Rebar3 itself should be enough for you.
|
| 12 |
+
|
| 13 |
+
## Setup
|
| 14 |
+
|
| 15 |
+
Add to your global rebar3 config in `~/.config/rebar3/rebar.config`:
|
| 16 |
+
|
| 17 |
+
```erlang
|
| 18 |
+
{plugins, [rebar3_hex]}.
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
Alternatively, you can add to your project's rebar3 config in project plugins :
|
| 22 |
+
|
| 23 |
+
```erlang
|
| 24 |
+
{project_plugins, [rebar3_hex]}.
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
**NOTE** : Be sure **not** to add `rebar3_hex` to the plugins section within a projects rebar3 config as this will
|
| 28 |
+
become a dependency for others downloading your package from hex.pm
|
| 29 |
+
|
| 30 |
+
### Documentation
|
| 31 |
+
|
| 32 |
+
rebar3_hex by default expects you to configure a documentation provider. We recommend using
|
| 33 |
+
[rebar3_ex_doc](https://hexdocs.pm/rebar3_ex_doc/) for publishing documentation along with your package for a
|
| 34 |
+
consistent format and style on [hex.pm](https://hex.pm/).
|
| 35 |
+
|
| 36 |
+
Example :
|
| 37 |
+
|
| 38 |
+
```erlang
|
| 39 |
+
|
| 40 |
+
{ex_doc, [
|
| 41 |
+
{extras, ["README.md", "LICENSE"]},
|
| 42 |
+
{main, "README.md"},
|
| 43 |
+
{source_url, "https://github.com/namespace/your_app"}
|
| 44 |
+
]}.
|
| 45 |
+
|
| 46 |
+
{hex, [{doc, ex_doc}]}.
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
Alternatively, or on Erlang versions older than OTP-24, you can use the edoc provider that ships with rebar3 :
|
| 50 |
+
|
| 51 |
+
```erlang
|
| 52 |
+
{hex, [{doc, edoc}]}.
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
## Basic usage
|
| 56 |
+
|
| 57 |
+
You should read the [docs](https://hexdocs.pm/rebar3_hex/) for a complete over for each provider, but below is a
|
| 58 |
+
brief overview of basic usage.
|
| 59 |
+
|
| 60 |
+
### Authenticating User
|
| 61 |
+
|
| 62 |
+
If you already have a user for [hex.pm](https://hex.pm) run:
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
```shell
|
| 66 |
+
$ rebar3 hex user auth
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
Note that this will ask for your hex.pm username and password, as well as a password for encrypting your api token that
|
| 70 |
+
has write permissions to the repository. When publishing a package you will have to give this password to decrypt the
|
| 71 |
+
token in order to publish.
|
| 72 |
+
|
| 73 |
+
See the [docs](https://hexdocs.pm/rebar3_hex/rebar3_hex_user.html) for more information.
|
| 74 |
+
|
| 75 |
+
### Building
|
| 76 |
+
|
| 77 |
+
The `build` provider is very useful for seeing exactly what would be published using either the `publish` or `cut` task
|
| 78 |
+
without any chance of actually publishing the package or docs. Tarballs for the package and docs are written to
|
| 79 |
+
`_build/<profile>/lib/your_app/hex/` by default.
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
```
|
| 83 |
+
$ rebar3 hex build
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
See the [docs](https://hexdocs.pm/rebar3_hex/rebar3_hex_build.html) for more information.
|
| 87 |
+
|
| 88 |
+
### Publishing
|
| 89 |
+
|
| 90 |
+
Two providers are available for publishing packages, `publish` and `cut`
|
| 91 |
+
|
| 92 |
+
By default `publish` builds and pushes your package and docs to a repository. See the
|
| 93 |
+
[docs](https://hexdocs.pm/rebar3_hex/rebar3_hex_publish.html) for more information.
|
| 94 |
+
|
| 95 |
+
``` shell
|
| 96 |
+
$ rebar3 hex publish
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
`cut` is available to provide some additional functionality around versioning and git tags. See the
|
| 100 |
+
[docs](https://hexdocs.pm/rebar3_hex/rebar3_hex_cut.html) for more information.
|
| 101 |
+
|
| 102 |
+
``` shell
|
| 103 |
+
$ rebar3 hex cut
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
In either case, both providers will display the details of what is being published
|
| 107 |
+
(what files, the version, dependencies) and ask if it should continue, so be sure to read the
|
| 108 |
+
output carefully and make sure it is publishing what you expected.
|
| 109 |
+
|
| 110 |
+
### Managing package owners
|
| 111 |
+
|
| 112 |
+
Owners can be added, removed, and listed for packages you are an owner of with the `hex owner` command. Packages
|
| 113 |
+
can also be transfered to other registered users on hexpm as well.
|
| 114 |
+
|
| 115 |
+
``` shell
|
| 116 |
+
$ rebar3 hex owner [add | remove | list | transfer] <package> <email>
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
See the [docs](https://hexdocs.pm/rebar3_hex/rebar3_hex_owner.html) for more information.
|
| 120 |
+
|
| 121 |
+
### Retiring packages
|
| 122 |
+
|
| 123 |
+
Packages can be flagged as retired on hexpm via the `retire` provider :
|
| 124 |
+
|
| 125 |
+
```
|
| 126 |
+
$ rebar3 hex retire PACKAGE VERSION REASON --message
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
They can also be unretired in case a mistake was made :
|
| 130 |
+
|
| 131 |
+
```
|
| 132 |
+
$ rebar3 hex retire PACKAGE VERSION --unretire
|
| 133 |
+
```
|
| 134 |
+
|
| 135 |
+
See the [docs](https://hexdocs.pm/rebar3_hex/rebar3_hex_retire.html) for more information.
|
| 136 |
+
|
| 137 |
+
### Organizations
|
| 138 |
+
|
| 139 |
+
rebar3_hex supports working with organizations via the `organization` provider.
|
| 140 |
+
|
| 141 |
+
Simply add your organization to either your global rebar.config (i.e., `~/.config/rebar3/rebar.config` ) or a local
|
| 142 |
+
project rebar.config.
|
| 143 |
+
|
| 144 |
+
```erlang
|
| 145 |
+
{hex, [{repos, [#{name => <<"hexpm:your_org">>}]}]}.
|
| 146 |
+
```
|
| 147 |
+
|
| 148 |
+
You can then authenticate with with the organization repository. Be sure you have already authenticated with the main
|
| 149 |
+
repository first:
|
| 150 |
+
|
| 151 |
+
```
|
| 152 |
+
$ rebar3 hex auth # make sure you're authenticated to the main repo first
|
| 153 |
+
$ rebar3 hex organization auth hexpm:your_org # authenticate to the org
|
| 154 |
+
```
|
| 155 |
+
|
| 156 |
+
Now you can generate, revoke, and list keys for your organizations. See below for an example of generating a key for use
|
| 157 |
+
in CI.
|
| 158 |
+
|
| 159 |
+
See the [docs](https://hexdocs.pm/rebar3_hex/rebar3_hex_organization.html) for more information.
|
| 160 |
+
|
| 161 |
+
#### Read-Only Repo Key for CI
|
| 162 |
+
|
| 163 |
+
If you have a private organization or other private repository it is recommended that you use a repo specific
|
| 164 |
+
auth token for reading from the repository in CI. To generate a token:
|
| 165 |
+
|
| 166 |
+
```shell
|
| 167 |
+
$ rebar3 hex organization auth hexpm:myrepo
|
| 168 |
+
Successfully authenticated to hexpm:myrepo
|
| 169 |
+
```
|
| 170 |
+
|
| 171 |
+
Now you can generate a key to use in CI for your organization
|
| 172 |
+
|
| 173 |
+
```
|
| 174 |
+
$ rebar3 hex organization key hexpm:myrepo generate
|
| 175 |
+
abc123
|
| 176 |
+
```
|
| 177 |
+
|
| 178 |
+
Then in CI use whatever method is available for setting an environment variable to the token and add this call at the
|
| 179 |
+
beginning of your CI runs to add the token to your rebar3 hex config. Below we'll use the environment `REPO_KEY` as an
|
| 180 |
+
example.
|
| 181 |
+
|
| 182 |
+
```shell
|
| 183 |
+
$ rebar3 hex organization auth hexpm:myrepo --key $REPO_KEY
|
| 184 |
+
```
|
| 185 |
+
|
| 186 |
+
### Searching hexpm
|
| 187 |
+
|
| 188 |
+
A `search` provider is available to search packages across hex.pm as a convenience.
|
| 189 |
+
|
| 190 |
+
```
|
| 191 |
+
$ rebar3 hex search
|
| 192 |
+
```
|
| 193 |
+
|
| 194 |
+
# Further reading
|
| 195 |
+
See [Publishing packages](https://hex.pm/docs/rebar3-publish) on hexpm for more setup and usage instructions. See the
|
| 196 |
+
[docs](https://hexdocs.pm/rebar3_hex) for detailed documentation for all available providers.
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex.app
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{application,rebar3_hex,
|
| 2 |
+
[{registered,[]},
|
| 3 |
+
{description,"Hex.pm plugin for rebar3"},
|
| 4 |
+
{vsn,"7.1.0"},
|
| 5 |
+
{applications,[kernel,stdlib,hex_core]},
|
| 6 |
+
{maintainers,["Tristan Sloughter","Bryan Paxton"]},
|
| 7 |
+
{licenses,["Apache-2.0"]},
|
| 8 |
+
{links,[{"GitHub","https://github.com/erlef/rebar3_hex"}]},
|
| 9 |
+
{modules,[rebar3_hex,rebar3_hex_app,rebar3_hex_build,
|
| 10 |
+
rebar3_hex_client,rebar3_hex_config,rebar3_hex_cut,
|
| 11 |
+
rebar3_hex_error,rebar3_hex_file,
|
| 12 |
+
rebar3_hex_httpc_adapter,rebar3_hex_io,rebar3_hex_key,
|
| 13 |
+
rebar3_hex_organization,rebar3_hex_owner,
|
| 14 |
+
rebar3_hex_publish,rebar3_hex_results,
|
| 15 |
+
rebar3_hex_retire,rebar3_hex_search,rebar3_hex_user,
|
| 16 |
+
rebar3_hex_version]}]}.
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex.beam
ADDED
|
Binary file (7.2 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_app.beam
ADDED
|
Binary file (11.6 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_build.beam
ADDED
|
Binary file (28.8 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_client.beam
ADDED
|
Binary file (8.4 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_config.beam
ADDED
|
Binary file (12.9 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_cut.beam
ADDED
|
Binary file (12.1 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_error.beam
ADDED
|
Binary file (4.05 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_file.beam
ADDED
|
Binary file (7.61 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_httpc_adapter.beam
ADDED
|
Binary file (3.71 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_io.beam
ADDED
|
Binary file (8.61 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_key.beam
ADDED
|
Binary file (6.73 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_organization.beam
ADDED
|
Binary file (18.7 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_owner.beam
ADDED
|
Binary file (13 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_publish.beam
ADDED
|
Binary file (38.3 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_results.beam
ADDED
|
Binary file (6.57 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_retire.beam
ADDED
|
Binary file (8.26 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_search.beam
ADDED
|
Binary file (9.2 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_user.beam
ADDED
|
Binary file (23.3 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/ebin/rebar3_hex_version.beam
ADDED
|
Binary file (3.12 kB). View file
|
|
|
deps/eini/_build/default/plugins/rebar3_hex/hex_metadata.config
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{<<"app">>,<<"rebar3_hex">>}.
|
| 2 |
+
{<<"build_tools">>,[<<"rebar3">>]}.
|
| 3 |
+
{<<"description">>,<<"Hex.pm plugin for rebar3">>}.
|
| 4 |
+
{<<"files">>,
|
| 5 |
+
[<<"LICENSE">>,<<"README.md">>,<<"rebar.config">>,<<"rebar.lock">>,<<"src">>,
|
| 6 |
+
<<"src/rebar3_hex.app.src">>,<<"src/rebar3_hex.erl">>,
|
| 7 |
+
<<"src/rebar3_hex.hrl">>,<<"src/rebar3_hex_app.erl">>,
|
| 8 |
+
<<"src/rebar3_hex_build.erl">>,<<"src/rebar3_hex_client.erl">>,
|
| 9 |
+
<<"src/rebar3_hex_config.erl">>,<<"src/rebar3_hex_cut.erl">>,
|
| 10 |
+
<<"src/rebar3_hex_error.erl">>,<<"src/rebar3_hex_file.erl">>,
|
| 11 |
+
<<"src/rebar3_hex_httpc_adapter.erl">>,<<"src/rebar3_hex_io.erl">>,
|
| 12 |
+
<<"src/rebar3_hex_key.erl">>,<<"src/rebar3_hex_organization.erl">>,
|
| 13 |
+
<<"src/rebar3_hex_owner.erl">>,<<"src/rebar3_hex_publish.erl">>,
|
| 14 |
+
<<"src/rebar3_hex_results.erl">>,<<"src/rebar3_hex_retire.erl">>,
|
| 15 |
+
<<"src/rebar3_hex_search.erl">>,<<"src/rebar3_hex_user.erl">>,
|
| 16 |
+
<<"src/rebar3_hex_version.erl">>]}.
|
| 17 |
+
{<<"licenses">>,[<<"Apache-2.0">>]}.
|
| 18 |
+
{<<"links">>,[{<<"GitHub">>,<<"https://github.com/erlef/rebar3_hex">>}]}.
|
| 19 |
+
{<<"name">>,<<"rebar3_hex">>}.
|
| 20 |
+
{<<"requirements">>,
|
| 21 |
+
[{<<"hex_core">>,
|
| 22 |
+
[{<<"app">>,<<"hex_core">>},
|
| 23 |
+
{<<"optional">>,false},
|
| 24 |
+
{<<"requirement">>,<<"0.12.2">>}]},
|
| 25 |
+
{<<"verl">>,
|
| 26 |
+
[{<<"app">>,<<"verl">>},
|
| 27 |
+
{<<"optional">>,false},
|
| 28 |
+
{<<"requirement">>,<<"1.1.1">>}]}]}.
|
| 29 |
+
{<<"version">>,<<"7.1.0">>}.
|
deps/eini/_build/default/plugins/rebar3_hex/rebar.config
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{minimum_otp_vsn, "18"}.
|
| 2 |
+
|
| 3 |
+
{erl_opts, [
|
| 4 |
+
debug_info,
|
| 5 |
+
{platform_define, "^2[3-9]", 'POST_OTP_22'},
|
| 6 |
+
{platform_define, "^20", 'POST_OTP_19'},
|
| 7 |
+
{platform_define, "^19", 'POST_OTP_18'},
|
| 8 |
+
{platform_define, "^[2-9]", 'POST_OTP_18'}
|
| 9 |
+
]}.
|
| 10 |
+
|
| 11 |
+
%% Some dependencies don't yet build cleanly with OTP-29.
|
| 12 |
+
{overrides, [
|
| 13 |
+
{add, katana_code, [{erl_opts, [nowarn_deprecated_catch]}]}
|
| 14 |
+
]}.
|
| 15 |
+
|
| 16 |
+
{project_plugins, [{covertool, "2.0.6"}, {rebar3_ex_doc, "0.2.30"}, {rebar3_hank, "1.4.0"}]}.
|
| 17 |
+
|
| 18 |
+
{deps, [{hex_core, "0.12.2"}, {verl, "1.1.1"}]}.
|
| 19 |
+
|
| 20 |
+
{profiles, [
|
| 21 |
+
{test, [
|
| 22 |
+
{extra_src_dirs, ["test/support"]},
|
| 23 |
+
{deps, [{erlware_commons, "1.7.0"}, {elli, "3.3.0"},
|
| 24 |
+
{jsone, "1.8.1"}, {meck, "0.9.2"}]},
|
| 25 |
+
{erl_opts, [nowarn_export_all]}
|
| 26 |
+
]}
|
| 27 |
+
]}.
|
| 28 |
+
|
| 29 |
+
{dialyzer, [
|
| 30 |
+
{warnings, [
|
| 31 |
+
error_handling,
|
| 32 |
+
no_unknown
|
| 33 |
+
]},
|
| 34 |
+
{plt_extra_apps, [hex_core, verl]}
|
| 35 |
+
]}.
|
| 36 |
+
|
| 37 |
+
{hank,
|
| 38 |
+
[{ignore,
|
| 39 |
+
[{"test/**/*.erl", unnecessary_function_arguments}]}]}.
|
| 40 |
+
|
| 41 |
+
{xref_checks,[undefined_function_calls,undefined_functions,locals_not_used,
|
| 42 |
+
deprecated_function_calls,deprecated_functions]}.
|
| 43 |
+
|
| 44 |
+
{alias, [{test, [{ct, "--cover"}, {cover, "-v"}]}]}.
|
| 45 |
+
|
| 46 |
+
{hex, [{doc, ex_doc}]}.
|
| 47 |
+
|
| 48 |
+
{ex_doc, [
|
| 49 |
+
{source_url, <<"https://github.com/erlef/rebar3_hex">>},
|
| 50 |
+
{extras, [<<"README.md">>, <<"LICENSE">>]},
|
| 51 |
+
{main, <<"readme">>}
|
| 52 |
+
]}.
|
deps/eini/_build/default/plugins/rebar3_hex/rebar.lock
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"1.2.0",
|
| 2 |
+
[{<<"hex_core">>,{pkg,<<"hex_core">>,<<"0.12.2">>},0},
|
| 3 |
+
{<<"verl">>,{pkg,<<"verl">>,<<"1.1.1">>},0}]}.
|
| 4 |
+
[
|
| 5 |
+
{pkg_hash,[
|
| 6 |
+
{<<"hex_core">>, <<"116F75685E707624BA79B6F6B06BE4F5E14C5FCCECCF31D4EA3ED4FED6134F8C">>},
|
| 7 |
+
{<<"verl">>, <<"98F3EC48B943AA4AE8E29742DE86A7CD752513687911FE07D2E00ECDF3107E45">>}]},
|
| 8 |
+
{pkg_hash_ext,[
|
| 9 |
+
{<<"hex_core">>, <<"00E402C302BF4B8CEDC2D3425E22B55F8C70A2542D69C87A2E5BA7AF2745F6C6">>},
|
| 10 |
+
{<<"verl">>, <<"0925E51CD92A0A8BE271765B02430B2E2CFF8AC30EF24D123BD0D58511E8FB18">>}]}
|
| 11 |
+
].
|
deps/eini/_build/default/plugins/rebar3_hex/src/rebar3_hex.app.src
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{application,rebar3_hex,
|
| 2 |
+
[{description,"Hex.pm plugin for rebar3"},
|
| 3 |
+
{vsn,"7.1.0"},
|
| 4 |
+
{applications,[kernel,stdlib,hex_core]},
|
| 5 |
+
{maintainers,["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
|
| 1 |
+
%% @private
|
| 2 |
+
-module(rebar3_hex).
|
| 3 |
+
|
| 4 |
+
-export([ init/1
|
| 5 |
+
, get_args/1
|
| 6 |
+
, gather_opts/2
|
| 7 |
+
, get_required/2
|
| 8 |
+
, task_args/1
|
| 9 |
+
, task_state/1
|
| 10 |
+
, task_state/2
|
| 11 |
+
, repo_opt/0
|
| 12 |
+
, help_opt/0
|
| 13 |
+
]).
|
| 14 |
+
|
| 15 |
+
-export([to_atom/1, to_list/1, to_binary/1]).
|
| 16 |
+
|
| 17 |
+
-type task() :: #{raw_opts := proplists:proplist(),
|
| 18 |
+
raw_args := list(),
|
| 19 |
+
args := map(),
|
| 20 |
+
repo := map(),
|
| 21 |
+
apps := [rebar_app_info:t()],
|
| 22 |
+
state := rebar_state:t(),
|
| 23 |
+
multi_app := boolean()
|
| 24 |
+
}.
|
| 25 |
+
|
| 26 |
+
-export_type([task/0]).
|
| 27 |
+
|
| 28 |
+
init(State) ->
|
| 29 |
+
lists:foldl(fun provider_init/2, {ok, State}, [rebar3_hex_user,
|
| 30 |
+
rebar3_hex_build,
|
| 31 |
+
rebar3_hex_cut,
|
| 32 |
+
rebar3_hex_owner,
|
| 33 |
+
rebar3_hex_organization,
|
| 34 |
+
rebar3_hex_search,
|
| 35 |
+
rebar3_hex_retire,
|
| 36 |
+
rebar3_hex_publish]).
|
| 37 |
+
|
| 38 |
+
provider_init(Module, {ok, State}) ->
|
| 39 |
+
Module:init(State).
|
| 40 |
+
|
| 41 |
+
gather_opts(Targets, State) ->
|
| 42 |
+
{Args, _} = rebar_state:command_parsed_args(State),
|
| 43 |
+
lists:foldl(fun(T, Acc) ->
|
| 44 |
+
case proplists:get_value(T, Args, undefined) of
|
| 45 |
+
undefined ->
|
| 46 |
+
Acc;
|
| 47 |
+
V ->
|
| 48 |
+
maps:put(T, V, Acc)
|
| 49 |
+
end
|
| 50 |
+
end, #{}, Targets).
|
| 51 |
+
|
| 52 |
+
get_required(Key, Args) ->
|
| 53 |
+
case proplists:get_value(Key, Args) of
|
| 54 |
+
undefined ->
|
| 55 |
+
{error, {required, Key}};
|
| 56 |
+
Value ->
|
| 57 |
+
Value
|
| 58 |
+
end.
|
| 59 |
+
|
| 60 |
+
task_args(State) ->
|
| 61 |
+
{Opts, _Args} = rebar_state:command_parsed_args(State),
|
| 62 |
+
case proplists:get_value(task, Opts, undefined) of
|
| 63 |
+
undefined ->
|
| 64 |
+
{undefined, Opts};
|
| 65 |
+
Task ->
|
| 66 |
+
{Task, proplists:delete(task, Opts)}
|
| 67 |
+
end.
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
%% TODO: A current limitation of rebar3_hex:task_state/1 is it returns strings.
|
| 71 |
+
%% This will need to be adjusted to return binaries. For now, we return the opts and args
|
| 72 |
+
%% as returned from rebar_state:command_parsed_args/1 as raw_args and raw_opts.
|
| 73 |
+
-spec task_state(rebar_state:t()) -> {ok, task()} | {error, term()}.
|
| 74 |
+
task_state(State) ->
|
| 75 |
+
case rebar3_hex_config:repo(State) of
|
| 76 |
+
{ok, Repo} ->
|
| 77 |
+
{ok, task_state(State, Repo)};
|
| 78 |
+
Err ->
|
| 79 |
+
Err
|
| 80 |
+
end.
|
| 81 |
+
|
| 82 |
+
-spec task_state(rebar_state:t(), map()) -> task().
|
| 83 |
+
task_state(State, Repo) ->
|
| 84 |
+
{Opts0, Args0} = rebar_state:command_parsed_args(State),
|
| 85 |
+
Opts = get_args(State),
|
| 86 |
+
CurrentTask = maps:get(task, Opts, undefined),
|
| 87 |
+
Opts1 = Opts#{task => CurrentTask},
|
| 88 |
+
case rebar_state:project_apps(State) of
|
| 89 |
+
[] ->
|
| 90 |
+
#{raw_opts => Opts0, raw_args => Args0, args => Opts1, repo => Repo, state => State, multi_app => false, apps => []};
|
| 91 |
+
[_App] = Apps ->
|
| 92 |
+
#{raw_opts => Opts0, raw_args => Args0, args => Opts1, repo => Repo, state => State, multi_app => false, apps => Apps};
|
| 93 |
+
[_|_] = Apps ->
|
| 94 |
+
#{raw_opts => Opts0, raw_args => Args0, args => Opts1, repo => Repo, state => State, multi_app => true, apps => Apps}
|
| 95 |
+
end.
|
| 96 |
+
|
| 97 |
+
-spec get_args(rebar_state:t()) -> map().
|
| 98 |
+
get_args(State) ->
|
| 99 |
+
{Opts, Args} = rebar_state:command_parsed_args(State),
|
| 100 |
+
Opts1 = lists:foldl(fun (Arg, Acc) ->
|
| 101 |
+
case is_atom(Arg) of
|
| 102 |
+
true ->
|
| 103 |
+
[{Arg, true} | Acc];
|
| 104 |
+
_ ->
|
| 105 |
+
case Arg of
|
| 106 |
+
{task, Task} ->
|
| 107 |
+
[{task, list_to_atom(Task)} | Acc];
|
| 108 |
+
_ ->
|
| 109 |
+
[Arg | Acc]
|
| 110 |
+
end
|
| 111 |
+
end
|
| 112 |
+
end,
|
| 113 |
+
[],
|
| 114 |
+
Opts),
|
| 115 |
+
|
| 116 |
+
Opts2 = lists:foldl(fun (Arg, Acc) ->
|
| 117 |
+
case is_atom(Arg) of
|
| 118 |
+
true ->
|
| 119 |
+
[{Arg, true} | Acc];
|
| 120 |
+
_ ->
|
| 121 |
+
[{list_to_atom(Arg), true} | Acc]
|
| 122 |
+
end
|
| 123 |
+
end,
|
| 124 |
+
Opts1,
|
| 125 |
+
Args),
|
| 126 |
+
maps:from_list(Opts2).
|
| 127 |
+
|
| 128 |
+
help_opt() ->
|
| 129 |
+
{help, $h, "help", undefined, "Help"}.
|
| 130 |
+
|
| 131 |
+
repo_opt() ->
|
| 132 |
+
{repo, $r, "repo", string, "Repository to use for this command."}.
|
| 133 |
+
|
| 134 |
+
to_binary(A) when is_atom(A) -> atom_to_binary(A, unicode);
|
| 135 |
+
to_binary(Str) -> unicode:characters_to_binary(Str).
|
| 136 |
+
|
| 137 |
+
to_list(A) when is_atom(A) -> atom_to_list(A);
|
| 138 |
+
to_list(B) when is_binary(B) -> unicode:characters_to_list(B);
|
| 139 |
+
to_list(I) when is_integer(I) -> integer_to_list(I);
|
| 140 |
+
to_list(Str) -> unicode:characters_to_list(Str).
|
| 141 |
+
|
| 142 |
+
to_atom(B) when is_binary(B) -> binary_to_atom(B, utf8);
|
| 143 |
+
to_atom(Str) when is_list(Str) -> list_to_atom(Str);
|
| 144 |
+
to_atom(A) when is_atom(A) -> A.
|
deps/eini/_build/default/plugins/rebar3_hex/src/rebar3_hex.hrl
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-define(PRV_ERROR(Reason),
|
| 2 |
+
{error, {?MODULE, Reason}}).
|
| 3 |
+
-define(RAISE(Reason), erlang:error(?PRV_ERROR(Reason))).
|
| 4 |
+
-define(DEFAULT_HEX_REPO, <<"hexpm">>).
|
deps/eini/_build/default/plugins/rebar3_hex/src/rebar3_hex_app.erl
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%% @private
|
| 2 |
+
%%% ===================================================================
|
| 3 |
+
%%% App utils
|
| 4 |
+
%%% ===================================================================
|
| 5 |
+
-module(rebar3_hex_app).
|
| 6 |
+
|
| 7 |
+
-export([vcs_vsn/2, find/2, get_deps/1, validate/1]).
|
| 8 |
+
|
| 9 |
+
-define(VALIDATIONS, [
|
| 10 |
+
has_semver,
|
| 11 |
+
has_contributors,
|
| 12 |
+
has_maintainers,
|
| 13 |
+
has_description,
|
| 14 |
+
has_valid_licenses,
|
| 15 |
+
has_unstable_deps
|
| 16 |
+
]).
|
| 17 |
+
|
| 18 |
+
-type app_data() :: #{
|
| 19 |
+
name := string(),
|
| 20 |
+
version := string(),
|
| 21 |
+
details := list(),
|
| 22 |
+
deps := list()
|
| 23 |
+
}.
|
| 24 |
+
|
| 25 |
+
-type validation_errors() :: #{
|
| 26 |
+
warnings => list(),
|
| 27 |
+
errors => list()
|
| 28 |
+
}.
|
| 29 |
+
|
| 30 |
+
-spec find([rebar_app_info:t()], string()) -> {ok, rebar_app_info:t()} | {error, app_not_found}.
|
| 31 |
+
find(Apps, Name) ->
|
| 32 |
+
Pred = fun(App) ->
|
| 33 |
+
rebar_app_info:name(App) =:= rebar_utils:to_binary(Name)
|
| 34 |
+
end,
|
| 35 |
+
case lists:filter(Pred, Apps) of
|
| 36 |
+
[App] ->
|
| 37 |
+
{ok, App};
|
| 38 |
+
_ ->
|
| 39 |
+
{error, app_not_found}
|
| 40 |
+
end.
|
| 41 |
+
|
| 42 |
+
-spec get_deps(list()) -> {ok, list()} | {error, {non_hex_deps, list()}}.
|
| 43 |
+
get_deps(Deps) ->
|
| 44 |
+
Top = locks_to_deps(Deps),
|
| 45 |
+
Excluded = [rebar_utils:to_list(N) || {N, {T, _, _, _}, 0} <- Deps, T =/= pkg],
|
| 46 |
+
Excluded1 = [rebar_utils:to_list(N) || {N, {T, _, _}, 0} <- Deps, T =/= pkg],
|
| 47 |
+
|
| 48 |
+
case Excluded ++ Excluded1 of
|
| 49 |
+
[] ->
|
| 50 |
+
{ok, Top};
|
| 51 |
+
Forbidden ->
|
| 52 |
+
{error, {non_hex_deps, Forbidden}}
|
| 53 |
+
end.
|
| 54 |
+
|
| 55 |
+
locks_to_deps(Deps) ->
|
| 56 |
+
lists:foldl(fun(D, Acc) -> lock_to_dep(D, Acc) end, [], Deps).
|
| 57 |
+
|
| 58 |
+
lock_to_dep({A, {pkg, N, V, _, _}, 0}, Acc) ->
|
| 59 |
+
[{N, [{<<"app">>, A}, {<<"optional">>, false}, {<<"requirement">>, V}]} | Acc];
|
| 60 |
+
lock_to_dep({A, {pkg, N, V, _}, 0}, Acc) ->
|
| 61 |
+
[{N, [{<<"app">>, A}, {<<"optional">>, false}, {<<"requirement">>, V}]} | Acc];
|
| 62 |
+
lock_to_dep(_, Acc) ->
|
| 63 |
+
Acc.
|
| 64 |
+
|
| 65 |
+
-spec validate(app_data()) -> ok | {error, validation_errors()}.
|
| 66 |
+
validate(AppData) ->
|
| 67 |
+
F = fun(K, Acc) ->
|
| 68 |
+
case validate_app(K, AppData) of
|
| 69 |
+
ok ->
|
| 70 |
+
Acc;
|
| 71 |
+
{warn, Warn} ->
|
| 72 |
+
#{warnings := WarnList} = Acc,
|
| 73 |
+
maps:put(warnings, [Warn | WarnList], Acc);
|
| 74 |
+
{error, Error} ->
|
| 75 |
+
#{errors := ErrList} = Acc,
|
| 76 |
+
maps:put(errors, [Error | ErrList], Acc)
|
| 77 |
+
end
|
| 78 |
+
end,
|
| 79 |
+
case lists:foldl(F, #{warnings => [], errors => []}, ?VALIDATIONS) of
|
| 80 |
+
[] ->
|
| 81 |
+
ok;
|
| 82 |
+
Errors ->
|
| 83 |
+
{error, Errors}
|
| 84 |
+
end.
|
| 85 |
+
|
| 86 |
+
validate_app(has_unstable_deps, #{deps := Deps}) ->
|
| 87 |
+
case lists:foldl(fun(Dep, Acc) -> is_unstable_dep(Dep, Acc) end, [], Deps) of
|
| 88 |
+
[] ->
|
| 89 |
+
ok;
|
| 90 |
+
PreDeps ->
|
| 91 |
+
{warn, {has_unstable_deps, PreDeps}}
|
| 92 |
+
end;
|
| 93 |
+
validate_app(has_semver, #{name := Name, version := Ver}) ->
|
| 94 |
+
case rebar3_hex_version:parse(Ver) of
|
| 95 |
+
{error, invalid_version} ->
|
| 96 |
+
{error, {invalid_semver, {Name, Ver}}};
|
| 97 |
+
_ ->
|
| 98 |
+
ok
|
| 99 |
+
end;
|
| 100 |
+
validate_app(has_contributors, #{name := Name, details := AppDetails}) ->
|
| 101 |
+
case proplists:is_defined(contributors, AppDetails) of
|
| 102 |
+
true ->
|
| 103 |
+
{warn, {has_contributors, Name}};
|
| 104 |
+
false ->
|
| 105 |
+
ok
|
| 106 |
+
end;
|
| 107 |
+
validate_app(has_maintainers, #{name := Name, details := AppDetails}) ->
|
| 108 |
+
case proplists:is_defined(maintainers, AppDetails) of
|
| 109 |
+
true ->
|
| 110 |
+
{warn, {has_maintainers, Name}};
|
| 111 |
+
false ->
|
| 112 |
+
ok
|
| 113 |
+
end;
|
| 114 |
+
validate_app(has_description, #{name := Name, details := AppDetails}) ->
|
| 115 |
+
case is_empty_prop(description, AppDetails) of
|
| 116 |
+
true ->
|
| 117 |
+
{warn, {no_description, Name}};
|
| 118 |
+
false ->
|
| 119 |
+
ok
|
| 120 |
+
end;
|
| 121 |
+
validate_app(has_valid_licenses, #{name := Name, details := AppDetails}) ->
|
| 122 |
+
case is_empty_prop(licenses, AppDetails) of
|
| 123 |
+
true ->
|
| 124 |
+
{warn, {no_license, Name}};
|
| 125 |
+
_ ->
|
| 126 |
+
Licenses = proplists:get_value(licenses, AppDetails),
|
| 127 |
+
case lists:filter(fun(L) -> not hex_licenses:valid(rebar_utils:to_binary(L)) end, Licenses) of
|
| 128 |
+
[] ->
|
| 129 |
+
ok;
|
| 130 |
+
[_|_] = Invalids ->
|
| 131 |
+
{warn, {invalid_licenses, Invalids, Name}}
|
| 132 |
+
end
|
| 133 |
+
end.
|
| 134 |
+
|
| 135 |
+
is_empty_prop(K, PropList) ->
|
| 136 |
+
Prop = proplists:get_value(K, PropList),
|
| 137 |
+
case Prop of
|
| 138 |
+
Empty when Empty =:= [] orelse Empty =:= undefined ->
|
| 139 |
+
true;
|
| 140 |
+
_ ->
|
| 141 |
+
false
|
| 142 |
+
end.
|
| 143 |
+
|
| 144 |
+
is_unstable_dep({_, {pkg, Pkg, Ver, _, _}, _}, Acc) ->
|
| 145 |
+
case rebar3_hex_version:parse(Ver) of
|
| 146 |
+
{ok, #{pre := Pre}} when Pre =/= [] ->
|
| 147 |
+
[{Pkg, Ver} | Acc];
|
| 148 |
+
_ ->
|
| 149 |
+
Acc
|
| 150 |
+
end;
|
| 151 |
+
is_unstable_dep(_, Acc) ->
|
| 152 |
+
Acc.
|
| 153 |
+
|
| 154 |
+
-spec vcs_vsn(rebar_state:t(), rebar_app_info:t()) -> string().
|
| 155 |
+
vcs_vsn(State, App) ->
|
| 156 |
+
Version = rebar_app_info:original_vsn(App),
|
| 157 |
+
AppDir = rebar_app_info:dir(App),
|
| 158 |
+
Resources = rebar_state:resources(State),
|
| 159 |
+
vcs_vsn(Version, AppDir, Resources).
|
| 160 |
+
|
| 161 |
+
vcs_vsn(OriginalVsn, Dir, Resources) when is_list(Dir), is_list(Resources) ->
|
| 162 |
+
FakeState = rebar_state:new(),
|
| 163 |
+
case rebar_app_info:new(fake, OriginalVsn, Dir) of
|
| 164 |
+
{ok, AppInfo} ->
|
| 165 |
+
vcs_vsn(
|
| 166 |
+
AppInfo,
|
| 167 |
+
OriginalVsn,
|
| 168 |
+
rebar_state:set_resources(FakeState, Resources)
|
| 169 |
+
);
|
| 170 |
+
Error ->
|
| 171 |
+
Error
|
| 172 |
+
end;
|
| 173 |
+
vcs_vsn(AppInfo, Vcs, State) ->
|
| 174 |
+
case vcs_vsn_cmd(AppInfo, Vcs, State) of
|
| 175 |
+
{plain, VsnString} ->
|
| 176 |
+
VsnString;
|
| 177 |
+
{cmd, CmdString} ->
|
| 178 |
+
cmd_vsn_invoke(CmdString, rebar_app_info:dir(AppInfo));
|
| 179 |
+
unknown ->
|
| 180 |
+
rebar_utils:abort("vcs_vsn: Unknown vsn format: ~p", [Vcs]);
|
| 181 |
+
{error, Reason} ->
|
| 182 |
+
rebar_utils:abort("vcs_vsn: ~ts", [Reason])
|
| 183 |
+
end.
|
| 184 |
+
|
| 185 |
+
%% Temp work around for repos like relx that use "semver"
|
| 186 |
+
vcs_vsn_cmd(_, Vsn, _) when is_binary(Vsn) ->
|
| 187 |
+
{plain, Vsn};
|
| 188 |
+
vcs_vsn_cmd(AppInfo, VCS, State) when VCS =:= semver; VCS =:= "semver" ->
|
| 189 |
+
vcs_vsn_cmd(AppInfo, git, State);
|
| 190 |
+
vcs_vsn_cmd(_AppInfo, {cmd, _Cmd} = Custom, _) ->
|
| 191 |
+
Custom;
|
| 192 |
+
vcs_vsn_cmd(AppInfo, {file, File}, _) ->
|
| 193 |
+
Path = filename:join(rebar_app_info:dir(AppInfo), File),
|
| 194 |
+
case file:read_file(Path) of
|
| 195 |
+
{ok, Vsn} ->
|
| 196 |
+
{plain, rebar_utils:to_list(rebar_string:trim(Vsn))};
|
| 197 |
+
Error ->
|
| 198 |
+
Error
|
| 199 |
+
end;
|
| 200 |
+
vcs_vsn_cmd(AppInfo, VCS, State) when is_atom(VCS) ->
|
| 201 |
+
rebar_resource_v2:make_vsn(AppInfo, VCS, State);
|
| 202 |
+
vcs_vsn_cmd(AppInfo, {VCS, _} = V, State) when is_atom(VCS) ->
|
| 203 |
+
rebar_resource_v2:make_vsn(AppInfo, V, State);
|
| 204 |
+
vcs_vsn_cmd(AppInfo, VCS, State) when is_list(VCS) ->
|
| 205 |
+
try list_to_existing_atom(VCS) of
|
| 206 |
+
AVCS ->
|
| 207 |
+
case vcs_vsn_cmd(AppInfo, AVCS, State) of
|
| 208 |
+
unknown -> {plain, VCS};
|
| 209 |
+
Other -> Other
|
| 210 |
+
end
|
| 211 |
+
catch
|
| 212 |
+
error:badarg ->
|
| 213 |
+
{plain, VCS}
|
| 214 |
+
end;
|
| 215 |
+
vcs_vsn_cmd(_, _, _) ->
|
| 216 |
+
unknown.
|
| 217 |
+
|
| 218 |
+
cmd_vsn_invoke(Cmd, Dir) ->
|
| 219 |
+
case rebar_utils:sh(Cmd, [{cd, Dir}, {use_stdout, false}]) of
|
| 220 |
+
{ok, VsnString} ->
|
| 221 |
+
rebar_string:trim(VsnString, trailing, "\n");
|
| 222 |
+
Error ->
|
| 223 |
+
Error
|
| 224 |
+
end.
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
% @doc `rebar3 hex build' - Build packages and docs
|
| 2 |
+
%
|
| 3 |
+
%% Builds a new local version of your package.
|
| 4 |
+
%%
|
| 5 |
+
%% By default this provider will build both a package tarball and docs tarball.
|
| 6 |
+
%%
|
| 7 |
+
%% The package and docs .tar files are created in the current directory, but is not pushed to the repository. An app
|
| 8 |
+
%% named foo at version 1.2.3 will be built as foo-1.2.3.tar. Likewise the docs .tar would be built as
|
| 9 |
+
%% foo-1.2.4-docs.tar.
|
| 10 |
+
%%
|
| 11 |
+
%% ```
|
| 12 |
+
%% $ rebar3 hex build
|
| 13 |
+
%% '''
|
| 14 |
+
%%
|
| 15 |
+
%% You may also build only a package or docs tarball utilizing the same available command line options.
|
| 16 |
+
%%
|
| 17 |
+
%% ```
|
| 18 |
+
%% $ rebar3 hex build package
|
| 19 |
+
%% '''
|
| 20 |
+
%%
|
| 21 |
+
%% ```
|
| 22 |
+
%% $ rebar3 hex build docs
|
| 23 |
+
%% '''
|
| 24 |
+
%%
|
| 25 |
+
%% <h2>Configuration</h2>
|
| 26 |
+
%% Packages are configured via `src/<myapp>.app.src' attributes.
|
| 27 |
+
%%
|
| 28 |
+
%% == Required configuration ==
|
| 29 |
+
%%
|
| 30 |
+
%% <ul>
|
| 31 |
+
%% <li>
|
| 32 |
+
%% `application' - application name. This is required per Erlang/OTP thus it should always be present anyway.
|
| 33 |
+
%% </li>
|
| 34 |
+
% <li>
|
| 35 |
+
% `vsn' - must be a valid <a href="https://semver.org/">semantic version</a> identifier.
|
| 36 |
+
% </li>
|
| 37 |
+
%% <li>
|
| 38 |
+
%% `licenses' - A list of licenses the project is licensed under. This attribute is required and must be a valid
|
| 39 |
+
%% <a href="https://spdx.org/licenses/">spdx</a> identifier.
|
| 40 |
+
%% </li>
|
| 41 |
+
%% </ul>
|
| 42 |
+
%%
|
| 43 |
+
%%
|
| 44 |
+
%% == Optional configuration ==
|
| 45 |
+
%% In addition, the following meta attributes are supported and highly recommended :
|
| 46 |
+
%%
|
| 47 |
+
%% <ul>
|
| 48 |
+
%% <li>
|
| 49 |
+
%% `description' - a brief description about your application.
|
| 50 |
+
%% </li>
|
| 51 |
+
%%
|
| 52 |
+
%% <li>
|
| 53 |
+
%% `pkg_name' - The name of the package in case you want to publish the package with a different name than the
|
| 54 |
+
%% application name.
|
| 55 |
+
%% </li>
|
| 56 |
+
%%
|
| 57 |
+
%% <li>
|
| 58 |
+
%% `links' - A map where the key is a link name and the value is the link URL. Optional but highly
|
| 59 |
+
%% recommended.
|
| 60 |
+
%% </li>
|
| 61 |
+
%%
|
| 62 |
+
%% <li> `files' - A list of files and directories to include in the package. Defaults to standard project directories,
|
| 63 |
+
%% so you usually don't need to set this property.
|
| 64 |
+
%% </li>
|
| 65 |
+
%% <li>
|
| 66 |
+
%% `include_paths' - A list of paths containing files you wish to include in a release.
|
| 67 |
+
%% </li>
|
| 68 |
+
%% <li>
|
| 69 |
+
%% `exclude_paths' - A list of paths containing files you wish to exclude in a release.
|
| 70 |
+
%% </li>
|
| 71 |
+
%% <li>
|
| 72 |
+
%% `exclude_patterns' - A list of regular expressions used to exclude files that may have been accumulated via
|
| 73 |
+
%% `files' and `include_paths' and standard project paths.
|
| 74 |
+
%% </li>
|
| 75 |
+
%% <li>
|
| 76 |
+
%% `build_tools' - List of build tools that can build the package. It's very rare that you need to set this.
|
| 77 |
+
%% </li>
|
| 78 |
+
%% </ul>
|
| 79 |
+
%%
|
| 80 |
+
%% Below is an example :
|
| 81 |
+
%%
|
| 82 |
+
%% ```
|
| 83 |
+
%% {application, myapp,
|
| 84 |
+
%% [{description, "An Erlang/OTP application"},
|
| 85 |
+
%% {vsn, "0.1.0"},
|
| 86 |
+
%% {modules, []},
|
| 87 |
+
%% {registered, []},
|
| 88 |
+
%% {applications, [kernel,
|
| 89 |
+
%% stdlib,
|
| 90 |
+
%% ]},
|
| 91 |
+
%% {licenses, ["Apache-2.0"]},
|
| 92 |
+
%% {links, [{"GitHub", "https://github.com/my_name/myapp"}]}]}.
|
| 93 |
+
%% '''
|
| 94 |
+
%%
|
| 95 |
+
%% <h2> Command line options </h2>
|
| 96 |
+
%%
|
| 97 |
+
%% <ul>
|
| 98 |
+
%% <li> `-r', `--repo' - Specify the repository to work with. This option is required when
|
| 99 |
+
%% you have multiple repositories configured, including organizations. The argument must
|
| 100 |
+
%% be a fully qualified repository name (e.g, `hexpm', `hexpm:my_org', `my_own_hexpm').
|
| 101 |
+
%% Defaults to `hexpm'.
|
| 102 |
+
%% </li>
|
| 103 |
+
%% <li> `-u', `--unpack' - Builds the tarball and unpacks contents into a directory. Useful for making sure the tarball
|
| 104 |
+
%% contains all needed files before publishing. See --output below for setting the output path.
|
| 105 |
+
%% </li>
|
| 106 |
+
%% <li> `-o', `--output' - Sets output path. When used with --unpack it means the directory
|
| 107 |
+
%% (Default: `<app>-<version>'). Otherwise, it specifies tarball path (Default: `<app>-<version>.tar').
|
| 108 |
+
%% Artifacts will be written to `_build/<profile>/lib/<your_app>/' by default.
|
| 109 |
+
%% </li>
|
| 110 |
+
%% </ul>
|
| 111 |
+
|
| 112 |
+
-module(rebar3_hex_build).
|
| 113 |
+
|
| 114 |
+
-export([create_package/2, create_docs/3, create_docs/4]).
|
| 115 |
+
|
| 116 |
+
-include("rebar3_hex.hrl").
|
| 117 |
+
|
| 118 |
+
-define(DEFAULT_FILES, [
|
| 119 |
+
"src",
|
| 120 |
+
"c_src",
|
| 121 |
+
"include",
|
| 122 |
+
"rebar.config.script",
|
| 123 |
+
"priv",
|
| 124 |
+
"rebar.config",
|
| 125 |
+
"rebar.lock",
|
| 126 |
+
"CHANGELOG*",
|
| 127 |
+
"changelog*",
|
| 128 |
+
"README*",
|
| 129 |
+
"readme*",
|
| 130 |
+
"LICENSE*",
|
| 131 |
+
"license*",
|
| 132 |
+
"NOTICE"
|
| 133 |
+
]).
|
| 134 |
+
|
| 135 |
+
-define(DEPS, [{default, compile}, {default, lock}]).
|
| 136 |
+
-define(PROVIDER, build).
|
| 137 |
+
-define(DEFAULT_DOC_DIR, "doc").
|
| 138 |
+
|
| 139 |
+
-export([
|
| 140 |
+
init/1,
|
| 141 |
+
do/1,
|
| 142 |
+
format_error/1
|
| 143 |
+
]).
|
| 144 |
+
|
| 145 |
+
%% Helpers
|
| 146 |
+
-export([doc_opts/2]).
|
| 147 |
+
|
| 148 |
+
%% ===================================================================
|
| 149 |
+
%% Public API
|
| 150 |
+
%% ===================================================================
|
| 151 |
+
|
| 152 |
+
%% @private
|
| 153 |
+
-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
|
| 154 |
+
init(State) ->
|
| 155 |
+
Provider = providers:create([
|
| 156 |
+
{name, ?PROVIDER},
|
| 157 |
+
{module, ?MODULE},
|
| 158 |
+
{namespace, hex},
|
| 159 |
+
{bare, true},
|
| 160 |
+
{deps, ?DEPS},
|
| 161 |
+
{example, "rebar3 hex build"},
|
| 162 |
+
{short_desc, "Builds a new local version of your package and docs."},
|
| 163 |
+
{desc, ""},
|
| 164 |
+
{opts, [
|
| 165 |
+
rebar3_hex:repo_opt(),
|
| 166 |
+
{app, $a, "app", {string, undefined}, "Specify the app to build."},
|
| 167 |
+
{output_dir, $o, "output", {string, undefined}, "Specify the directory to output artifacts to."},
|
| 168 |
+
{unpack, $u, "unpack", {boolean, false}, "Unpack the contents of tarballs generated vs writing them out to the filesystem."}
|
| 169 |
+
]}
|
| 170 |
+
]),
|
| 171 |
+
State1 = rebar_state:add_provider(State, Provider),
|
| 172 |
+
{ok, State1}.
|
| 173 |
+
|
| 174 |
+
%% @private
|
| 175 |
+
-spec do(rebar_state:t()) -> {ok, rebar_state:t()}.
|
| 176 |
+
do(State) ->
|
| 177 |
+
Task = rebar3_hex:task_state(State, get_repo(State)),
|
| 178 |
+
handle_task(Task).
|
| 179 |
+
|
| 180 |
+
get_repo(State) ->
|
| 181 |
+
{Args, _} = rebar_state:command_parsed_args(State),
|
| 182 |
+
case proplists:get_value(repo, Args, undefined) of
|
| 183 |
+
undefined ->
|
| 184 |
+
rebar3_hex_config:default_repo(State);
|
| 185 |
+
RepoName ->
|
| 186 |
+
rebar3_hex_config:repo(State, RepoName)
|
| 187 |
+
end.
|
| 188 |
+
|
| 189 |
+
%% @private
|
| 190 |
+
-spec format_error(any()) -> iolist().
|
| 191 |
+
format_error({build_package, Error}) when is_list(Error) ->
|
| 192 |
+
io_lib:format("Error building package : ~ts", [Error]);
|
| 193 |
+
|
| 194 |
+
format_error({build_package, {error, Error}}) when is_list(Error) ->
|
| 195 |
+
io_lib:format("Error building package : ~ts", [Error]);
|
| 196 |
+
|
| 197 |
+
format_error({build_package,{error,{non_hex_deps,Deps}}}) ->
|
| 198 |
+
DepsStr = lists:join(",", Deps),
|
| 199 |
+
Error = "Some dependencies were excluded from the package; only Hex packages can be dependencies: ~s",
|
| 200 |
+
io_lib:format(Error, [DepsStr]);
|
| 201 |
+
|
| 202 |
+
format_error({build_docs, {error, no_doc_config}}) ->
|
| 203 |
+
no_doc_config_messsage();
|
| 204 |
+
|
| 205 |
+
format_error({build_docs, {error, {doc_provider_not_found, PrvName}}}) ->
|
| 206 |
+
doc_provider_not_found(PrvName);
|
| 207 |
+
|
| 208 |
+
format_error({build_docs, {error, missing_doc_index}}) ->
|
| 209 |
+
doc_missing_index_message();
|
| 210 |
+
|
| 211 |
+
format_error({build_docs, Error}) when is_list(Error) ->
|
| 212 |
+
io_lib:format("Error building docs : ~ts", [Error]);
|
| 213 |
+
|
| 214 |
+
format_error({create_package, no_lock_file, default}) ->
|
| 215 |
+
"No lockfile detected.";
|
| 216 |
+
|
| 217 |
+
format_error({create_package, no_lock_file, CurrentProfiles}) ->
|
| 218 |
+
case lists:any(fun(P) -> P =:= lock end, CurrentProfiles) of
|
| 219 |
+
true ->
|
| 220 |
+
"No lockfile detected.";
|
| 221 |
+
false ->
|
| 222 |
+
Err = "No lockfile detected and one can not be generated running under the current profile.~n~n"
|
| 223 |
+
++ "Be sure to run rebar3 deps, rebar3 lock, or rebar3 hex build under the default ~n"
|
| 224 |
+
++ "profile prior to building or publishing under an alternative profile.~n",
|
| 225 |
+
io_lib:format(Err, [])
|
| 226 |
+
end;
|
| 227 |
+
|
| 228 |
+
format_error(repo_required_for_docs) ->
|
| 229 |
+
Str = "Error :~n\tA repo argument is required when building docs if multiple repos exist"
|
| 230 |
+
" and at least one has doc configuration.~n\tSpecify a repo argument or run"
|
| 231 |
+
" rebar3 hex build package if you only need to build a package.",
|
| 232 |
+
io_lib:format(Str, []);
|
| 233 |
+
|
| 234 |
+
format_error({app_not_found, AppName}) ->
|
| 235 |
+
io_lib:format("App ~s specified with --app switch not found in project", [AppName]);
|
| 236 |
+
|
| 237 |
+
format_error(app_switch_required) ->
|
| 238 |
+
"--app switch is required when building packages or docs in a umbrella with multiple apps";
|
| 239 |
+
|
| 240 |
+
format_error(Reason) ->
|
| 241 |
+
rebar3_hex_error:format_error(Reason).
|
| 242 |
+
|
| 243 |
+
no_doc_config_messsage() ->
|
| 244 |
+
"No doc provider has been specified in your hex config.\n"
|
| 245 |
+
"Be sure to add a doc provider to the hex config you rebar configuration file.\n\n"
|
| 246 |
+
"Example : {hex, [{doc, ex_doc}]\n".
|
| 247 |
+
|
| 248 |
+
doc_missing_index_message() ->
|
| 249 |
+
"An index.html file was not found in docs after running docs provider.\n"
|
| 250 |
+
"Be sure the docs provider is configured correctly and double check it by running it on its own\n".
|
| 251 |
+
|
| 252 |
+
doc_provider_not_found(Provider) ->
|
| 253 |
+
io_lib:format("The doc provider ~ts specified in your hex config could not be found", [Provider]).
|
| 254 |
+
|
| 255 |
+
handle_task(#{apps := [_,_|_] = Apps, args := #{app := AppName}} = T) ->
|
| 256 |
+
case rebar3_hex_app:find(Apps, AppName) of
|
| 257 |
+
{ok, App} ->
|
| 258 |
+
handle_task(T#{apps := [App]});
|
| 259 |
+
_Error ->
|
| 260 |
+
?RAISE({app_not_found, AppName})
|
| 261 |
+
end;
|
| 262 |
+
|
| 263 |
+
handle_task(#{apps := [_,_|_]}) ->
|
| 264 |
+
?RAISE(app_switch_required);
|
| 265 |
+
|
| 266 |
+
handle_task(#{state := State, repo := Repo, apps := [App], args := #{task := docs} = Args}) ->
|
| 267 |
+
case create_docs(State, Repo, App) of
|
| 268 |
+
{ok, Docs} ->
|
| 269 |
+
AbsDir = write_or_unpack(App, Docs, Args),
|
| 270 |
+
rebar3_hex_io:say("Your docs can be inspected at ~ts", [AbsDir]),
|
| 271 |
+
{ok, State};
|
| 272 |
+
Error ->
|
| 273 |
+
?RAISE({build_docs, Error})
|
| 274 |
+
end;
|
| 275 |
+
|
| 276 |
+
handle_task(#{state := State, apps := [App], args := #{task := package} = Args}) ->
|
| 277 |
+
case create_package(State, App) of
|
| 278 |
+
{ok, Pkg} ->
|
| 279 |
+
AbsDir = write_or_unpack(App, Pkg, Args),
|
| 280 |
+
rebar3_hex_io:say("Your package contents can be inspected at ~ts", [AbsDir]),
|
| 281 |
+
{ok, State};
|
| 282 |
+
Error ->
|
| 283 |
+
?RAISE({build_package, Error})
|
| 284 |
+
end;
|
| 285 |
+
|
| 286 |
+
handle_task(#{state := State, repo := Repo, apps := [App], args := Args}) ->
|
| 287 |
+
case create_package(State, App) of
|
| 288 |
+
{ok, Pkg} ->
|
| 289 |
+
AbsOutput = write_or_unpack(App, Pkg, Args),
|
| 290 |
+
rebar3_hex_io:say("Your package tarball is available at ~ts", [AbsOutput]),
|
| 291 |
+
case create_docs(State, Repo, App) of
|
| 292 |
+
{ok, Docs} ->
|
| 293 |
+
AbsFile = write_or_unpack(App, Docs, Args),
|
| 294 |
+
rebar3_hex_io:say("Your docs tarball is available at ~ts", [AbsFile]),
|
| 295 |
+
{ok, State};
|
| 296 |
+
{error, no_doc_config} ->
|
| 297 |
+
rebar_api:warn(no_doc_config_messsage(), []),
|
| 298 |
+
{ok, State};
|
| 299 |
+
{error, {doc_provider_not_found, PrvName}} ->
|
| 300 |
+
rebar_api:warn(doc_provider_not_found(PrvName), []),
|
| 301 |
+
{ok, State};
|
| 302 |
+
{error, missing_doc_index} ->
|
| 303 |
+
rebar_api:warn(doc_missing_index_message(), []),
|
| 304 |
+
{ok, State};
|
| 305 |
+
Error ->
|
| 306 |
+
?RAISE({build_docs, Error})
|
| 307 |
+
end;
|
| 308 |
+
Error ->
|
| 309 |
+
?RAISE({build_package, Error})
|
| 310 |
+
end.
|
| 311 |
+
|
| 312 |
+
output_path(docs, Name, Version, #{unpack := true}) ->
|
| 313 |
+
io_lib:format("~ts-~ts-docs", [Name, Version]);
|
| 314 |
+
output_path(docs, Name, Version, _Args) ->
|
| 315 |
+
io_lib:format("~ts-~ts-docs.tar", [Name, Version]);
|
| 316 |
+
output_path(package, Name, Version, #{unpack := true}) ->
|
| 317 |
+
io_lib:format("~ts-~ts", [Name, Version]);
|
| 318 |
+
output_path(package, Name, Version, _Args) ->
|
| 319 |
+
io_lib:format("~ts-~ts.tar", [Name, Version]).
|
| 320 |
+
|
| 321 |
+
write_or_unpack(App, #{type := Type, tarball := Tarball, name := Name, version := Version}, Args) ->
|
| 322 |
+
OutputDir = output_dir(App, Args),
|
| 323 |
+
Out = output_path(Type, Name, Version, Args),
|
| 324 |
+
AbsOut = filename:join(OutputDir, Out),
|
| 325 |
+
case Args of
|
| 326 |
+
#{unpack := true} ->
|
| 327 |
+
file:make_dir(AbsOut),
|
| 328 |
+
case Type of
|
| 329 |
+
docs ->
|
| 330 |
+
hex_tarball:unpack_docs(Tarball, AbsOut);
|
| 331 |
+
package ->
|
| 332 |
+
hex_tarball:unpack(Tarball, AbsOut)
|
| 333 |
+
end;
|
| 334 |
+
_ ->
|
| 335 |
+
file:write_file(AbsOut, Tarball)
|
| 336 |
+
end,
|
| 337 |
+
AbsOut.
|
| 338 |
+
|
| 339 |
+
%% We are exploiting a feature of ensuredir that that creates all
|
| 340 |
+
%% directories up to the last element in the filename, then ignores
|
| 341 |
+
%% that last element. This way we ensure that the dir is created
|
| 342 |
+
%% and not have any worries about path names
|
| 343 |
+
output_dir(App, #{output_dir := undefined}) ->
|
| 344 |
+
Dir = filename:join([rebar_app_info:out_dir(App), "hex"]),
|
| 345 |
+
filelib:ensure_dir(filename:join(Dir, "tmp")),
|
| 346 |
+
Dir;
|
| 347 |
+
output_dir(_App, #{output_dir := Output}) ->
|
| 348 |
+
Dir = filename:join(filename:absname(Output), "tmp"),
|
| 349 |
+
filelib:ensure_dir(Dir),
|
| 350 |
+
Dir;
|
| 351 |
+
output_dir(App, _) ->
|
| 352 |
+
Dir = filename:join([rebar_app_info:out_dir(App), "hex"]),
|
| 353 |
+
filelib:ensure_dir(filename:join(Dir, "tmp")),
|
| 354 |
+
Dir.
|
| 355 |
+
|
| 356 |
+
lock_file_exists(State) ->
|
| 357 |
+
Dir = rebar_state:dir(State),
|
| 358 |
+
LockFile = filename:join(Dir, "rebar.lock"),
|
| 359 |
+
filelib:is_regular(LockFile).
|
| 360 |
+
|
| 361 |
+
%% @private
|
| 362 |
+
create_package(State, App) ->
|
| 363 |
+
Name = rebar_app_info:name(App),
|
| 364 |
+
Version = rebar3_hex_app:vcs_vsn(State, App),
|
| 365 |
+
{application, _, AppDetails} = rebar3_hex_file:update_app_src(App, Version),
|
| 366 |
+
|
| 367 |
+
lock_file_exists(State) orelse ?RAISE({create_package, no_lock_file, rebar_state:current_profiles(State)}),
|
| 368 |
+
|
| 369 |
+
LockDeps = rebar_state:get(State, {locks, default}, []),
|
| 370 |
+
case rebar3_hex_app:get_deps(LockDeps) of
|
| 371 |
+
{ok, TopLevel} ->
|
| 372 |
+
AppDir = rebar_app_info:dir(App),
|
| 373 |
+
Config = rebar_config:consult(AppDir),
|
| 374 |
+
ConfigDeps = proplists:get_value(deps, Config, []),
|
| 375 |
+
Deps1 = update_versions(ConfigDeps, TopLevel),
|
| 376 |
+
Description = proplists:get_value(description, AppDetails, ""),
|
| 377 |
+
PackageFiles = include_files(Name, AppDir, AppDetails),
|
| 378 |
+
Licenses = proplists:get_value(licenses, AppDetails, []),
|
| 379 |
+
Links = proplists:get_value(links, AppDetails, []),
|
| 380 |
+
BuildTools = proplists:get_value(build_tools, AppDetails, [<<"rebar3">>]),
|
| 381 |
+
|
| 382 |
+
%% We check the app file for the 'pkg' key which allows us to select
|
| 383 |
+
%% a package name other then the app name, if it is not set we default
|
| 384 |
+
%% back to the app name.
|
| 385 |
+
PkgName = binarify(proplists:get_value(pkg_name, AppDetails, Name)),
|
| 386 |
+
|
| 387 |
+
Optional = [
|
| 388 |
+
{<<"app">>, Name},
|
| 389 |
+
{<<"parameters">>, []},
|
| 390 |
+
{<<"description">>, binarify(Description)},
|
| 391 |
+
{<<"files">>, [binarify(File) || {File, _} <- PackageFiles]},
|
| 392 |
+
{<<"licenses">>, binarify(Licenses)},
|
| 393 |
+
{<<"links">>, to_map(binarify(Links))},
|
| 394 |
+
{<<"build_tools">>, binarify(BuildTools)}
|
| 395 |
+
],
|
| 396 |
+
OptionalFiltered = [{Key, Value} || {Key, Value} <- Optional, Value =/= []],
|
| 397 |
+
Metadata = maps:from_list([
|
| 398 |
+
{<<"name">>, PkgName},
|
| 399 |
+
{<<"version">>, binarify(Version)},
|
| 400 |
+
{<<"requirements">>, maps:from_list(Deps1)}
|
| 401 |
+
| OptionalFiltered
|
| 402 |
+
]),
|
| 403 |
+
|
| 404 |
+
case create_package_tarball(Metadata, PackageFiles) of
|
| 405 |
+
{error, _} = Err ->
|
| 406 |
+
Err;
|
| 407 |
+
Tarball ->
|
| 408 |
+
Package = #{
|
| 409 |
+
type => package,
|
| 410 |
+
name => PkgName,
|
| 411 |
+
deps => Deps1,
|
| 412 |
+
version => Version,
|
| 413 |
+
metadata => Metadata,
|
| 414 |
+
files => PackageFiles,
|
| 415 |
+
tarball => Tarball,
|
| 416 |
+
has_checkouts => has_checkouts(State)
|
| 417 |
+
},
|
| 418 |
+
{ok, Package}
|
| 419 |
+
end;
|
| 420 |
+
Error ->
|
| 421 |
+
Error
|
| 422 |
+
end.
|
| 423 |
+
|
| 424 |
+
update_versions(ConfigDeps, LockDeps) ->
|
| 425 |
+
[
|
| 426 |
+
begin
|
| 427 |
+
case lists:keyfind(binary_to_atom(N, utf8), 1, ConfigDeps) of
|
| 428 |
+
{_, V} when is_binary(V) ->
|
| 429 |
+
Req = {<<"requirement">>, V},
|
| 430 |
+
{N, maps:from_list(lists:keyreplace(<<"requirement">>, 1, M, Req))};
|
| 431 |
+
{_, V} when is_list(V) ->
|
| 432 |
+
Req = {<<"requirement">>, binarify(V)},
|
| 433 |
+
{N, maps:from_list(lists:keyreplace(<<"requirement">>, 1, M, Req))};
|
| 434 |
+
_ ->
|
| 435 |
+
%% using version from lock. prepend ~> to make it looser
|
| 436 |
+
{_, Version} = lists:keyfind(<<"requirement">>, 1, M),
|
| 437 |
+
Req = {<<"requirement">>, <<"~>", Version/binary>>},
|
| 438 |
+
{N, maps:from_list(lists:keyreplace(<<"requirement">>, 1, M, Req))}
|
| 439 |
+
end
|
| 440 |
+
end
|
| 441 |
+
|| {N, M} <- LockDeps
|
| 442 |
+
].
|
| 443 |
+
|
| 444 |
+
include_files(Name, AppDir, AppDetails) ->
|
| 445 |
+
AppSrc = {application, to_atom(Name), AppDetails},
|
| 446 |
+
FilePaths = proplists:get_value(files, AppDetails, ?DEFAULT_FILES),
|
| 447 |
+
%% In versions prior to v7 the name of the for including paths and excluding paths was include_files and
|
| 448 |
+
%% exclude_files. We don't document this anymore, but we do support it to avoid breaking changes. However,
|
| 449 |
+
%% users should be instructed to use *_paths. Likewise for exclude_regexps which is now documented as
|
| 450 |
+
%% exclude_patterns.
|
| 451 |
+
maybe_warn_about(include_files, proplists:get_value(include_files, AppDetails, undefined)),
|
| 452 |
+
maybe_warn_about(exclude_regexps, proplists:get_value(exclude_regexps, AppDetails, undefined)),
|
| 453 |
+
IncludePaths = proplists:get_value(include_paths, AppDetails, proplists:get_value(include_files, AppDetails, [])),
|
| 454 |
+
ExcludePaths = proplists:get_value(exclude_paths, AppDetails, proplists:get_value(exclude_files, AppDetails, [])),
|
| 455 |
+
ExcludeRes = proplists:get_value(exclude_patterns, AppDetails, proplists:get_value(exclude_regexps, AppDetails, [])),
|
| 456 |
+
|
| 457 |
+
AllFiles = lists:ukeysort(2, rebar3_hex_file:expand_paths(FilePaths, AppDir)),
|
| 458 |
+
IncludeFiles = lists:ukeysort(2, rebar3_hex_file:expand_paths(IncludePaths, AppDir)),
|
| 459 |
+
ExcludeFiles = lists:ukeysort(2, rebar3_hex_file:expand_paths(ExcludePaths, AppDir)),
|
| 460 |
+
|
| 461 |
+
%% We filter first and then include, that way glob excludes can be
|
| 462 |
+
%% overwritten be explict includes
|
| 463 |
+
FilterExcluded = lists:filter(
|
| 464 |
+
fun({_, Path}) ->
|
| 465 |
+
not exclude_file(Path, ExcludeFiles, ExcludeRes)
|
| 466 |
+
end,
|
| 467 |
+
AllFiles
|
| 468 |
+
),
|
| 469 |
+
WithIncludes = lists:ukeymerge(2, FilterExcluded, IncludeFiles),
|
| 470 |
+
|
| 471 |
+
AppFileSrc = filename:join("src", rebar_utils:to_list(Name) ++ ".app.src"),
|
| 472 |
+
AppSrcBinary = binarify(lists:flatten(io_lib:format("~tp.\n", [AppSrc]))),
|
| 473 |
+
lists:keystore(AppFileSrc, 1, WithIncludes, {AppFileSrc, AppSrcBinary}).
|
| 474 |
+
|
| 475 |
+
maybe_warn_about(_, undefined) -> ok;
|
| 476 |
+
maybe_warn_about(include_files, _) ->
|
| 477 |
+
Deprecation = "include_files has been deprecated, and will be "
|
| 478 |
+
++ "removed in a later version of rebar3_hex. "
|
| 479 |
+
++ "You should use include_paths instead. See "
|
| 480 |
+
++ "\"rebar3 help hex build\" or \"rebar3_hex_build\" "
|
| 481 |
+
++ "module docs for more info.",
|
| 482 |
+
rebar_api:warn(Deprecation, []);
|
| 483 |
+
maybe_warn_about(exclude_regexps, _) ->
|
| 484 |
+
Deprecation = "exclude_regexps has been deprecated, and will be "
|
| 485 |
+
++ "removed in a later version of rebar3_hex. "
|
| 486 |
+
++ "You should use exclude_paths instead. See "
|
| 487 |
+
++ "\"rebar3 help hex build\" or \"rebar3_hex_build\" "
|
| 488 |
+
++ "module docs for more info.",
|
| 489 |
+
rebar_api:warn(Deprecation, []).
|
| 490 |
+
|
| 491 |
+
exclude_file(Path, ExcludeFiles, ExcludeRe) ->
|
| 492 |
+
lists:keymember(Path, 2, ExcludeFiles) orelse
|
| 493 |
+
known_exclude_file(Path, ExcludeRe).
|
| 494 |
+
|
| 495 |
+
known_exclude_file(Path, ExcludeRe) ->
|
| 496 |
+
KnownExcludes = [
|
| 497 |
+
%% emacs temp files
|
| 498 |
+
"~$",
|
| 499 |
+
%% c object files
|
| 500 |
+
"\\.o$",
|
| 501 |
+
%% compiled nif libraries
|
| 502 |
+
"\\.so$",
|
| 503 |
+
%% vim swap files
|
| 504 |
+
"\\.swp$"
|
| 505 |
+
],
|
| 506 |
+
lists:foldl(
|
| 507 |
+
fun
|
| 508 |
+
(_, true) -> true;
|
| 509 |
+
(RE, false) -> re:run(Path, RE) =/= nomatch
|
| 510 |
+
end,
|
| 511 |
+
false,
|
| 512 |
+
KnownExcludes ++ ExcludeRe
|
| 513 |
+
).
|
| 514 |
+
|
| 515 |
+
%% Note that we return a list
|
| 516 |
+
has_checkouts(State) ->
|
| 517 |
+
filelib:is_dir(rebar_dir:checkouts_dir(State)).
|
| 518 |
+
|
| 519 |
+
%% @private
|
| 520 |
+
create_docs(State, Repo, App) ->
|
| 521 |
+
create_docs(State, Repo, App, #{doc_dir => undefined}).
|
| 522 |
+
|
| 523 |
+
%% @private
|
| 524 |
+
create_docs(State, Repo, App, Args) ->
|
| 525 |
+
case maybe_gen_docs(State, Repo, App, Args) of
|
| 526 |
+
{ok, DocDir} ->
|
| 527 |
+
case docs_detected(DocDir) of
|
| 528 |
+
true ->
|
| 529 |
+
AppDetails = rebar_app_info:app_details(App),
|
| 530 |
+
Files = rebar3_hex_file:expand_paths([DocDir], DocDir),
|
| 531 |
+
Name = rebar_utils:to_list(rebar_app_info:name(App)),
|
| 532 |
+
PkgName = rebar_utils:to_list(proplists:get_value(pkg_name, AppDetails, Name)),
|
| 533 |
+
OriginalVsn = rebar_app_info:original_vsn(App),
|
| 534 |
+
Vsn = rebar_utils:vcs_vsn(App, OriginalVsn, State),
|
| 535 |
+
case hex_tarball:create_docs(Files) of
|
| 536 |
+
{ok, Tarball} ->
|
| 537 |
+
{ok, #{
|
| 538 |
+
type => docs, tarball => Tarball, name => binarify(PkgName), version => binarify(Vsn)
|
| 539 |
+
}};
|
| 540 |
+
{error, Reason} ->
|
| 541 |
+
{error, hex_tarball:format_error(Reason)}
|
| 542 |
+
end;
|
| 543 |
+
false ->
|
| 544 |
+
{error, missing_doc_index}
|
| 545 |
+
end;
|
| 546 |
+
{error, _} = Err ->
|
| 547 |
+
Err
|
| 548 |
+
end.
|
| 549 |
+
|
| 550 |
+
maybe_gen_docs(_State, _Repo, App, #{doc_dir := DocDir}) when is_list(DocDir) ->
|
| 551 |
+
AppDir = rebar_app_info:dir(App),
|
| 552 |
+
{ok, filename:absname(filename:join(AppDir, DocDir))};
|
| 553 |
+
maybe_gen_docs(State, Repo, App, _Args) ->
|
| 554 |
+
case doc_opts(State, Repo) of
|
| 555 |
+
{ok, PrvName} ->
|
| 556 |
+
case providers:get_provider(PrvName, rebar_state:providers(State)) of
|
| 557 |
+
not_found ->
|
| 558 |
+
{error, {doc_provider_not_found, PrvName}};
|
| 559 |
+
Prv ->
|
| 560 |
+
case providers:do(Prv, State) of
|
| 561 |
+
{ok, _State1} ->
|
| 562 |
+
{ok, resolve_dir(App, PrvName)};
|
| 563 |
+
_ ->
|
| 564 |
+
{error, {doc_provider_failed, PrvName}}
|
| 565 |
+
end
|
| 566 |
+
end;
|
| 567 |
+
_ ->
|
| 568 |
+
{error, no_doc_config}
|
| 569 |
+
end.
|
| 570 |
+
|
| 571 |
+
resolve_dir(App, PrvName) ->
|
| 572 |
+
AppDir = rebar_app_info:dir(App),
|
| 573 |
+
AppOpts = rebar_app_info:opts(App),
|
| 574 |
+
DocOpts =
|
| 575 |
+
case PrvName of
|
| 576 |
+
edoc ->
|
| 577 |
+
rebar_opts:get(AppOpts, edoc_opts, []);
|
| 578 |
+
_ ->
|
| 579 |
+
rebar_opts:get(AppOpts, PrvName, [])
|
| 580 |
+
end,
|
| 581 |
+
DocDir = proplists:get_value(dir, DocOpts, ?DEFAULT_DOC_DIR),
|
| 582 |
+
filename:absname(filename:join(AppDir, DocDir)).
|
| 583 |
+
|
| 584 |
+
docs_detected(DocDir) ->
|
| 585 |
+
filelib:is_file(DocDir ++ "/index.html").
|
| 586 |
+
|
| 587 |
+
-spec doc_opts(rebar_state:t(), map()) -> {ok, atom()} | undefined.
|
| 588 |
+
doc_opts(State, Repo) ->
|
| 589 |
+
case Repo of
|
| 590 |
+
#{doc := #{provider := PrvName}} when is_atom(PrvName) ->
|
| 591 |
+
Deprecation = "Setting doc options in repo configuration has been deprecated."
|
| 592 |
+
" You should configure a docmentation provider in top level hex "
|
| 593 |
+
" configuration now.",
|
| 594 |
+
rebar_api:warn(Deprecation, []),
|
| 595 |
+
{ok, PrvName};
|
| 596 |
+
_ ->
|
| 597 |
+
Opts = rebar_state:opts(State),
|
| 598 |
+
case proplists:get_value(doc, rebar_opts:get(Opts, hex, []), undefined) of
|
| 599 |
+
undefined -> undefined;
|
| 600 |
+
PrvName when is_atom(PrvName) -> {ok, PrvName};
|
| 601 |
+
#{provider := PrvName} -> {ok, PrvName};
|
| 602 |
+
_ -> undefined
|
| 603 |
+
end
|
| 604 |
+
end.
|
| 605 |
+
|
| 606 |
+
binarify(Term) when is_boolean(Term) ->
|
| 607 |
+
Term;
|
| 608 |
+
binarify(Term) when is_atom(Term) ->
|
| 609 |
+
atom_to_binary(Term, utf8);
|
| 610 |
+
binarify([]) ->
|
| 611 |
+
[];
|
| 612 |
+
binarify(Map) when is_map(Map) ->
|
| 613 |
+
maps:from_list(binarify(maps:to_list(Map)));
|
| 614 |
+
binarify(Term) when is_list(Term) ->
|
| 615 |
+
case io_lib:printable_unicode_list(Term) of
|
| 616 |
+
true ->
|
| 617 |
+
rebar_utils:to_binary(Term);
|
| 618 |
+
false ->
|
| 619 |
+
[binarify(X) || X <- Term]
|
| 620 |
+
end;
|
| 621 |
+
binarify({Key, Value}) ->
|
| 622 |
+
{binarify(Key), binarify(Value)};
|
| 623 |
+
binarify(Term) ->
|
| 624 |
+
Term.
|
| 625 |
+
|
| 626 |
+
create_package_tarball(Metadata, Files) ->
|
| 627 |
+
case hex_tarball:create(Metadata, Files) of
|
| 628 |
+
{ok, #{tarball := Tarball, inner_checksum := _Checksum}} ->
|
| 629 |
+
Tarball;
|
| 630 |
+
{error, Reason} ->
|
| 631 |
+
{error, hex_tarball:format_error(Reason)}
|
| 632 |
+
end.
|
| 633 |
+
|
| 634 |
+
-spec to_atom(atom() | string() | binary() | integer() | float()) ->
|
| 635 |
+
atom().
|
| 636 |
+
to_atom(X) when erlang:is_atom(X) ->
|
| 637 |
+
X;
|
| 638 |
+
to_atom(X) when erlang:is_list(X) ->
|
| 639 |
+
list_to_existing_atom(X);
|
| 640 |
+
to_atom(X) ->
|
| 641 |
+
to_atom(rebar_utils:to_list(X)).
|
| 642 |
+
|
| 643 |
+
to_map(Map) when is_map(Map) ->
|
| 644 |
+
Map;
|
| 645 |
+
to_map(List) when is_list(List) ->
|
| 646 |
+
maps:from_list(List).
|
deps/eini/_build/default/plugins/rebar3_hex/src/rebar3_hex_client.erl
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%% @private
|
| 2 |
+
-module(rebar3_hex_client).
|
| 3 |
+
|
| 4 |
+
-export([ is_success/1
|
| 5 |
+
, create_user/4
|
| 6 |
+
, delete_release/3
|
| 7 |
+
, me/1
|
| 8 |
+
, key_add/3
|
| 9 |
+
, key_get/2
|
| 10 |
+
, key_delete/2
|
| 11 |
+
, key_delete_all/1
|
| 12 |
+
, key_list/1
|
| 13 |
+
, publish/3
|
| 14 |
+
, publish_docs/4
|
| 15 |
+
, delete_docs/3
|
| 16 |
+
, test_key/2
|
| 17 |
+
, member_of/1
|
| 18 |
+
, pretty_print_status/1
|
| 19 |
+
, pretty_print_errors/1
|
| 20 |
+
, reset_password/2
|
| 21 |
+
, retire/5
|
| 22 |
+
, unretire/3
|
| 23 |
+
]).
|
| 24 |
+
|
| 25 |
+
-include("rebar3_hex.hrl").
|
| 26 |
+
|
| 27 |
+
-define(is_success(N), N >= 200 andalso N =< 299).
|
| 28 |
+
|
| 29 |
+
create_user(HexConfig, Username, Password, Email) ->
|
| 30 |
+
Res = hex_api_user:create(HexConfig, Username, Password, Email),
|
| 31 |
+
response(Res).
|
| 32 |
+
|
| 33 |
+
reset_password(HexConfig, User) ->
|
| 34 |
+
Res = hex_api_user:reset_password(HexConfig, User),
|
| 35 |
+
response(Res).
|
| 36 |
+
|
| 37 |
+
me(HexConfig) ->
|
| 38 |
+
Res = hex_api_user:me(to_hex_core_config(HexConfig)),
|
| 39 |
+
response(Res).
|
| 40 |
+
|
| 41 |
+
key_add(HexConfig, <<KeyName/binary>>, Perms) ->
|
| 42 |
+
Res = hex_api_key:add(HexConfig, KeyName, Perms),
|
| 43 |
+
response(Res);
|
| 44 |
+
key_add(HexConfig, KeyName, Perms) ->
|
| 45 |
+
key_add(HexConfig, to_binary(KeyName), Perms).
|
| 46 |
+
|
| 47 |
+
key_get(HexConfig, <<KeyName/binary>>) ->
|
| 48 |
+
Res = hex_api_key:get(HexConfig, KeyName),
|
| 49 |
+
response(Res);
|
| 50 |
+
key_get(HexConfig, KeyName) ->
|
| 51 |
+
key_get(HexConfig, to_binary(KeyName)).
|
| 52 |
+
|
| 53 |
+
member_of(HexConfig) ->
|
| 54 |
+
Res = hex_api_organization:list(HexConfig),
|
| 55 |
+
response(Res).
|
| 56 |
+
|
| 57 |
+
key_list(HexConfig) ->
|
| 58 |
+
Res = hex_api_key:list(HexConfig),
|
| 59 |
+
response(Res).
|
| 60 |
+
|
| 61 |
+
key_delete(HexConfig, <<KeyName/binary>>) ->
|
| 62 |
+
Res = hex_api_key:delete(HexConfig, KeyName),
|
| 63 |
+
response(Res);
|
| 64 |
+
key_delete(HexConfig, KeyName) ->
|
| 65 |
+
key_delete(HexConfig, to_binary(KeyName)).
|
| 66 |
+
|
| 67 |
+
key_delete_all(HexConfig) ->
|
| 68 |
+
Res = hex_api_key:delete_all(HexConfig),
|
| 69 |
+
response(Res).
|
| 70 |
+
|
| 71 |
+
test_key(HexConfig, Perms) ->
|
| 72 |
+
Res = hex_api_auth:test(to_hex_core_config(HexConfig), Perms),
|
| 73 |
+
response(Res).
|
| 74 |
+
|
| 75 |
+
publish(HexConfig, Tarball, Opts) ->
|
| 76 |
+
Res = hex_api_release:publish(to_hex_core_config(HexConfig), Tarball, Opts),
|
| 77 |
+
response(Res).
|
| 78 |
+
|
| 79 |
+
delete_release(HexConfig, Name, Version) ->
|
| 80 |
+
Res = hex_api_release:delete(HexConfig, Name, Version),
|
| 81 |
+
response(Res).
|
| 82 |
+
|
| 83 |
+
publish_docs(Config, Name, Version, Tarball) ->
|
| 84 |
+
TarballContentType = "application/octet-stream",
|
| 85 |
+
|
| 86 |
+
Headers = maps:get(http_headers, Config, #{}),
|
| 87 |
+
Headers1 = maps:put(<<"content-length">>, integer_to_binary(byte_size(Tarball)), Headers),
|
| 88 |
+
Config2 = maps:put(http_headers, Headers1, Config),
|
| 89 |
+
Path = hex_api:build_repository_path(Config2, ["packages", Name, "releases", Version, "docs"]),
|
| 90 |
+
Body = {TarballContentType, Tarball},
|
| 91 |
+
Res = hex_api:post(Config2, Path, Body),
|
| 92 |
+
response(Res).
|
| 93 |
+
|
| 94 |
+
delete_docs(Config, Name, Version) ->
|
| 95 |
+
Res = hex_api:delete(Config, ["packages", Name, "releases", Version, "docs"]),
|
| 96 |
+
response(Res).
|
| 97 |
+
|
| 98 |
+
retire(Config, Package, Version, Reason, Message) ->
|
| 99 |
+
Msg = #{<<"reason">> => Reason,
|
| 100 |
+
<<"message">> => Message
|
| 101 |
+
},
|
| 102 |
+
Res = hex_api_release:retire(Config, Package, Version, Msg),
|
| 103 |
+
response(Res).
|
| 104 |
+
|
| 105 |
+
unretire(Config, Package, Version) ->
|
| 106 |
+
Res = hex_api_release:unretire(Config, Package, Version),
|
| 107 |
+
response(Res).
|
| 108 |
+
|
| 109 |
+
response({ok, {201, _Headers, Res}}) ->
|
| 110 |
+
{ok, Res};
|
| 111 |
+
response({ok, {204, _Headers, Res}}) ->
|
| 112 |
+
{ok, Res};
|
| 113 |
+
response({ok, {N, _Headers, Res}}) when ?is_success(N) ->
|
| 114 |
+
{ok, Res};
|
| 115 |
+
response({ok, {401, _Headers, Res}}) ->
|
| 116 |
+
{error, Res};
|
| 117 |
+
response({ok, {403, _Headers, Res}}) ->
|
| 118 |
+
{error, Res};
|
| 119 |
+
response({ok, {404, _Headers, Res}}) ->
|
| 120 |
+
{error, Res};
|
| 121 |
+
response({ok, {422, _Headers, #{<<"message">> := <<"Validation error(s)">>} = Res}}) ->
|
| 122 |
+
{error, Res};
|
| 123 |
+
response({ok, {422, _Headers, Res}}) ->
|
| 124 |
+
{error, Res};
|
| 125 |
+
response({ok, {500, _Headers, Res}}) ->
|
| 126 |
+
{error, Res};
|
| 127 |
+
response({_, _} = Unknown) ->
|
| 128 |
+
Unknown.
|
| 129 |
+
|
| 130 |
+
is_success(N) when ?is_success(N) -> true;
|
| 131 |
+
is_success(_N) -> false.
|
| 132 |
+
|
| 133 |
+
pretty_print_status(401) -> "Authentication failed (401)";
|
| 134 |
+
pretty_print_status(403) -> "Forbidden (403)";
|
| 135 |
+
pretty_print_status(404) -> "Entity not found (404)";
|
| 136 |
+
pretty_print_status(422) -> "Validation failed (422)";
|
| 137 |
+
pretty_print_status(Code) -> io_lib:format("HTTP status code: ~p", [Code]).
|
| 138 |
+
|
| 139 |
+
pretty_print_errors(Errors) ->
|
| 140 |
+
L = maps:fold(fun(K,V,Acc) ->
|
| 141 |
+
case is_map(V) of
|
| 142 |
+
true ->
|
| 143 |
+
Acc ++ [pretty_print_errors(V)];
|
| 144 |
+
false ->
|
| 145 |
+
Acc ++ [<<K/binary, " ", V/binary>>]
|
| 146 |
+
end
|
| 147 |
+
end,
|
| 148 |
+
[],
|
| 149 |
+
Errors),
|
| 150 |
+
binary:list_to_bin(join_lists(", ", L)).
|
| 151 |
+
|
| 152 |
+
-ifdef(POST_OTP_18).
|
| 153 |
+
join_lists(Sep, List) -> lists:join(Sep, List).
|
| 154 |
+
-else.
|
| 155 |
+
join_lists(_Sep, []) -> [];
|
| 156 |
+
join_lists(Sep, List) ->
|
| 157 |
+
[Last | AllButLast] = lists:reverse(List),
|
| 158 |
+
lists:foldl(fun (Elem,Acc) -> [Elem,Sep|Acc] end, [Last], AllButLast).
|
| 159 |
+
-endif.
|
| 160 |
+
|
| 161 |
+
to_binary(Subject) ->
|
| 162 |
+
rebar_utils:to_binary(Subject).
|
| 163 |
+
|
| 164 |
+
to_hex_core_config(#{name := Name} = HexConfig) ->
|
| 165 |
+
NewHexConfig = HexConfig#{repo_name := Name},
|
| 166 |
+
maps:remove(name, NewHexConfig).
|
deps/eini/_build/default/plugins/rebar3_hex/src/rebar3_hex_config.erl
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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_key_name/0
|
| 10 |
+
, org_key_name/2
|
| 11 |
+
, parent_repos/1
|
| 12 |
+
, get_hex_config/3
|
| 13 |
+
, default_repo/1
|
| 14 |
+
, repo/1
|
| 15 |
+
, repo/2
|
| 16 |
+
, update_auth_config/2
|
| 17 |
+
]).
|
| 18 |
+
|
| 19 |
+
-include("rebar3_hex.hrl").
|
| 20 |
+
|
| 21 |
+
-type repo_error() :: {not_valid_repo, string()} | no_repo_in_state | {required, repo}.
|
| 22 |
+
-export_type([repo_error/0]).
|
| 23 |
+
|
| 24 |
+
-spec api_key_name(binary()) -> binary().
|
| 25 |
+
api_key_name(Key) ->
|
| 26 |
+
Prefix = key_name_prefix(Key),
|
| 27 |
+
key_name(Prefix, <<"-api">>).
|
| 28 |
+
|
| 29 |
+
-spec api_key_name(binary(), binary()) -> binary().
|
| 30 |
+
api_key_name(Key, Suffix) ->
|
| 31 |
+
Prefix = key_name_prefix(Key),
|
| 32 |
+
key_name(Prefix, <<"-api-">>, Suffix).
|
| 33 |
+
|
| 34 |
+
-ifdef(POST_OTP_22).
|
| 35 |
+
-spec encrypt_write_key(binary(), binary(), binary()) -> {binary(), {binary(), binary()}}.
|
| 36 |
+
encrypt_write_key(Username, LocalPassword, WriteKey) ->
|
| 37 |
+
AAD = Username,
|
| 38 |
+
IV = crypto:strong_rand_bytes(16),
|
| 39 |
+
Key = pad(LocalPassword),
|
| 40 |
+
{IV, crypto:crypto_one_time_aead(cipher(Key), Key, IV, WriteKey, AAD, true)}.
|
| 41 |
+
-else.
|
| 42 |
+
-spec encrypt_write_key(binary(), binary(), binary()) -> {binary(), {binary(), binary()}}.
|
| 43 |
+
encrypt_write_key(Username, LocalPassword, WriteKey) ->
|
| 44 |
+
AAD = Username,
|
| 45 |
+
IV = crypto:strong_rand_bytes(16),
|
| 46 |
+
{IV, crypto:block_encrypt(aes_gcm, pad(LocalPassword), IV, {AAD, WriteKey})}.
|
| 47 |
+
-endif.
|
| 48 |
+
|
| 49 |
+
-ifdef(POST_OTP_22).
|
| 50 |
+
decrypt_write_key(Username, LocalPassword, {IV, {CipherText, CipherTag}}) ->
|
| 51 |
+
Key = pad(LocalPassword),
|
| 52 |
+
crypto:crypto_one_time_aead(cipher(Key), Key, IV, CipherText, Username, CipherTag, false).
|
| 53 |
+
-else.
|
| 54 |
+
decrypt_write_key(Username, LocalPassword, {IV, {CipherText, CipherTag}}) ->
|
| 55 |
+
crypto:block_decrypt(aes_gcm, pad(LocalPassword), IV, {Username, CipherText, CipherTag}).
|
| 56 |
+
-endif.
|
| 57 |
+
|
| 58 |
+
-ifdef(POST_OTP_22).
|
| 59 |
+
cipher(Key) when byte_size(Key) == 16 -> aes_128_gcm;
|
| 60 |
+
cipher(Key) when byte_size(Key) == 24 -> aes_192_gcm;
|
| 61 |
+
cipher(Key) when byte_size(Key) == 32 -> aes_256_gcm.
|
| 62 |
+
-endif.
|
| 63 |
+
|
| 64 |
+
pad(Binary) ->
|
| 65 |
+
case byte_size(Binary) of
|
| 66 |
+
Size when Size =< 16 ->
|
| 67 |
+
<<Binary/binary, 0:((16 - Size) * 8)>>;
|
| 68 |
+
Size when Size =< 24 ->
|
| 69 |
+
<<Binary/binary, 0:((24 - Size) * 8)>>;
|
| 70 |
+
Size when Size =< 32 ->
|
| 71 |
+
<<Binary/binary, 0:((32 - Size) * 8)>>
|
| 72 |
+
end.
|
| 73 |
+
|
| 74 |
+
-spec repos_key_name() -> binary().
|
| 75 |
+
repos_key_name() ->
|
| 76 |
+
key_name(hostname(), <<"-repositories">>).
|
| 77 |
+
|
| 78 |
+
-spec org_key_name(binary(), binary()) -> binary().
|
| 79 |
+
org_key_name(Key, Org) ->
|
| 80 |
+
Prefix = key_name_prefix(Key),
|
| 81 |
+
key_name(Prefix, <<"-repository-">>, Org).
|
| 82 |
+
|
| 83 |
+
-spec hostname() -> binary().
|
| 84 |
+
hostname() ->
|
| 85 |
+
{ok, Name} = inet:gethostname(),
|
| 86 |
+
list_to_binary(Name).
|
| 87 |
+
|
| 88 |
+
key_name(Prefix, Suffix) ->
|
| 89 |
+
<<Prefix/binary, Suffix/binary>>.
|
| 90 |
+
|
| 91 |
+
key_name(Prefix, Interfix, Suffix) ->
|
| 92 |
+
<<Prefix/binary, Interfix/binary, Suffix/binary>>.
|
| 93 |
+
|
| 94 |
+
key_name_prefix(undefined) -> hostname();
|
| 95 |
+
key_name_prefix(Key) -> Key.
|
| 96 |
+
|
| 97 |
+
update_auth_config(Config, State) ->
|
| 98 |
+
rebar_hex_repos:update_auth_config(Config, State).
|
| 99 |
+
|
| 100 |
+
all_repos(State) ->
|
| 101 |
+
Resources = rebar_state:resources(State),
|
| 102 |
+
#{repos := Repos} = rebar_resource_v2:find_resource_state(pkg, Resources),
|
| 103 |
+
Repos.
|
| 104 |
+
|
| 105 |
+
-spec repo(rebar_state:t()) -> {ok, map()} | {error, repo_error()}.
|
| 106 |
+
repo(State) ->
|
| 107 |
+
{Args, _} = rebar_state:command_parsed_args(State),
|
| 108 |
+
Repos = all_repos(State),
|
| 109 |
+
case proplists:get_value(repo, Args, undefined) of
|
| 110 |
+
undefined ->
|
| 111 |
+
Res = [R || R <- Repos, maps:get(name, R) =/= ?DEFAULT_HEX_REPO],
|
| 112 |
+
case Res of
|
| 113 |
+
[] ->
|
| 114 |
+
case rebar_hex_repos:get_repo_config(?DEFAULT_HEX_REPO, Repos) of
|
| 115 |
+
{ok, Repo} ->
|
| 116 |
+
{ok, set_http_adapter(Repo)};
|
| 117 |
+
_ ->
|
| 118 |
+
{error, no_repo_in_state}
|
| 119 |
+
end;
|
| 120 |
+
[_Repo|_Rest] ->
|
| 121 |
+
{error, {required, repo}}
|
| 122 |
+
end;
|
| 123 |
+
RepoName ->
|
| 124 |
+
repo(State, RepoName)
|
| 125 |
+
end.
|
| 126 |
+
|
| 127 |
+
repo(State, RepoName) ->
|
| 128 |
+
BinName = rebar_utils:to_binary(RepoName),
|
| 129 |
+
Repos = all_repos(State),
|
| 130 |
+
MaybeFound1 = get_repo(BinName, all_repos(State)),
|
| 131 |
+
MaybeParentRepo = <<"hexpm:">>,
|
| 132 |
+
MaybeFound2 = get_repo(<<MaybeParentRepo/binary, BinName/binary>>, Repos),
|
| 133 |
+
case {MaybeFound1, MaybeFound2} of
|
| 134 |
+
{{ok, Repo1}, undefined} ->
|
| 135 |
+
Repo2 = set_http_adapter(merge_with_env(Repo1)),
|
| 136 |
+
Repo3 = maybe_set_api_organization(Repo2),
|
| 137 |
+
{ok, maybe_set_api_repository(Repo3)};
|
| 138 |
+
{undefined, {ok, Repo2}} ->
|
| 139 |
+
Repo3 = set_http_adapter(merge_with_env(Repo2)),
|
| 140 |
+
Repo4 = maybe_set_api_organization(Repo3),
|
| 141 |
+
{ok, maybe_set_api_repository(Repo4)};
|
| 142 |
+
{undefined, undefined} ->
|
| 143 |
+
{error, {not_valid_repo, RepoName}}
|
| 144 |
+
end.
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
-define( ENV_VARS
|
| 148 |
+
, [ {"HEX_API_KEY", {api_key, {string, undefined}}}
|
| 149 |
+
, {"HEX_API_URL", {api_url, {string, undefined}}}
|
| 150 |
+
, {"HEX_UNSAFE_REGISTRY", {repo_verify, {boolean, false}}}
|
| 151 |
+
, {"HEX_NO_VERIFY_REPO_ORIGIN", {repo_verify_origin, {boolean, true}}}
|
| 152 |
+
]
|
| 153 |
+
).
|
| 154 |
+
|
| 155 |
+
merge_with_env(Repo) ->
|
| 156 |
+
lists:foldl(fun({EnvName, {Key, _} = Default}, Acc) ->
|
| 157 |
+
Val = maybe_env_val(EnvName, Default),
|
| 158 |
+
maybe_put_key(Key, Val, Acc)
|
| 159 |
+
end, Repo, ?ENV_VARS).
|
| 160 |
+
|
| 161 |
+
maybe_put_key(_Key, undefined, Repo) ->
|
| 162 |
+
Repo;
|
| 163 |
+
maybe_put_key(Key, Val, Repo) ->
|
| 164 |
+
case maps:get(Key, Repo, undefined) of
|
| 165 |
+
Val ->
|
| 166 |
+
Repo;
|
| 167 |
+
_ ->
|
| 168 |
+
Repo#{Key => Val}
|
| 169 |
+
end.
|
| 170 |
+
|
| 171 |
+
maybe_env_val(K, {_, {Type, Default}}) ->
|
| 172 |
+
case {os:getenv(K), {Type, Default}} of
|
| 173 |
+
{false, {_, Default}} ->
|
| 174 |
+
Default;
|
| 175 |
+
{"", {_, Default}} ->
|
| 176 |
+
Default;
|
| 177 |
+
{Val, {boolean, _}} ->
|
| 178 |
+
to_bool(string:to_lower(Val));
|
| 179 |
+
{Val, {string, _}} ->
|
| 180 |
+
rebar_utils:to_binary(Val)
|
| 181 |
+
end.
|
| 182 |
+
|
| 183 |
+
set_http_adapter(Repo) ->
|
| 184 |
+
Repo#{http_adapter => {rebar3_hex_httpc_adapter, #{profile => rebar}}}.
|
| 185 |
+
|
| 186 |
+
to_bool("0") -> false;
|
| 187 |
+
to_bool("false") -> false;
|
| 188 |
+
to_bool(_) -> true.
|
| 189 |
+
|
| 190 |
+
parent_repos(State) ->
|
| 191 |
+
Fun = fun(#{name := Name} = Repo, Acc) ->
|
| 192 |
+
[Parent|_] = rebar3_hex_io:str_split(Name, <<":">>),
|
| 193 |
+
case maps:is_key(Parent, Acc) of
|
| 194 |
+
true ->
|
| 195 |
+
Acc;
|
| 196 |
+
false ->
|
| 197 |
+
maps:put(name, Repo, Acc)
|
| 198 |
+
end
|
| 199 |
+
end,
|
| 200 |
+
Map = lists:foldl(Fun, #{}, all_repos(State)),
|
| 201 |
+
maps:values(Map).
|
| 202 |
+
|
| 203 |
+
default_repo(State) ->
|
| 204 |
+
rebar_hex_repos:get_repo_config(?DEFAULT_HEX_REPO, all_repos(State)).
|
| 205 |
+
|
| 206 |
+
get_repo(BinaryName, Repos) ->
|
| 207 |
+
try rebar_hex_repos:get_repo_config(BinaryName, Repos) of
|
| 208 |
+
Name ->
|
| 209 |
+
Name
|
| 210 |
+
catch
|
| 211 |
+
{error,{rebar_hex_repos,{repo_not_found,BinaryName}}} -> undefined
|
| 212 |
+
end.
|
| 213 |
+
|
| 214 |
+
-spec get_hex_config(module(), map(), read | write) -> map().
|
| 215 |
+
get_hex_config(Module, Repo, Mode) ->
|
| 216 |
+
case hex_config(Repo, Mode) of
|
| 217 |
+
{ok, HexConfig} ->
|
| 218 |
+
HexConfig;
|
| 219 |
+
{error, Reason} ->
|
| 220 |
+
erlang:error({error, {Module, {get_hex_config, Reason}}})
|
| 221 |
+
end.
|
| 222 |
+
|
| 223 |
+
hex_config(Repo, read) ->
|
| 224 |
+
hex_config_read(Repo);
|
| 225 |
+
hex_config(Repo, write) ->
|
| 226 |
+
hex_config_write(Repo).
|
| 227 |
+
|
| 228 |
+
hex_config_write(#{api_key := Key} = HexConfig) when is_binary(Key) ->
|
| 229 |
+
{ok, set_http_adapter(HexConfig)};
|
| 230 |
+
hex_config_write(#{write_key := undefined}) ->
|
| 231 |
+
{error, no_write_key};
|
| 232 |
+
hex_config_write(#{write_key := WriteKey, username := Username} = HexConfig) ->
|
| 233 |
+
DecryptedWriteKey = rebar3_hex_user:decrypt_write_key(Username, WriteKey),
|
| 234 |
+
{ok, set_http_adapter(HexConfig#{api_key => DecryptedWriteKey})};
|
| 235 |
+
hex_config_write(_) ->
|
| 236 |
+
{error, no_write_key}.
|
| 237 |
+
|
| 238 |
+
hex_config_read(#{read_key := ReadKey} = HexConfig) ->
|
| 239 |
+
{ok, set_http_adapter(HexConfig#{api_key => ReadKey})};
|
| 240 |
+
hex_config_read(_Config) ->
|
| 241 |
+
{error, no_read_key}.
|
| 242 |
+
|
| 243 |
+
maybe_set_api_organization(#{name := Name} = Repo) ->
|
| 244 |
+
case binary:split(Name, <<":">>) of
|
| 245 |
+
[_] ->
|
| 246 |
+
Repo#{api_organization => undefined};
|
| 247 |
+
[_,Org] ->
|
| 248 |
+
Repo#{api_organization => Org}
|
| 249 |
+
end.
|
| 250 |
+
|
| 251 |
+
maybe_set_api_repository(#{api_repository := _} = Repo) ->
|
| 252 |
+
Repo;
|
| 253 |
+
maybe_set_api_repository(#{} = Repo) ->
|
| 254 |
+
Repo#{api_repository => undefined}.
|