mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
Better org. of how upgraded apps are determined
get_apps/3 now returns which apps have been added, removed and ugpgraded in a reasonable way. It should prove more usable should we want to access any of those lists in future appup related changes.
This commit is contained in:
parent
1628879b21
commit
b7e20f3234
2 changed files with 49 additions and 17 deletions
|
@ -56,7 +56,7 @@
|
|||
"Reltool and .rel release names do not match~n", []),
|
||||
|
||||
%% Find all the apps that have been upgraded
|
||||
UpgradedApps = get_upgraded_apps(Name, OldVerPath, NewVerPath),
|
||||
{_Added, _Removed, Upgraded} = get_apps(Name, OldVerPath, NewVerPath),
|
||||
|
||||
%% Get a list of any appup files that exist in the new release
|
||||
NewAppUpFiles = rebar_utils:find_files(
|
||||
|
@ -68,10 +68,10 @@
|
|||
end, NewAppUpFiles),
|
||||
|
||||
%% Create a list of apps that don't already have appups
|
||||
Apps = genappup_which_apps(UpgradedApps, AppUpApps),
|
||||
UpgradeApps = genappup_which_apps(Upgraded, AppUpApps),
|
||||
|
||||
%% Generate appup files
|
||||
generate_appup_files(Name, OldVerPath, Apps),
|
||||
%% Generate appup files for upgraded apps
|
||||
generate_appup_files(Name, OldVerPath, UpgradeApps),
|
||||
|
||||
ok.
|
||||
|
||||
|
@ -79,24 +79,43 @@
|
|||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
get_upgraded_apps(Name, OldVerPath, NewVerPath) ->
|
||||
get_apps(Name, OldVerPath, NewVerPath) ->
|
||||
OldApps = rebar_rel_utils:get_rel_apps(Name, OldVerPath),
|
||||
?DEBUG("Old Version Apps: ~p~n", [OldApps]),
|
||||
|
||||
NewApps = rebar_rel_utils:get_rel_apps(Name, NewVerPath),
|
||||
?DEBUG("New Version Apps: ~p~n", [NewApps]),
|
||||
|
||||
Sorted = lists:umerge(lists:sort(NewApps), lists:sort(OldApps)),
|
||||
AddedorChanged = lists:subtract(Sorted, OldApps),
|
||||
DeletedorChanged = lists:subtract(Sorted, NewApps),
|
||||
?DEBUG("Added or Changed: ~p~n", [AddedorChanged]),
|
||||
?DEBUG("Deleted or Changed: ~p~n", [DeletedorChanged]),
|
||||
Added = app_list_diff(NewApps, OldApps),
|
||||
?DEBUG("Added: ~p~n", [Added]),
|
||||
|
||||
AddedDeletedChanged = lists:ukeysort(1, lists:append(DeletedorChanged,
|
||||
AddedorChanged)),
|
||||
UpgradedApps = lists:subtract(AddedorChanged, AddedDeletedChanged),
|
||||
?DEBUG("Upgraded Apps:~p~n", [UpgradedApps]),
|
||||
Removed = app_list_diff(OldApps, NewApps),
|
||||
?DEBUG("Removed: ~p~n", [Removed]),
|
||||
|
||||
[{AppName, {proplists:get_value(AppName, OldApps), NewVer}}
|
||||
|| {AppName, NewVer} <- UpgradedApps].
|
||||
PossiblyUpgraded = proplists:get_keys(NewApps),
|
||||
|
||||
UpgradedApps = [upgraded_app(AppName,
|
||||
proplists:get_value(AppName, OldApps),
|
||||
proplists:get_value(AppName, NewApps))
|
||||
|| AppName <- PossiblyUpgraded],
|
||||
|
||||
Upgraded = lists:dropwhile(fun(Elem) ->
|
||||
Elem == false
|
||||
end, lists:sort(UpgradedApps)),
|
||||
|
||||
?DEBUG("Upgraded: ~p~n", [Upgraded]),
|
||||
|
||||
{Added, Removed, Upgraded}.
|
||||
|
||||
upgraded_app(AppName, OldAppVer, NewAppVer) when OldAppVer /= NewAppVer ->
|
||||
{AppName, {OldAppVer, NewAppVer}};
|
||||
upgraded_app(_, _, _) ->
|
||||
false.
|
||||
|
||||
app_list_diff(List1, List2) ->
|
||||
List3 = lists:umerge(lists:sort(proplists:get_keys(List1)),
|
||||
lists:sort(proplists:get_keys(List2))),
|
||||
lists:subtract(List3, proplists:get_keys(List2)).
|
||||
|
||||
file_to_name(File) ->
|
||||
filename:rootname(filename:basename(File)).
|
||||
|
|
|
@ -80,7 +80,7 @@ get_rel_release_info(Name, Path) ->
|
|||
get_rel_apps(RelFile) ->
|
||||
case file:consult(RelFile) of
|
||||
{ok, [{release, _, _, Apps}]} ->
|
||||
Apps;
|
||||
make_proplist(Apps, []);
|
||||
_ ->
|
||||
?ABORT("Failed to parse ~s~n", [RelFile])
|
||||
end.
|
||||
|
@ -106,3 +106,16 @@ get_previous_release_path() ->
|
|||
OldVerPath ->
|
||||
OldVerPath
|
||||
end.
|
||||
|
||||
%% ===================================================================
|
||||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
make_proplist([{_,_}=H|T], Acc) ->
|
||||
make_proplist(T, [H|Acc]);
|
||||
make_proplist([H|T], Acc) ->
|
||||
App = erlang:element(1, H),
|
||||
Ver = erlang:element(2, H),
|
||||
make_proplist(T, [{App,Ver}|Acc]);
|
||||
make_proplist([], Acc) ->
|
||||
Acc.
|
||||
|
|
Loading…
Reference in a new issue