mirror of
https://github.com/correl/rebar.git
synced 2024-12-24 03:00:16 +00:00
Merge branch 'terrencehan-fix_upgrade_error'
This commit is contained in:
commit
899d60cdb0
3 changed files with 52 additions and 14 deletions
|
@ -35,6 +35,7 @@
|
|||
get_rel_apps/2,
|
||||
get_previous_release_path/1,
|
||||
get_rel_file_path/2,
|
||||
get_rel_file_path/3,
|
||||
load_config/2,
|
||||
get_sys_tuple/1,
|
||||
get_excl_lib_tuple/1,
|
||||
|
@ -106,9 +107,18 @@ get_rel_apps(Name, Path) ->
|
|||
|
||||
%% Get rel file path from name and path
|
||||
get_rel_file_path(Name, Path) ->
|
||||
[RelFile] = filelib:wildcard(filename:join([Path, "releases", "*",
|
||||
Name ++ ".rel"])),
|
||||
RelFile.
|
||||
PVer = get_permanent_version(Path),
|
||||
get_rel_file_path(Name, Path, PVer).
|
||||
|
||||
get_rel_file_path(Name, Path, Version) ->
|
||||
Dir = filename:join([Path, "releases", Version]),
|
||||
Path1 = filename:join([Dir, Name ++ "_" ++ Version ++".rel"]),
|
||||
Path2 = filename:join([Dir, Name ++ ".rel"]),
|
||||
case {filelib:is_file(Path1), filelib:is_file(Path2)} of
|
||||
{true, _} -> Path1;
|
||||
{_, true} -> Path2;
|
||||
_ -> ?ABORT("can not find .rel file for version ~p~n", [Version])
|
||||
end.
|
||||
|
||||
%% Get the previous release path from a global variable
|
||||
get_previous_release_path(Config) ->
|
||||
|
@ -128,7 +138,7 @@ load_config(Config, ReltoolFile) ->
|
|||
{ok, Terms} ->
|
||||
expand_version(Config, Terms, filename:dirname(ReltoolFile));
|
||||
Other ->
|
||||
?ABORT("Failed to load expected config from ~s: ~p\n",
|
||||
?ABORT("Failed to load expected config from ~s: ~p~n",
|
||||
[ReltoolFile, Other])
|
||||
end.
|
||||
|
||||
|
@ -141,7 +151,7 @@ get_sys_tuple(ReltoolConfig) ->
|
|||
{sys, _} = SysTuple ->
|
||||
SysTuple;
|
||||
false ->
|
||||
?ABORT("Failed to find {sys, [...]} tuple in reltool.config.", [])
|
||||
?ABORT("Failed to find {sys, [...]} tuple in reltool.config~n", [])
|
||||
end.
|
||||
|
||||
%%
|
||||
|
@ -244,3 +254,16 @@ expand_rel_version(Config, {rel, Name, Version, Apps}, Dir) ->
|
|||
{NewConfig, {rel, Name, VsnString, Apps}};
|
||||
expand_rel_version(Config, Other, _Dir) ->
|
||||
{Config, Other}.
|
||||
|
||||
%% get permanent version from start_erl.data
|
||||
get_permanent_version(Path) ->
|
||||
DataFile = filename:join([Path, "releases", "start_erl.data"]),
|
||||
case file:read_file(DataFile) of
|
||||
{ok, DataBin} ->
|
||||
[_, Version] = string:tokens(
|
||||
string:strip(binary_to_list(DataBin), right, $\n),
|
||||
" "),
|
||||
Version;
|
||||
{error, enoent} ->
|
||||
?ABORT("~s is missing~n", [DataFile])
|
||||
end.
|
||||
|
|
|
@ -52,9 +52,10 @@
|
|||
OldVerPath = filename:join([TargetParentDir, PrevRelPath]),
|
||||
|
||||
%% Run checks to make sure that building a package is possible
|
||||
{NewVerPath, NewName, NewVer} = run_checks(Config, OldVerPath,
|
||||
ReltoolConfig),
|
||||
{NewVerPath, NewName, NewVer, OldVer} = run_checks(Config, OldVerPath,
|
||||
ReltoolConfig),
|
||||
NameVer = NewName ++ "_" ++ NewVer,
|
||||
OldRelName = get_old_rel_name(OldVerPath, OldVer, NewName),
|
||||
|
||||
%% Save the code path prior to doing anything
|
||||
OrigPath = code:get_path(),
|
||||
|
@ -63,7 +64,7 @@
|
|||
ok = setup(OldVerPath, NewVerPath, NewName, NewVer, NameVer),
|
||||
|
||||
%% Build the package
|
||||
run_systools(NameVer, NewName),
|
||||
run_systools(NameVer, OldRelName),
|
||||
|
||||
%% Boot file changes
|
||||
{ok, _} = boot_files(TargetDir, NewVer, NewName),
|
||||
|
@ -122,7 +123,7 @@ run_checks(Config, OldVerPath, ReltoolConfig) ->
|
|||
rebar_utils:prop_check(Ver == NewVer,
|
||||
"Reltool and .rel versions do not match~n", []),
|
||||
|
||||
{NewVerPath, NewName, NewVer}.
|
||||
{NewVerPath, NewName, NewVer, OldVer}.
|
||||
|
||||
setup(OldVerPath, NewVerPath, NewName, NewVer, NameVer) ->
|
||||
Src = filename:join([NewVerPath, "releases",
|
||||
|
@ -139,9 +140,9 @@ setup(OldVerPath, NewVerPath, NewName, NewVer, NameVer) ->
|
|||
"lib", "*", "ebin"]))
|
||||
])).
|
||||
|
||||
run_systools(NewVer, Name) ->
|
||||
run_systools(NewVer, OldRelName) ->
|
||||
Opts = [silent],
|
||||
NameList = [Name],
|
||||
NameList = [OldRelName],
|
||||
case systools:make_relup(NewVer, NameList, NameList, Opts) of
|
||||
{error, _, Msg} ->
|
||||
?ABORT("Systools [systools:make_relup/4] aborted with: ~p~n",
|
||||
|
@ -264,3 +265,7 @@ file_info(Path) ->
|
|||
Error ->
|
||||
Error
|
||||
end.
|
||||
|
||||
get_old_rel_name(OldVerPath, OldVer, Name) ->
|
||||
OldRelFile = rebar_rel_utils:get_rel_file_path(Name, OldVerPath, OldVer),
|
||||
filename:basename(OldRelFile, ".rel").
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#### Building version 0.1
|
||||
rebar compile
|
||||
cd rel
|
||||
rebar generate
|
||||
mv rel/dummy rel/dummy_0.1
|
||||
mv dummy dummy_0.1
|
||||
cd ..
|
||||
rebar clean
|
||||
# start the release:
|
||||
cd rel/dummy_0.1
|
||||
|
@ -20,15 +22,17 @@
|
|||
$EDITOR rel/reltool.config
|
||||
|
||||
rebar compile
|
||||
cd rel
|
||||
rebar generate
|
||||
# previous_release path is relative to your rel directory
|
||||
rebar generate-appups previous_release=dummy_0.1
|
||||
rebar generate-upgrade previous_release=dummy_0.1
|
||||
tar -zvtf rel/dummy_0.2.tar.gz
|
||||
tar -zvtf dummy_0.2.tar.gz
|
||||
mv dummy dummy_0.2
|
||||
|
||||
|
||||
#### Deploying with release_handler
|
||||
mv rel/dummy_0.2.tar.gz rel/dummy_0.1/releases/
|
||||
mv dummy_0.2.tar.gz dummy_0.1/releases/
|
||||
|
||||
# Now use release_handler in the running erlang console for the deploy:
|
||||
|
||||
|
@ -38,3 +42,9 @@
|
|||
|
||||
erl> release_handler:which_releases().
|
||||
erl> dummy_server:get_state().
|
||||
|
||||
#### Building version 0.3
|
||||
rm -r rel/dummy
|
||||
|
||||
# Now repeat steps in 'Building version 0.2' and 'Deploying with release_handler'
|
||||
# while replacing '0.2' by '0.3' and '0.1' by '0.2'.
|
||||
|
|
Loading…
Reference in a new issue