aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2011-10-11 10:58:47 +0200
committerSiri Hansen <[email protected]>2011-11-17 16:47:28 +0100
commit1dec251ad333045847b75b8ee75d4bff4237108e (patch)
treef47bdea7e2e4017f51d38599686879230b6f3960 /lib
parent8a013f1f16fd4730c24839127afdf46f96a45b0b (diff)
downloadotp-1dec251ad333045847b75b8ee75d4bff4237108e.tar.gz
otp-1dec251ad333045847b75b8ee75d4bff4237108e.tar.bz2
otp-1dec251ad333045847b75b8ee75d4bff4237108e.zip
Upgrade erts: merge sys.config for tmp release instead of using old
The sys.config file used for the temporary release in an erts upgrade is now a hybrid where kernel, stdlib and sasl configuration is taken from the new release, and other configuration is taken from the old release. I.e. similar to how the temporary boot file is created.
Diffstat (limited to 'lib')
-rw-r--r--lib/sasl/src/release_handler.erl53
-rw-r--r--lib/sasl/src/systools_make.erl8
-rw-r--r--lib/sasl/test/systools_SUITE.erl10
3 files changed, 57 insertions, 14 deletions
diff --git a/lib/sasl/src/release_handler.erl b/lib/sasl/src/release_handler.erl
index 38aee9ecde..931347bde2 100644
--- a/lib/sasl/src/release_handler.erl
+++ b/lib/sasl/src/release_handler.erl
@@ -1049,10 +1049,9 @@ new_emulator_make_tmp_release(CurrentRelease,ToRelease,RelDir,Opts,Masters) ->
erts_vsn=ToRelease#release.erts_vsn,
libs = BaseLibs ++ RestLibs,
status = unpacked},
- new_emulator_make_boot_hybrid(CurrentVsn,ToVsn,TmpVsn,BaseLibs,
+ new_emulator_make_hybrid_boot(CurrentVsn,ToVsn,TmpVsn,BaseLibs,
RelDir,Opts,Masters),
- SysConfig = filename:join([RelDir,CurrentVsn,"sys.config"]),
- copy_file(SysConfig,filename:join(RelDir,TmpVsn),Masters),
+ new_emulator_make_hybrid_config(CurrentVsn,ToVsn,TmpVsn,RelDir,Masters),
{TmpVsn,TmpRelease}.
check_base_libs([_,_,_]=BaseLibs,_Vsn) ->
@@ -1069,7 +1068,7 @@ find_missing(SomeMissing,[H|T],Vsn) ->
throw({error,{missing_base_app,Vsn,H}})
end.
-new_emulator_make_boot_hybrid(CurrentVsn,ToVsn,TmpVsn,BaseLibs,RelDir,Opts,Masters) ->
+new_emulator_make_hybrid_boot(CurrentVsn,ToVsn,TmpVsn,BaseLibs,RelDir,Opts,Masters) ->
FromBootFile = filename:join([RelDir,CurrentVsn,"start.boot"]),
ToBootFile = filename:join([RelDir,ToVsn,"start.boot"]),
TmpBootFile = filename:join([RelDir,TmpVsn,"start.boot"]),
@@ -1080,13 +1079,57 @@ new_emulator_make_boot_hybrid(CurrentVsn,ToVsn,TmpVsn,BaseLibs,RelDir,Opts,Maste
[KernelPath,SaslPath,StdlibPath] =
[filename:join(Path,ebin) || {_,_,Path} <- lists:keysort(1,BaseLibs)],
Paths = {KernelPath,StdlibPath,SaslPath},
- case systools_make:make_boot_hybrid(TmpVsn,FromBoot,ToBoot,Paths,Args) of
+ case systools_make:make_hybrid_boot(TmpVsn,FromBoot,ToBoot,Paths,Args) of
{ok,TmpBoot} ->
write_file(TmpBootFile,TmpBoot,Masters);
{error,Reason} ->
throw({error,{could_not_create_hybrid_boot,Reason}})
end.
+new_emulator_make_hybrid_config(CurrentVsn,ToVsn,TmpVsn,RelDir,Masters) ->
+ FromFile = filename:join([RelDir,CurrentVsn,"sys.config"]),
+ ToFile = filename:join([RelDir,ToVsn,"sys.config"]),
+ TmpFile = filename:join([RelDir,TmpVsn,"sys.config"]),
+
+ FromConfig =
+ case consult(FromFile,Masters) of
+ {ok,[FC]} ->
+ FC;
+ {error,Error1} ->
+ io:format("Warning: ~p can not read ~p: ~p~n",
+ [?MODULE,FromFile,Error1]),
+ []
+ end,
+
+ [Kernel,Stdlib,Sasl] =
+ case consult(ToFile,Masters) of
+ {ok,[ToConfig]} ->
+ [lists:keyfind(App,1,ToConfig) || App <- [kernel,stdlib,sasl]];
+ {error,Error2} ->
+ io:format("Warning: ~p can not read ~p: ~p~n",
+ [?MODULE,ToFile,Error2]),
+ [false,false,false]
+ end,
+
+ Config1 = replace_config(kernel,FromConfig,Kernel),
+ Config2 = replace_config(stdlib,Config1,Stdlib),
+ Config3 = replace_config(sasl,Config2,Sasl),
+
+ ConfigStr = io_lib:format("~p.~n",[Config3]),
+ write_file(TmpFile,ConfigStr,Masters).
+
+%% Take the configuration for application App from the new config and
+%% insert in the old config.
+%% If no entry exists in the new config, then delete the entry (if it exists)
+%% from the old config.
+%% If entry exists in the new config, but not in the old config, then
+%% add the entry.
+replace_config(App,Config,false) ->
+ lists:keydelete(App,1,Config);
+replace_config(App,Config,AppConfig) ->
+ lists:keystore(App,1,Config,AppConfig).
+
+%% Remove all files related to the temporary release
new_emulator_rm_tmp_release(?tmp_vsn(_)=TmpVsn,RelDir,Releases,Masters) ->
remove_dir(filename:join(RelDir,TmpVsn),Masters),
lists:keydelete(TmpVsn,#release.vsn,Releases);
diff --git a/lib/sasl/src/systools_make.erl b/lib/sasl/src/systools_make.erl
index 42b528540e..33bd51ecbb 100644
--- a/lib/sasl/src/systools_make.erl
+++ b/lib/sasl/src/systools_make.erl
@@ -31,7 +31,7 @@
-export([read_application/4]).
--export([make_boot_hybrid/5]).
+-export([make_hybrid_boot/5]).
-import(lists, [filter/2, keysort/2, keysearch/3, map/2, reverse/1,
append/1, foldl/3, member/2, foreach/2]).
@@ -182,9 +182,9 @@ return({error,Mod,Error},_,Flags) ->
%% Boot1 = Boot2 = Boot = binary()
%% Reason = {app_not_found,App} | {app_not_replaced,App}
%% App = kernel | stdlib | sasl
-make_boot_hybrid(TmpVsn, Boot1, Boot2, Paths, Args) ->
- catch do_make_boot_hybrid(TmpVsn, Boot1, Boot2, Paths, Args).
-do_make_boot_hybrid(TmpVsn, Boot1, Boot2, Paths, Args) ->
+make_hybrid_boot(TmpVsn, Boot1, Boot2, Paths, Args) ->
+ catch do_make_hybrid_boot(TmpVsn, Boot1, Boot2, Paths, Args).
+do_make_hybrid_boot(TmpVsn, Boot1, Boot2, Paths, Args) ->
{script,{_RelName1,_RelVsn1},Script1} = binary_to_term(Boot1),
{script,{RelName2,_RelVsn2},Script2} = binary_to_term(Boot2),
MatchPaths = get_regexp_path(Paths),
diff --git a/lib/sasl/test/systools_SUITE.erl b/lib/sasl/test/systools_SUITE.erl
index 960ba3cc21..5b3abad219 100644
--- a/lib/sasl/test/systools_SUITE.erl
+++ b/lib/sasl/test/systools_SUITE.erl
@@ -1486,7 +1486,7 @@ normal_hybrid(Config) ->
?line ok = file:set_cwd(OldDir),
?line BasePaths = {"testkernelpath","teststdlibpath","testsaslpath"},
- ?line {ok,Hybrid} = systools_make:make_boot_hybrid("tmp_vsn",Boot1,Boot2,
+ ?line {ok,Hybrid} = systools_make:make_hybrid_boot("tmp_vsn",Boot1,Boot2,
BasePaths, [dummy,args]),
?line {script,{"Test release 4","tmp_vsn"},Script} = binary_to_term(Hybrid),
@@ -1560,7 +1560,7 @@ normal_hybrid(Config) ->
ok.
-%% Check that systools_make:make_boot_hybrid fails with a meaningful
+%% Check that systools_make:make_hybrid_boot fails with a meaningful
%% error message if the FromBoot does not include the sasl
%% application.
hybrid_no_old_sasl(Config) ->
@@ -1584,14 +1584,14 @@ hybrid_no_old_sasl(Config) ->
?line BasePaths = {"testkernelpath","teststdlibpath","testsaslpath"},
?line {error,{app_not_replaced,sasl}} =
- systools_make:make_boot_hybrid("tmp_vsn",Boot1,Boot2,
+ systools_make:make_hybrid_boot("tmp_vsn",Boot1,Boot2,
BasePaths,[dummy,args]),
?line ok = file:set_cwd(OldDir),
ok.
-%% Check that systools_make:make_boot_hybrid fails with a meaningful
+%% Check that systools_make:make_hybrid_boot fails with a meaningful
%% error message if the ToBoot does not include the sasl
%% application.
hybrid_no_new_sasl(Config) ->
@@ -1615,7 +1615,7 @@ hybrid_no_new_sasl(Config) ->
?line BasePaths = {"testkernelpath","teststdlibpath","testsaslpath"},
?line {error,{app_not_found,sasl}} =
- systools_make:make_boot_hybrid("tmp_vsn",Boot1,Boot2,
+ systools_make:make_hybrid_boot("tmp_vsn",Boot1,Boot2,
BasePaths,[dummy,args]),
?line ok = file:set_cwd(OldDir),