author | herrick |
Mon, 14 Oct 2019 14:36:45 -0400 | |
branch | JDK-8200758-branch |
changeset 58584 | 910b14f4fe3a |
parent 58582 | 558a0842c5aa |
child 58647 | 2c43b89b1679 |
permissions | -rw-r--r-- |
57038 | 1 |
/* |
57106
ea870b9ce89a
8216492: Update copyright of all new jpackage fils to 2019
kcr
parents:
57096
diff
changeset
|
2 |
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. |
57038 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
57039 | 26 |
package jdk.jpackage.internal; |
57038 | 27 |
|
28 |
import java.io.File; |
|
58582
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
29 |
import java.io.FileOutputStream; |
57038 | 30 |
import java.io.IOException; |
58582
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
31 |
import java.io.OutputStreamWriter; |
57217
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
32 |
import java.io.PrintWriter; |
57038 | 33 |
import java.io.Writer; |
58584
910b14f4fe3a
8232042: [macos] Installation fails if application name contains spaces
herrick
parents:
58582
diff
changeset
|
34 |
import java.net.URI; |
910b14f4fe3a
8232042: [macos] Installation fails if application name contains spaces
herrick
parents:
58582
diff
changeset
|
35 |
import java.net.URISyntaxException; |
57217
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
36 |
import java.nio.file.Files; |
57331
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
37 |
import java.nio.file.Path; |
57038 | 38 |
import java.text.MessageFormat; |
39 |
import java.util.ArrayList; |
|
40 |
import java.util.HashMap; |
|
41 |
import java.util.List; |
|
42 |
import java.util.Map; |
|
43 |
import java.util.Optional; |
|
44 |
import java.util.ResourceBundle; |
|
58582
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
45 |
import javax.xml.stream.XMLOutputFactory; |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
46 |
import javax.xml.stream.XMLStreamException; |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
47 |
import javax.xml.stream.XMLStreamWriter; |
57038 | 48 |
|
57039 | 49 |
import static jdk.jpackage.internal.StandardBundlerParam.*; |
57067
9c17d779808e
8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents:
57059
diff
changeset
|
50 |
import static jdk.jpackage.internal.MacBaseInstallerBundler.SIGNING_KEYCHAIN; |
9c17d779808e
8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents:
57059
diff
changeset
|
51 |
import static jdk.jpackage.internal.MacBaseInstallerBundler.SIGNING_KEY_USER; |
58415 | 52 |
import static jdk.jpackage.internal.MacAppImageBuilder.MAC_CF_BUNDLE_IDENTIFIER; |
57038 | 53 |
|
54 |
public class MacPkgBundler extends MacBaseInstallerBundler { |
|
55 |
||
56 |
private static final ResourceBundle I18N = ResourceBundle.getBundle( |
|
57059 | 57 |
"jdk.jpackage.internal.resources.MacResources"); |
57038 | 58 |
|
58582
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
59 |
private static final String DEFAULT_BACKGROUND_IMAGE = "background_pkg.png"; |
57038 | 60 |
|
61 |
private static final String TEMPLATE_PREINSTALL_SCRIPT = |
|
62 |
"preinstall.template"; |
|
63 |
private static final String TEMPLATE_POSTINSTALL_SCRIPT = |
|
64 |
"postinstall.template"; |
|
65 |
||
66 |
private static final BundlerParamInfo<File> PACKAGES_ROOT = |
|
67 |
new StandardBundlerParam<>( |
|
68 |
"mac.pkg.packagesRoot", |
|
69 |
File.class, |
|
70 |
params -> { |
|
71 |
File packagesRoot = |
|
57256 | 72 |
new File(TEMP_ROOT.fetchFrom(params), "packages"); |
57038 | 73 |
packagesRoot.mkdirs(); |
74 |
return packagesRoot; |
|
75 |
}, |
|
76 |
(s, p) -> new File(s)); |
|
77 |
||
78 |
||
79 |
protected final BundlerParamInfo<File> SCRIPTS_DIR = |
|
80 |
new StandardBundlerParam<>( |
|
81 |
"mac.pkg.scriptsDir", |
|
82 |
File.class, |
|
83 |
params -> { |
|
84 |
File scriptsDir = |
|
85 |
new File(CONFIG_ROOT.fetchFrom(params), "scripts"); |
|
86 |
scriptsDir.mkdirs(); |
|
87 |
return scriptsDir; |
|
88 |
}, |
|
89 |
(s, p) -> new File(s)); |
|
90 |
||
91 |
public static final |
|
92 |
BundlerParamInfo<String> DEVELOPER_ID_INSTALLER_SIGNING_KEY = |
|
93 |
new StandardBundlerParam<>( |
|
94 |
"mac.signing-key-developer-id-installer", |
|
95 |
String.class, |
|
96 |
params -> { |
|
97 |
String result = MacBaseInstallerBundler.findKey( |
|
98 |
"Developer ID Installer: " |
|
99 |
+ SIGNING_KEY_USER.fetchFrom(params), |
|
100 |
SIGNING_KEYCHAIN.fetchFrom(params), |
|
101 |
VERBOSE.fetchFrom(params)); |
|
102 |
if (result != null) { |
|
103 |
MacCertificate certificate = new MacCertificate( |
|
104 |
result, VERBOSE.fetchFrom(params)); |
|
105 |
||
106 |
if (!certificate.isValid()) { |
|
107 |
Log.error(MessageFormat.format( |
|
108 |
I18N.getString("error.certificate.expired"), |
|
109 |
result)); |
|
110 |
} |
|
111 |
} |
|
112 |
||
113 |
return result; |
|
114 |
}, |
|
115 |
(s, p) -> s); |
|
116 |
||
117 |
public static final BundlerParamInfo<String> MAC_INSTALL_DIR = |
|
118 |
new StandardBundlerParam<>( |
|
119 |
"mac-install-dir", |
|
120 |
String.class, |
|
121 |
params -> { |
|
122 |
String dir = INSTALL_DIR.fetchFrom(params); |
|
123 |
return (dir != null) ? dir : "/Applications"; |
|
124 |
}, |
|
125 |
(s, p) -> s |
|
126 |
); |
|
127 |
||
128 |
public static final BundlerParamInfo<String> INSTALLER_SUFFIX = |
|
129 |
new StandardBundlerParam<> ( |
|
130 |
"mac.pkg.installerName.suffix", |
|
131 |
String.class, |
|
132 |
params -> "", |
|
133 |
(s, p) -> s); |
|
134 |
||
57140 | 135 |
public File bundle(Map<String, ? super Object> params, |
136 |
File outdir) throws PackagerException { |
|
57038 | 137 |
Log.verbose(MessageFormat.format(I18N.getString("message.building-pkg"), |
138 |
APP_NAME.fetchFrom(params))); |
|
57407 | 139 |
|
140 |
IOUtils.writableOutputDir(outdir.toPath()); |
|
57038 | 141 |
|
142 |
try { |
|
57554 | 143 |
File appImageDir = prepareAppBundle(params); |
57038 | 144 |
|
145 |
if (appImageDir != null && prepareConfigFiles(params)) { |
|
146 |
||
147 |
File configScript = getConfig_Script(params); |
|
148 |
if (configScript.exists()) { |
|
149 |
Log.verbose(MessageFormat.format(I18N.getString( |
|
150 |
"message.running-script"), |
|
151 |
configScript.getAbsolutePath())); |
|
57391 | 152 |
IOUtils.run("bash", configScript); |
57038 | 153 |
} |
154 |
||
155 |
return createPKG(params, outdir, appImageDir); |
|
156 |
} |
|
157 |
return null; |
|
58584
910b14f4fe3a
8232042: [macos] Installation fails if application name contains spaces
herrick
parents:
58582
diff
changeset
|
158 |
} catch (IOException|URISyntaxException ex) { |
57038 | 159 |
Log.verbose(ex); |
57140 | 160 |
throw new PackagerException(ex); |
57038 | 161 |
} |
162 |
} |
|
163 |
||
164 |
private File getPackages_AppPackage(Map<String, ? super Object> params) { |
|
165 |
return new File(PACKAGES_ROOT.fetchFrom(params), |
|
57119 | 166 |
APP_NAME.fetchFrom(params) + "-app.pkg"); |
57038 | 167 |
} |
168 |
||
169 |
private File getConfig_DistributionXMLFile( |
|
170 |
Map<String, ? super Object> params) { |
|
171 |
return new File(CONFIG_ROOT.fetchFrom(params), "distribution.dist"); |
|
172 |
} |
|
173 |
||
174 |
private File getConfig_BackgroundImage(Map<String, ? super Object> params) { |
|
175 |
return new File(CONFIG_ROOT.fetchFrom(params), |
|
176 |
APP_NAME.fetchFrom(params) + "-background.png"); |
|
177 |
} |
|
178 |
||
58582
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
179 |
private File getConfig_BackgroundImageDarkAqua(Map<String, ? super Object> params) { |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
180 |
return new File(CONFIG_ROOT.fetchFrom(params), |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
181 |
APP_NAME.fetchFrom(params) + "-background-darkAqua.png"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
182 |
} |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
183 |
|
57038 | 184 |
private File getScripts_PreinstallFile(Map<String, ? super Object> params) { |
185 |
return new File(SCRIPTS_DIR.fetchFrom(params), "preinstall"); |
|
186 |
} |
|
187 |
||
188 |
private File getScripts_PostinstallFile( |
|
189 |
Map<String, ? super Object> params) { |
|
190 |
return new File(SCRIPTS_DIR.fetchFrom(params), "postinstall"); |
|
191 |
} |
|
192 |
||
193 |
private String getAppIdentifier(Map<String, ? super Object> params) { |
|
58582
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
194 |
return MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params); |
57038 | 195 |
} |
196 |
||
197 |
private void preparePackageScripts(Map<String, ? super Object> params) |
|
198 |
throws IOException { |
|
199 |
Log.verbose(I18N.getString("message.preparing-scripts")); |
|
200 |
||
201 |
Map<String, String> data = new HashMap<>(); |
|
202 |
||
58581
657e25d9e4e4
8231858:[macos] App does not run if installed with pkg
herrick
parents:
58415
diff
changeset
|
203 |
Path appLocation = Path.of(MAC_INSTALL_DIR.fetchFrom(params), |
657e25d9e4e4
8231858:[macos] App does not run if installed with pkg
herrick
parents:
58415
diff
changeset
|
204 |
APP_NAME.fetchFrom(params) + ".app", "Contents", "app"); |
657e25d9e4e4
8231858:[macos] App does not run if installed with pkg
herrick
parents:
58415
diff
changeset
|
205 |
|
57290
47c2aca6c306
8215241: Permissions are not set correctly on sub-folders in /Applications
ssadetsky
parents:
57256
diff
changeset
|
206 |
data.put("INSTALL_LOCATION", MAC_INSTALL_DIR.fetchFrom(params)); |
58581
657e25d9e4e4
8231858:[macos] App does not run if installed with pkg
herrick
parents:
58415
diff
changeset
|
207 |
data.put("APP_LOCATION", appLocation.toString()); |
57038 | 208 |
|
57390 | 209 |
try (Writer w = Files.newBufferedWriter( |
210 |
getScripts_PreinstallFile(params).toPath())) { |
|
211 |
String content = preprocessTextResource( |
|
212 |
getScripts_PreinstallFile(params).getName(), |
|
213 |
I18N.getString("resource.pkg-preinstall-script"), |
|
214 |
TEMPLATE_PREINSTALL_SCRIPT, |
|
215 |
data, |
|
216 |
VERBOSE.fetchFrom(params), |
|
217 |
RESOURCE_DIR.fetchFrom(params)); |
|
218 |
w.write(content); |
|
219 |
} |
|
57038 | 220 |
getScripts_PreinstallFile(params).setExecutable(true, false); |
221 |
||
57390 | 222 |
try (Writer w = Files.newBufferedWriter( |
223 |
getScripts_PostinstallFile(params).toPath())) { |
|
224 |
String content = preprocessTextResource( |
|
225 |
getScripts_PostinstallFile(params).getName(), |
|
226 |
I18N.getString("resource.pkg-postinstall-script"), |
|
227 |
TEMPLATE_POSTINSTALL_SCRIPT, |
|
228 |
data, |
|
229 |
VERBOSE.fetchFrom(params), |
|
230 |
RESOURCE_DIR.fetchFrom(params)); |
|
231 |
w.write(content); |
|
232 |
} |
|
57038 | 233 |
getScripts_PostinstallFile(params).setExecutable(true, false); |
234 |
} |
|
235 |
||
58584
910b14f4fe3a
8232042: [macos] Installation fails if application name contains spaces
herrick
parents:
58582
diff
changeset
|
236 |
private String URLEncoding(String pkgName) throws URISyntaxException { |
910b14f4fe3a
8232042: [macos] Installation fails if application name contains spaces
herrick
parents:
58582
diff
changeset
|
237 |
URI uri = new URI(null, null, pkgName, null); |
910b14f4fe3a
8232042: [macos] Installation fails if application name contains spaces
herrick
parents:
58582
diff
changeset
|
238 |
return uri.toASCIIString(); |
910b14f4fe3a
8232042: [macos] Installation fails if application name contains spaces
herrick
parents:
58582
diff
changeset
|
239 |
} |
910b14f4fe3a
8232042: [macos] Installation fails if application name contains spaces
herrick
parents:
58582
diff
changeset
|
240 |
|
57038 | 241 |
private void prepareDistributionXMLFile(Map<String, ? super Object> params) |
58584
910b14f4fe3a
8232042: [macos] Installation fails if application name contains spaces
herrick
parents:
58582
diff
changeset
|
242 |
throws IOException, URISyntaxException { |
57038 | 243 |
File f = getConfig_DistributionXMLFile(params); |
244 |
||
245 |
Log.verbose(MessageFormat.format(I18N.getString( |
|
246 |
"message.preparing-distribution-dist"), f.getAbsolutePath())); |
|
247 |
||
58582
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
248 |
XMLOutputFactory xmlFactory = XMLOutputFactory.newInstance(); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
249 |
|
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
250 |
try (Writer w = new OutputStreamWriter(new FileOutputStream(f), "UTF-8")) { |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
251 |
XMLStreamWriter xml = xmlFactory.createXMLStreamWriter(w); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
252 |
|
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
253 |
xml.writeStartDocument("UTF-8", "1.0"); |
57038 | 254 |
|
58582
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
255 |
xml.writeStartElement("installer-gui-script"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
256 |
xml.writeAttribute("minSpecVersion", "1"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
257 |
|
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
258 |
xml.writeStartElement("title"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
259 |
xml.writeCharacters(APP_NAME.fetchFrom(params)); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
260 |
xml.writeEndElement(); |
57038 | 261 |
|
58582
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
262 |
xml.writeStartElement("background"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
263 |
xml.writeAttribute("file", getConfig_BackgroundImage(params).getName()); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
264 |
xml.writeAttribute("mime-type", "image/png"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
265 |
xml.writeAttribute("alignment", "bottomleft"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
266 |
xml.writeAttribute("scaling", "none"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
267 |
xml.writeEndElement(); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
268 |
|
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
269 |
xml.writeStartElement("background-darkAqua"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
270 |
xml.writeAttribute("file", getConfig_BackgroundImageDarkAqua(params).getName()); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
271 |
xml.writeAttribute("mime-type", "image/png"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
272 |
xml.writeAttribute("alignment", "bottomleft"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
273 |
xml.writeAttribute("scaling", "none"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
274 |
xml.writeEndElement(); |
57038 | 275 |
|
57390 | 276 |
String licFileStr = LICENSE_FILE.fetchFrom(params); |
277 |
if (licFileStr != null) { |
|
278 |
File licFile = new File(licFileStr); |
|
58582
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
279 |
xml.writeStartElement("license"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
280 |
xml.writeAttribute("file", licFile.getAbsolutePath()); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
281 |
xml.writeAttribute("mime-type", "text/rtf"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
282 |
xml.writeEndElement(); |
57390 | 283 |
} |
57038 | 284 |
|
57390 | 285 |
/* |
286 |
* Note that the content of the distribution file |
|
287 |
* below is generated by productbuild --synthesize |
|
288 |
*/ |
|
289 |
String appId = getAppIdentifier(params); |
|
57038 | 290 |
|
58582
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
291 |
xml.writeStartElement("pkg-ref"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
292 |
xml.writeAttribute("id", appId); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
293 |
xml.writeEndElement(); // </pkg-ref> |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
294 |
xml.writeStartElement("options"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
295 |
xml.writeAttribute("customize", "never"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
296 |
xml.writeAttribute("require-scripts", "false"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
297 |
xml.writeEndElement(); // </options> |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
298 |
xml.writeStartElement("choices-outline"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
299 |
xml.writeStartElement("line"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
300 |
xml.writeAttribute("choice", "default"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
301 |
xml.writeStartElement("line"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
302 |
xml.writeAttribute("choice", appId); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
303 |
xml.writeEndElement(); // </line> |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
304 |
xml.writeEndElement(); // </line> |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
305 |
xml.writeEndElement(); // </choices-outline> |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
306 |
xml.writeStartElement("choice"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
307 |
xml.writeAttribute("id", "default"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
308 |
xml.writeEndElement(); // </choice> |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
309 |
xml.writeStartElement("choice"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
310 |
xml.writeAttribute("id", appId); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
311 |
xml.writeAttribute("visible", "false"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
312 |
xml.writeStartElement("pkg-ref"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
313 |
xml.writeAttribute("id", appId); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
314 |
xml.writeEndElement(); // </pkg-ref> |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
315 |
xml.writeEndElement(); // </choice> |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
316 |
xml.writeStartElement("pkg-ref"); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
317 |
xml.writeAttribute("id", appId); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
318 |
xml.writeAttribute("version", VERSION.fetchFrom(params)); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
319 |
xml.writeAttribute("onConclusion", "none"); |
58584
910b14f4fe3a
8232042: [macos] Installation fails if application name contains spaces
herrick
parents:
58582
diff
changeset
|
320 |
xml.writeCharacters(URLEncoding( |
910b14f4fe3a
8232042: [macos] Installation fails if application name contains spaces
herrick
parents:
58582
diff
changeset
|
321 |
getPackages_AppPackage(params).getName())); |
58582
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
322 |
xml.writeEndElement(); // </pkg-ref> |
57038 | 323 |
|
58582
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
324 |
xml.writeEndElement(); // </installer-gui-script> |
57038 | 325 |
|
58582
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
326 |
xml.writeEndDocument(); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
327 |
xml.flush(); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
328 |
xml.close(); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
329 |
|
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
330 |
} catch (XMLStreamException ex) { |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
331 |
Log.verbose(ex); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
332 |
throw new IOException(ex); |
57390 | 333 |
} |
57038 | 334 |
} |
335 |
||
336 |
private boolean prepareConfigFiles(Map<String, ? super Object> params) |
|
58584
910b14f4fe3a
8232042: [macos] Installation fails if application name contains spaces
herrick
parents:
58582
diff
changeset
|
337 |
throws IOException, URISyntaxException { |
57038 | 338 |
File imageTarget = getConfig_BackgroundImage(params); |
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
339 |
fetchResource(imageTarget.getName(), |
57038 | 340 |
I18N.getString("resource.pkg-background-image"), |
341 |
DEFAULT_BACKGROUND_IMAGE, |
|
342 |
imageTarget, |
|
343 |
VERBOSE.fetchFrom(params), |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
344 |
RESOURCE_DIR.fetchFrom(params)); |
57038 | 345 |
|
58582
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
346 |
imageTarget = getConfig_BackgroundImageDarkAqua(params); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
347 |
fetchResource(imageTarget.getName(), |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
348 |
I18N.getString("resource.pkg-background-image"), |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
349 |
DEFAULT_BACKGROUND_IMAGE, |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
350 |
imageTarget, |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
351 |
VERBOSE.fetchFrom(params), |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
352 |
RESOURCE_DIR.fetchFrom(params)); |
558a0842c5aa
8231856: pkg installer dialog contains background image which does not look correc
herrick
parents:
58581
diff
changeset
|
353 |
|
57038 | 354 |
prepareDistributionXMLFile(params); |
355 |
||
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
356 |
fetchResource(getConfig_Script(params).getName(), |
57038 | 357 |
I18N.getString("resource.post-install-script"), |
358 |
(String) null, |
|
359 |
getConfig_Script(params), |
|
360 |
VERBOSE.fetchFrom(params), |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
361 |
RESOURCE_DIR.fetchFrom(params)); |
57038 | 362 |
|
363 |
return true; |
|
364 |
} |
|
365 |
||
366 |
// name of post-image script |
|
367 |
private File getConfig_Script(Map<String, ? super Object> params) { |
|
368 |
return new File(CONFIG_ROOT.fetchFrom(params), |
|
369 |
APP_NAME.fetchFrom(params) + "-post-image.sh"); |
|
370 |
} |
|
371 |
||
57217
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
372 |
private void patchCPLFile(File cpl) throws IOException { |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
373 |
String cplData = Files.readString(cpl.toPath()); |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
374 |
String[] lines = cplData.split("\n"); |
57390 | 375 |
try (PrintWriter out = new PrintWriter(Files.newBufferedWriter( |
376 |
cpl.toPath()))) { |
|
57529
e3b156ad362f
8224627: Creating installer with --runtime-image on OS X fails
herrick
parents:
57438
diff
changeset
|
377 |
int skip = 0; |
e3b156ad362f
8224627: Creating installer with --runtime-image on OS X fails
herrick
parents:
57438
diff
changeset
|
378 |
// Used to skip Java.runtime bundle, since |
57217
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
379 |
// pkgbuild with --root will find two bundles app and Java runtime. |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
380 |
// We cannot generate component proprty list when using |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
381 |
// --component argument. |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
382 |
for (int i = 0; i < lines.length; i++) { |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
383 |
if (lines[i].trim().equals("<key>BundleIsRelocatable</key>")) { |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
384 |
out.println(lines[i]); |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
385 |
out.println("<false/>"); |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
386 |
i++; |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
387 |
} else if (lines[i].trim().equals("<key>ChildBundles</key>")) { |
57529
e3b156ad362f
8224627: Creating installer with --runtime-image on OS X fails
herrick
parents:
57438
diff
changeset
|
388 |
++skip; |
e3b156ad362f
8224627: Creating installer with --runtime-image on OS X fails
herrick
parents:
57438
diff
changeset
|
389 |
} else if ((skip > 0) && lines[i].trim().equals("</array>")) { |
e3b156ad362f
8224627: Creating installer with --runtime-image on OS X fails
herrick
parents:
57438
diff
changeset
|
390 |
--skip; |
57217
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
391 |
} else { |
57529
e3b156ad362f
8224627: Creating installer with --runtime-image on OS X fails
herrick
parents:
57438
diff
changeset
|
392 |
if (skip == 0) { |
57217
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
393 |
out.println(lines[i]); |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
394 |
} |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
395 |
} |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
396 |
} |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
397 |
} |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
398 |
} |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
399 |
|
57331
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
400 |
// pkgbuild includes all components from "--root" and subfolders, |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
401 |
// so if we have app image in folder which contains other images, then they |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
402 |
// will be included as well. It does have "--filter" option which use regex |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
403 |
// to exclude files/folder, but it will overwrite default one which excludes |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
404 |
// based on doc "any .svn or CVS directories, and any .DS_Store files". |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
405 |
// So easy aproach will be to copy user provided app-image into temp folder |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
406 |
// if root path contains other files. |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
407 |
private String getRoot(Map<String, ? super Object> params, |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
408 |
File appLocation) throws IOException { |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
409 |
String root = appLocation.getParent() == null ? |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
410 |
"." : appLocation.getParent(); |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
411 |
File rootDir = new File(root); |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
412 |
File[] list = rootDir.listFiles(); |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
413 |
if (list != null) { // Should not happend |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
414 |
// We should only have app image and/or .DS_Store |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
415 |
if (list.length == 1) { |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
416 |
return root; |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
417 |
} else if (list.length == 2) { |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
418 |
// Check case with app image and .DS_Store |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
419 |
if (list[0].toString().toLowerCase().endsWith(".ds_store") || |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
420 |
list[1].toString().toLowerCase().endsWith(".ds_store")) { |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
421 |
return root; // Only app image and .DS_Store |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
422 |
} |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
423 |
} |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
424 |
} |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
425 |
|
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
426 |
// Copy to new root |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
427 |
Path newRoot = Files.createTempDirectory( |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
428 |
TEMP_ROOT.fetchFrom(params).toPath(), |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
429 |
"root-"); |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
430 |
|
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
431 |
IOUtils.copyRecursive(appLocation.toPath(), |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
432 |
newRoot.resolve(appLocation.getName())); |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
433 |
|
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
434 |
return newRoot.toString(); |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
435 |
} |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
436 |
|
57038 | 437 |
private File createPKG(Map<String, ? super Object> params, |
438 |
File outdir, File appLocation) { |
|
439 |
// generic find attempt |
|
440 |
try { |
|
441 |
File appPKG = getPackages_AppPackage(params); |
|
442 |
||
57331
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
443 |
String root = getRoot(params, appLocation); |
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
444 |
|
57217
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
445 |
// Generate default CPL file |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
446 |
File cpl = new File(CONFIG_ROOT.fetchFrom(params).getAbsolutePath() |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
447 |
+ File.separator + "cpl.plist"); |
57038 | 448 |
ProcessBuilder pb = new ProcessBuilder("pkgbuild", |
57217
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
449 |
"--root", |
57331
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
450 |
root, |
57038 | 451 |
"--install-location", |
452 |
MAC_INSTALL_DIR.fetchFrom(params), |
|
57217
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
453 |
"--analyze", |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
454 |
cpl.getAbsolutePath()); |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
455 |
|
57391 | 456 |
IOUtils.exec(pb); |
57217
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
457 |
|
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
458 |
patchCPLFile(cpl); |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
459 |
|
57290
47c2aca6c306
8215241: Permissions are not set correctly on sub-folders in /Applications
ssadetsky
parents:
57256
diff
changeset
|
460 |
preparePackageScripts(params); |
47c2aca6c306
8215241: Permissions are not set correctly on sub-folders in /Applications
ssadetsky
parents:
57256
diff
changeset
|
461 |
|
57217
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
462 |
// build application package |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
463 |
pb = new ProcessBuilder("pkgbuild", |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
464 |
"--root", |
57331
221a589c52ee
8222676: create-installer with --app-image fails on mac
herrick
parents:
57290
diff
changeset
|
465 |
root, |
57217
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
466 |
"--install-location", |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
467 |
MAC_INSTALL_DIR.fetchFrom(params), |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
468 |
"--component-plist", |
b1291b2cedc9
8219144: Cannot find installed application on Mac
herrick
parents:
57150
diff
changeset
|
469 |
cpl.getAbsolutePath(), |
57290
47c2aca6c306
8215241: Permissions are not set correctly on sub-folders in /Applications
ssadetsky
parents:
57256
diff
changeset
|
470 |
"--scripts", |
47c2aca6c306
8215241: Permissions are not set correctly on sub-folders in /Applications
ssadetsky
parents:
57256
diff
changeset
|
471 |
SCRIPTS_DIR.fetchFrom(params).getAbsolutePath(), |
57038 | 472 |
appPKG.getAbsolutePath()); |
57391 | 473 |
IOUtils.exec(pb); |
57038 | 474 |
|
475 |
// build final package |
|
476 |
File finalPKG = new File(outdir, INSTALLER_NAME.fetchFrom(params) |
|
477 |
+ INSTALLER_SUFFIX.fetchFrom(params) |
|
478 |
+ ".pkg"); |
|
479 |
outdir.mkdirs(); |
|
480 |
||
481 |
List<String> commandLine = new ArrayList<>(); |
|
482 |
commandLine.add("productbuild"); |
|
483 |
||
484 |
commandLine.add("--resources"); |
|
485 |
commandLine.add(CONFIG_ROOT.fetchFrom(params).getAbsolutePath()); |
|
486 |
||
487 |
// maybe sign |
|
488 |
if (Optional.ofNullable(MacAppImageBuilder. |
|
489 |
SIGN_BUNDLE.fetchFrom(params)).orElse(Boolean.TRUE)) { |
|
490 |
if (Platform.getMajorVersion() > 10 || |
|
491 |
(Platform.getMajorVersion() == 10 && |
|
492 |
Platform.getMinorVersion() >= 12)) { |
|
493 |
// we need this for OS X 10.12+ |
|
494 |
Log.verbose(I18N.getString("message.signing.pkg")); |
|
495 |
} |
|
496 |
||
497 |
String signingIdentity = |
|
498 |
DEVELOPER_ID_INSTALLER_SIGNING_KEY.fetchFrom(params); |
|
499 |
if (signingIdentity != null) { |
|
500 |
commandLine.add("--sign"); |
|
501 |
commandLine.add(signingIdentity); |
|
502 |
} |
|
503 |
||
504 |
String keychainName = SIGNING_KEYCHAIN.fetchFrom(params); |
|
505 |
if (keychainName != null && !keychainName.isEmpty()) { |
|
506 |
commandLine.add("--keychain"); |
|
507 |
commandLine.add(keychainName); |
|
508 |
} |
|
509 |
} |
|
510 |
||
511 |
commandLine.add("--distribution"); |
|
512 |
commandLine.add( |
|
513 |
getConfig_DistributionXMLFile(params).getAbsolutePath()); |
|
514 |
commandLine.add("--package-path"); |
|
515 |
commandLine.add(PACKAGES_ROOT.fetchFrom(params).getAbsolutePath()); |
|
516 |
||
517 |
commandLine.add(finalPKG.getAbsolutePath()); |
|
518 |
||
519 |
pb = new ProcessBuilder(commandLine); |
|
57391 | 520 |
IOUtils.exec(pb); |
57038 | 521 |
|
522 |
return finalPKG; |
|
523 |
} catch (Exception ignored) { |
|
524 |
Log.verbose(ignored); |
|
525 |
return null; |
|
526 |
} |
|
527 |
} |
|
528 |
||
529 |
////////////////////////////////////////////////////////////////////////// |
|
530 |
// Implement Bundler |
|
531 |
////////////////////////////////////////////////////////////////////////// |
|
532 |
||
533 |
@Override |
|
534 |
public String getName() { |
|
57059 | 535 |
return I18N.getString("pkg.bundler.name"); |
57038 | 536 |
} |
537 |
||
538 |
@Override |
|
539 |
public String getID() { |
|
540 |
return "pkg"; |
|
541 |
} |
|
542 |
||
543 |
@Override |
|
544 |
public boolean validate(Map<String, ? super Object> params) |
|
57438
4a31db8d42bd
8226599: use code coverage results to remove dead code
herrick
parents:
57407
diff
changeset
|
545 |
throws ConfigException { |
57038 | 546 |
try { |
547 |
if (params == null) throw new ConfigException( |
|
548 |
I18N.getString("error.parameters-null"), |
|
549 |
I18N.getString("error.parameters-null.advice")); |
|
550 |
||
551 |
// run basic validation to ensure requirements are met |
|
552 |
// we are not interested in return code, only possible exception |
|
553 |
validateAppImageAndBundeler(params); |
|
554 |
||
58415 | 555 |
if (MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params) == null) { |
556 |
throw new ConfigException( |
|
557 |
I18N.getString("message.app-image-requires-identifier"), |
|
558 |
I18N.getString( |
|
559 |
"message.app-image-requires-identifier.advice")); |
|
560 |
} |
|
561 |
||
57038 | 562 |
// reject explicitly set sign to true and no valid signature key |
563 |
if (Optional.ofNullable(MacAppImageBuilder. |
|
564 |
SIGN_BUNDLE.fetchFrom(params)).orElse(Boolean.FALSE)) { |
|
565 |
String signingIdentity = |
|
566 |
DEVELOPER_ID_INSTALLER_SIGNING_KEY.fetchFrom(params); |
|
567 |
if (signingIdentity == null) { |
|
568 |
throw new ConfigException( |
|
569 |
I18N.getString("error.explicit-sign-no-cert"), |
|
570 |
I18N.getString( |
|
571 |
"error.explicit-sign-no-cert.advice")); |
|
572 |
} |
|
573 |
} |
|
574 |
||
575 |
// hdiutil is always available so there's no need |
|
576 |
// to test for availability. |
|
577 |
||
578 |
return true; |
|
579 |
} catch (RuntimeException re) { |
|
580 |
if (re.getCause() instanceof ConfigException) { |
|
581 |
throw (ConfigException) re.getCause(); |
|
582 |
} else { |
|
583 |
throw new ConfigException(re); |
|
584 |
} |
|
585 |
} |
|
586 |
} |
|
587 |
||
588 |
@Override |
|
57140 | 589 |
public File execute(Map<String, ? super Object> params, |
590 |
File outputParentDir) throws PackagerException { |
|
57038 | 591 |
return bundle(params, outputParentDir); |
592 |
} |
|
593 |
||
594 |
@Override |
|
57150 | 595 |
public boolean supported(boolean runtimeInstaller) { |
57438
4a31db8d42bd
8226599: use code coverage results to remove dead code
herrick
parents:
57407
diff
changeset
|
596 |
return true; |
57038 | 597 |
} |
598 |
||
58114
42df7de58e39
8230519: jpackage "--package-type" values and default
herrick
parents:
58037
diff
changeset
|
599 |
@Override |
42df7de58e39
8230519: jpackage "--package-type" values and default
herrick
parents:
58037
diff
changeset
|
600 |
public boolean isDefault() { |
42df7de58e39
8230519: jpackage "--package-type" values and default
herrick
parents:
58037
diff
changeset
|
601 |
return false; |
42df7de58e39
8230519: jpackage "--package-type" values and default
herrick
parents:
58037
diff
changeset
|
602 |
} |
42df7de58e39
8230519: jpackage "--package-type" values and default
herrick
parents:
58037
diff
changeset
|
603 |
|
57038 | 604 |
} |