Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 9 commits
  • 11 files changed
  • 0 comments
  • 3 contributors
2  README.md
Source Rendered
@@ -125,7 +125,7 @@ Command 'debug' not understood or not applicable
125 125 Congratulations! You now have a self-contained script called "rebar" in
126 126 your current working directory. Place this script anywhere in your path
127 127 and you can use rebar to build OTP-compliant apps.
128   -make: [xref_warnings] Error 1 (ignored)
  128 +==> rebar (xref)
129 129 make: [dialyzer_warnings] Error 2 (ignored)
130 130 ```
131 131
1  THANKS
@@ -90,3 +90,4 @@ Ali Yakout
90 90 Adam Schepis
91 91 Amit Kapoor
92 92 Ulf Wiger
  93 +Nick Vatamaniuc
3  priv/shell-completion/bash/rebar
@@ -12,8 +12,7 @@ _rebar()
12 12 ct doc delete-deps eunit get-deps generate generate-upgrade \
13 13 help list-deps list-templates update-deps version xref overlay \
14 14 apps= case= force=1 jobs= suites= verbose=1 appid= previous_release= \
15   - nodeid= root_dir= skip_deps=true skip_apps= template= template_dir= \
16   - alt_urls=true"
  15 + nodeid= root_dir= skip_deps=true skip_apps= template= template_dir="
17 16
18 17 if [[ ${cur} == --* ]] ; then
19 18 COMPREPLY=( $(compgen -W "${lopts}" -- ${cur}) )
26 priv/templates/simplenode.runner
@@ -50,6 +50,14 @@ if [ -z "$NAME_ARG" ]; then
50 50 exit 1
51 51 fi
52 52
  53 +# Extract the name type and name from the NAME_ARG for REMSH
  54 +REMSH_TYPE=`echo $NAME_ARG | awk '{print $1}'`
  55 +REMSH_NAME=`echo $NAME_ARG | awk '{print $2}'`
  56 +
  57 +# Note the `date +%s`, used to allow multiple remsh to the same node transparently
  58 +REMSH_NAME_ARG="$REMSH_TYPE remsh`date +%s`@`echo $REMSH_NAME | awk -F@ '{print $2}'`"
  59 +REMSH_REMSH_ARG="-remsh $REMSH_NAME"
  60 +
53 61 # Extract the target cookie
54 62 COOKIE_ARG=`grep '^-setcookie' $VMARGS_PATH`
55 63 if [ -z "$COOKIE_ARG" ]; then
@@ -63,6 +71,9 @@ ERTS_PATH=$RUNNER_BASE_DIR/erts-$ERTS_VSN/bin
63 71 # Setup command to control the node
64 72 NODETOOL="$ERTS_PATH/escript $ERTS_PATH/nodetool $NAME_ARG $COOKIE_ARG"
65 73
  74 +# Setup remote shell command to control node
  75 +REMSH="$ERTS_PATH/erl $REMSH_NAME_ARG $REMSH_REMSH_ARG $COOKIE_ARG"
  76 +
66 77 # Check the first argument for instructions
67 78 case "$1" in
68 79 start)
@@ -149,6 +160,19 @@ case "$1" in
149 160 exec $ERTS_PATH/to_erl $PIPE_DIR
150 161 ;;
151 162
  163 + remote_console)
  164 + # Make sure a node IS running
  165 + RES=`$NODETOOL ping`
  166 + ES=$?
  167 + if [ "$ES" -ne 0 ]; then
  168 + echo "Node is not running!"
  169 + exit $ES
  170 + fi
  171 +
  172 + shift
  173 + exec $REMSH
  174 + ;;
  175 +
152 176 upgrade)
153 177 if [ -z "$2" ]; then
154 178 echo "Missing upgrade package argument"
@@ -226,7 +250,7 @@ case "$1" in
226 250 exec $CMD -- ${1+"$@"}
227 251 ;;
228 252 *)
229   - echo "Usage: $SCRIPT {start|foreground|stop|restart|reboot|ping|console|console_clean|attach|upgrade}"
  253 + echo "Usage: $SCRIPT {start|foreground|stop|restart|reboot|ping|console|console_clean|attach|remote_console|upgrade}"
230 254 exit 1
231 255 ;;
232 256 esac
5 rebar.config.sample
@@ -115,10 +115,7 @@
115 115 {deps, [application_name,
116 116 {application_name, "1.0.*"},
117 117 {application_name, "1.0.*",
118   - {git, "git://github.com/basho/rebar.git", {branch, "master"}}},
119   - {application_name, "1.0.*",
120   - {git, "git://github.com/basho/rebar.git", {branch, "master"}},
121   - [{alt_url, "https://github.com/basho/rebar.git"}]}]}.
  118 + {git, "git://github.com/basho/rebar.git", {branch, "master"}}}]}.
122 119
123 120 %% == Subdirectories ==
124 121
15 src/rebar_config.erl
@@ -38,10 +38,7 @@
38 38
39 39 -record(config, { dir :: file:filename(),
40 40 opts = [] :: list(),
41   - envs = [] :: list({module(), env()}) }).
42   -
43   --type env() :: [env_var()].
44   --type env_var() :: {string(), string()}.
  41 + envs = new_env() :: dict() }).
45 42
46 43 %% Types that can be used from other modules -- alphabetically ordered.
47 44 -export_type([config/0]).
@@ -149,14 +146,11 @@ consult_file(File) ->
149 146
150 147 set_env(Config, Mod, Env) ->
151 148 OldEnvs = Config#config.envs,
152   - NewEnvs = case lists:keymember(Mod, 1, OldEnvs) of
153   - true -> lists:keyreplace(Mod, 1, OldEnvs, {Mod, Env});
154   - false -> [{Mod,Env}|OldEnvs]
155   - end,
  149 + NewEnvs = dict:store(Mod, Env, OldEnvs),
156 150 Config#config{envs=NewEnvs}.
157 151
158 152 get_env(Config, Mod) ->
159   - proplists:get_value(Mod, Config#config.envs, []).
  153 + dict:fetch(Mod, Config#config.envs).
160 154
161 155 %% ===================================================================
162 156 %% Internal functions
@@ -193,3 +187,6 @@ local_opts([local | _Rest], Acc) ->
193 187 lists:reverse(Acc);
194 188 local_opts([Item | Rest], Acc) ->
195 189 local_opts(Rest, [Item | Acc]).
  190 +
  191 +new_env() ->
  192 + dict:new().
45 src/rebar_deps.erl
@@ -229,30 +229,15 @@ find_deps(Mode, [App | Rest], Acc) when is_atom(App) ->
229 229 find_deps(Mode, [{App, VsnRegex} | Rest], Acc) when is_atom(App) ->
230 230 find_deps(Mode, [{App, VsnRegex, undefined} | Rest], Acc);
231 231 find_deps(Mode, [{App, VsnRegex, Source} | Rest], Acc) ->
232   - find_deps(Mode, [{App, VsnRegex, Source, []} | Rest], Acc);
233   -find_deps(Mode, [{App, VsnRegex, Source, Opts} | Rest], Acc) ->
234 232 Dep = #dep { app = App,
235 233 vsn_regex = VsnRegex,
236   - source = get_source(Source, Opts) },
  234 + source = Source },
237 235 {Availability, FoundDir} = find_dep(Dep),
238 236 find_deps(Mode, Rest, acc_deps(Mode, Availability, Dep, FoundDir, Acc));
239 237 find_deps(_Mode, [Other | _Rest], _Acc) ->
240 238 ?ABORT("Invalid dependency specification ~p in ~s\n",
241 239 [Other, rebar_utils:get_cwd()]).
242 240
243   -get_source(undefined, _Opts) ->
244   - undefined;
245   -get_source(Source, Opts) ->
246   - setelement(2, Source, dep_url(element(2, Source), Opts)).
247   -
248   -dep_url(Url, Opts) ->
249   - case rebar_config:get_global(alt_urls, "false") of
250   - "true" ->
251   - proplists:get_value(alt_url, Opts, Url);
252   - "false" ->
253   - Url
254   - end.
255   -
256 241 find_dep(Dep) ->
257 242 %% Find a dep based on its source,
258 243 %% e.g. {git, "https://github.com/mochi/mochiweb.git", "HEAD"}
@@ -400,7 +385,10 @@ download_source(AppDir, {svn, Url, Rev}) ->
400 385 ok = filelib:ensure_dir(AppDir),
401 386 rebar_utils:sh(?FMT("svn checkout -r ~s ~s ~s",
402 387 [Rev, Url, filename:basename(AppDir)]),
403   - [{cd, filename:dirname(AppDir)}]).
  388 + [{cd, filename:dirname(AppDir)}]);
  389 +download_source(AppDir, {rsync, Url}) ->
  390 + ok = filelib:ensure_dir(AppDir),
  391 + rebar_utils:sh(?FMT("rsync -az --delete ~s/ ~s", [Url, AppDir]), []).
404 392
405 393 update_source(Dep) ->
406 394 %% It's possible when updating a source, that a given dep does not have a
@@ -441,7 +429,10 @@ update_source(AppDir, {svn, _Url, Rev}) ->
441 429 update_source(AppDir, {hg, _Url, Rev}) ->
442 430 rebar_utils:sh(?FMT("hg pull -u -r ~s", [Rev]), [{cd, AppDir}]);
443 431 update_source(AppDir, {bzr, _Url, Rev}) ->
444   - rebar_utils:sh(?FMT("bzr update -r ~s", [Rev]), [{cd, AppDir}]).
  432 + rebar_utils:sh(?FMT("bzr update -r ~s", [Rev]), [{cd, AppDir}]);
  433 +update_source(AppDir, {rsync, Url}) ->
  434 + rebar_utils:sh(?FMT("rsync -az --delete ~s/ ~s",[Url,AppDir]),[]).
  435 +
445 436
446 437
447 438
@@ -454,7 +445,7 @@ source_engine_avail(Source) ->
454 445 source_engine_avail(Name, Source).
455 446
456 447 source_engine_avail(Name, Source)
457   - when Name == hg; Name == git; Name == svn; Name == bzr ->
  448 + when Name == hg; Name == git; Name == svn; Name == bzr; Name == rsync ->
458 449 case vcs_client_vsn(Name) >= required_vcs_client_vsn(Name) of
459 450 true ->
460 451 true;
@@ -475,10 +466,11 @@ vcs_client_vsn(Path, VsnArg, VsnRegex) ->
475 466 false
476 467 end.
477 468
478   -required_vcs_client_vsn(hg) -> {1, 1};
479   -required_vcs_client_vsn(git) -> {1, 5};
480   -required_vcs_client_vsn(bzr) -> {2, 0};
481   -required_vcs_client_vsn(svn) -> {1, 6}.
  469 +required_vcs_client_vsn(hg) -> {1, 1};
  470 +required_vcs_client_vsn(git) -> {1, 5};
  471 +required_vcs_client_vsn(bzr) -> {2, 0};
  472 +required_vcs_client_vsn(svn) -> {1, 6};
  473 +required_vcs_client_vsn(rsync) -> {2, 0}.
482 474
483 475 vcs_client_vsn(hg) ->
484 476 vcs_client_vsn(rebar_utils:find_executable("hg"), " --version",
@@ -491,7 +483,10 @@ vcs_client_vsn(bzr) ->
491 483 "Bazaar \\(bzr\\) (\\d+).(\\d+)");
492 484 vcs_client_vsn(svn) ->
493 485 vcs_client_vsn(rebar_utils:find_executable("svn"), " --version",
494   - "svn, version (\\d+).(\\d+)").
  486 + "svn, version (\\d+).(\\d+)");
  487 +vcs_client_vsn(rsync) ->
  488 + vcs_client_vsn(rebar_utils:find_executable("rsync"), " --version",
  489 + "rsync version (\\d+).(\\d+)").
495 490
496 491 has_vcs_dir(git, Dir) ->
497 492 filelib:is_dir(filename:join(Dir, ".git"));
@@ -502,6 +497,8 @@ has_vcs_dir(bzr, Dir) ->
502 497 has_vcs_dir(svn, Dir) ->
503 498 filelib:is_dir(filename:join(Dir, ".svn"))
504 499 orelse filelib:is_dir(filename:join(Dir, "_svn"));
  500 +has_vcs_dir(rsync, _) ->
  501 + true;
505 502 has_vcs_dir(_, _) ->
506 503 true.
507 504
39 src/rebar_port_compiler.erl
@@ -247,7 +247,7 @@ needs_link(SoName, NewBins) ->
247 247 %%
248 248
249 249 get_specs(Config, AppFile) ->
250   - case rebar_config:get(Config, port_specs, undefined) of
  250 + case rebar_config:get_local(Config, port_specs, undefined) of
251 251 undefined ->
252 252 %% TODO: DEPRECATED: remove support for non-port_specs syntax
253 253 {old, old_get_specs(Config, AppFile)};
@@ -304,9 +304,9 @@ maybe_switch_extension(_OsType, Target) ->
304 304
305 305 switch_to_dll_or_exe(Target) ->
306 306 case filename:extension(Target) of
307   - ".so" -> filename:rootname(Target, ".so") ++ ".dll";
308   - [] -> Target ++ ".exe";
309   - Other -> Other
  307 + ".so" -> filename:rootname(Target, ".so") ++ ".dll";
  308 + [] -> Target ++ ".exe";
  309 + _Other -> Target
310 310 end.
311 311
312 312 %% TODO: DEPRECATED: remove support for non-port_specs syntax [old_*()]
@@ -314,24 +314,25 @@ old_get_specs(Config, AppFile) ->
314 314 OsType = os:type(),
315 315 SourceFiles = old_get_sources(Config),
316 316 Specs =
317   - case rebar_config:get(Config, so_specs, undefined) of
  317 + case rebar_config:get_local(Config, so_specs, undefined) of
318 318 undefined ->
319 319 Objects = port_objects(SourceFiles),
320 320 %% New form of so_specs is not provided. See if the old form
321 321 %% of {so_name} is available instead
322 322 Dir = "priv",
323   - SoName = case rebar_config:get(Config, so_name, undefined) of
324   - undefined ->
325   - %% Ok, neither old nor new form is
326   - %% available. Use the app name and
327   - %% generate a sensible default.
328   - AppName = rebar_app_utils:app_name(AppFile),
329   - DrvName = ?FMT("~s_drv.so", [AppName]),
330   - filename:join([Dir, DrvName]);
331   - AName ->
332   - %% Old form is available -- use it
333   - filename:join(Dir, AName)
334   - end,
  323 + SoName =
  324 + case rebar_config:get_local(Config, so_name, undefined) of
  325 + undefined ->
  326 + %% Ok, neither old nor new form is
  327 + %% available. Use the app name and
  328 + %% generate a sensible default.
  329 + AppName = rebar_app_utils:app_name(AppFile),
  330 + DrvName = ?FMT("~s_drv.so", [AppName]),
  331 + filename:join([Dir, DrvName]);
  332 + AName ->
  333 + %% Old form is available -- use it
  334 + filename:join(Dir, AName)
  335 + end,
335 336 [old_get_so_spec({SoName, Objects}, OsType)];
336 337 SoSpecs ->
337 338 [old_get_so_spec(S, OsType) || S <- SoSpecs]
@@ -339,8 +340,8 @@ old_get_specs(Config, AppFile) ->
339 340 {SourceFiles, Specs}.
340 341
341 342 old_get_sources(Config) ->
342   - RawSources = rebar_config:get_list(Config, port_sources,
343   - ["c_src/*.c"]),
  343 + RawSources = rebar_config:get_local(Config, port_sources,
  344 + ["c_src/*.c"]),
344 345 FilteredSources = old_filter_port_sources(RawSources),
345 346 old_expand_sources(FilteredSources).
346 347
5 src/rebar_utils.erl
@@ -423,9 +423,8 @@ emulate_escript_foldl(Fun, Acc, File) ->
423 423 end.
424 424
425 425 vcs_vsn_cmd(git) ->
426   - %% Explicitly git-describe a committish to accommodate for projects
427   - %% in subdirs which don't have a GIT_DIR. In that case we will
428   - %% get a description of the last commit that touched the subdir.
  426 + %% git describe the last commit that touched CWD
  427 + %% required for correct versioning of apps in subdirs, such as apps/app1
429 428 case os:type() of
430 429 {win32,nt} ->
431 430 "FOR /F \"usebackq tokens=* delims=\" %i in "
86 test/upgrade_project/rel/files/dummy
@@ -50,6 +50,14 @@ if [ -z "$NAME_ARG" ]; then
50 50 exit 1
51 51 fi
52 52
  53 +# Extract the name type and name from the NAME_ARG for REMSH
  54 +REMSH_TYPE=`echo $NAME_ARG | awk '{print $1}'`
  55 +REMSH_NAME=`echo $NAME_ARG | awk '{print $2}'`
  56 +
  57 +# Note the `date +%s`, used to allow multiple remsh to the same node transparently
  58 +REMSH_NAME_ARG="$REMSH_TYPE attach`date +%s`@`echo $REMSH_NAME | awk -F@ '{print $2}'`"
  59 +REMSH_REMSH_ARG="-remsh $REMSH_NAME"
  60 +
53 61 # Extract the target cookie
54 62 COOKIE_ARG=`grep '^-setcookie' $VMARGS_PATH`
55 63 if [ -z "$COOKIE_ARG" ]; then
@@ -63,6 +71,9 @@ ERTS_PATH=$RUNNER_BASE_DIR/erts-$ERTS_VSN/bin
63 71 # Setup command to control the node
64 72 NODETOOL="$ERTS_PATH/escript $ERTS_PATH/nodetool $NAME_ARG $COOKIE_ARG"
65 73
  74 +# Setup remote shell command to control node
  75 +REMSH="$ERTS_PATH/erl $REMSH_NAME_ARG $REMSH_REMSH_ARG $COOKIE_ARG"
  76 +
66 77 # Check the first argument for instructions
67 78 case "$1" in
68 79 start)
@@ -72,11 +83,12 @@ case "$1" in
72 83 echo "Node is already running!"
73 84 exit 1
74 85 fi
75   - HEART_COMMAND="$RUNNER_BASE_DIR/bin/$SCRIPT start"
  86 + shift # remove $1
  87 + RUN_PARAM=$(printf "\'%s\' " "$@")
  88 + HEART_COMMAND="$RUNNER_BASE_DIR/bin/$SCRIPT start $RUN_PARAM"
76 89 export HEART_COMMAND
77 90 mkdir -p $PIPE_DIR
78   - shift # remove $1
79   - $ERTS_PATH/run_erl -daemon $PIPE_DIR $RUNNER_LOG_DIR "exec $RUNNER_BASE_DIR/bin/$SCRIPT console $@" 2>&1
  91 + $ERTS_PATH/run_erl -daemon $PIPE_DIR $RUNNER_LOG_DIR "exec $RUNNER_BASE_DIR/bin/$SCRIPT console $RUN_PARAM" 2>&1
80 92 ;;
81 93
82 94 stop)
@@ -148,6 +160,41 @@ case "$1" in
148 160 exec $ERTS_PATH/to_erl $PIPE_DIR
149 161 ;;
150 162
  163 + remote_console)
  164 + # Make sure a node IS running
  165 + RES=`$NODETOOL ping`
  166 + ES=$?
  167 + if [ "$ES" -ne 0 ]; then
  168 + echo "Node is not running!"
  169 + exit $ES
  170 + fi
  171 +
  172 + shift
  173 + exec $REMSH
  174 + ;;
  175 +
  176 + upgrade)
  177 + if [ -z "$2" ]; then
  178 + echo "Missing upgrade package argument"
  179 + echo "Usage: $SCRIPT upgrade {package base name}"
  180 + echo "NOTE {package base name} MUST NOT include the .tar.gz suffix"
  181 + exit 1
  182 + fi
  183 +
  184 + # Make sure a node IS running
  185 + RES=`$NODETOOL ping`
  186 + ES=$?
  187 + if [ "$ES" -ne 0 ]; then
  188 + echo "Node is not running!"
  189 + exit $ES
  190 + fi
  191 +
  192 + node_name=`echo $NAME_ARG | awk '{print $2}'`
  193 + erlang_cookie=`echo $COOKIE_ARG | awk '{print $2}'`
  194 +
  195 + $ERTS_PATH/escript $RUNNER_BASE_DIR/bin/install_upgrade.escript $node_name $erlang_cookie $2
  196 + ;;
  197 +
151 198 console|console_clean)
152 199 # .boot file typically just $SCRIPT (ie, the app name)
153 200 # however, for debugging, sometimes start_clean.boot is useful:
@@ -160,25 +207,50 @@ case "$1" in
160 207 BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
161 208 EMU=beam
162 209 PROGNAME=`echo $0 | sed 's/.*\\///'`
163   - CMD="$BINDIR/erlexec -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$BOOTFILE -mode embedded -config $CONFIG_PATH -args_file $VMARGS_PATH -- ${1+"$@"}"
  210 + CMD="$BINDIR/erlexec -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$BOOTFILE -mode embedded -config $CONFIG_PATH -args_file $VMARGS_PATH"
164 211 export EMU
165 212 export ROOTDIR
166 213 export BINDIR
167 214 export PROGNAME
168 215
169 216 # Dump environment info for logging purposes
170   - echo "Exec: $CMD"
  217 + echo "Exec: $CMD" -- ${1+"$@"}
171 218 echo "Root: $ROOTDIR"
172 219
173 220 # Log the startup
174 221 logger -t "$SCRIPT[$$]" "Starting up"
175 222
176 223 # Start the VM
177   - exec $CMD
  224 + exec $CMD -- ${1+"$@"}
178 225 ;;
179 226
  227 + foreground)
  228 + # start up the release in the foreground for use by runit
  229 + # or other supervision services
  230 +
  231 + BOOTFILE=$SCRIPT
  232 + FOREGROUNDOPTIONS="-noinput +Bd"
  233 +
  234 + # Setup beam-required vars
  235 + ROOTDIR=$RUNNER_BASE_DIR
  236 + BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
  237 + EMU=beam
  238 + PROGNAME=`echo $0 | sed 's/.*\///'`
  239 + CMD="$BINDIR/erlexec $FOREGROUNDOPTIONS -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$BOOTFILE -config $CONFIG_PATH -args_file $VMARGS_PATH"
  240 + export EMU
  241 + export ROOTDIR
  242 + export BINDIR
  243 + export PROGNAME
  244 +
  245 + # Dump environment info for logging purposes
  246 + echo "Exec: $CMD" -- ${1+"$@"}
  247 + echo "Root: $ROOTDIR"
  248 +
  249 + # Start the VM
  250 + exec $CMD -- ${1+"$@"}
  251 + ;;
180 252 *)
181   - echo "Usage: $SCRIPT {start|stop|restart|reboot|ping|console|console_clean|attach}"
  253 + echo "Usage: $SCRIPT {start|foreground|stop|restart|reboot|ping|console|console_clean|attach|remote_console|upgrade}"
182 254 exit 1
183 255 ;;
184 256 esac
2  test/upgrade_project/rel/reltool.config
@@ -12,6 +12,8 @@
12 12 {excl_sys_filters, ["^bin/.*", "^erts.*/bin/(dialyzer|typer)"]},
13 13 {excl_archive_filters, [".*"]},
14 14
  15 + {app, hipe, [{incl_cond, exclude}]},
  16 +
15 17 {app, dummy, [{incl_cond, include}]}
16 18 ]}.
17 19

No commit comments for this range

Something went wrong with that request. Please try again.