checksum() = binary()
contents() = [{filename(), binary()}]
file_options() = #{executable => boolean()}
filename() = string()
files() = [{filename(), filename() | binary()} | {filename(), filename() | binary(), file_options()}]
metadata() = map()
tarball() = binary()
| create/2 | |
| create/3 | Creates a package tarball. |
| create_docs/1 | |
| create_docs/2 | Creates a docs tarball. |
| format_checksum/1 | Returns base16-encoded representation of checksum. |
| format_error/1 | Converts an error reason term to a human-readable error message string. |
| unpack/2 | Unpacks a package tarball. |
| unpack/3 | Unpacks a package tarball. |
| unpack_docs/2 | |
| unpack_docs/3 | Unpacks a documentation tarball. |
create(Metadata::metadata(), Files::files()) -> {ok, #{tarball => tarball(), outer_checksum => checksum(), inner_checksum => tarball()}} | {error, term()}
create(Metadata::metadata(), Files::files(), Config::r3_hex_core:config()) -> {ok, #{tarball => tarball(), outer_checksum => checksum(), inner_checksum => tarball()}} | {error, term()}
Creates a package tarball.
Returns the binary of the tarball the "inner checksum" and "outer checksum". The inner checksum is deprecated in favor of the outer checksum.
Each file is given as {Name, Contents} with the contents as a binary, or
{Name, Path} with the path of a file, directory or symbolic link on disk.
Regular files are stored with mode 0755 when the owner execute bit is set
on disk and with mode 0644 otherwise. {Name, ContentsOrPath, #{executable
=> boolean()}} sets the mode of a regular file regardless of the file
system, the option doesn't apply to directories and symbolic links.
Examples:
> Metadata = #{<<"name">> => <<"foo">>, <<"version">> => <<"1.0.0">>},
> Files = [{"src/foo.erl", <<"-module(foo).">>}],
> r3_hex_tarball:create(Metadata, Files).
{ok, #{tarball => <<86,69,...>>,
outer_checksum => <<40,32,...>>,
inner_checksum => <<178,12,...>>}}
create_docs(Files::files(), Config::r3_hex_core:config()) -> {ok, tarball()} | {error, term()}
Creates a docs tarball.
Examples:
> Files = [{"doc/index.html", <<"Docs">>}],
> r3_hex_tarball:create_docs(Files).
{ok, <<86,69,...>>}
format_checksum(Checksum::checksum()) -> binary()
Returns base16-encoded representation of checksum.
format_error(X1::term()) -> string()
Converts an error reason term to a human-readable error message string.
unpack(Tarball::tarball() | {file, filename()}, Output::memory) -> {ok, #{outer_checksum => checksum(), inner_checksum => checksum(), metadata => metadata(), contents => contents()}} | {error, term()}
unpack(Tarball::tarball() | {file, filename()}, Output::none) -> {ok, #{outer_checksum => checksum(), inner_checksum => checksum(), metadata => metadata()}} | {error, term()}
unpack(Tarball::tarball() | {file, filename()}, Output::filename()) -> {ok, #{outer_checksum => checksum(), inner_checksum => checksum(), metadata => metadata()}} | {error, term()}
Unpacks a package tarball.
See also: unpack/3.
unpack(Input::tarball() | {file, filename()}, Output::memory, Config::r3_hex_core:config()) -> {ok, #{outer_checksum => checksum(), inner_checksum => checksum(), metadata => metadata(), contents => contents()}} | {error, term()}
unpack(Input::tarball() | {file, filename()}, Output::none, Config::r3_hex_core:config()) -> {ok, #{outer_checksum => checksum(), inner_checksum => checksum(), metadata => metadata()}} | {error, term()}
unpack(Input::tarball() | {file, filename()}, Output::filename(), Config::r3_hex_core:config()) -> {ok, #{outer_checksum => checksum(), inner_checksum => checksum(), metadata => metadata()}} | {error, term()}
Unpacks a package tarball.
Remember to verify the outer tarball checksum against the registry checksum
returned from r3_hex_repo:get_package(Config, Package).
The first argument is the tarball, either as a binary or {file, Path}
to read from a file on disk. Using {file, Path} avoids loading the
tarball into memory.
The second argument controls the output:
- memory - unpack contents into memory and return them
- none - only extract metadata and checksums, skip contents
- A path string - extract contents to the given directory
Examples:
> r3_hex_tarball:unpack(Tarball, memory).
{ok,#{outer_checksum => <<...>>,
contents => [{"src/foo.erl",<<"-module(foo).">>}],
metadata => #{<<"name">> => <<"foo">>, ...}}}
> r3_hex_tarball:unpack(Tarball, none).
{ok,#{outer_checksum => <<...>>,
metadata => #{<<"name">> => <<"foo">>, ...}}}
> r3_hex_tarball:unpack(Tarball, "path/to/unpack").
{ok,#{outer_checksum => <<...>>,
metadata => #{<<"name">> => <<"foo">>, ...}}}
unpack_docs(Input::tarball() | {file, filename()}, Output::memory) -> {ok, contents()} | {error, term()}
unpack_docs(Input::tarball() | {file, filename()}, Output::filename()) -> ok | {error, term()}
unpack_docs(Input::tarball() | {file, filename()}, Output::memory, Config::r3_hex_core:config()) -> {ok, contents()} | {error, term()}
unpack_docs(Input::tarball() | {file, filename()}, Output::filename(), Config::r3_hex_core:config()) -> ok | {error, term()}
Unpacks a documentation tarball.
The first argument is the tarball, either as a binary or {file, Path}
to read from a file on disk. Using {file, Path} avoids loading the
tarball into memory.
Examples:
> r3_hex_tarball:unpack_docs(Tarball, memory).
{ok, [{"index.html", <<"<!doctype>">>}, ...]}
> r3_hex_tarball:unpack_docs(Tarball, "path/to/unpack").
ok
Generated by EDoc