mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 11:06:20 +00:00
Fix bug that causes appup generation to fail
This commit changes how rebar determines which apps have been updated, added and removed from a release during appup generation. Rather than use app files it now determines this from the rel file in each version of the release. In addition it fixes a bug reported on the mailing list when generating appups when an application has been added or removed from either release.
This commit is contained in:
parent
d725e5fe92
commit
0f99ba2280
2 changed files with 43 additions and 22 deletions
|
@ -55,14 +55,8 @@
|
||||||
NewName == OldName,
|
NewName == OldName,
|
||||||
"Reltool and .rel release names do not match~n", []),
|
"Reltool and .rel release names do not match~n", []),
|
||||||
|
|
||||||
%% Get lists of the old and new app files
|
|
||||||
OldAppFiles = filelib:wildcard(
|
|
||||||
filename:join([OldVerPath, "lib", "*", "ebin", "*.app"])),
|
|
||||||
NewAppFiles = filelib:wildcard(
|
|
||||||
filename:join([NewName, "lib", "*", "ebin", "*.app"])),
|
|
||||||
|
|
||||||
%% Find all the apps that have been upgraded
|
%% Find all the apps that have been upgraded
|
||||||
UpgradedApps = get_upgraded_apps(OldAppFiles, NewAppFiles),
|
UpgradedApps = get_upgraded_apps(Name, OldVerPath, NewVerPath),
|
||||||
|
|
||||||
%% Get a list of any appup files that exist in the new release
|
%% Get a list of any appup files that exist in the new release
|
||||||
NewAppUpFiles = rebar_utils:find_files(
|
NewAppUpFiles = rebar_utils:find_files(
|
||||||
|
@ -85,18 +79,24 @@
|
||||||
%% Internal functions
|
%% Internal functions
|
||||||
%% ===================================================================
|
%% ===================================================================
|
||||||
|
|
||||||
get_upgraded_apps(OldAppFiles, NewAppFiles) ->
|
get_upgraded_apps(Name, OldVerPath, NewVerPath) ->
|
||||||
OldAppsVer = [{rebar_app_utils:app_name(AppFile),
|
OldApps = rebar_rel_utils:get_rel_apps(Name, OldVerPath),
|
||||||
rebar_app_utils:app_vsn(AppFile)} || AppFile <- OldAppFiles],
|
NewApps = rebar_rel_utils:get_rel_apps(Name, NewVerPath),
|
||||||
NewAppsVer = [{rebar_app_utils:app_name(AppFile),
|
|
||||||
rebar_app_utils:app_vsn(AppFile)} || AppFile <- NewAppFiles],
|
Sorted = lists:umerge(lists:sort(NewApps), lists:sort(OldApps)),
|
||||||
UpgradedApps = lists:subtract(NewAppsVer, OldAppsVer),
|
AddedorChanged = lists:subtract(Sorted, OldApps),
|
||||||
lists:map(
|
DeletedorChanged = lists:subtract(Sorted, NewApps),
|
||||||
fun({App, NewVer}) ->
|
?DEBUG("Added or Changed: ~p~n", [AddedorChanged]),
|
||||||
{App, OldVer} = proplists:lookup(App, OldAppsVer),
|
?DEBUG("Deleted or Changed: ~p~n", [DeletedorChanged]),
|
||||||
{App, {OldVer, NewVer}}
|
|
||||||
end,
|
AddedDeletedChanged = lists:ukeysort(1, lists:append(DeletedorChanged,
|
||||||
UpgradedApps).
|
AddedorChanged)),
|
||||||
|
UpgradedApps = lists:subtract(AddedorChanged, AddedDeletedChanged),
|
||||||
|
?DEBUG("Upgraded Apps:~p~n", [UpgradedApps]),
|
||||||
|
|
||||||
|
[{AppName, {proplists:get_value(AppName, OldApps), NewVer}}
|
||||||
|
|| {AppName, NewVer} <- UpgradedApps].
|
||||||
|
|
||||||
|
|
||||||
file_to_name(File) ->
|
file_to_name(File) ->
|
||||||
filename:rootname(filename:basename(File)).
|
filename:rootname(filename:basename(File)).
|
||||||
|
|
|
@ -31,7 +31,10 @@
|
||||||
get_reltool_release_info/1,
|
get_reltool_release_info/1,
|
||||||
get_rel_release_info/1,
|
get_rel_release_info/1,
|
||||||
get_rel_release_info/2,
|
get_rel_release_info/2,
|
||||||
get_previous_release_path/0]).
|
get_rel_apps/1,
|
||||||
|
get_rel_apps/2,
|
||||||
|
get_previous_release_path/0,
|
||||||
|
get_rel_file_path/2]).
|
||||||
|
|
||||||
-include("rebar.hrl").
|
-include("rebar.hrl").
|
||||||
|
|
||||||
|
@ -70,11 +73,29 @@ get_rel_release_info(RelFile) ->
|
||||||
|
|
||||||
%% Get release name and version from a name and a path
|
%% Get release name and version from a name and a path
|
||||||
get_rel_release_info(Name, Path) ->
|
get_rel_release_info(Name, Path) ->
|
||||||
|
RelPath = get_rel_file_path(Name, Path),
|
||||||
|
get_rel_release_info(RelPath).
|
||||||
|
|
||||||
|
%% Get list of apps included in a release from a rel file
|
||||||
|
get_rel_apps(RelFile) ->
|
||||||
|
case file:consult(RelFile) of
|
||||||
|
{ok, [{release, _, _, Apps}]} ->
|
||||||
|
Apps;
|
||||||
|
_ ->
|
||||||
|
?ABORT("Failed to parse ~s~n", [RelFile])
|
||||||
|
end.
|
||||||
|
|
||||||
|
%% Get list of apps included in a release from a name and a path
|
||||||
|
get_rel_apps(Name, Path) ->
|
||||||
|
RelPath = get_rel_file_path(Name, Path),
|
||||||
|
get_rel_apps(RelPath).
|
||||||
|
|
||||||
|
%% Get rel file path from name and path
|
||||||
|
get_rel_file_path(Name, Path) ->
|
||||||
[RelFile] = filelib:wildcard(filename:join([Path, "releases", "*",
|
[RelFile] = filelib:wildcard(filename:join([Path, "releases", "*",
|
||||||
Name ++ ".rel"])),
|
Name ++ ".rel"])),
|
||||||
[BinDir|_] = re:replace(RelFile, Name ++ "\\.rel", ""),
|
[BinDir|_] = re:replace(RelFile, Name ++ "\\.rel", ""),
|
||||||
get_rel_release_info(filename:join([binary_to_list(BinDir),
|
filename:join([binary_to_list(BinDir), Name ++ ".rel"]).
|
||||||
Name ++ ".rel"])).
|
|
||||||
|
|
||||||
%% Get the previous release path from a global variable
|
%% Get the previous release path from a global variable
|
||||||
get_previous_release_path() ->
|
get_previous_release_path() ->
|
||||||
|
|
Loading…
Reference in a new issue