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