| author | nipkow | 
| Fri, 23 Aug 2024 18:40:12 +0200 | |
| changeset 80738 | 6adf6cc82013 | 
| parent 78286 | 68f1c4ca48c3 | 
| child 83339 | d4cd9812472b | 
| permissions | -rw-r--r-- | 
| 77566 
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
 wenzelm parents: 
76548diff
changeset | 1 | /* Title: Pure/Admin/component_lipics.scala | 
| 76395 | 2 | Author: Makarius | 
| 3 | ||
| 4 | Build Isabelle component for Dagstuhl LIPIcs style. | |
| 5 | ||
| 6 | See also: | |
| 7 | ||
| 8 | - https://github.com/dagstuhl-publishing/styles | |
| 9 | - https://submission.dagstuhl.de/documentation/authors | |
| 10 | - https://www.dagstuhl.de/en/publications/lipics | |
| 11 | */ | |
| 12 | ||
| 13 | package isabelle | |
| 14 | ||
| 15 | ||
| 77566 
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
 wenzelm parents: 
76548diff
changeset | 16 | object Component_LIPIcs {
 | 
| 77758 | 17 | /* resources */ | 
| 76451 
87cd8506e000
document_build engine for "lipics", with options and document_files;
 wenzelm parents: 
76395diff
changeset | 18 | |
| 
87cd8506e000
document_build engine for "lipics", with options and document_files;
 wenzelm parents: 
76395diff
changeset | 19 | val document_files: List[Path] = | 
| 
87cd8506e000
document_build engine for "lipics", with options and document_files;
 wenzelm parents: 
76395diff
changeset | 20 |     for (name <- List("cc-by.pdf", "lipics-logo-bw.pdf", "lipics-v2021.cls"))
 | 
| 
87cd8506e000
document_build engine for "lipics", with options and document_files;
 wenzelm parents: 
76395diff
changeset | 21 |       yield Path.explode("$ISABELLE_LIPICS_HOME/" + name)
 | 
| 
87cd8506e000
document_build engine for "lipics", with options and document_files;
 wenzelm parents: 
76395diff
changeset | 22 | |
| 
87cd8506e000
document_build engine for "lipics", with options and document_files;
 wenzelm parents: 
76395diff
changeset | 23 | |
| 76395 | 24 | /* build lipics component */ | 
| 25 | ||
| 78286 | 26 | val default_url = "https://github.com/dagstuhl-publishing/styles/archive/refs/tags/v2021.1.3.tar.gz" | 
| 76395 | 27 | |
| 28 | def build_lipics( | |
| 29 | download_url: String = default_url, | |
| 30 | target_dir: Path = Path.current, | |
| 31 | progress: Progress = new Progress | |
| 32 |   ): Unit = {
 | |
| 33 |     Isabelle_System.with_tmp_file("download", ext = "tar.gz") { download_file =>
 | |
| 34 |       Isabelle_System.with_tmp_dir("download") { download_dir =>
 | |
| 35 | ||
| 36 | /* download */ | |
| 37 | ||
| 38 | Isabelle_System.download_file(download_url, download_file, progress = progress) | |
| 76540 
83de6e9ae983
clarified signature: prefer Scala functions instead of shell scripts;
 wenzelm parents: 
76518diff
changeset | 39 | Isabelle_System.extract(download_file, download_dir, strip = true) | 
| 76395 | 40 | |
| 41 |         val lipics_dir = download_dir + Path.explode("LIPIcs/authors")
 | |
| 42 | ||
| 43 | ||
| 44 | /* component */ | |
| 45 | ||
| 46 |         val version = {
 | |
| 47 | val Version = """^*.* v(.*)$""".r | |
| 48 |           val changelog = Path.explode("CHANGELOG.md")
 | |
| 49 | split_lines(File.read(lipics_dir + changelog)) | |
| 50 |             .collectFirst({ case Version(v) => v })
 | |
| 51 |             .getOrElse(error("Failed to detect version in " + changelog))
 | |
| 52 | } | |
| 53 | ||
| 54 | val component = "lipics-" + version | |
| 76518 | 55 | val component_dir = | 
| 76547 | 56 | Components.Directory(target_dir + Path.basic(component)).create(progress = progress) | 
| 76395 | 57 | |
| 76518 | 58 | Isabelle_System.copy_dir(lipics_dir, component_dir.path) | 
| 76395 | 59 | |
| 60 | ||
| 61 | /* settings */ | |
| 62 | ||
| 76548 | 63 |         component_dir.write_settings("""
 | 
| 76395 | 64 | ISABELLE_LIPICS_HOME="$COMPONENT/authors" | 
| 65 | """) | |
| 66 | ||
| 67 | ||
| 68 | /* README */ | |
| 69 | ||
| 76518 | 70 | File.write(component_dir.README, | 
| 76395 | 71 | """This is the Dagstuhl LIPIcs style for authors from | 
| 72 | """ + download_url + """ | |
| 73 | ||
| 74 | ||
| 75 | Makarius | |
| 76 | """ + Date.Format.date(Date.now()) + "\n") | |
| 77 | } | |
| 78 | } | |
| 79 | } | |
| 80 | ||
| 81 | ||
| 82 | /* Isabelle tool wrapper */ | |
| 83 | ||
| 84 | val isabelle_tool = | |
| 77566 
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
 wenzelm parents: 
76548diff
changeset | 85 |     Isabelle_Tool("component_lipics", "build component for Dagstuhl LIPIcs style",
 | 
| 76395 | 86 | Scala_Project.here, | 
| 87 |       { args =>
 | |
| 88 | var target_dir = Path.current | |
| 89 | var download_url = default_url | |
| 90 | ||
| 91 |         val getopts = Getopts("""
 | |
| 77566 
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
 wenzelm parents: 
76548diff
changeset | 92 | Usage: isabelle component_lipics [OPTIONS] | 
| 76395 | 93 | |
| 94 | Options are: | |
| 95 | -D DIR target directory (default ".") | |
| 96 | -U URL download URL (default: """" + default_url + """") | |
| 97 | ||
| 98 | Build component for Dagstuhl LIPIcs style. | |
| 99 | """, | |
| 100 | "D:" -> (arg => target_dir = Path.explode(arg)), | |
| 101 | "U:" -> (arg => download_url = arg)) | |
| 102 | ||
| 103 | val more_args = getopts(args) | |
| 104 | if (more_args.nonEmpty) getopts.usage() | |
| 105 | ||
| 106 | val progress = new Console_Progress() | |
| 107 | ||
| 108 | build_lipics(download_url = download_url, target_dir = target_dir, progress = progress) | |
| 109 | }) | |
| 110 | } |