summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatt Campbell <matthew.campbell@asolutions.com>2011-12-29 14:28:03 -0600
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2012-01-09 12:33:39 +0100
commitc15d99d8bb5f2889e3b1d9f81dc3efbdc6a1e821 (patch)
treee13b8a20e32da55ec975d7941599e0071508dce7 /src
parent816d1805d54504b6b82600b3a8c3d920e4b3a39f (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/rebar_upgrade.erl22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/rebar_upgrade.erl b/src/rebar_upgrade.erl
index 8666fe5..3c63a6c 100644
--- a/src/rebar_upgrade.erl
+++ b/src/rebar_upgrade.erl
@@ -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", []),