You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2013/12/16 17:49:05 UTC
[08/10] Import rebar
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/inttest/thooks/thooks_rt.erl
----------------------------------------------------------------------
diff --git a/src/rebar/inttest/thooks/thooks_rt.erl b/src/rebar/inttest/thooks/thooks_rt.erl
new file mode 100644
index 0000000..52af9f5
--- /dev/null
+++ b/src/rebar/inttest/thooks/thooks_rt.erl
@@ -0,0 +1,40 @@
+-module(thooks_rt).
+
+-include_lib("eunit/include/eunit.hrl").
+-compile(export_all).
+
+files() ->
+ [
+ %% dummy lfe files
+ {copy, "../../rebar", "rebar"},
+ {copy, "rebar.config", "rebar.config"},
+ {copy, "fish.erl", "src/fish.erl"},
+ {create, "ebin/fish.app", app(fish, [fish])}
+ ].
+
+run(_Dir) ->
+ ?assertMatch({ok, _}, retest_sh:run("./rebar -v clean compile", [])),
+ ensure_command_ran_only_once("preclean"),
+ ensure_command_ran_only_once("precompile"),
+ ensure_command_ran_only_once("postclean"),
+ ensure_command_ran_only_once("postcompile"),
+ ok.
+
+ensure_command_ran_only_once(Command) ->
+ File = Command ++ ".out",
+ ?assert(filelib:is_regular(File)),
+ %% ensure that this command only ran once (not for each module)
+ {ok, Content} = file:read_file(File),
+ ?assertEqual(Command ++ "\n", binary_to_list(Content)).
+
+%%
+%% Generate the contents of a simple .app file
+%%
+app(Name, Modules) ->
+ App = {application, Name,
+ [{description, atom_to_list(Name)},
+ {vsn, "1"},
+ {modules, Modules},
+ {registered, []},
+ {applications, [kernel, stdlib]}]},
+ io_lib:format("~p.\n", [App]).
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/inttest/tplugins/bad.config
----------------------------------------------------------------------
diff --git a/src/rebar/inttest/tplugins/bad.config b/src/rebar/inttest/tplugins/bad.config
new file mode 100644
index 0000000..23069b8
--- /dev/null
+++ b/src/rebar/inttest/tplugins/bad.config
@@ -0,0 +1,2 @@
+{plugins, [bad_plugin]}.
+{plugin_dir, "bad_plugins"}.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/inttest/tplugins/bad_plugin.erl
----------------------------------------------------------------------
diff --git a/src/rebar/inttest/tplugins/bad_plugin.erl b/src/rebar/inttest/tplugins/bad_plugin.erl
new file mode 100644
index 0000000..77ec01b
--- /dev/null
+++ b/src/rebar/inttest/tplugins/bad_plugin.erl
@@ -0,0 +1,7 @@
+-module(bad_plugin).
+-compile(export_all).
+
+%% this plugin contains numerous DELIBERATE syntax errors
+
+fwibble(Config, _) >
+ file:delete("fwibble.test")
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/inttest/tplugins/fish.erl
----------------------------------------------------------------------
diff --git a/src/rebar/inttest/tplugins/fish.erl b/src/rebar/inttest/tplugins/fish.erl
new file mode 100644
index 0000000..739cb94
--- /dev/null
+++ b/src/rebar/inttest/tplugins/fish.erl
@@ -0,0 +1,5 @@
+-module(fish).
+
+-compile(export_all).
+
+fish() -> fish.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/inttest/tplugins/rebar.config
----------------------------------------------------------------------
diff --git a/src/rebar/inttest/tplugins/rebar.config b/src/rebar/inttest/tplugins/rebar.config
new file mode 100644
index 0000000..0b9c887
--- /dev/null
+++ b/src/rebar/inttest/tplugins/rebar.config
@@ -0,0 +1 @@
+{plugins, [test_plugin]}.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/inttest/tplugins/test_plugin.erl
----------------------------------------------------------------------
diff --git a/src/rebar/inttest/tplugins/test_plugin.erl b/src/rebar/inttest/tplugins/test_plugin.erl
new file mode 100644
index 0000000..461247c
--- /dev/null
+++ b/src/rebar/inttest/tplugins/test_plugin.erl
@@ -0,0 +1,8 @@
+-module(test_plugin).
+-compile(export_all).
+
+fwibble(Config, _) ->
+ Pwd = rebar_utils:get_cwd(),
+ Ok = filelib:is_regular(filename:join(Pwd, "fwibble.test")),
+ rebar_log:log(info, "~p:~p in ~s :: ~p~n", [test_plugin, clean, Pwd, Ok]),
+ ok = file:delete("fwibble.test").
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/inttest/tplugins/tplugins_rt.erl
----------------------------------------------------------------------
diff --git a/src/rebar/inttest/tplugins/tplugins_rt.erl b/src/rebar/inttest/tplugins/tplugins_rt.erl
new file mode 100644
index 0000000..d6908ad
--- /dev/null
+++ b/src/rebar/inttest/tplugins/tplugins_rt.erl
@@ -0,0 +1,40 @@
+-module(tplugins_rt).
+-compile(export_all).
+
+-include_lib("eunit/include/eunit.hrl").
+
+-define(COMPILE_ERROR,
+ "ERROR: Plugin bad_plugin contains compilation errors:").
+
+files() ->
+ [
+ {copy, "../../rebar", "rebar"},
+ {copy, "rebar.config", "rebar.config"},
+ {copy, "bad.config", "bad.config"},
+ {copy, "fish.erl", "src/fish.erl"},
+ {copy, "test_plugin.erl", "plugins/test_plugin.erl"},
+ {copy, "bad_plugin.erl", "bad_plugins/bad_plugin.erl"},
+ {create, "fwibble.test", <<"fwibble">>},
+ {create, "ebin/fish.app", app(fish, [fish])}
+ ].
+
+run(_Dir) ->
+ ?assertMatch({ok, _}, retest_sh:run("./rebar fwibble -v", [])),
+ ?assertEqual(false, filelib:is_regular("fwibble.test")),
+ Ref = retest:sh("./rebar -C bad.config -v clean", [{async, true}]),
+ {ok, _} = retest:sh_expect(Ref, "ERROR: Plugin .*bad_plugin.erl "
+ "contains compilation errors:.*",
+ [{newline, any}]),
+ ok.
+
+%%
+%% Generate the contents of a simple .app file
+%%
+app(Name, Modules) ->
+ App = {application, Name,
+ [{description, atom_to_list(Name)},
+ {vsn, "1"},
+ {modules, Modules},
+ {registered, []},
+ {applications, [kernel, stdlib]}]},
+ io_lib:format("~p.\n", [App]).
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/shell-completion/bash/rebar
----------------------------------------------------------------------
diff --git a/src/rebar/priv/shell-completion/bash/rebar b/src/rebar/priv/shell-completion/bash/rebar
new file mode 100644
index 0000000..d4a42dc
--- /dev/null
+++ b/src/rebar/priv/shell-completion/bash/rebar
@@ -0,0 +1,85 @@
+# bash completion for rebar
+
+_rebar()
+{
+ local cur prev sopts lopts cmdsnvars
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ sopts="-h -c -v -V -f -D -j -C -p -k"
+ lopts="--help \
+ --commands \
+ --verbose \
+ --force \
+ --jobs \
+ --config \
+ --profile \
+ --keep-going \
+ --version"
+ cmdsnvars="check-deps \
+ clean \
+ compile \
+ create \
+ create-app \
+ create-node \
+ ct \
+ doc \
+ delete-deps \
+ escriptize \
+ eunit \
+ get-deps \
+ generate \
+ generate-appups \
+ generate-upgrade \
+ help \
+ list-deps \
+ list-templates \
+ qc \
+ update-deps \
+ version \
+ xref \
+ overlay \
+ apps= \
+ case= \
+ dump_spec=1 \
+ force=1 \
+ jobs= \
+ suites= \
+ verbose=1 \
+ appid= \
+ overlay_vars= \
+ previous_release= \
+ nodeid= \
+ root_dir= \
+ skip_deps=true \
+ skip_apps= \
+ target_dir= \
+ template= \
+ template_dir= \
+ tests="
+
+ if [[ ${cur} == --* ]] ; then
+ COMPREPLY=( $(compgen -W "${lopts}" -- ${cur}) )
+ elif [[ ${cur} == -* ]] ; then
+ COMPREPLY=( $(compgen -W "${sopts}" -- ${cur}) )
+ else
+ COMPREPLY=( $(compgen -W "${cmdsnvars}" -- ${cur}) )
+ fi
+
+ if [ -n "$COMPREPLY" ] ; then
+ # append space if matched
+ COMPREPLY="${COMPREPLY} "
+ # remove trailing space after equal sign
+ COMPREPLY=${COMPREPLY/%= /=}
+ fi
+ return 0
+}
+complete -o nospace -F _rebar rebar
+
+# Local variables:
+# mode: shell-script
+# sh-basic-offset: 4
+# sh-indent-comment: t
+# indent-tabs-mode: nil
+# End:
+# ex: ts=4 sw=4 et filetype=sh
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/shell-completion/zsh/_rebar
----------------------------------------------------------------------
diff --git a/src/rebar/priv/shell-completion/zsh/_rebar b/src/rebar/priv/shell-completion/zsh/_rebar
new file mode 100644
index 0000000..3d04ba1
--- /dev/null
+++ b/src/rebar/priv/shell-completion/zsh/_rebar
@@ -0,0 +1,83 @@
+#compdef rebar
+
+local curcontext=$curcontext state ret=1
+typeset -ga _rebar_global_opts
+
+_rebar_global_opts=(
+ '(--help -h)'{--help,-h}'[Show the program options]'
+ '(--commands -c)'{--commands,-c}'[Show available commands]'
+ '(--version -V)'{--version,-V}'[Show version information]'
+ '(-vvv -vv -v)'--verbose+'[Verbosity level. Default: 0]:verbosity level:(0 1 2 3)'
+ '(-vvv)-v[Slightly more verbose output]'
+ '(-vvv)-vv[More verbose output]'
+ '(-v -vv)-vvv[Most verbose output]'
+ '(--force -f)'{--force,-f}'[Force]'
+ '-D+[Define compiler macro]'
+ '(--jobs -j)'{--jobs+,-j+}'[Number of concurrent workers a command may use. Default: 3]:workers:(1 2 3 4 5 6 7 8 9)'
+ '(--config -C)'{--config,-C}'[Rebar config file to use]:files:_files'
+ '(--profile -p)'{--profile,-p}'[Profile this run of rebar]'
+ '(--keep-going -k)'{--keep-going,-k}'[Keep running after a command fails]'
+)
+
+_rebar () {
+ _arguments -C $_rebar_global_opts \
+ '*::command and variable:->cmd_and_var' \
+ && return
+
+ case $state in
+ cmd_and_var)
+ _values -S = 'variables' \
+ 'clean[Clean]' \
+ 'compile[Compile sources]' \
+ 'create[Create skel based on template and vars]' \
+ 'create-app[Create simple app skel]' \
+ 'create-node[Create simple node skel]' \
+ 'list-template[List avaiavle templates]' \
+ 'doc[Generate Erlang program documentation]' \
+ 'check-deps[Display to be fetched dependencies]' \
+ 'get-deps[Fetch dependencies]' \
+ 'update-deps[Update fetched dependencies]' \
+ 'delete-deps[Delete fetched dependencies]' \
+ 'list-deps[List dependencies]' \
+ 'generate[Build release with reltool]' \
+ 'overlay[Run reltool overlays only]' \
+ 'generate-appups[Generate appup files]' \
+ 'generate-upgrade[Build an upgrade package]' \
+ 'escriptize[Create stand-alone escript executable]' \
+ 'eunit[Run eunit tests]' \
+ 'ct[Run common_test suites]' \
+ 'qc[Test QuickCheck properties]' \
+ 'xref[Run cross reference analysis]' \
+ 'help[Show the program options]' \
+ 'version[Show version information]' \
+ 'apps[Application names to process]:' \
+ 'case[Common Test case]:' \
+ 'dump_spec[Dump reltool spec]::flag:(1)' \
+ 'jobs[Number of workers]::workers:(0 1 2 3 4 5 6 7 8 9)' \
+ 'suites[Common Test suites]::suite name:_path_files -W "(src test)" -g "*.erl(:r)"' \
+ 'verbose[Verbosity level]::verbosity level:(0 1 2 3)' \
+ 'appid[Application id]:' \
+ 'overlay_vars[Overlay variables file]:' \
+ 'previous_release[Previous release path]:' \
+ 'nodeid[Node id]:' \
+ 'root_dir[Reltool config root directory]::directory:_files -/' \
+ 'skip_deps[Skip deps]::flag:(true false)' \
+ 'skip_apps[Application names to not process]::flag:(true false)' \
+ 'target_dir[Target directory]:' \
+ 'template[Template name]:' \
+ 'template_dir[Template directory]::directory:_files -/' \
+ 'tests[Run eunit tests whose name starts with given string]:' \
+ && ret=0
+ ;;
+ esac
+}
+
+_rebar
+
+# Local variables:
+# mode: shell-script
+# sh-basic-offset: 2
+# sh-indent-comment: t
+# indent-tabs-mode: nil
+# End:
+# ex: sw=2 ts=2 et filetype=sh
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/basicnif.c
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/basicnif.c b/src/rebar/priv/templates/basicnif.c
new file mode 100644
index 0000000..a1aa9e9
--- /dev/null
+++ b/src/rebar/priv/templates/basicnif.c
@@ -0,0 +1,59 @@
+#include "erl_nif.h"
+
+static ErlNifResourceType* {{module}}_RESOURCE = NULL;
+
+typedef struct
+{
+} {{module}}_handle;
+
+// Prototypes
+static ERL_NIF_TERM {{module}}_new(ErlNifEnv* env, int argc,
+ const ERL_NIF_TERM argv[]);
+static ERL_NIF_TERM {{module}}_myfunction(ErlNifEnv* env, int argc,
+ const ERL_NIF_TERM argv[]);
+
+static ErlNifFunc nif_funcs[] =
+{
+ {"new", 0, {{module}}_new},
+ {"myfunction", 1, {{module}}_myfunction}
+};
+
+static ERL_NIF_TERM {{module}}_new(ErlNifEnv* env, int argc,
+ const ERL_NIF_TERM argv[])
+{
+ {{module}}_handle* handle = enif_alloc_resource({{module}}_RESOURCE,
+ sizeof({{module}}_handle));
+ ERL_NIF_TERM result = enif_make_resource(env, handle);
+ enif_release_resource(handle);
+ return enif_make_tuple2(env, enif_make_atom(env, "ok"), result);
+}
+
+
+static ERL_NIF_TERM {{module}}_myfunction(ErlNifEnv* env, int argc,
+ const ERL_NIF_TERM argv[])
+{
+ return enif_make_atom(env, "ok");
+}
+
+static void {{module}}_resource_cleanup(ErlNifEnv* env, void* arg)
+{
+ /* Delete any dynamically allocated memory stored in {{module}}_handle */
+ /* {{module}}_handle* handle = ({{module}}_handle*)arg; */
+}
+
+static int on_load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
+{
+ ErlNifResourceFlags flags = ERL_NIF_RT_CREATE | ERL_NIF_RT_TAKEOVER;
+ ErlNifResourceType* rt = enif_open_resource_type(env, NULL,
+ "{{module}}_resource",
+ &{{module}}_resource_cleanup,
+ flags, NULL);
+ if (rt == NULL)
+ return -1;
+
+ {{module}}_RESOURCE = rt;
+
+ return 0;
+}
+
+ERL_NIF_INIT({{module}}, nif_funcs, &on_load, NULL, NULL, NULL);
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/basicnif.erl
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/basicnif.erl b/src/rebar/priv/templates/basicnif.erl
new file mode 100644
index 0000000..e1f4143
--- /dev/null
+++ b/src/rebar/priv/templates/basicnif.erl
@@ -0,0 +1,42 @@
+-module({{module}}).
+
+-export([new/0,
+ myfunction/1]).
+
+-on_load(init/0).
+
+-define(nif_stub, nif_stub_error(?LINE)).
+nif_stub_error(Line) ->
+ erlang:nif_error({nif_not_loaded,module,?MODULE,line,Line}).
+
+-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
+-endif.
+
+init() ->
+ PrivDir = case code:priv_dir(?MODULE) of
+ {error, bad_name} ->
+ EbinDir = filename:dirname(code:which(?MODULE)),
+ AppPath = filename:dirname(EbinDir),
+ filename:join(AppPath, "priv");
+ Path ->
+ Path
+ end,
+ erlang:load_nif(filename:join(PrivDir, ?MODULE), 0).
+
+new() ->
+ ?nif_stub.
+
+myfunction(_Ref) ->
+ ?nif_stub.
+
+%% ===================================================================
+%% EUnit tests
+%% ===================================================================
+-ifdef(TEST).
+
+basic_test() ->
+ {ok, Ref} = new(),
+ ?assertEqual(ok, myfunction(Ref)).
+
+-endif.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/basicnif.template
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/basicnif.template b/src/rebar/priv/templates/basicnif.template
new file mode 100644
index 0000000..6dde8bb
--- /dev/null
+++ b/src/rebar/priv/templates/basicnif.template
@@ -0,0 +1,3 @@
+{variables, [{module, "mymodule"}]}.
+{template, "basicnif.erl", "src/{{module}}.erl"}.
+{template, "basicnif.c", "c_src/{{module}}.c"}.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/ctsuite.erl
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/ctsuite.erl b/src/rebar/priv/templates/ctsuite.erl
new file mode 100644
index 0000000..33a8fac
--- /dev/null
+++ b/src/rebar/priv/templates/ctsuite.erl
@@ -0,0 +1,167 @@
+%% common_test suite for {{testmod}}
+
+-module({{testmod}}_SUITE).
+-include_lib("common_test/include/ct.hrl").
+
+-compile(export_all).
+
+%%--------------------------------------------------------------------
+%% Function: suite() -> Info
+%%
+%% Info = [tuple()]
+%% List of key/value pairs.
+%%
+%% Description: Returns list of tuples to set default properties
+%% for the suite.
+%%
+%% Note: The suite/0 function is only meant to be used to return
+%% default data values, not perform any other operations.
+%%--------------------------------------------------------------------
+suite() -> [{timetrap, {seconds, 20}}].
+
+%%--------------------------------------------------------------------
+%% Function: groups() -> [Group]
+%%
+%% Group = {GroupName,Properties,GroupsAndTestCases}
+%% GroupName = atom()
+%% The name of the group.
+%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]
+%% Group properties that may be combined.
+%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]
+%% TestCase = atom()
+%% The name of a test case.
+%% Shuffle = shuffle | {shuffle,Seed}
+%% To get cases executed in random order.
+%% Seed = {integer(),integer(),integer()}
+%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |
+%% repeat_until_any_ok | repeat_until_any_fail
+%% To get execution of cases repeated.
+%% N = integer() | forever
+%%
+%% Description: Returns a list of test case group definitions.
+%%--------------------------------------------------------------------
+groups() -> [].
+
+%%--------------------------------------------------------------------
+%% Function: all() -> GroupsAndTestCases
+%%
+%% GroupsAndTestCases = [{group,GroupName} | TestCase]
+%% GroupName = atom()
+%% Name of a test case group.
+%% TestCase = atom()
+%% Name of a test case.
+%%
+%% Description: Returns the list of groups and test cases that
+%% are to be executed.
+%%
+%% NB: By default, we export all 1-arity user defined functions
+%%--------------------------------------------------------------------
+all() ->
+ [ {exports, Functions} | _ ] = ?MODULE:module_info(),
+ [ FName || {FName, _} <- lists:filter(
+ fun ({module_info,_}) -> false;
+ ({all,_}) -> false;
+ ({init_per_suite,1}) -> false;
+ ({end_per_suite,1}) -> false;
+ ({_,1}) -> true;
+ ({_,_}) -> false
+ end, Functions)].
+
+%%--------------------------------------------------------------------
+%% Function: init_per_suite(Config0) ->
+%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
+%%
+%% Config0 = Config1 = [tuple()]
+%% A list of key/value pairs, holding the test case configuration.
+%% Reason = term()
+%% The reason for skipping the suite.
+%%
+%% Description: Initialization before the suite.
+%%
+%% Note: This function is free to add any key/value pairs to the Config
+%% variable, but should NOT alter/remove any existing entries.
+%%--------------------------------------------------------------------
+init_per_suite(Config) ->
+ Config.
+
+%%--------------------------------------------------------------------
+%% Function: end_per_suite(Config0) -> void() | {save_config,Config1}
+%%
+%% Config0 = Config1 = [tuple()]
+%% A list of key/value pairs, holding the test case configuration.
+%%
+%% Description: Cleanup after the suite.
+%%--------------------------------------------------------------------
+end_per_suite(_Config) ->
+ ok.
+
+%%--------------------------------------------------------------------
+%% Function: init_per_group(GroupName, Config0) ->
+%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
+%%
+%% GroupName = atom()
+%% Name of the test case group that is about to run.
+%% Config0 = Config1 = [tuple()]
+%% A list of key/value pairs, holding configuration data for the group.
+%% Reason = term()
+%% The reason for skipping all test cases and subgroups in the group.
+%%
+%% Description: Initialization before each test case group.
+%%--------------------------------------------------------------------
+init_per_group(_group, Config) ->
+ Config.
+
+%%--------------------------------------------------------------------
+%% Function: end_per_group(GroupName, Config0) ->
+%% void() | {save_config,Config1}
+%%
+%% GroupName = atom()
+%% Name of the test case group that is finished.
+%% Config0 = Config1 = [tuple()]
+%% A list of key/value pairs, holding configuration data for the group.
+%%
+%% Description: Cleanup after each test case group.
+%%--------------------------------------------------------------------
+end_per_group(_group, Config) ->
+ Config.
+
+%%--------------------------------------------------------------------
+%% Function: init_per_testcase(TestCase, Config0) ->
+%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
+%%
+%% TestCase = atom()
+%% Name of the test case that is about to run.
+%% Config0 = Config1 = [tuple()]
+%% A list of key/value pairs, holding the test case configuration.
+%% Reason = term()
+%% The reason for skipping the test case.
+%%
+%% Description: Initialization before each test case.
+%%
+%% Note: This function is free to add any key/value pairs to the Config
+%% variable, but should NOT alter/remove any existing entries.
+%%--------------------------------------------------------------------
+init_per_testcase(TestCase, Config) ->
+ Config.
+
+%%--------------------------------------------------------------------
+%% Function: end_per_testcase(TestCase, Config0) ->
+%% void() | {save_config,Config1} | {fail,Reason}
+%%
+%% TestCase = atom()
+%% Name of the test case that is finished.
+%% Config0 = Config1 = [tuple()]
+%% A list of key/value pairs, holding the test case configuration.
+%% Reason = term()
+%% The reason for failing the test case.
+%%
+%% Description: Cleanup after each test case.
+%%--------------------------------------------------------------------
+end_per_testcase(TestCase, Config) ->
+ Config.
+
+test_{{testmod}}() ->
+ [{userdata,[{doc,"Testing the {{testmod}} module"}]}].
+
+test_{{testmod}}(_Config) ->
+ {skip,"Not implemented."}.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/ctsuite.template
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/ctsuite.template b/src/rebar/priv/templates/ctsuite.template
new file mode 100644
index 0000000..b7de337
--- /dev/null
+++ b/src/rebar/priv/templates/ctsuite.template
@@ -0,0 +1,2 @@
+{variables, [{testmod, "mymodule"}]}.
+{template, "ctsuite.erl", "test/{{testmod}}_SUITE.erl"}.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simpleapp.app.src
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simpleapp.app.src b/src/rebar/priv/templates/simpleapp.app.src
new file mode 100644
index 0000000..803e1ff
--- /dev/null
+++ b/src/rebar/priv/templates/simpleapp.app.src
@@ -0,0 +1,12 @@
+{application, {{appid}},
+ [
+ {description, ""},
+ {vsn, "1"},
+ {registered, []},
+ {applications, [
+ kernel,
+ stdlib
+ ]},
+ {mod, { {{appid}}_app, []}},
+ {env, []}
+ ]}.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simpleapp.template
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simpleapp.template b/src/rebar/priv/templates/simpleapp.template
new file mode 100644
index 0000000..2419a00
--- /dev/null
+++ b/src/rebar/priv/templates/simpleapp.template
@@ -0,0 +1,4 @@
+{variables, [{appid, "myapp"}]}.
+{template, "simpleapp.app.src", "src/{{appid}}.app.src"}.
+{template, "simpleapp_app.erl", "src/{{appid}}_app.erl"}.
+{template, "simpleapp_sup.erl", "src/{{appid}}_sup.erl"}.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simpleapp_app.erl
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simpleapp_app.erl b/src/rebar/priv/templates/simpleapp_app.erl
new file mode 100644
index 0000000..1af863b
--- /dev/null
+++ b/src/rebar/priv/templates/simpleapp_app.erl
@@ -0,0 +1,16 @@
+-module({{appid}}_app).
+
+-behaviour(application).
+
+%% Application callbacks
+-export([start/2, stop/1]).
+
+%% ===================================================================
+%% Application callbacks
+%% ===================================================================
+
+start(_StartType, _StartArgs) ->
+ {{appid}}_sup:start_link().
+
+stop(_State) ->
+ ok.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simpleapp_sup.erl
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simpleapp_sup.erl b/src/rebar/priv/templates/simpleapp_sup.erl
new file mode 100644
index 0000000..477479f
--- /dev/null
+++ b/src/rebar/priv/templates/simpleapp_sup.erl
@@ -0,0 +1,27 @@
+-module({{appid}}_sup).
+
+-behaviour(supervisor).
+
+%% API
+-export([start_link/0]).
+
+%% Supervisor callbacks
+-export([init/1]).
+
+%% Helper macro for declaring children of supervisor
+-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
+
+%% ===================================================================
+%% API functions
+%% ===================================================================
+
+start_link() ->
+ supervisor:start_link({local, ?MODULE}, ?MODULE, []).
+
+%% ===================================================================
+%% Supervisor callbacks
+%% ===================================================================
+
+init([]) ->
+ {ok, { {one_for_one, 5, 10}, []} }.
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simplefsm.erl
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simplefsm.erl b/src/rebar/priv/templates/simplefsm.erl
new file mode 100644
index 0000000..776081e
--- /dev/null
+++ b/src/rebar/priv/templates/simplefsm.erl
@@ -0,0 +1,57 @@
+-module({{fsmid}}).
+-behaviour(gen_fsm).
+-define(SERVER, ?MODULE).
+
+%% ------------------------------------------------------------------
+%% API Function Exports
+%% ------------------------------------------------------------------
+
+-export([start_link/0]).
+
+%% ------------------------------------------------------------------
+%% gen_fsm Function Exports
+%% ------------------------------------------------------------------
+
+-export([init/1, state_name/2, state_name/3, handle_event/3,
+ handle_sync_event/4, handle_info/3, terminate/3,
+ code_change/4]).
+
+%% ------------------------------------------------------------------
+%% API Function Definitions
+%% ------------------------------------------------------------------
+
+start_link() ->
+ gen_fsm:start_link({local, ?SERVER}, ?MODULE, [], []).
+
+%% ------------------------------------------------------------------
+%% gen_fsm Function Definitions
+%% ------------------------------------------------------------------
+
+init(_Args) ->
+ {ok, initial_state_name, initial_state}.
+
+state_name(_Event, State) ->
+ {next_state, state_name, State}.
+
+state_name(_Event, _From, State) ->
+ {reply, ok, state_name, State}.
+
+handle_event(_Event, StateName, State) ->
+ {next_state, StateName, State}.
+
+handle_sync_event(_Event, _From, StateName, State) ->
+ {reply, ok, StateName, State}.
+
+handle_info(_Info, StateName, State) ->
+ {next_state, StateName, State}.
+
+terminate(_Reason, _StateName, _State) ->
+ ok.
+
+code_change(_OldVsn, StateName, State, _Extra) ->
+ {ok, StateName, State}.
+
+%% ------------------------------------------------------------------
+%% Internal Function Definitions
+%% ------------------------------------------------------------------
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simplefsm.template
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simplefsm.template b/src/rebar/priv/templates/simplefsm.template
new file mode 100644
index 0000000..179c739
--- /dev/null
+++ b/src/rebar/priv/templates/simplefsm.template
@@ -0,0 +1,2 @@
+{variables, [{fsmid, "myfsm"}]}.
+{template, "simplefsm.erl", "src/{{fsmid}}.erl"}.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simplemod.erl
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simplemod.erl b/src/rebar/priv/templates/simplemod.erl
new file mode 100644
index 0000000..46597ae
--- /dev/null
+++ b/src/rebar/priv/templates/simplemod.erl
@@ -0,0 +1,6 @@
+-module({{modid}}).
+
+-export([my_func/0]).
+
+my_func() ->
+ ok.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simplemod.template
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simplemod.template b/src/rebar/priv/templates/simplemod.template
new file mode 100644
index 0000000..04d61f3
--- /dev/null
+++ b/src/rebar/priv/templates/simplemod.template
@@ -0,0 +1,3 @@
+{variables, [{modid, "mymod"}]}.
+{template, "simplemod.erl", "src/{{modid}}.erl"}.
+{template, "simplemod_tests.erl", "test/{{modid}}_tests.erl"}.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simplemod_tests.erl
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simplemod_tests.erl b/src/rebar/priv/templates/simplemod_tests.erl
new file mode 100644
index 0000000..c5ca0bb
--- /dev/null
+++ b/src/rebar/priv/templates/simplemod_tests.erl
@@ -0,0 +1,3 @@
+-module({{modid}}_tests).
+-include_lib("eunit/include/eunit.hrl").
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simplenode.erl.script
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simplenode.erl.script b/src/rebar/priv/templates/simplenode.erl.script
new file mode 100644
index 0000000..f4c63af
--- /dev/null
+++ b/src/rebar/priv/templates/simplenode.erl.script
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# /bin/sh on Solaris is not a POSIX compatible shell, but /usr/bin/ksh is.
+if [ `uname -s` = 'SunOS' -a "${POSIX_SHELL}" != "true" ]; then
+ POSIX_SHELL="true"
+ export POSIX_SHELL
+ exec /usr/bin/ksh $0 "$@"
+fi
+
+# clear it so if we invoke other scripts, they run as ksh as well
+unset POSIX_SHELL
+
+## This script replaces the default "erl" in erts-VSN/bin. This is
+## necessary as escript depends on erl and in turn, erl depends on
+## having access to a bootscript (start.boot). Note that this script
+## is ONLY invoked as a side-effect of running escript -- the embedded
+## node bypasses erl and uses erlexec directly (as it should).
+##
+## Note that this script makes the assumption that there is a
+## start_clean.boot file available in $ROOTDIR/release/VSN.
+
+# Determine the abspath of where this script is executing from.
+ERTS_BIN_DIR=$(cd ${0%/*} && pwd -P)
+
+# Now determine the root directory -- this script runs from erts-VSN/bin,
+# so we simply need to strip off two dirs from the end of the ERTS_BIN_DIR
+# path.
+ROOTDIR=${ERTS_BIN_DIR%/*/*}
+
+# Parse out release and erts info
+START_ERL=`cat $ROOTDIR/releases/start_erl.data`
+ERTS_VSN=${START_ERL% *}
+APP_VSN=${START_ERL#* }
+
+BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
+EMU=beam
+PROGNAME=`echo $0 | sed 's/.*\\///'`
+CMD="$BINDIR/erlexec"
+export EMU
+export ROOTDIR
+export BINDIR
+export PROGNAME
+
+exec $CMD -boot $ROOTDIR/releases/$APP_VSN/start_clean ${1+"$@"}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simplenode.install_upgrade.escript
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simplenode.install_upgrade.escript b/src/rebar/priv/templates/simplenode.install_upgrade.escript
new file mode 100644
index 0000000..56cea19
--- /dev/null
+++ b/src/rebar/priv/templates/simplenode.install_upgrade.escript
@@ -0,0 +1,44 @@
+#!/usr/bin/env escript
+%%! -noshell -noinput
+%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ft=erlang ts=4 sw=4 et
+
+-define(TIMEOUT, 60000).
+-define(INFO(Fmt,Args), io:format(Fmt,Args)).
+
+main([NodeName, Cookie, ReleasePackage]) ->
+ TargetNode = start_distribution(NodeName, Cookie),
+ {ok, Vsn} = rpc:call(TargetNode, release_handler, unpack_release,
+ [ReleasePackage], ?TIMEOUT),
+ ?INFO("Unpacked Release ~p~n", [Vsn]),
+ {ok, OtherVsn, Desc} = rpc:call(TargetNode, release_handler,
+ check_install_release, [Vsn], ?TIMEOUT),
+ {ok, OtherVsn, Desc} = rpc:call(TargetNode, release_handler,
+ install_release, [Vsn], ?TIMEOUT),
+ ?INFO("Installed Release ~p~n", [Vsn]),
+ ok = rpc:call(TargetNode, release_handler, make_permanent, [Vsn], ?TIMEOUT),
+ ?INFO("Made Release ~p Permanent~n", [Vsn]);
+main(_) ->
+ init:stop(1).
+
+start_distribution(NodeName, Cookie) ->
+ MyNode = make_script_node(NodeName),
+ {ok, _Pid} = net_kernel:start([MyNode, shortnames]),
+ erlang:set_cookie(node(), list_to_atom(Cookie)),
+ TargetNode = make_target_node(NodeName),
+ case {net_kernel:hidden_connect_node(TargetNode),
+ net_adm:ping(TargetNode)} of
+ {true, pong} ->
+ ok;
+ {_, pang} ->
+ io:format("Node ~p not responding to pings.\n", [TargetNode]),
+ init:stop(1)
+ end,
+ TargetNode.
+
+make_target_node(Node) ->
+ [_, Host] = string:tokens(atom_to_list(node()), "@"),
+ list_to_atom(lists:concat([Node, "@", Host])).
+
+make_script_node(Node) ->
+ list_to_atom(lists:concat([Node, "_upgrader_", os:getpid()])).
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simplenode.nodetool
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simplenode.nodetool b/src/rebar/priv/templates/simplenode.nodetool
new file mode 100755
index 0000000..ce06c6a
--- /dev/null
+++ b/src/rebar/priv/templates/simplenode.nodetool
@@ -0,0 +1,182 @@
+#!/usr/bin/env escript
+%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ft=erlang ts=4 sw=4 et
+%% -------------------------------------------------------------------
+%%
+%% nodetool: Helper Script for interacting with live nodes
+%%
+%% -------------------------------------------------------------------
+main(Args) ->
+ ok = start_epmd(),
+ %% Extract the args
+ {RestArgs, TargetNode} = process_args(Args, [], undefined),
+
+ %% any commands that don't need a running node
+ case RestArgs of
+ ["chkconfig", File] ->
+ case file:consult(File) of
+ {ok, _} ->
+ io:format("ok\n"),
+ halt(0);
+ {error, {Line, Mod, Term}} ->
+ io:format(standard_error, ["Error on line ",
+ file:format_error({Line, Mod, Term}), "\n"], []),
+ halt(1);
+ {error, R} ->
+ io:format(standard_error, ["Error reading config file: ",
+ file:format_error(R), "\n"], []),
+ halt(1)
+ end;
+ _ ->
+ ok
+ end,
+
+ %% See if the node is currently running -- if it's not, we'll bail
+ case {net_kernel:hidden_connect_node(TargetNode),
+ net_adm:ping(TargetNode)} of
+ {true, pong} ->
+ ok;
+ {false,pong} ->
+ io:format("Failed to connect to node ~p .\n", [TargetNode]),
+ halt(1);
+ {_, pang} ->
+ io:format("Node ~p not responding to pings.\n", [TargetNode]),
+ halt(1)
+ end,
+
+ case RestArgs of
+ ["getpid"] ->
+ io:format("~p\n",
+ [list_to_integer(rpc:call(TargetNode, os, getpid, []))]);
+ ["ping"] ->
+ %% If we got this far, the node already responsed to a
+ %% ping, so just dump a "pong"
+ io:format("pong\n");
+ ["stop"] ->
+ io:format("~p\n", [rpc:call(TargetNode, init, stop, [], 60000)]);
+ ["restart"] ->
+ io:format("~p\n", [rpc:call(TargetNode, init, restart, [], 60000)]);
+ ["reboot"] ->
+ io:format("~p\n", [rpc:call(TargetNode, init, reboot, [], 60000)]);
+ ["rpc", Module, Function | RpcArgs] ->
+ case rpc:call(TargetNode,
+ list_to_atom(Module),
+ list_to_atom(Function),
+ [RpcArgs], 60000) of
+ ok ->
+ ok;
+ {badrpc, Reason} ->
+ io:format("RPC to ~p failed: ~p\n", [TargetNode, Reason]),
+ halt(1);
+ _ ->
+ halt(1)
+ end;
+ ["rpc_infinity", Module, Function | RpcArgs] ->
+ case rpc:call(TargetNode,
+ list_to_atom(Module),
+ list_to_atom(Function),
+ [RpcArgs], infinity) of
+ ok ->
+ ok;
+ {badrpc, Reason} ->
+ io:format("RPC to ~p failed: ~p\n", [TargetNode, Reason]),
+ halt(1);
+ _ ->
+ halt(1)
+ end;
+ ["rpcterms", Module, Function, ArgsAsString] ->
+ case rpc:call(TargetNode,
+ list_to_atom(Module),
+ list_to_atom(Function),
+ consult(ArgsAsString), 60000) of
+ {badrpc, Reason} ->
+ io:format("RPC to ~p failed: ~p\n", [TargetNode, Reason]),
+ halt(1);
+ Other ->
+ io:format("~p\n", [Other])
+ end;
+ Other ->
+ io:format("Other: ~p\n", [Other]),
+ io:format("Usage: nodetool {chkconfig|getpid|ping|stop|restart|reboot|rpc|rpc_infinity|rpcterms}\n")
+ end,
+ net_kernel:stop().
+
+process_args([], Acc, TargetNode) ->
+ {lists:reverse(Acc), TargetNode};
+process_args(["-setcookie", Cookie | Rest], Acc, TargetNode) ->
+ erlang:set_cookie(node(), list_to_atom(Cookie)),
+ process_args(Rest, Acc, TargetNode);
+process_args(["-name", TargetName | Rest], Acc, _) ->
+ ThisNode = append_node_suffix(TargetName, "_maint_"),
+ {ok, _} = net_kernel:start([ThisNode, longnames]),
+ process_args(Rest, Acc, nodename(TargetName));
+process_args(["-sname", TargetName | Rest], Acc, _) ->
+ ThisNode = append_node_suffix(TargetName, "_maint_"),
+ {ok, _} = net_kernel:start([ThisNode, shortnames]),
+ process_args(Rest, Acc, nodename(TargetName));
+process_args([Arg | Rest], Acc, Opts) ->
+ process_args(Rest, [Arg | Acc], Opts).
+
+
+start_epmd() ->
+ [] = os:cmd(epmd_path() ++ " -daemon"),
+ ok.
+
+epmd_path() ->
+ ErtsBinDir = filename:dirname(escript:script_name()),
+ Name = "epmd",
+ case os:find_executable(Name, ErtsBinDir) of
+ false ->
+ case os:find_executable(Name) of
+ false ->
+ io:format("Could not find epmd.~n"),
+ halt(1);
+ GlobalEpmd ->
+ GlobalEpmd
+ end;
+ Epmd ->
+ Epmd
+ end.
+
+
+nodename(Name) ->
+ case string:tokens(Name, "@") of
+ [_Node, _Host] ->
+ list_to_atom(Name);
+ [Node] ->
+ [_, Host] = string:tokens(atom_to_list(node()), "@"),
+ list_to_atom(lists:concat([Node, "@", Host]))
+ end.
+
+append_node_suffix(Name, Suffix) ->
+ case string:tokens(Name, "@") of
+ [Node, Host] ->
+ list_to_atom(lists:concat([Node, Suffix, os:getpid(), "@", Host]));
+ [Node] ->
+ list_to_atom(lists:concat([Node, Suffix, os:getpid()]))
+ end.
+
+
+%%
+%% Given a string or binary, parse it into a list of terms, ala file:consult/0
+%%
+consult(Str) when is_list(Str) ->
+ consult([], Str, []);
+consult(Bin) when is_binary(Bin)->
+ consult([], binary_to_list(Bin), []).
+
+consult(Cont, Str, Acc) ->
+ case erl_scan:tokens(Cont, Str, 0) of
+ {done, Result, Remaining} ->
+ case Result of
+ {ok, Tokens, _} ->
+ {ok, Term} = erl_parse:parse_term(Tokens),
+ consult([], Remaining, [Term | Acc]);
+ {eof, _Other} ->
+ lists:reverse(Acc);
+ {error, Info, _} ->
+ {error, Info}
+ end;
+ {more, Cont1} ->
+ consult(Cont1, eof, Acc)
+ end.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simplenode.reltool.config
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simplenode.reltool.config b/src/rebar/priv/templates/simplenode.reltool.config
new file mode 100644
index 0000000..bac7270
--- /dev/null
+++ b/src/rebar/priv/templates/simplenode.reltool.config
@@ -0,0 +1,44 @@
+%% -*- mode: erlang -*-
+%% ex: ft=erlang
+{sys, [
+ {lib_dirs, []},
+ {erts, [{mod_cond, derived}, {app_file, strip}]},
+ {app_file, strip},
+ {rel, "{{nodeid}}", "1",
+ [
+ kernel,
+ stdlib,
+ sasl,
+ {{nodeid}}
+ ]},
+ {rel, "start_clean", "",
+ [
+ kernel,
+ stdlib
+ ]},
+ {boot_rel, "{{nodeid}}"},
+ {profile, embedded},
+ {incl_cond, derived},
+ {excl_archive_filters, [".*"]}, %% Do not archive built libs
+ {excl_sys_filters, ["^bin/(?!start_clean.boot)",
+ "^erts.*/bin/(dialyzer|typer)",
+ "^erts.*/(doc|info|include|lib|man|src)"]},
+ {excl_app_filters, ["\.gitignore"]},
+ {app, {{nodeid}}, [{mod_cond, app}, {incl_cond, include}]}
+ ]}.
+
+{target_dir, "{{nodeid}}"}.
+
+{overlay, [
+ {mkdir, "log/sasl"},
+ {copy, "files/erl", "\{\{erts_vsn\}\}/bin/erl"},
+ {copy, "files/nodetool", "\{\{erts_vsn\}\}/bin/nodetool"},
+ {copy, "{{nodeid}}/bin/start_clean.boot",
+ "\{\{erts_vsn\}\}/bin/start_clean.boot"},
+ {copy, "files/{{nodeid}}", "bin/{{nodeid}}"},
+ {copy, "files/{{nodeid}}.cmd", "bin/{{nodeid}}.cmd"},
+ {copy, "files/start_erl.cmd", "bin/start_erl.cmd"},
+ {copy, "files/install_upgrade.escript", "bin/install_upgrade.escript"},
+ {copy, "files/sys.config", "releases/\{\{rel_vsn\}\}/sys.config"},
+ {copy, "files/vm.args", "releases/\{\{rel_vsn\}\}/vm.args"}
+ ]}.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simplenode.runner
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simplenode.runner b/src/rebar/priv/templates/simplenode.runner
new file mode 100755
index 0000000..2786e72
--- /dev/null
+++ b/src/rebar/priv/templates/simplenode.runner
@@ -0,0 +1,348 @@
+#!/bin/sh
+# -*- tab-width:4;indent-tabs-mode:nil -*-
+# ex: ts=4 sw=4 et
+
+# /bin/sh on Solaris is not a POSIX compatible shell, but /usr/bin/ksh is.
+if [ `uname -s` = 'SunOS' -a "${POSIX_SHELL}" != "true" ]; then
+ POSIX_SHELL="true"
+ export POSIX_SHELL
+ # To support 'whoami' add /usr/ucb to path
+ PATH=/usr/ucb:$PATH
+ export PATH
+ exec /usr/bin/ksh $0 "$@"
+fi
+
+# clear it so if we invoke other scripts, they run as ksh
+unset POSIX_SHELL
+
+RUNNER_SCRIPT_DIR=$(cd ${0%/*} && pwd -P)
+RUNNER_SCRIPT=${0##*/}
+
+CALLER_DIR=$PWD
+
+RUNNER_BASE_DIR=${RUNNER_SCRIPT_DIR%/*}
+RUNNER_ETC_DIR=$RUNNER_BASE_DIR/etc
+# Note the trailing slash on $PIPE_DIR/
+PIPE_DIR=/tmp/$RUNNER_BASE_DIR/
+RUNNER_USER=
+WHOAMI=$(whoami)
+
+# Make sure this script is running as the appropriate user
+if ([ "$RUNNER_USER" ] && [ "x$WHOAMI" != "x$RUNNER_USER" ]); then
+ type sudo > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ echo "sudo doesn't appear to be installed and your EUID isn't $RUNNER_USER" 1>&2
+ exit 1
+ fi
+ echo "Attempting to restart script through sudo -H -u $RUNNER_USER" >&2
+ exec sudo -H -u $RUNNER_USER -i $RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT $@
+fi
+
+# Identify the script name
+SCRIPT=`basename $0`
+
+# Parse out release and erts info
+START_ERL=`cat $RUNNER_BASE_DIR/releases/start_erl.data`
+ERTS_VSN=${START_ERL% *}
+APP_VSN=${START_ERL#* }
+
+# Use $CWD/vm.args if exists, otherwise releases/APP_VSN/vm.args, or
+# else etc/vm.args
+if [ -e "$CALLER_DIR/vm.args" ]; then
+ VMARGS_PATH=$CALLER_DIR/vm.args
+ USE_DIR=$CALLER_DIR
+else
+ USE_DIR=$RUNNER_BASE_DIR
+ if [ -e "$RUNNER_BASE_DIR/releases/$APP_VSN/vm.args" ]; then
+ VMARGS_PATH="$RUNNER_BASE_DIR/releases/$APP_VSN/vm.args"
+ else
+ VMARGS_PATH="$RUNNER_ETC_DIR/vm.args"
+ fi
+fi
+
+RUNNER_LOG_DIR=$USE_DIR/log
+# Make sure log directory exists
+mkdir -p $RUNNER_LOG_DIR
+
+# Use releases/VSN/sys.config if it exists otherwise use etc/app.config
+if [ -e "$USE_DIR/sys.config" ]; then
+ CONFIG_PATH="$USE_DIR/sys.config"
+else
+ if [ -e "$RUNNER_BASE_DIR/releases/$APP_VSN/sys.config" ]; then
+ CONFIG_PATH="$RUNNER_BASE_DIR/releases/$APP_VSN/sys.config"
+ else
+ CONFIG_PATH="$RUNNER_ETC_DIR/app.config"
+ fi
+fi
+
+# Extract the target node name from node.args
+NAME_ARG=`egrep '^\-s?name' $VMARGS_PATH`
+if [ -z "$NAME_ARG" ]; then
+ echo "vm.args needs to have either -name or -sname parameter."
+ exit 1
+fi
+
+# Extract the name type and name from the NAME_ARG for REMSH
+REMSH_TYPE=`echo $NAME_ARG | awk '{print $1}'`
+REMSH_NAME=`echo $NAME_ARG | awk '{print $2}'`
+
+# Note the `date +%s`, used to allow multiple remsh to the same node
+# transparently
+REMSH_NAME_ARG="$REMSH_TYPE remsh`date +%s`@`echo $REMSH_NAME | awk -F@ '{print $2}'`"
+REMSH_REMSH_ARG="-remsh $REMSH_NAME"
+
+# Extract the target cookie
+COOKIE_ARG=`grep '^\-setcookie' $VMARGS_PATH`
+if [ -z "$COOKIE_ARG" ]; then
+ echo "vm.args needs to have a -setcookie parameter."
+ exit 1
+fi
+
+# Make sure CWD is set to the right dir
+cd $USE_DIR
+
+# Make sure log directory exists
+mkdir -p $USE_DIR/log
+
+# Add ERTS bin dir to our path
+ERTS_PATH=$RUNNER_BASE_DIR/erts-$ERTS_VSN/bin
+
+# Setup command to control the node
+NODETOOL="$ERTS_PATH/escript $ERTS_PATH/nodetool $NAME_ARG $COOKIE_ARG"
+
+# Setup remote shell command to control node
+REMSH="$ERTS_PATH/erl $REMSH_NAME_ARG $REMSH_REMSH_ARG $COOKIE_ARG"
+
+# Common functions
+
+# Ping node without allowing nodetool to take stdin
+ping_node() {
+ $NODETOOL ping < /dev/null
+}
+
+# Set the PID global variable, return 1 on error
+get_pid() {
+ PID=`$NODETOOL getpid < /dev/null`
+ ES=$?
+ if [ "$ES" -ne 0 ]; then
+ echo "Node is not running!"
+ return 1
+ fi
+
+ # don't allow empty or init pid's
+ if [ -z $PID ] || [ "$PID" -le 1 ]; then
+ return 1
+ fi
+
+ return 0
+}
+
+# Check the first argument for instructions
+case "$1" in
+ start|start_boot)
+ # Make sure there is not already a node running
+ RES=`ping_node`
+ if [ "$RES" = "pong" ]; then
+ echo "Node is already running!"
+ exit 1
+ fi
+ case "$1" in
+ start)
+ shift
+ START_OPTION="console"
+ HEART_OPTION="start"
+ ;;
+ start_boot)
+ shift
+ START_OPTION="console_boot"
+ HEART_OPTION="start_boot"
+ ;;
+ esac
+ RUN_PARAM=$(printf "\'%s\' " "$@")
+ HEART_COMMAND="$RUNNER_BASE_DIR/bin/$SCRIPT $HEART_OPTION $RUN_PARAM"
+ export HEART_COMMAND
+ mkdir -p $PIPE_DIR
+ $ERTS_PATH/run_erl -daemon $PIPE_DIR $RUNNER_LOG_DIR "exec $RUNNER_BASE_DIR/bin/$SCRIPT $START_OPTION $RUN_PARAM" 2>&1
+ ;;
+
+ stop)
+ # Wait for the node to completely stop...
+ case `uname -s` in
+ Darwin)
+ # Make sure we explicitly set this because iTerm.app doesn't for
+ # some reason.
+ COMMAND_MODE=unix2003
+ esac
+
+ # Get the PID from nodetool
+ get_pid
+ GPR=$?
+ if [ "$GPR" -ne 0 ] || [ -z $PID ]; then
+ exit $GPR
+ fi
+
+ # Tell nodetool to initiate a stop
+ $NODETOOL stop
+ ES=$?
+ if [ "$ES" -ne 0 ]; then
+ exit $ES
+ fi
+
+ # Wait for the node to completely stop...
+ while `kill -s 0 $PID 2>/dev/null`
+ do
+ sleep 1
+ done
+ ;;
+
+ restart)
+ ## Restart the VM without exiting the process
+ $NODETOOL restart
+ ES=$?
+ if [ "$ES" -ne 0 ]; then
+ exit $ES
+ fi
+ ;;
+
+ reboot)
+ ## Restart the VM completely (uses heart to restart it)
+ $NODETOOL reboot
+ ES=$?
+ if [ "$ES" -ne 0 ]; then
+ exit $ES
+ fi
+ ;;
+
+ ping)
+ ## See if the VM is alive
+ ping_node
+ ES=$?
+ if [ "$ES" -ne 0 ]; then
+ exit $ES
+ fi
+ ;;
+
+ attach)
+ # Make sure a node is running
+ ping_node
+ ES=$?
+ if [ "$ES" -ne 0 ]; then
+ echo "Node is not running!"
+ exit $ES
+ fi
+
+ shift
+ exec $ERTS_PATH/to_erl $PIPE_DIR
+ ;;
+
+ remote_console)
+ # Make sure a node is running
+ ping_node
+ ES=$?
+ if [ "$ES" -ne 0 ]; then
+ echo "Node is not running!"
+ exit $ES
+ fi
+
+ shift
+ exec $REMSH
+ ;;
+
+ upgrade)
+ if [ -z "$2" ]; then
+ echo "Missing upgrade package argument"
+ echo "Usage: $SCRIPT upgrade {package base name}"
+ echo "NOTE {package base name} MUST NOT include the .tar.gz suffix"
+ exit 1
+ fi
+
+ # Make sure a node IS running
+ ping_node
+ ES=$?
+ if [ "$ES" -ne 0 ]; then
+ echo "Node is not running!"
+ exit $ES
+ fi
+
+ node_name=`echo $NAME_ARG | awk '{print $2}'`
+ erlang_cookie=`echo $COOKIE_ARG | awk '{print $2}'`
+
+ $ERTS_PATH/escript $RUNNER_BASE_DIR/bin/install_upgrade.escript $node_name $erlang_cookie $2
+ ;;
+
+ console|console_clean|console_boot)
+ # .boot file typically just $SCRIPT (ie, the app name)
+ # however, for debugging, sometimes start_clean.boot is useful.
+ # For e.g. 'setup', one may even want to name another boot script.
+ case "$1" in
+ console) BOOTFILE=$SCRIPT ;;
+ console_clean) BOOTFILE=start_clean ;;
+ console_boot)
+ shift
+ BOOTFILE="$1"
+ shift
+ ;;
+ esac
+ # Setup beam-required vars
+ ROOTDIR=$RUNNER_BASE_DIR
+ BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
+ EMU=beam
+ PROGNAME=`echo $0 | sed 's/.*\\///'`
+ CMD="$BINDIR/erlexec -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$BOOTFILE -mode embedded -config $CONFIG_PATH -args_file $VMARGS_PATH"
+ export EMU
+ export ROOTDIR
+ export BINDIR
+ export PROGNAME
+
+ # Dump environment info for logging purposes
+ echo "Exec: $CMD" -- ${1+"$@"}
+ echo "Root: $ROOTDIR"
+
+ # Log the startup
+ logger -t "$SCRIPT[$$]" "Starting up"
+
+ # Start the VM
+ exec $CMD -- ${1+"$@"}
+ ;;
+
+ foreground)
+ # start up the release in the foreground for use by runit
+ # or other supervision services
+
+ BOOTFILE=$SCRIPT
+ FOREGROUNDOPTIONS="-noinput +Bd"
+
+ # Setup beam-required vars
+ ROOTDIR=$RUNNER_BASE_DIR
+ BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
+ EMU=beam
+ PROGNAME=`echo $0 | sed 's/.*\///'`
+ CMD="$BINDIR/erlexec $FOREGROUNDOPTIONS -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$BOOTFILE -config $CONFIG_PATH -args_file $VMARGS_PATH"
+ export EMU
+ export ROOTDIR
+ export BINDIR
+ export PROGNAME
+
+ # Dump environment info for logging purposes
+ echo "Exec: $CMD" -- ${1+"$@"}
+ echo "Root: $ROOTDIR"
+
+ # Start the VM
+ exec $CMD -- ${1+"$@"}
+ ;;
+ getpid)
+ # Get the PID from nodetool
+ get_pid
+ ES=$?
+ if [ "$ES" -ne 0 ] || [ -z $PID ]; then
+ exit $ES
+ fi
+ echo $PID
+ ;;
+ *)
+ echo "Usage: $SCRIPT {start|start_boot <file>|foreground|stop|restart|reboot|ping|console|getpid|console_clean|console_boot <file>|attach|remote_console|upgrade}"
+ exit 1
+ ;;
+esac
+
+exit 0
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simplenode.sys.config
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simplenode.sys.config b/src/rebar/priv/templates/simplenode.sys.config
new file mode 100644
index 0000000..3b7f6bd
--- /dev/null
+++ b/src/rebar/priv/templates/simplenode.sys.config
@@ -0,0 +1,11 @@
+[
+ %% SASL config
+ {sasl, [
+ {sasl_error_logger, {file, "log/sasl-error.log"}},
+ {errlog_type, error},
+ {error_logger_mf_dir, "log/sasl"}, % Log directory
+ {error_logger_mf_maxbytes, 10485760}, % 10 MB max file size
+ {error_logger_mf_maxfiles, 5} % 5 files max
+ ]}
+].
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simplenode.template
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simplenode.template b/src/rebar/priv/templates/simplenode.template
new file mode 100644
index 0000000..5d2c49d
--- /dev/null
+++ b/src/rebar/priv/templates/simplenode.template
@@ -0,0 +1,13 @@
+{variables, [{nodeid, "mynode"}]}.
+{template, "simplenode.reltool.config", "reltool.config"}.
+{file, "simplenode.erl.script", "files/erl"}.
+{chmod, 8#744, "files/erl"}.
+{file, "simplenode.nodetool", "files/nodetool"}.
+{chmod, 8#744, "files/nodetool"}.
+{file, "simplenode.runner", "files/{{nodeid}}"}.
+{chmod, 8#744, "files/{{nodeid}}"}.
+{file, "simplenode.sys.config", "files/sys.config"}.
+{template, "simplenode.vm.args", "files/vm.args"}.
+{template, "simplenode.windows.runner.cmd", "files/{{nodeid}}.cmd"}.
+{file, "simplenode.windows.start_erl.cmd", "files/start_erl.cmd"}.
+{file, "simplenode.install_upgrade.escript", "files/install_upgrade.escript"}.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simplenode.vm.args
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simplenode.vm.args b/src/rebar/priv/templates/simplenode.vm.args
new file mode 100644
index 0000000..700b15e
--- /dev/null
+++ b/src/rebar/priv/templates/simplenode.vm.args
@@ -0,0 +1,19 @@
+## Name of the node
+-name {{nodeid}}@127.0.0.1
+
+## Cookie for distributed erlang
+-setcookie {{nodeid}}
+
+## Heartbeat management; auto-restarts VM if it dies or becomes unresponsive
+## (Disabled by default..use with caution!)
+##-heart
+
+## Enable kernel poll and a few async threads
+##+K true
+##+A 5
+
+## Increase number of concurrent ports/sockets
+##-env ERL_MAX_PORTS 4096
+
+## Tweak GC to run more often
+##-env ERL_FULLSWEEP_AFTER 10
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simplenode.windows.runner.cmd
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simplenode.windows.runner.cmd b/src/rebar/priv/templates/simplenode.windows.runner.cmd
new file mode 100644
index 0000000..d45f438
--- /dev/null
+++ b/src/rebar/priv/templates/simplenode.windows.runner.cmd
@@ -0,0 +1,103 @@
+@setlocal
+
+@set node_name={{nodeid}}
+
+@rem Get the absolute path to the parent directory,
+@rem which is assumed to be the node root.
+@for /F "delims=" %%I in ("%~dp0..") do @set node_root=%%~fI
+
+@set releases_dir=%node_root%\releases
+
+@rem Parse ERTS version and release version from start_erl.data
+@for /F "usebackq tokens=1,2" %%I in ("%releases_dir%\start_erl.data") do @(
+ @call :set_trim erts_version %%I
+ @call :set_trim release_version %%J
+)
+
+@set vm_args=%releases_dir%\%release_version%\vm.args
+@set sys_config=%releases_dir%\%release_version%\sys.config
+@set node_boot_script=%releases_dir%\%release_version%\%node_name%
+@set clean_boot_script=%releases_dir%\%release_version%\start_clean
+
+@rem extract erlang cookie from vm.args
+@for /f "usebackq tokens=1-2" %%I in (`findstr /b \-setcookie "%vm_args%"`) do @set erlang_cookie=%%J
+
+@set erts_bin=%node_root%\erts-%erts_version%\bin
+
+@set service_name=%node_name%_%release_version%
+
+@set erlsrv="%erts_bin%\erlsrv.exe"
+@set epmd="%erts_bin%\epmd.exe"
+@set escript="%erts_bin%\escript.exe"
+@set werl="%erts_bin%\werl.exe"
+@set nodetool="%erts_bin%\nodetool"
+
+@if "%1"=="usage" @goto usage
+@if "%1"=="install" @goto install
+@if "%1"=="uninstall" @goto uninstall
+@if "%1"=="start" @goto start
+@if "%1"=="stop" @goto stop
+@if "%1"=="restart" @call :stop && @goto start
+@if "%1"=="console" @goto console
+@if "%1"=="ping" @goto ping
+@if "%1"=="query" @goto query
+@if "%1"=="attach" @goto attach
+@if "%1"=="upgrade" @goto upgrade
+@echo Unknown command: "%1"
+
+:usage
+@echo Usage: %~n0 [install^|uninstall^|start^|stop^|restart^|console^|ping^|query^|attach^|upgrade]
+@goto :EOF
+
+:install
+@set description=Erlang node %node_name% in %node_root%
+@set start_erl=%node_root%\bin\start_erl.cmd
+@set args= ++ %node_name% ++ %node_root%
+@%erlsrv% add %service_name% -c "%description%" -sname %node_name% -w "%node_root%" -m "%start_erl%" -args "%args%" -stopaction "init:stop()."
+@goto :EOF
+
+:uninstall
+@%erlsrv% remove %service_name%
+@%epmd% -kill
+@goto :EOF
+
+:start
+@%erlsrv% start %service_name%
+@goto :EOF
+
+:stop
+@%erlsrv% stop %service_name%
+@goto :EOF
+
+:console
+@start "%node_name% console" %werl% -boot "%node_boot_script%" -config "%sys_config%" -args_file "%vm_args%" -sname %node_name%
+@goto :EOF
+
+:ping
+@%escript% %nodetool% ping -sname "%node_name%" -setcookie "%erlang_cookie%"
+@exit %ERRORLEVEL%
+@goto :EOF
+
+:query
+@%erlsrv% list %service_name%
+@exit %ERRORLEVEL%
+@goto :EOF
+
+:attach
+@for /f "usebackq" %%I in (`hostname`) do @set hostname=%%I
+start "%node_name% attach" %werl% -boot "%clean_boot_script%" -remsh %node_name%@%hostname% -sname console -setcookie %erlang_cookie%
+@goto :EOF
+
+:upgrade
+@if "%2"=="" (
+ @echo Missing upgrade package argument
+ @echo Usage: %~n0 upgrade {package base name}
+ @echo NOTE {package base name} MUST NOT include the .tar.gz suffix
+ @goto :EOF
+)
+@%escript% %node_root%\bin\install_upgrade.escript %node_name% %erlang_cookie% %2
+@goto :EOF
+
+:set_trim
+@set %1=%2
+@goto :EOF
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simplenode.windows.start_erl.cmd
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simplenode.windows.start_erl.cmd b/src/rebar/priv/templates/simplenode.windows.start_erl.cmd
new file mode 100644
index 0000000..c0f2072
--- /dev/null
+++ b/src/rebar/priv/templates/simplenode.windows.start_erl.cmd
@@ -0,0 +1,40 @@
+@setlocal
+
+@rem Parse arguments. erlsrv.exe prepends erl arguments prior to first ++.
+@rem Other args are position dependent.
+@set args="%*"
+@for /F "delims=++ tokens=1,2,3" %%I in (%args%) do @(
+ @set erl_args=%%I
+ @call :set_trim node_name %%J
+ @rem Trim spaces from the left of %%K (node_root), which may have spaces inside
+ @for /f "tokens=* delims= " %%a in ("%%K") do @set node_root=%%a
+)
+
+@set releases_dir=%node_root%\releases
+
+@rem parse ERTS version and release version from start_erl.dat
+@for /F "usebackq tokens=1,2" %%I in ("%releases_dir%\start_erl.data") do @(
+ @call :set_trim erts_version %%I
+ @call :set_trim release_version %%J
+)
+
+@set erl_exe="%node_root%\erts-%erts_version%\bin\erl.exe"
+@set boot_file="%releases_dir%\%release_version%\%node_name%"
+
+@if exist "%releases_dir%\%release_version%\sys.config" (
+ @set app_config="%releases_dir%\%release_version%\sys.config"
+) else (
+ @set app_config="%node_root%\etc\app.config"
+)
+
+@if exist "%releases_dir%\%release_version%\vm.args" (
+ @set vm_args="%releases_dir%\%release_version%\vm.args"
+) else (
+ @set vm_args="%node_root%\etc\vm.args"
+)
+
+@%erl_exe% %erl_args% -boot %boot_file% -config %app_config% -args_file %vm_args%
+
+:set_trim
+@set %1=%2
+@goto :EOF
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simplesrv.erl
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simplesrv.erl b/src/rebar/priv/templates/simplesrv.erl
new file mode 100644
index 0000000..af6ca50
--- /dev/null
+++ b/src/rebar/priv/templates/simplesrv.erl
@@ -0,0 +1,50 @@
+-module({{srvid}}).
+-behaviour(gen_server).
+-define(SERVER, ?MODULE).
+
+%% ------------------------------------------------------------------
+%% API Function Exports
+%% ------------------------------------------------------------------
+
+-export([start_link/0]).
+
+%% ------------------------------------------------------------------
+%% gen_server Function Exports
+%% ------------------------------------------------------------------
+
+-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
+ terminate/2, code_change/3]).
+
+%% ------------------------------------------------------------------
+%% API Function Definitions
+%% ------------------------------------------------------------------
+
+start_link() ->
+ gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
+
+%% ------------------------------------------------------------------
+%% gen_server Function Definitions
+%% ------------------------------------------------------------------
+
+init(Args) ->
+ {ok, Args}.
+
+handle_call(_Request, _From, State) ->
+ {reply, ok, State}.
+
+handle_cast(_Msg, State) ->
+ {noreply, State}.
+
+handle_info(_Info, State) ->
+ {noreply, State}.
+
+terminate(_Reason, _State) ->
+ ok.
+
+code_change(_OldVsn, State, _Extra) ->
+ {ok, State}.
+
+%% ------------------------------------------------------------------
+%% Internal Function Definitions
+%% ------------------------------------------------------------------
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/priv/templates/simplesrv.template
----------------------------------------------------------------------
diff --git a/src/rebar/priv/templates/simplesrv.template b/src/rebar/priv/templates/simplesrv.template
new file mode 100644
index 0000000..101844a
--- /dev/null
+++ b/src/rebar/priv/templates/simplesrv.template
@@ -0,0 +1,2 @@
+{variables, [{srvid, "myserver"}]}.
+{template, "simplesrv.erl", "src/{{srvid}}.erl"}.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/rebar.config
----------------------------------------------------------------------
diff --git a/src/rebar/rebar.config b/src/rebar/rebar.config
new file mode 100644
index 0000000..9028737
--- /dev/null
+++ b/src/rebar/rebar.config
@@ -0,0 +1,21 @@
+%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ts=4 sw=4 ft=erlang et
+
+%% escript_incl_extra is for internal rebar-private use only.
+%% Do not use outside rebar. Config interface is not stable.
+{escript_incl_extra, [{"priv/templates/*", "."}]}.
+{erl_opts, [warnings_as_errors]}.
+{xref_checks, []}.
+{xref_queries,
+ [{"(XC - UC) || (XU - X - B
+ - (\"escript\":\"foldl\"/\"3\")
+ - (\"eunit_test\":\"function_wrapper\"/\"2\")
+ - (\"abnfc\":\"file\"/\"2\")
+ - (\"erlydtl\":\"compile\"/\"3\")
+ - (\"lfe_comp\":\"file\"/\"2\")
+ - (\"neotoma\":\"file\"/\"2\")
+ - (\"protobuffs_compile\":\"scan_file\"/\"2\")
+ - (\"diameter_codegen\":\"from_dict\"/\"4\")
+ - (\"diameter_dict_util\":\"format_error\"/\"1\")
+ - (\"diameter_dict_util\":\"parse\"/\"2\"))",
+ []}]}.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/rebar.config.sample
----------------------------------------------------------------------
diff --git a/src/rebar/rebar.config.sample b/src/rebar/rebar.config.sample
new file mode 100644
index 0000000..e6071bd
--- /dev/null
+++ b/src/rebar/rebar.config.sample
@@ -0,0 +1,236 @@
+%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ts=4 sw=4 ft=erlang et
+%% This is a sample rebar.conf file that shows examples of some of rebar's
+%% options.
+
+%% == Core ==
+
+%% Check required ERTS or OTP release version
+{require_erts_vsn, ".*"}.
+{require_otp_vsn, ".*"}.
+{require_min_otp_vsn, ".*"}.
+
+%% Additional library directories to add to the code path
+{lib_dirs, []}.
+
+%% == Erlang Compiler ==
+
+%% Erlang files to compile before the rest. Rebar automatically compiles
+%% parse_transforms and custom behaviours before anything other than the files
+%% in this list.
+{erl_first_files, ["mymib1", "mymib2"]}.
+
+%% Erlang compiler options
+{erl_opts, [no_debug_info,
+ {i, "myinclude"},
+ {src_dirs, ["src", "src2", "src3"]},
+ {platform_define,
+ "(linux|solaris|freebsd|darwin)", 'HAVE_SENDFILE'},
+ {platform_define, "(linux|freebsd)", 'BACKLOG', 128},
+ {platform_define, "R13", 'old_inets'}]}.
+
+%% MIB Options?
+{mib_opts, []}.
+
+%% SNMP mibs to compile first?
+{mib_first_files, []}.
+
+%% leex options
+{xrl_opts, []}.
+
+%% leex files to compile first
+{xrl_first_files, []}.
+
+%% yecc options
+{yrl_opts, []}.
+
+%% yecc files to compile first
+{yrl_first_files, []}.
+
+%% == EDoc ==
+
+%% EDoc options
+{edoc_opts, []}.
+
+%% == Port Compiler ==
+
+%% Port compilation environment variables. See rebar_port_compiler.erl for
+%% more info. Default is `[]'
+{port_env, [{"CFLAGS", "$CFLAGS -Ifoo"},
+ {"freebsd", "LDFLAGS", "$LDFLAGS -lfoo"}]}.
+
+%% port_specs
+%% List of filenames or wildcards to be compiled. May also contain a tuple
+%% consisting of a regular expression to be applied against the system
+%% architecture as a filter.
+{port_specs, [{"priv/so_name.so", ["c_src/*.c"]},
+ {"linux", "priv/hello_linux", ["c_src/hello_linux.c"]},
+ {"linux", "priv/hello_linux", ["c_src/*.c"], [{env, []}]}]}.
+
+%% == escriptize ==
+{escript_name, "application"}.
+{escript_incl_apps, []}.
+{escript_shebang, "#!/usr/bin/env escript\n"}.
+{escript_comment, "%%\n"}.
+{escript_emu_args, "%%! -pa application/application/ebin\n"}.
+
+%% == LFE Compiler ==
+
+%% LFE files to compile before the rest
+{lfe_first_files, []}.
+
+%% Options for the LFE compiler: reuse {erl_opts, []}
+
+%% == ErlyDTL Compiler ==
+
+%% Options for the ErlyDTL compiler
+{erlydtl_opts, []}.
+
+%% == EUnit ==
+
+%% Options for eunit:test()
+{eunit_opts, []}.
+
+%% Additional compile options for eunit. erl_opts is also used
+{eunit_compile_opts, []}.
+
+%% Same as erl_first_files, but used only when running 'eunit'
+{eunit_first_files, []}.
+
+%% == Cover ==
+
+%% Whether to enable coverage reporting. Default is `false'
+{cover_enabled, false}.
+
+%% Whether to print coverage report to console. Default is `false'
+{cover_print_enabled, false}.
+
+%% Whether to export coverage report to file. Default is `false'
+{cover_export_enabled, false}.
+
+%% == Common Test ==
+
+%% Override the default "test" directory in which SUITEs are located
+{ct_dir, "itest"}.
+
+%% Override the default "logs" directory in which SUITEs are logged
+{ct_log_dir, "test/logs"}.
+
+%% Option to pass extra parameters when launching Common Test
+{ct_extra_params, "-boot start_sasl -s myapp"}.
+
+%% Option to use short names (i.e., -sname test) when starting ct
+{ct_use_short_names, true}.
+
+%% == QuickCheck ==
+
+%% If qc_mod is unspecified, rebar tries to detect Triq or EQC
+{qc_opts, [{qc_mod, module()}, Options]}.
+
+%% Additional compile options for qc. erl_opts is also used
+{qc_compile_opts, []}.
+
+%% Same as erl_first_files, but used only when running 'qc'
+{qc_first_files, []}.
+
+%% == Cleanup ==
+
+%% Which files to cleanup
+{clean_files, ["file", "file2"]}.
+
+%% == OTP Applications ==
+
+%% Enable validation of the OTP app module list. Default is 'true'
+{validate_app_modules, true}.
+
+%% == Dependencies ==
+
+%% Where to put any downloaded dependencies. Default is "deps"
+{deps_dir, "deps"}.
+
+%% What dependencies we have, dependencies can be of 3 forms, an application
+%% name as an atom, eg. mochiweb, a name and a version (from the .app file), or
+%% an application name, a version and the SCM details on how to fetch it (SCM
+%% type, location and revision).
+%% Rebar currently supports git, hg, bzr, svn, rsync, and fossil.
+{deps, [app_name,
+ {rebar, "1.0.*"},
+ {rebar, ".*",
+ {git, "git://github.com/rebar/rebar.git"}},
+ {rebar, ".*",
+ {git, "git://github.com/rebar/rebar.git", "Rev"}},
+ {rebar, "1.0.*",
+ {git, "git://github.com/rebar/rebar.git", {branch, "master"}}},
+ {rebar, "1.0.0",
+ {git, "git://github.com/rebar/rebar.git", {tag, "1.0.0"}}},
+ %% Dependencies can be marked as 'raw'. Rebar does not require
+ %% such dependencies to have a standard Erlang/OTP layout
+ %% which assumes the presence of either
+ %% "src/dependency_name.app.src" or "ebin/dependency_name.app"
+ %% files.
+ %%
+ %% 'raw' dependencies can still contain 'rebar.config' and
+ %% even can have the proper OTP directory layout, but they
+ %% won't be compiled.
+ %%
+ %% Only a subset of rebar commands will be executed on the
+ %% 'raw' subdirectories: get-deps, update-deps, check-deps,
+ %% list-deps and delete-deps.
+ {rebar, "",
+ {git, "git://github.com/rebar/rebar.git", {branch, "master"}},
+ [raw]},
+ {app_name, ".*", {hg, "https://www.example.org/url"}},
+ {app_name, ".*", {rsync, "Url"}},
+ {app_name, ".*", {svn, "https://www.example.org/url"}},
+ {app_name, ".*", {svn, "svn://svn.example.org/url"}},
+ {app_name, ".*", {bzr, "https://www.example.org/url", "Rev"}},
+ {app_name, ".*", {fossil, "https://www.example.org/url"}},
+ {app_name, ".*", {fossil, "https://www.example.org/url", "Vsn"}}]}.
+
+%% == Subdirectories ==
+
+%% Subdirectories?
+{sub_dirs, ["dir1", "dir2"]}.
+
+%% == Plugins ==
+
+%% Plugins you wish to include.
+%% These can include any module on the code path, including deps.
+%% Alternatively, plugins can be placed as source files in the plugin_dir, in
+%% which case they will be compiled and loaded dynamically at runtime.
+{plugins, [plugin1, plugin2]}.
+
+%% Override the directory in which plugin sources can be found.
+%% Defaults to ./plugins
+{plugin_dir, "some_other_directory"}.
+
+
+%% == Pre/Post Command Hooks ==
+
+{pre_hooks, [{clean, "./prepare_package_files.sh"},
+ {"linux", compile, "c_src/build_linux.sh"},
+ {compile, "escript generate_headers"},
+ {compile, "escript check_headers"}]}.
+
+{post_hooks, [{clean, "touch file1.out"},
+ {"freebsd", compile, "c_src/freebsd_tweaks.sh"},
+ {eunit, "touch file2.out"},
+ {compile, "touch postcompile.out"}]}.
+
+%% == xref ==
+
+{xref_warnings, false}.
+
+%% xref checks to run
+{xref_checks, [undefined_function_calls, undefined_functions,
+ locals_not_used, exports_not_used,
+ deprecated_function_calls, deprecated_functions]}.
+
+%% Optional custom xref queries (xref manual has details) specified as
+%% {xref_queries, [{query_string(), expected_query_result()},...]}
+%% The following for example removes all references to mod:*foo/4
+%% functions from undefined external function calls as those are in a
+%% generated module
+{xref_queries,
+ [{"(XC - UC) || (XU - X - B"
+ " - (\"mod\":\".*foo\"/\"4\"))",[]}]}.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/626455a4/src/rebar/rebar.config.script
----------------------------------------------------------------------
diff --git a/src/rebar/rebar.config.script b/src/rebar/rebar.config.script
new file mode 100644
index 0000000..be61b5e
--- /dev/null
+++ b/src/rebar/rebar.config.script
@@ -0,0 +1,20 @@
+%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ts=4 sw=4 ft=erlang et
+
+%% TODO: Change temporary retest fork back to dizzyd/retest after merge
+%% ExtraDeps = [{retest, ".*", {git, "git://github.com/dizzyd/retest.git"}}],
+ExtraDeps = [{retest, ".*",
+ {git, "git://github.com/dizzyd/retest.git"}}],
+
+case os:getenv("REBAR_EXTRA_DEPS") of
+ false ->
+ CONFIG;
+ _ ->
+ case lists:keysearch(deps, 1, CONFIG) of
+ {value, {deps, Deps}} ->
+ NDeps = Deps ++ ExtraDeps,
+ lists:keyreplace(deps, 1, CONFIG, {deps, NDeps});
+ false ->
+ CONFIG ++ [{deps, ExtraDeps}]
+ end
+end.