aboutsummaryrefslogtreecommitdiff
path: root/lang/sml-nj-devel/files/do-patch-src::system::smlnj::installer::libinstall.sml
blob: 1ffa5bd5647e18aa65633e964754ee460a41fcbb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
--- src/system/smlnj/installer/libinstall.sml.orig	Tue Jul 13 20:49:54 2004
+++ src/system/smlnj/installer/libinstall.sml	Thu Aug 12 01:23:08 2004
@@ -78,9 +78,40 @@
     fun mkdir "" = ()
       | mkdir d = if fexists d then () else (mkdir (P.dir d); F.mkDir d)
 
+    (* hack for cross-device moves *)
+    val move = if isUnix
+	then fn args as { old : string, new : string } =>
+		let val xdev_exnName = "SysErr\000"
+		    val xdev_exnMessage_substring = "xdev"
+		in F.rename args
+		   handle exn =>
+			if exnName exn = xdev_exnName
+			then if String.isSubstring xdev_exnMessage_substring
+						   (exnMessage exn)
+			     then if OS.Process.system
+					("mv '" ^ old ^ "' '" ^ new ^ "'")
+				     = OS.Process.success
+				  then print ("(* cross device mv of \"" ^ old
+						^ "\" to \"" ^ new
+						^ "\" done. *)\n")
+				  else fail ["move: mv " ^ old ^ " " ^ new
+						 ^ " failed.\n"]
+			      else ( print ("(* move: \""
+						^ xdev_exnMessage_substring
+						^ "\" not found in \""
+						^ (exnMessage exn)
+						^ "\". *)\n") ;
+				     raise exn )
+			else ( print ("(* move: \"" ^ xdev_exnName
+					^ "\" != \""
+					^ (exnName exn) ^ "\". *)\n") ;
+			       raise exn )
+		end
+	else F.rename
+
     (* move a stable library file to its final location *)
     fun movelib src dst () =
-	(mkdir (P.dir dst); F.rename { old = src, new = dst })
+	(mkdir (P.dir dst); move { old = src, new = dst })
 
     (* register a temporary anchor-value binding *)
     fun localanchor { anchor, path } =
@@ -325,7 +356,7 @@
 		 F.chDir treedir;
 		 if OS.Process.system buildcmd = OS.Process.success then
 		     if fexists targetheaploc then
-			 (F.rename { old = targetheaploc,
+			 (move { old = targetheaploc,
 				     new = finalheaploc };
 			  instcmd target;
 			  #set (CM.Anchor.anchor target) (SOME bindir))