author | wenzelm |
Thu, 15 Jun 2023 14:28:17 +0200 | |
changeset 78158 | 8b5a2e4b16d4 |
parent 77794 | 89e4971df810 |
child 78299 | 337ef5cdb70c |
permissions | -rw-r--r-- |
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
76553
diff
changeset
|
1 |
/* Title: Pure/Admin/component_cygwin.scala |
65071 | 2 |
Author: Makarius |
3 |
||
4 |
Produce pre-canned Cygwin distribution for Isabelle. |
|
5 |
*/ |
|
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
76553
diff
changeset
|
10 |
object Component_Cygwin { |
76028 | 11 |
val default_mirror: String = "https://isabelle.sketis.net/cygwin_2022" |
65071 | 12 |
|
77794 | 13 |
val packages: List[String] = List("curl", "libgmp-devel", "nano", "openssh") |
65071 | 14 |
|
76526
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
15 |
def build_cygwin( |
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
16 |
target_dir: Path = Path.current, |
65071 | 17 |
mirror: String = default_mirror, |
76526
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
18 |
more_packages: List[String] = Nil, |
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
19 |
progress: Progress = new Progress |
75393 | 20 |
): Unit = { |
73120
c3589f2dff31
more informative errors: simplify diagnosis of spurious failures reported by users;
wenzelm
parents:
72763
diff
changeset
|
21 |
require(Platform.is_windows, "Windows platform expected") |
65071 | 22 |
|
75394 | 23 |
Isabelle_System.with_tmp_dir("cygwin") { tmp_dir => |
65071 | 24 |
val cygwin = tmp_dir + Path.explode("cygwin") |
25 |
val cygwin_etc = cygwin + Path.explode("etc") |
|
72376 | 26 |
val cygwin_isabelle = Isabelle_System.make_directory(cygwin + Path.explode("isabelle")) |
65071 | 27 |
|
66727 | 28 |
val cygwin_exe_name = mirror + "/setup-x86_64.exe" |
65071 | 29 |
val cygwin_exe = cygwin_isabelle + Path.explode("cygwin.exe") |
30 |
Bytes.write(cygwin_exe, |
|
77717 | 31 |
try { Bytes.read_url(cygwin_exe_name) } |
65071 | 32 |
catch { case ERROR(_) => error("Failed to download " + quote(cygwin_exe_name)) }) |
33 |
||
68374
8740e1241555
updated to current Cygwin, after 2.10.0-1 from 02-Feb-2018;
wenzelm
parents:
66727
diff
changeset
|
34 |
File.write(cygwin_isabelle + Path.explode("cygwin_mirror"), mirror) |
8740e1241555
updated to current Cygwin, after 2.10.0-1 from 02-Feb-2018;
wenzelm
parents:
66727
diff
changeset
|
35 |
|
78158 | 36 |
File.set_executable(cygwin_exe) |
69405
22428643351f
more direct File.executable operation: avoid external process (on Unix);
wenzelm
parents:
69277
diff
changeset
|
37 |
Isabelle_System.bash(File.bash_path(cygwin_exe) + " -h </dev/null >/dev/null").check |
65071 | 38 |
|
39 |
val res = |
|
40 |
progress.bash( |
|
41 |
File.bash_path(cygwin_exe) + " --site " + Bash.string(mirror) + " --no-verify" + |
|
42 |
" --local-package-dir 'C:\\temp'" + |
|
72036 | 43 |
" --root " + File.bash_platform_path(cygwin) + |
65071 | 44 |
" --packages " + quote((packages ::: more_packages).mkString(",")) + |
45 |
" --no-shortcuts --no-startmenu --no-desktop --quiet-mode", |
|
46 |
echo = true) |
|
47 |
if (!res.ok || !cygwin_etc.is_dir) error("Failed") |
|
48 |
||
49 |
for (name <- List("hosts", "protocols", "services", "networks", "passwd", "group")) |
|
50 |
(cygwin_etc + Path.explode(name)).file.delete |
|
51 |
||
52 |
(cygwin + Path.explode("Cygwin.bat")).file.delete |
|
53 |
||
76526
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
54 |
val archive = |
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
55 |
target_dir + Path.explode("cygwin-" + Date.Format.alt_date(Date.now()) + ".tar.gz") |
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
56 |
Isabelle_System.gnutar("-czf " + File.bash_path(archive) + " cygwin", dir = tmp_dir).check |
75394 | 57 |
} |
65071 | 58 |
} |
59 |
||
60 |
||
61 |
/* Isabelle tool wrapper */ |
|
62 |
||
63 |
val isabelle_tool = |
|
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
76553
diff
changeset
|
64 |
Isabelle_Tool("component_cygwin", "produce pre-canned Cygwin distribution for Isabelle", |
75394 | 65 |
Scala_Project.here, |
66 |
{ args => |
|
76526
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
67 |
var target_dir = Path.current |
75394 | 68 |
var mirror = default_mirror |
69 |
var more_packages: List[String] = Nil |
|
65071 | 70 |
|
75394 | 71 |
val getopts = |
72 |
Getopts(""" |
|
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
76553
diff
changeset
|
73 |
Usage: isabelle component_cygwin [OPTIONS] |
65071 | 74 |
|
75 |
Options are: |
|
76526
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
76 |
-D DIR target directory (default ".") |
65071 | 77 |
-R MIRROR Cygwin mirror site (default """ + quote(default_mirror) + """) |
78 |
-p NAME additional Cygwin package |
|
79 |
||
80 |
Produce pre-canned Cygwin distribution for Isabelle: this requires |
|
81 |
Windows administrator mode. |
|
82 |
""", |
|
76526
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
83 |
"D:" -> (arg => target_dir = Path.explode(arg)), |
75394 | 84 |
"R:" -> (arg => mirror = arg), |
85 |
"p:" -> (arg => more_packages ::= arg)) |
|
65071 | 86 |
|
75394 | 87 |
val more_args = getopts(args) |
88 |
if (more_args.nonEmpty) getopts.usage() |
|
65071 | 89 |
|
76526
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
90 |
val progress = new Console_Progress() |
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
91 |
|
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
92 |
build_cygwin(target_dir = target_dir, mirror = mirror, more_packages = more_packages, |
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
93 |
progress = progress) |
75394 | 94 |
}) |
65071 | 95 |
} |