aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sasl/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sasl/src')
-rw-r--r--lib/sasl/src/systools_make.erl60
1 files changed, 36 insertions, 24 deletions
diff --git a/lib/sasl/src/systools_make.erl b/lib/sasl/src/systools_make.erl
index 12ba2a5476..3c1002e4a6 100644
--- a/lib/sasl/src/systools_make.erl
+++ b/lib/sasl/src/systools_make.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -375,7 +375,7 @@ get_release1(File, Path, ModTestP, Machine) ->
{ok, Release, Warnings1} = read_release(File, Path),
{ok, Appls0} = collect_applications(Release, Path),
{ok, Appls1} = check_applications(Appls0),
- {ok, Appls2} = sort_included_applications(Appls1, Release), % OTP-4121
+ {ok, Appls2} = sort_used_and_incl_appls(Appls1, Release), % OTP-4121, OTP-9984
{ok, Warnings2} = check_modules(Appls2, Path, ModTestP, Machine),
{ok, Appls} = sort_appls(Appls2),
{ok, Release, Appls, Warnings1 ++ Warnings2}.
@@ -842,34 +842,45 @@ undefined_applications(Appls) ->
filter(fun(X) -> not member(X, Defined) end, Uses).
%%______________________________________________________________________
-%% sort_included_applications(Applications, Release) -> Applications
+%% sort_used_and_incl_appls(Applications, Release) -> Applications
%% Applications = [{{Name,Vsn},#application}]
%% Release = #release{}
%%
-%% Check that included applications are given in the same order as in
-%% the release resource file (.rel). Otherwise load instructions in
-%% the boot script, and consequently release upgrade instructions in
-%% relup, may end up in the wrong order.
+%% OTP-4121, OTP-9984
+%% Check that used and included applications are given in the same
+%% order as in the release resource file (.rel). Otherwise load and
+%% start instructions in the boot script, and consequently release
+%% upgrade instructions in relup, may end up in the wrong order.
-sort_included_applications(Applications, Release) when is_tuple(Release) ->
+sort_used_and_incl_appls(Applications, Release) when is_tuple(Release) ->
{ok,
- sort_included_applications(Applications, Release#release.applications)};
-
-sort_included_applications([{Tuple,Appl}|Appls], OrderedAppls) ->
- case Appl#application.includes of
- Incls when length(Incls)>1 ->
- IndexedIncls = find_pos(Incls, OrderedAppls),
- SortedIndexedIncls = lists:keysort(1, IndexedIncls),
- Incls2 = lists:map(fun({_Index,Name}) -> Name end,
- SortedIndexedIncls),
- Appl2 = Appl#application{includes=Incls2},
- [{Tuple,Appl2}|sort_included_applications(Appls, OrderedAppls)];
- _Incls ->
- [{Tuple,Appl}|sort_included_applications(Appls, OrderedAppls)]
- end;
-sort_included_applications([], _OrderedAppls) ->
+ sort_used_and_incl_appls(Applications, Release#release.applications)};
+
+sort_used_and_incl_appls([{Tuple,Appl}|Appls], OrderedAppls) ->
+ Incls2 =
+ case Appl#application.includes of
+ Incls when length(Incls)>1 ->
+ sort_appl_list(Incls, OrderedAppls);
+ Incls ->
+ Incls
+ end,
+ Uses2 =
+ case Appl#application.uses of
+ Uses when length(Uses)>1 ->
+ sort_appl_list(Uses, OrderedAppls);
+ Uses ->
+ Uses
+ end,
+ Appl2 = Appl#application{includes=Incls2, uses=Uses2},
+ [{Tuple,Appl2}|sort_used_and_incl_appls(Appls, OrderedAppls)];
+sort_used_and_incl_appls([], _OrderedAppls) ->
[].
+sort_appl_list(List, Order) ->
+ IndexedList = find_pos(List, Order),
+ SortedIndexedList = lists:keysort(1, IndexedList),
+ lists:map(fun({_Index,Name}) -> Name end, SortedIndexedList).
+
find_pos([Name|Incs], OrderedAppls) ->
[find_pos(1, Name, OrderedAppls)|find_pos(Incs, OrderedAppls)];
find_pos([], _OrderedAppls) ->
@@ -1253,7 +1264,8 @@ sort_appls(Appls) -> {ok, sort_appls(Appls, [], [], [])}.
sort_appls([{N, A}|T], Missing, Circular, Visited) ->
{Name,_Vsn} = N,
- {Uses, T1, NotFnd1} = find_all(Name, A#application.uses, T, Visited, [], []),
+ {Uses, T1, NotFnd1} = find_all(Name, lists:reverse(A#application.uses),
+ T, Visited, [], []),
{Incs, T2, NotFnd2} = find_all(Name, lists:reverse(A#application.includes),
T1, Visited, [], []),
Missing1 = NotFnd1 ++ NotFnd2 ++ Missing,