author | wenzelm |
Thu, 24 May 2012 23:13:06 +0200 | |
changeset 47996 | 25b9f59ab1b9 |
parent 47679 | 93e0dada1266 |
child 47997 | 0a43fc778cd2 |
permissions | -rw-r--r-- |
31499 | 1 |
/* Title: Pure/System/cygwin.scala |
45673
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
wenzelm
parents:
45667
diff
changeset
|
2 |
Module: PIDE |
31499 | 3 |
Author: Makarius |
4 |
||
5 |
Accessing the Cygwin installation. |
|
6 |
*/ |
|
7 |
||
8 |
package isabelle |
|
9 |
||
43520
cec9b95fa35d
explicit import java.lang.System to prevent odd scope problems;
wenzelm
parents:
41333
diff
changeset
|
10 |
import java.lang.System |
31826 | 11 |
import java.io.File |
34219 | 12 |
import java.net.URL |
13 |
import java.awt.Component |
|
31499 | 14 |
|
15 |
||
16 |
object Cygwin |
|
17 |
{ |
|
18 |
/* Cygwin installation */ |
|
19 |
||
34220 | 20 |
private def sanity_check(root: File) |
21 |
{ |
|
22 |
if (!new File(root, "bin\\bash.exe").isFile || |
|
23 |
!new File(root, "bin\\env.exe").isFile || |
|
24 |
!new File(root, "bin\\tar.exe").isFile) |
|
25 |
error("Bad Cygwin installation: " + root.toString) |
|
26 |
} |
|
27 |
||
34045
bc71778a327d
simplified Cygwin setup, assuming 1.7 registry layout (version 1.5 suffers from upcaseenv problem anyway);
wenzelm
parents:
34043
diff
changeset
|
28 |
def check_root(): String = |
31826 | 29 |
{ |
47996
25b9f59ab1b9
simplified Cygwin root: warm start via env, cold start via property, no registry magic;
wenzelm
parents:
47679
diff
changeset
|
30 |
val cygwin_root1 = System.getenv("CYGWIN_ROOT") |
25b9f59ab1b9
simplified Cygwin root: warm start via env, cold start via property, no registry magic;
wenzelm
parents:
47679
diff
changeset
|
31 |
val cygwin_root2 = System.getProperty("cygwin.root") |
34045
bc71778a327d
simplified Cygwin setup, assuming 1.7 registry layout (version 1.5 suffers from upcaseenv problem anyway);
wenzelm
parents:
34043
diff
changeset
|
32 |
val root = |
47996
25b9f59ab1b9
simplified Cygwin root: warm start via env, cold start via property, no registry magic;
wenzelm
parents:
47679
diff
changeset
|
33 |
if (cygwin_root1 != null && cygwin_root1 != "") cygwin_root1 |
25b9f59ab1b9
simplified Cygwin root: warm start via env, cold start via property, no registry magic;
wenzelm
parents:
47679
diff
changeset
|
34 |
else if (cygwin_root2 != null && cygwin_root2 != "") cygwin_root2 |
25b9f59ab1b9
simplified Cygwin root: warm start via env, cold start via property, no registry magic;
wenzelm
parents:
47679
diff
changeset
|
35 |
else error("Bad Cygwin installation: unknown root") |
34220 | 36 |
sanity_check(new File(root)) |
34045
bc71778a327d
simplified Cygwin setup, assuming 1.7 registry layout (version 1.5 suffers from upcaseenv problem anyway);
wenzelm
parents:
34043
diff
changeset
|
37 |
root |
31826 | 38 |
} |
34203 | 39 |
|
34219 | 40 |
def setup(parent: Component, root: File) |
34203 | 41 |
{ |
34258 | 42 |
if (!root.isDirectory && !root.mkdirs) error("Failed to create root directory: " + root) |
34219 | 43 |
|
44 |
val download = new File(root, "download") |
|
45 |
if (!download.mkdir) error("Failed to create download directory: " + download) |
|
46 |
||
47 |
val setup_exe = new File(root, "setup.exe") |
|
34220 | 48 |
|
39703 | 49 |
try { |
50 |
Download.file(parent, "Downloading", new URL("http://www.cygwin.com/setup.exe"), setup_exe) |
|
51 |
} |
|
43650 | 52 |
catch { case ERROR(_) => error("Failed to download Cygwin setup program") } |
34219 | 53 |
|
34258 | 54 |
val (_, rc) = Standard_System.raw_exec(root, null, true, |
55 |
setup_exe.toString, "-R", root.toString, "-l", download.toString, |
|
41333 | 56 |
"-P", "libgmp3,make,perl,python", "-q", "-n") |
34219 | 57 |
if (rc != 0) error("Cygwin setup failed!") |
34220 | 58 |
|
59 |
sanity_check(root) |
|
34203 | 60 |
} |
31499 | 61 |
} |
62 |