Skip to content

Commit

Permalink
Merge pull request #40 from tsloughter/master
Browse files Browse the repository at this point in the history
Misc fixes, log improvements and README improvements
  • Loading branch information
jwilberding committed Sep 16, 2013
2 parents 55f0f5a + 26d1d19 commit 47d157e
Show file tree
Hide file tree
Showing 17 changed files with 166 additions and 115 deletions.
83 changes: 41 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,66 @@
[![Build Status](https://drone.io/github.com/erlware/relx/status.png)](https://drone.io/github.com/erlware/relx/latest)

# NAME
Relx
=======

relx - A release assembler for erlang
A release assembler for Erlang.

# SYNOPSIS
Synopsis
--------

relx [*options*] [*release-specification-file*]

# DESCRIPTION
Description
-----------

Relx assembles releases for an Erlang/OTP release. Given a release
specification and a list of directories in which to search for OTP
applications it will generate a release output. That output depends
heavily on what plugins available and what options are defined, but
usually it is simple a well configured release directory.

relx -c relx.config -l ~/my-dirs --relname foo --relvsn 0.0.1 --target-spec myapp --target-spec getopt>=0.5.1 -o output-dir
usually it is simply a well configured release directory.

The *release-specification-file* is optional but otherwise contains
additional specification information for releases.

# BUILDING
Building
--------

To build relx and generate a standalone escript executable:

$ make

This creates the executable `relx`.

# OPTIONS

-r *STRING*, \--root *STRING*
: Specify the root directory for the project (if different from cwd)

-n *STRING*, \--relname *STRING*
: Specify the name for the release that will be generated

-v *STRING*, \--relvsn=*STRING*
: Specify the version for the release

-g *STRING*, \--goals *STRING*
: Specify a goal to the system. These are usually the OTP
Apps that are part of the release

-o *STRING*, \--output-dir *STRING*
: The output directory for the release. This is `./` by default.

-l *STRING*, \--lib-dir *STRING*
: Additional dirs that should be searched for OTP Apps

-V *INTEGER*, \--verbose *INTEGER*
: The verbosity level of the system. Valid values are 1 - 3

-c *INTEGER*, \--config *INTEGER*
: The custom config file for the relx system

# CONFIGURATION FILES

Configuration files

# SEE ALSO

`reltool` (1).
Config File
-----------

By default `relx` looks for `relx.config` in the current working directory:

```erlang
{release, {relname, "vsn"},
[app1,
app2]}.

{extended_start_script, true}.
```

Options
-------

| Short | Long | Type | Default | Description |
|:-----:|:------------:|:-------:|:------:|------------------------------------------------------------------------------------------- |
| -r | --root | string | ./ | Name for the release that will be generated |
| -v | --relvsn | string | | Version for the release |
| -g | --goal | string | | A goal for the system. These are usually the OTP apps that are part of the release |
| -u | --upfrom | string | | The release to upgrade from. Only valid with relup target |
| -o | --output-dir | string | ./ | The output directory for the release |
| -l | --lib-dir | string | | Additional dirs to search for OTP apps |
| | --disable-default-libs | boolean | false | Disable use of the default system added lib dirs |
| -V | --verbose | integer | 0 | The verbosity level between 0 and 2 |
| -a | --override_app | string | | An app name and a directory to override in the form appname:dir |
| -c | --config | string | ./relx.config | Config file path |

Wiki
----

[relx wiki](https://github.com/erlware/relx/wiki)
File renamed without changes.
File renamed without changes.
29 changes: 23 additions & 6 deletions src/relx.erl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ main(Args) ->
OptSpecList = opt_spec_list(),
Result = case getopt:parse(OptSpecList, Args) of
{ok, {Options, NonOptions}} ->
do([{caller, command_line} | Options], NonOptions);
case lists:member(help, Options) of
true ->
usage();
false ->
do([{caller, command_line} | Options], NonOptions)
end;
{error, Detail} ->
?RLX_ERROR({opt_parse, Detail})
end,
Expand Down Expand Up @@ -174,6 +179,8 @@ opt_spec_list() ->
"Only valid with relup target, specify the release to upgrade from"},
{output_dir, $o, "output-dir", string,
"The output directory for the release. This is `./` by default."},
{help, $h, "help", undefined,
"Print usage"},
{lib_dir, $l, "lib-dir", string,
"Additional dirs that should be searched for OTP Apps"},
{disable_default_libs, undefined, "disable-default-libs",
Expand All @@ -186,14 +193,16 @@ opt_spec_list() ->
{config, $c, "config", {string, ""}, "The path to a config file"},
{root_dir, $r, "root", string, "The project root directory"}].

-spec format_error(Reason::term()) -> iolist().
-spec format_error(Reason::term()) -> string().
format_error({invalid_return_value, Provider, Value}) ->
[rlx_provider:format(Provider), " returned an invalid value ",
io_lib:format("~p", [Value])];
io_lib:format(lists:flatten([rlx_provider:format(Provider), " returned an invalid value ",
io_lib:format("~p", [Value])]), []);
format_error({opt_parse, {invalid_option, Opt}}) ->
io_lib:format("invalid option ~s~n", [Opt]);
format_error({opt_parse, Arg}) ->
io_lib:format("~p~n", [Arg]);
format_error({error, {relx, Reason}}) ->
format_error(Reason);
format_error({error, {Module, Reason}}) ->
io_lib:format("~s~n", [Module:format_error(Reason)]).

Expand Down Expand Up @@ -268,8 +277,16 @@ usage() ->

-spec report_error(rlx_state:t(), error()) -> none() | error().
report_error(State, Error) ->
io:format(format_error(Error)),
usage(),
case Error of
{error, {relx, {opt_parse, _}}} ->
io:format(standard_error, format_error(Error), []),
usage();
{error, {rlx_cmd_args, _}} ->
io:format(standard_error, format_error(Error), []),
usage();
_ ->
io:format(standard_error, format_error(Error), [])
end,
case rlx_state:caller(State) of
command_line ->
erlang:halt(127);
Expand Down
6 changes: 3 additions & 3 deletions src/rlx_app_discovery.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@

%% @doc recursively dig down into the library directories specified in the state
%% looking for OTP Applications
-spec do(rlx_state:t(), [filename:name()]) -> {ok, [rlx_app_info:t()]} | relx:error().
-spec do(rlx_state:t(), [file:name()]) -> {ok, [rlx_app_info:t()]} | relx:error().
do(State, LibDirs) ->
rlx_log:info(rlx_state:log(State),
fun() ->
["Resolving OTP Applications from directories:\n",
[[rlx_util:indent(1), LibDir, "\n"] || LibDir <- LibDirs]]
[[rlx_util:indent(2), LibDir, "\n"] || LibDir <- LibDirs]]
end),
resolve_app_metadata(State, LibDirs).

Expand Down Expand Up @@ -72,7 +72,7 @@ resolve_app_metadata(State, LibDirs) ->
rlx_log:debug(rlx_state:log(State),
fun() ->
["Resolved the following OTP Applications from the system: \n",
[[rlx_app_info:format(1, App), "\n"] || App <- AppMeta1]]
[[rlx_app_info:format(2, App), "\n"] || App <- AppMeta1]]
end),
{ok, AppMeta1};
Errors ->
Expand Down
7 changes: 4 additions & 3 deletions src/rlx_cmd_args.erl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ handle_config(Opts, Targets, CommandLineConfig) ->
convert_targets(Targets) ->
convert_targets(Targets, []).

