author | wenzelm |
Tue, 07 Mar 2023 22:54:44 +0100 | |
changeset 77566 | 2a99fcb283ee |
parent 76553 | src/Pure/Admin/build_cygwin.scala@120f79cdb492 |
child 77717 | 6a2daddc238c |
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 |
|
13 |
val packages: List[String] = |
|
76553
120f79cdb492
discontinued "unzip" executable (see also eb96243a25c5 and 662de910a96b);
wenzelm
parents:
76526
diff
changeset
|
14 |
List("curl", "libgmp-devel", "nano", "openssh", "rsync") |
65071 | 15 |
|
76526
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
16 |
def build_cygwin( |
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
17 |
target_dir: Path = Path.current, |
65071 | 18 |
mirror: String = default_mirror, |
76526
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
19 |
more_packages: List[String] = Nil, |
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
20 |
progress: Progress = new Progress |
75393 | 21 |
): Unit = { |
73120
c3589f2dff31
more informative errors: simplify diagnosis of spurious failures reported by users;
wenzelm
parents:
72763
diff
changeset
|
22 |
require(Platform.is_windows, "Windows platform expected") |
65071 | 23 |
|
75394 | 24 |
Isabelle_System.with_tmp_dir("cygwin") { tmp_dir => |
65071 | 25 |
val cygwin = tmp_dir + Path.explode("cygwin") |
26 |
val cygwin_etc = cygwin + Path.explode("etc") |
|
72376 | 27 |
val cygwin_isabelle = Isabelle_System.make_directory(cygwin + Path.explode("isabelle")) |
65071 | 28 |
|
66727 | 29 |
val cygwin_exe_name = mirror + "/setup-x86_64.exe" |
65071 | 30 |
val cygwin_exe = cygwin_isabelle + Path.explode("cygwin.exe") |
31 |
Bytes.write(cygwin_exe, |
|
32 |
try { Bytes.read(Url(cygwin_exe_name)) } |
|
33 |
catch { case ERROR(_) => error("Failed to download " + quote(cygwin_exe_name)) }) |
|
34 |
||
68374
8740e1241555
updated to current Cygwin, after 2.10.0-1 from 02-Feb-2018;
wenzelm
parents:
66727
diff
changeset
|
35 |
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
|
36 |
|
69789
2c3e5e58d93f
more thorough File.set_executable, notably for Windows;
wenzelm
parents:
69425
diff
changeset
|
37 |
File.set_executable(cygwin_exe, true) |
69405
22428643351f
more direct File.executable operation: avoid external process (on Unix);
wenzelm
parents:
69277
diff
changeset
|
38 |
Isabelle_System.bash(File.bash_path(cygwin_exe) + " -h </dev/null >/dev/null").check |
65071 | 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'" + |
|
72036 | 44 |
" --root " + File.bash_platform_path(cygwin) + |
65071 | 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 |
||
76526
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
55 |
val archive = |
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
56 |
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
|
57 |
Isabelle_System.gnutar("-czf " + File.bash_path(archive) + " cygwin", dir = tmp_dir).check |
75394 | 58 |
} |
65071 | 59 |
} |
60 |
||
61 |
||
62 |
/* Isabelle tool wrapper */ |
|
63 |
||
64 |
val isabelle_tool = |
|
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
76553
diff
changeset
|
65 |
Isabelle_Tool("component_cygwin", "produce pre-canned Cygwin distribution for Isabelle", |
75394 | 66 |
Scala_Project.here, |
67 |
{ args => |
|
76526
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
68 |
var target_dir = Path.current |
75394 | 69 |
var mirror = default_mirror |
70 |
var more_packages: List[String] = Nil |
|
65071 | 71 |
|
75394 | 72 |
val getopts = |
73 |
Getopts(""" |
|
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
76553
diff
changeset
|
74 |
Usage: isabelle component_cygwin [OPTIONS] |
65071 | 75 |
|
76 |
Options are: |
|
76526
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
77 |
-D DIR target directory (default ".") |
65071 | 78 |
-R MIRROR Cygwin mirror site (default """ + quote(default_mirror) + """) |
79 |
-p NAME additional Cygwin package |
|
80 |
||
81 |
Produce pre-canned Cygwin distribution for Isabelle: this requires |
|
82 |
Windows administrator mode. |
|
83 |
""", |
|
76526
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
84 |
"D:" -> (arg => target_dir = Path.explode(arg)), |
75394 | 85 |
"R:" -> (arg => mirror = arg), |
86 |
"p:" -> (arg => more_packages ::= arg)) |
|
65071 | 87 |
|
75394 | 88 |
val more_args = getopts(args) |
89 |
if (more_args.nonEmpty) getopts.usage() |
|
65071 | 90 |
|
76526
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
91 |
val progress = new Console_Progress() |
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
92 |
|
33025e13dcdc
clarified command-line arguments: follow more recent isabelle build_XYZ;
wenzelm
parents:
76239
diff
changeset
|
93 |
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
|
94 |
progress = progress) |
75394 | 95 |
}) |
65071 | 96 |
} |