diff options
author | Alexey Romanov <alexey.v.romanov@gmail.com> | 2011-03-05 14:11:31 +0300 |
---|---|---|
committer | Alexey Romanov <alexey.v.romanov@gmail.com> | 2011-03-05 14:11:31 +0300 |
commit | 7c40d624dc344e534c7b576341463648091f56e8 (patch) | |
tree | 4b384980bd6fe327cdecf25c55a6dd2622cd8412 /src/rebar_appups.erl | |
parent | 48d23b90acb688a68354b20a1b19fa0aa0e592be (diff) | |
parent | 25c0226ab94560c5e182944c4c71b9f71ac3f08e (diff) |
Merge commit 'upstream/master'
Diffstat (limited to 'src/rebar_appups.erl')
-rw-r--r-- | src/rebar_appups.erl | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/rebar_appups.erl b/src/rebar_appups.erl index ab5af29..079d596 100644 --- a/src/rebar_appups.erl +++ b/src/rebar_appups.erl @@ -55,14 +55,8 @@ NewName == OldName, "Reltool and .rel release names do not match~n", []), - %% Get lists of the old and new app files - OldAppFiles = rebar_utils:find_files( - filename:join([OldVerPath, "lib"]), "^.*.app$"), - NewAppFiles = rebar_utils:find_files( - filename:join([NewName, "lib"]), "^.*.app$"), - %% 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 NewAppUpFiles = rebar_utils:find_files( @@ -85,18 +79,24 @@ %% Internal functions %% =================================================================== -get_upgraded_apps(OldAppFiles, NewAppFiles) -> - OldAppsVer = [{rebar_app_utils:app_name(AppFile), - rebar_app_utils:app_vsn(AppFile)} || AppFile <- OldAppFiles], - NewAppsVer = [{rebar_app_utils:app_name(AppFile), - rebar_app_utils:app_vsn(AppFile)} || AppFile <- NewAppFiles], - UpgradedApps = lists:subtract(NewAppsVer, OldAppsVer), - lists:map( - fun({App, NewVer}) -> - {App, OldVer} = proplists:lookup(App, OldAppsVer), - {App, {OldVer, NewVer}} - end, - UpgradedApps). +get_upgraded_apps(Name, OldVerPath, NewVerPath) -> + OldApps = rebar_rel_utils:get_rel_apps(Name, OldVerPath), + NewApps = rebar_rel_utils:get_rel_apps(Name, NewVerPath), + + 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]), + + AddedDeletedChanged = lists:ukeysort(1, lists:append(DeletedorChanged, + 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) -> filename:rootname(filename:basename(File)). |