-spec convert_targets([string()], [string()]) -> {ok, release | relup} | relx:error().
-spec convert_targets([string()], [rlx_state:action()]) ->
{ok, [rlx_state:action()]} | relx:error().
convert_targets([], []) ->
{ok, [release]};
convert_targets([], Acc) ->
Expand Down Expand Up @@ -134,7 +135,7 @@ create_log(Opts, Acc) ->
LogLevel = proplists:get_value(log_level, Opts, 0),
if
LogLevel >= 0, LogLevel =< 2 ->
create_goals(Opts, [{log, rlx_log:new(LogLevel)} | Acc]);
create_goals(Opts, [{log, rlx_log:new(LogLevel, command_line)} | Acc]);
true ->
?RLX_ERROR({invalid_log_level, LogLevel})
end.
Expand Down Expand Up @@ -245,7 +246,7 @@ create_disable_default_libs(Opts, Acc) ->
Def = proplists:get_value(disable_default_libs, Opts, false),
create_upfrom(Opts, [{disable_default_libs, Def} | Acc]).

-spec create_upfrom([getopt:option()], rcl:cmd_args()) ->
-spec create_upfrom([getopt:option()], rlx_state:cmd_args()) ->
{ok, rlx_state:cmd_args()} | relx:error().
create_upfrom(Opts, Acc) ->
case proplists:get_value(upfrom, Opts, undefined) of
Expand Down
1 change: 1 addition & 0 deletions src/rlx_depsolver.erl
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
-export_type([t/0,
pkg/0,
constraint_op/0,
raw_constraint/0,
pkg_name/0,
vsn/0,
constraint/0,
Expand Down
4 changes: 2 additions & 2 deletions src/rlx_dscv_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
%% Types
%%============================================================================

-type process_fun(Result) :: fun((filename:name(), file | directory) ->
-type process_fun(Result) :: fun((file:name(), file | directory) ->
{ok, Result} |
{error, term()} |
{ok, Result, Recurse::boolean()} |
Expand All @@ -46,7 +46,7 @@

%% @doc recursively dig down into the library directories specified in the state
%% looking for OTP Applications
-spec do(process_fun([term()] | term()), [filename:name()]) ->
-spec do(process_fun([term()] | term()), [file:name()]) ->
[term() | {error, term()}].
do(ProcessDir, LibDirs) ->
lists:flatten(ec_plists:map(fun(LibDir) ->
Expand Down
Loading

0 comments on commit 47d157e

Please sign in to comment.