author | wenzelm |
Thu, 06 Dec 2018 14:25:27 +0100 | |
changeset 69410 | c071fcec4323 |
parent 69401 | 7a1b7b737c02 |
child 69413 | 52727566c1ba |
permissions | -rw-r--r-- |
69395 | 1 |
/* Title: Pure/Admin/components.scala |
2 |
Author: Makarius |
|
3 |
||
4 |
Isabelle system components. |
|
5 |
*/ |
|
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
69401
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
10 |
import java.io.{File => JFile} |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
11 |
|
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
12 |
|
69395 | 13 |
object Components |
14 |
{ |
|
15 |
/* component collections */ |
|
16 |
||
17 |
def admin(dir: Path): Path = dir + Path.explode("Admin/components") |
|
18 |
||
19 |
def contrib(dir: Path = Path.current, name: String = ""): Path = |
|
20 |
dir + Path.explode("contrib") + Path.explode(name) |
|
21 |
||
69401
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
22 |
def resolve(base_dir: Path, names: List[String], |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
23 |
target_dir: Option[Path] = None, |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
24 |
progress: Progress = No_Progress) |
69398
0698ded5caf1
Components.download similar to "isabelle components", but without unpacking;
wenzelm
parents:
69395
diff
changeset
|
25 |
{ |
69401
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
26 |
Isabelle_System.mkdirs(base_dir) |
69398
0698ded5caf1
Components.download similar to "isabelle components", but without unpacking;
wenzelm
parents:
69395
diff
changeset
|
27 |
for (name <- names) { |
69401
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
28 |
val archive_name = name + ".tar.gz" |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
29 |
val archive = base_dir + Path.explode(archive_name) |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
30 |
if (!archive.is_file) { |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
31 |
val remote = Isabelle_System.getenv("ISABELLE_COMPONENT_REPOSITORY") + "/" + archive_name |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
32 |
progress.echo("Getting " + remote) |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
33 |
Bytes.write(archive, Url.read_bytes(Url(remote))) |
69398
0698ded5caf1
Components.download similar to "isabelle components", but without unpacking;
wenzelm
parents:
69395
diff
changeset
|
34 |
} |
69401
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
35 |
progress.echo("Unpacking " + archive_name) |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
36 |
Isabelle_System.gnutar( |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
37 |
"-C " + File.bash_path(target_dir getOrElse base_dir) + |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
38 |
" -xzf " + File.bash_path(archive)).check |
69398
0698ded5caf1
Components.download similar to "isabelle components", but without unpacking;
wenzelm
parents:
69395
diff
changeset
|
39 |
} |
0698ded5caf1
Components.download similar to "isabelle components", but without unpacking;
wenzelm
parents:
69395
diff
changeset
|
40 |
} |
0698ded5caf1
Components.download similar to "isabelle components", but without unpacking;
wenzelm
parents:
69395
diff
changeset
|
41 |
|
69410 | 42 |
def purge(dir: Path, platform: Platform.Family.Value) |
69401
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
43 |
{ |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
44 |
def purge_platforms(platforms: String*): Set[String] = |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
45 |
platforms.flatMap(name => List("x86-" + name, "x86_64-" + name)).toSet + "ppc-darwin" |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
46 |
val purge_set = |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
47 |
platform match { |
69410 | 48 |
case Platform.Family.linux => purge_platforms("darwin", "cygwin", "windows") |
49 |
case Platform.Family.macos => purge_platforms("linux", "cygwin", "windows") |
|
50 |
case Platform.Family.windows => purge_platforms("linux", "darwin") |
|
69401
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
51 |
} |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
52 |
|
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
53 |
File.find_files(dir.file, |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
54 |
(file: JFile) => file.isDirectory && purge_set(file.getName), |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
55 |
include_dirs = true).foreach(Isabelle_System.rm_tree) |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
56 |
} |
7a1b7b737c02
eliminated old makedist_bundle and remote_dmg: build_release does everything in Scala;
wenzelm
parents:
69398
diff
changeset
|
57 |
|
69395 | 58 |
|
59 |
/* component directory content */ |
|
60 |
||
61 |
def settings(dir: Path): Path = dir + Path.explode("etc/settings") |
|
62 |
def components(dir: Path): Path = dir + Path.explode("etc/components") |
|
63 |
||
64 |
def check_dir(dir: Path): Boolean = |
|
65 |
settings(dir).is_file || components(dir).is_file |
|
66 |
||
67 |
def read_components(dir: Path): List[String] = |
|
68 |
split_lines(File.read(components(dir))).filter(_.nonEmpty) |
|
69 |
||
70 |
def write_components(dir: Path, lines: List[String]): Unit = |
|
71 |
File.write(components(dir), terminate_lines(lines)) |
|
72 |
} |