65071
|
1 |
/* Title: Pure/Admin/build_cygwin.scala
|
|
2 |
Author: Makarius
|
|
3 |
|
|
4 |
Produce pre-canned Cygwin distribution for Isabelle.
|
|
5 |
*/
|
|
6 |
|
|
7 |
package isabelle
|
|
8 |
|
|
9 |
|
|
10 |
object Build_Cygwin
|
|
11 |
{
|
|
12 |
val default_mirror: String = "http://isabelle.in.tum.de/cygwin_2016-1"
|
|
13 |
|
|
14 |
val packages: List[String] =
|
|
15 |
List("curl", "nano", "perl", "perl-libwww-perl", "rlwrap", "unzip")
|
|
16 |
|
|
17 |
def build_cygwin(progress: Progress,
|
|
18 |
mirror: String = default_mirror,
|
|
19 |
more_packages: List[String] = Nil)
|
|
20 |
{
|
|
21 |
require(Platform.is_windows)
|
|
22 |
|
|
23 |
Isabelle_System.with_tmp_dir("cygwin")(tmp_dir =>
|
|
24 |
{
|
|
25 |
val cygwin = tmp_dir + Path.explode("cygwin")
|
|
26 |
val cygwin_etc = cygwin + Path.explode("etc")
|
|
27 |
val cygwin_isabelle = cygwin + Path.explode("isabelle")
|
|
28 |
Isabelle_System.mkdirs(cygwin_isabelle)
|
|
29 |
|
|
30 |
val cygwin_exe_name = mirror + "/setup-x86.exe"
|
|
31 |
val cygwin_exe = cygwin_isabelle + Path.explode("cygwin.exe")
|
|
32 |
Bytes.write(cygwin_exe,
|
|
33 |
try { Bytes.read(Url(cygwin_exe_name)) }
|
|
34 |
catch { case ERROR(_) => error("Failed to download " + quote(cygwin_exe_name)) })
|
|
35 |
|
|
36 |
Isabelle_System.bash(
|
|
37 |
"chmod +x " + File.bash_path(cygwin_exe) + " && " +
|
|
38 |
File.bash_path(cygwin_exe) + " -h </dev/null >/dev/null").check
|
|
39 |
|
|
40 |
val res =
|
|
41 |
progress.bash(
|
|
42 |
File.bash_path(cygwin_exe) + " --site " + Bash.string(mirror) + " --no-verify" +
|
|
43 |
" --local-package-dir 'C:\\temp'" +
|
|
44 |
" --root " + Bash.string(File.platform_path(cygwin)) +
|
|
45 |
" --packages " + quote((packages ::: more_packages).mkString(",")) +
|
|
46 |
" --no-shortcuts --no-startmenu --no-desktop --quiet-mode",
|
|
47 |
echo = true)
|
|
48 |
if (!res.ok || !cygwin_etc.is_dir) error("Failed")
|
|
49 |
|
|
50 |
for (name <- List("hosts", "protocols", "services", "networks", "passwd", "group"))
|
|
51 |
(cygwin_etc + Path.explode(name)).file.delete
|
|
52 |
|
|
53 |
(cygwin + Path.explode("Cygwin.bat")).file.delete
|
|
54 |
|
|
55 |
val archive = "cygwin-" + Date.Format("uuuuMMdd")(Date.now()) + ".tar.gz"
|
|
56 |
Isabelle_System.gnutar("-C " + File.bash_path(tmp_dir) +
|
|
57 |
" -czf " + Bash.string(archive) + " cygwin").check
|
|
58 |
})
|
|
59 |
}
|
|
60 |
|
|
61 |
|
|
62 |
/* Isabelle tool wrapper */
|
|
63 |
|
|
64 |
val isabelle_tool =
|
|
65 |
Isabelle_Tool("build_cygwin", "produce pre-canned Cygwin distribution for Isabelle", args =>
|
|
66 |
{
|
|
67 |
var mirror = default_mirror
|
|
68 |
var more_packages: List[String] = Nil
|
|
69 |
|
|
70 |
val getopts =
|
|
71 |
Getopts("""
|
|
72 |
Usage: isabelle build_cygwin [OPTIONS]
|
|
73 |
|
|
74 |
Options are:
|
|
75 |
-R MIRROR Cygwin mirror site (default """ + quote(default_mirror) + """)
|
|
76 |
-p NAME additional Cygwin package
|
|
77 |
|
|
78 |
Produce pre-canned Cygwin distribution for Isabelle: this requires
|
|
79 |
Windows administrator mode.
|
|
80 |
""",
|
|
81 |
"R:" -> (arg => mirror = arg),
|
|
82 |
"p:" -> (arg => more_packages ::= arg))
|
|
83 |
|
|
84 |
val more_args = getopts(args)
|
|
85 |
if (more_args.nonEmpty) getopts.usage()
|
|
86 |
|
|
87 |
build_cygwin(new Console_Progress(), mirror = mirror, more_packages = more_packages)
|
|
88 |
}, admin = true)
|
|
89 |
}
|