76396
|
1 |
/* Title: Pure/Admin/build_easychair.scala
|
|
2 |
Author: Makarius
|
|
3 |
|
76479
|
4 |
Build Isabelle component for Easychair LaTeX style.
|
76396
|
5 |
|
76398
|
6 |
See also https://easychair.org/publications/for_authors
|
76396
|
7 |
*/
|
|
8 |
|
|
9 |
package isabelle
|
|
10 |
|
|
11 |
|
|
12 |
object Build_Easychair {
|
|
13 |
/* build easychair component */
|
|
14 |
|
|
15 |
val default_url = "https://easychair.org/publications/easychair.zip"
|
|
16 |
|
|
17 |
def build_easychair(
|
|
18 |
download_url: String = default_url,
|
|
19 |
target_dir: Path = Path.current,
|
|
20 |
progress: Progress = new Progress
|
|
21 |
): Unit = {
|
|
22 |
Isabelle_System.with_tmp_file("download", ext = "zip") { download_file =>
|
|
23 |
Isabelle_System.with_tmp_dir("download") { download_dir =>
|
|
24 |
|
|
25 |
/* download */
|
|
26 |
|
|
27 |
Isabelle_System.download_file(download_url, download_file, progress = progress)
|
76530
|
28 |
Isabelle_System.extract(download_file, download_dir)
|
76396
|
29 |
|
76529
|
30 |
val easychair_dir = File.get_dir(download_dir, title = download_url)
|
76396
|
31 |
|
|
32 |
|
|
33 |
/* component */
|
|
34 |
|
|
35 |
val version =
|
|
36 |
Library.try_unprefix("EasyChair", easychair_dir.file_name)
|
|
37 |
.getOrElse("Failed to detect version from " + quote(easychair_dir.file_name))
|
|
38 |
|
|
39 |
val component = "easychair-" + version
|
76518
|
40 |
val component_dir =
|
76547
|
41 |
Components.Directory(target_dir + Path.basic(component)).create(progress = progress)
|
76396
|
42 |
|
76546
|
43 |
Isabelle_System.extract(download_file, component_dir.path, strip = true)
|
76396
|
44 |
|
|
45 |
|
|
46 |
/* settings */
|
|
47 |
|
76548
|
48 |
component_dir.write_settings("""
|
76396
|
49 |
ISABELLE_EASYCHAIR_HOME="$COMPONENT"
|
|
50 |
""")
|
|
51 |
|
|
52 |
|
|
53 |
/* README */
|
|
54 |
|
76518
|
55 |
File.write(component_dir.README,
|
76396
|
56 |
"""This is the Easychair style for authors from
|
|
57 |
""" + download_url + """
|
|
58 |
|
|
59 |
|
|
60 |
Makarius
|
|
61 |
""" + Date.Format.date(Date.now()) + "\n")
|
|
62 |
}
|
|
63 |
}
|
|
64 |
}
|
|
65 |
|
|
66 |
|
|
67 |
/* Isabelle tool wrapper */
|
|
68 |
|
|
69 |
val isabelle_tool =
|
76479
|
70 |
Isabelle_Tool("build_easychair", "build component for Easychair LaTeX style",
|
76396
|
71 |
Scala_Project.here,
|
|
72 |
{ args =>
|
|
73 |
var target_dir = Path.current
|
|
74 |
var download_url = default_url
|
|
75 |
|
|
76 |
val getopts = Getopts("""
|
|
77 |
Usage: isabelle build_easychair [OPTIONS]
|
|
78 |
|
|
79 |
Options are:
|
|
80 |
-D DIR target directory (default ".")
|
|
81 |
-U URL download URL (default: """" + default_url + """")
|
|
82 |
|
76479
|
83 |
Build component for Easychair LaTeX style.
|
76396
|
84 |
""",
|
|
85 |
"D:" -> (arg => target_dir = Path.explode(arg)),
|
|
86 |
"U:" -> (arg => download_url = arg))
|
|
87 |
|
|
88 |
val more_args = getopts(args)
|
|
89 |
if (more_args.nonEmpty) getopts.usage()
|
|
90 |
|
|
91 |
val progress = new Console_Progress()
|
|
92 |
|
|
93 |
build_easychair(download_url = download_url, target_dir = target_dir, progress = progress)
|
|
94 |
})
|
|
95 |
}
|