76075
|
1 |
/* Title: Pure/Admin/build_postgresql.scala
|
|
2 |
Author: Makarius
|
|
3 |
|
|
4 |
Build Isabelle postgresql component from official download.
|
|
5 |
*/
|
|
6 |
|
|
7 |
package isabelle
|
|
8 |
|
|
9 |
|
|
10 |
object Build_PostgreSQL {
|
|
11 |
/* URLs */
|
|
12 |
|
|
13 |
val notable_urls =
|
|
14 |
List("https://jdbc.postgresql.org", "https://jdbc.postgresql.org/download.html")
|
|
15 |
|
|
16 |
val default_download_url = "https://jdbc.postgresql.org/download/postgresql-42.5.0.jar"
|
|
17 |
|
|
18 |
|
|
19 |
/* build postgresql */
|
|
20 |
|
|
21 |
def build_postgresql(
|
|
22 |
download_url: String = default_download_url,
|
|
23 |
progress: Progress = new Progress,
|
|
24 |
target_dir: Path = Path.current
|
|
25 |
): Unit = {
|
|
26 |
/* name and version */
|
|
27 |
|
|
28 |
def err(): Nothing = error("Malformed jar download URL: " + quote(download_url))
|
|
29 |
|
|
30 |
val Name = """^.*/([^/]+)\.jar""".r
|
|
31 |
val download_name = download_url match { case Name(name) => name case _ => err() }
|
|
32 |
|
|
33 |
val Version = """^.[^0-9]*([0-9].*)$""".r
|
|
34 |
val download_version = download_name match { case Version(version) => version case _ => err() }
|
|
35 |
|
|
36 |
|
|
37 |
/* component */
|
|
38 |
|
76518
|
39 |
val component_dir =
|
|
40 |
Components.Directory.create(target_dir + Path.basic(download_name), progress = progress)
|
76075
|
41 |
|
|
42 |
|
|
43 |
/* LICENSE */
|
|
44 |
|
76518
|
45 |
File.write(component_dir.LICENSE,
|
76075
|
46 |
"""Copyright (c) 1997, PostgreSQL Global Development Group
|
|
47 |
All rights reserved.
|
|
48 |
|
|
49 |
Redistribution and use in source and binary forms, with or without
|
|
50 |
modification, are permitted provided that the following conditions are met:
|
|
51 |
|
|
52 |
1. Redistributions of source code must retain the above copyright notice,
|
|
53 |
this list of conditions and the following disclaimer.
|
|
54 |
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
55 |
this list of conditions and the following disclaimer in the documentation
|
|
56 |
and/or other materials provided with the distribution.
|
|
57 |
|
|
58 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
59 |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
60 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
61 |
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
62 |
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
63 |
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
64 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
65 |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
66 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
67 |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
68 |
POSSIBILITY OF SUCH DAMAGE.
|
|
69 |
""")
|
|
70 |
|
|
71 |
|
|
72 |
/* README */
|
|
73 |
|
76518
|
74 |
File.write(component_dir.README,
|
76075
|
75 |
"""This is PostgreSQL JDBC """ + download_version + """ from
|
|
76 |
""" + notable_urls.mkString(" and ") + """
|
|
77 |
|
|
78 |
Makarius
|
|
79 |
""" + Date.Format.date(Date.now()) + "\n")
|
|
80 |
|
|
81 |
|
|
82 |
/* settings */
|
|
83 |
|
76518
|
84 |
File.write(component_dir.settings,
|
76075
|
85 |
"""# -*- shell-script -*- :mode=shellscript:
|
|
86 |
|
|
87 |
classpath "$COMPONENT/""" + download_name + """.jar"
|
|
88 |
""")
|
|
89 |
|
|
90 |
|
|
91 |
/* jar */
|
|
92 |
|
76518
|
93 |
val jar = component_dir.path + Path.basic(download_name).ext("jar")
|
76075
|
94 |
Isabelle_System.download_file(download_url, jar, progress = progress)
|
|
95 |
}
|
|
96 |
|
|
97 |
|
|
98 |
/* Isabelle tool wrapper */
|
|
99 |
|
|
100 |
val isabelle_tool =
|
|
101 |
Isabelle_Tool("build_postgresql", "build Isabelle postgresql component from official download",
|
|
102 |
Scala_Project.here,
|
|
103 |
{ args =>
|
|
104 |
var target_dir = Path.current
|
|
105 |
var download_url = default_download_url
|
|
106 |
|
|
107 |
val getopts = Getopts("""
|
|
108 |
Usage: isabelle build_postgresql [OPTIONS]
|
|
109 |
|
|
110 |
Options are:
|
|
111 |
-D DIR target directory (default ".")
|
|
112 |
-U URL download URL
|
|
113 |
(default: """" + default_download_url + """")
|
|
114 |
|
|
115 |
Build postgresql component from the specified download URL (JAR), see also
|
|
116 |
""" + notable_urls.mkString(" and "),
|
|
117 |
"D:" -> (arg => target_dir = Path.explode(arg)),
|
|
118 |
"U:" -> (arg => download_url = arg))
|
|
119 |
|
|
120 |
val more_args = getopts(args)
|
|
121 |
if (more_args.nonEmpty) getopts.usage()
|
|
122 |
|
|
123 |
val progress = new Console_Progress()
|
|
124 |
|
|
125 |
build_postgresql(download_url, progress = progress, target_dir = target_dir)
|
|
126 |
})
|
|
127 |
}
|