--- a/src/Pure/System/cygwin.scala Sat Jan 02 01:14:49 2010 +0100
+++ b/src/Pure/System/cygwin.scala Sat Jan 02 20:08:04 2010 +0100
@@ -81,6 +81,14 @@
private val CYGWIN_SETUP1 = "Software\\Cygwin\\setup"
private val CYGWIN_SETUP2 = "Software\\Wow6432Node\\Cygwin\\setup"
+ private def sanity_check(root: File)
+ {
+ if (!new File(root, "bin\\bash.exe").isFile ||
+ !new File(root, "bin\\env.exe").isFile ||
+ !new File(root, "bin\\tar.exe").isFile)
+ error("Bad Cygwin installation: " + root.toString)
+ }
+
def check_root(): String =
{
val root_env = java.lang.System.getenv("CYGWIN_ROOT")
@@ -90,14 +98,10 @@
query_registry(CYGWIN_SETUP1, "rootdir") orElse
query_registry(CYGWIN_SETUP2, "rootdir") getOrElse
error("Failed to determine Cygwin installation -- version 1.7 required")
- val ok =
- new File(root + "\\bin\\bash.exe").isFile &&
- new File(root + "\\bin\\env.exe").isFile
- if (!ok) error("Bad Cygwin installation: " + root)
+ sanity_check(new File(root))
root
}
- // FIXME error handling (dialogs)
def setup(parent: Component, root: File)
{
if (!root.mkdirs) error("Failed to create root directory: " + root)
@@ -106,14 +110,17 @@
if (!download.mkdir) error("Failed to create download directory: " + download)
val setup_exe = new File(root, "setup.exe")
- if (!Download.file(parent, new URL("http://www.cygwin.com/setup.exe"), setup_exe))
- error("Failed to download Cygwin setup program")
+
+ try { Download.file(parent, new URL("http://www.cygwin.com/setup.exe"), setup_exe) }
+ catch { case _: RuntimeException => error("Failed to download Cygwin setup program") }
val (_, rc) = Standard_System.process_output(
Standard_System.raw_execute(root, null, true,
setup_exe.toString, "-R", root.toString, "-l", download.toString,
"-P", "perl,python", "-q", "-n"))
if (rc != 0) error("Cygwin setup failed!")
+
+ sanity_check(root)
}
}