On windows, avoid symlink during upgrade

a) make_symlink throws "not supported" on OS < Vista (e.g. 2003)
b) tarball creation stores windows symlinks as absolute paths
   instead of relative, causing service to fail to start after upgrade
   is made permanent.
This commit is contained in:
Matt Campbell 2011-12-29 14:28:03 -06:00 committed by Tuncer Ayaz
parent 816d1805d5
commit c15d99d8bb

View file

@ -64,7 +64,7 @@
{ok, _} = boot_files(TargetDir, NewVer, NewName),
%% Extract upgrade and tar it back up with changes
make_tar(NameVer),
make_tar(NameVer, NewVer, NewName),
%% Clean up files that systools created
ok = cleanup(NameVer),
@ -149,9 +149,14 @@ boot_files(TargetDir, Ver, Name) ->
ok = file:make_dir(filename:join([".", ?TMP])),
ok = file:make_dir(filename:join([".", ?TMP, "releases"])),
ok = file:make_dir(filename:join([".", ?TMP, "releases", Ver])),
ok = file:make_symlink(
filename:join(["start.boot"]),
filename:join([".", ?TMP, "releases", Ver, Name ++ ".boot"])),
case os:type() of
{win32,_} ->
ok;
_ ->
ok = file:make_symlink(
filename:join(["start.boot"]),
filename:join([".", ?TMP, "releases", Ver, Name ++ ".boot"]))
end,
{ok, _} =
file:copy(
filename:join([TargetDir, "releases", Ver, "start_clean.boot"]),
@ -165,13 +170,20 @@ boot_files(TargetDir, Ver, Name) ->
filename:join([TargetDir, "releases", Ver, "vm.args"]),
filename:join([".", ?TMP, "releases", Ver, "vm.args"])).
make_tar(NameVer) ->
make_tar(NameVer, NewVer, NewName) ->
Filename = NameVer ++ ".tar.gz",
{ok, Cwd} = file:get_cwd(),
Absname = filename:join([Cwd, Filename]),
ok = file:set_cwd(?TMP),
ok = erl_tar:extract(Absname, [compressed]),
ok = file:delete(Absname),
case os:type() of
{win32,_} ->
{ok, _} = file:copy(
filename:join([".", "releases", NewVer, "start.boot"]),
filename:join([".", "releases", NewVer, NewName ++ ".boot"]));
_ -> ok
end,
{ok, Tar} = erl_tar:open(Absname, [write, compressed]),
ok = erl_tar:add(Tar, "lib", []),
ok = erl_tar:add(Tar, "releases", []),