169 private File getConfig_BackgroundImage(Map<String, ? super Object> params) { |
173 private File getConfig_BackgroundImage(Map<String, ? super Object> params) { |
170 return new File(CONFIG_ROOT.fetchFrom(params), |
174 return new File(CONFIG_ROOT.fetchFrom(params), |
171 APP_NAME.fetchFrom(params) + "-background.png"); |
175 APP_NAME.fetchFrom(params) + "-background.png"); |
172 } |
176 } |
173 |
177 |
|
178 private File getConfig_BackgroundImageDarkAqua(Map<String, ? super Object> params) { |
|
179 return new File(CONFIG_ROOT.fetchFrom(params), |
|
180 APP_NAME.fetchFrom(params) + "-background-darkAqua.png"); |
|
181 } |
|
182 |
174 private File getScripts_PreinstallFile(Map<String, ? super Object> params) { |
183 private File getScripts_PreinstallFile(Map<String, ? super Object> params) { |
175 return new File(SCRIPTS_DIR.fetchFrom(params), "preinstall"); |
184 return new File(SCRIPTS_DIR.fetchFrom(params), "preinstall"); |
176 } |
185 } |
177 |
186 |
178 private File getScripts_PostinstallFile( |
187 private File getScripts_PostinstallFile( |
179 Map<String, ? super Object> params) { |
188 Map<String, ? super Object> params) { |
180 return new File(SCRIPTS_DIR.fetchFrom(params), "postinstall"); |
189 return new File(SCRIPTS_DIR.fetchFrom(params), "postinstall"); |
181 } |
190 } |
182 |
191 |
183 private String getAppIdentifier(Map<String, ? super Object> params) { |
192 private String getAppIdentifier(Map<String, ? super Object> params) { |
184 return IDENTIFIER.fetchFrom(params); |
193 return MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params); |
185 } |
194 } |
186 |
195 |
187 private void preparePackageScripts(Map<String, ? super Object> params) |
196 private void preparePackageScripts(Map<String, ? super Object> params) |
188 throws IOException { |
197 throws IOException { |
189 Log.verbose(I18N.getString("message.preparing-scripts")); |
198 Log.verbose(I18N.getString("message.preparing-scripts")); |
228 File f = getConfig_DistributionXMLFile(params); |
237 File f = getConfig_DistributionXMLFile(params); |
229 |
238 |
230 Log.verbose(MessageFormat.format(I18N.getString( |
239 Log.verbose(MessageFormat.format(I18N.getString( |
231 "message.preparing-distribution-dist"), f.getAbsolutePath())); |
240 "message.preparing-distribution-dist"), f.getAbsolutePath())); |
232 |
241 |
233 try (PrintStream out = new PrintStream(f)) { |
242 XMLOutputFactory xmlFactory = XMLOutputFactory.newInstance(); |
234 |
243 |
235 out.println( |
244 try (Writer w = new OutputStreamWriter(new FileOutputStream(f), "UTF-8")) { |
236 "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>"); |
245 XMLStreamWriter xml = xmlFactory.createXMLStreamWriter(w); |
237 out.println("<installer-gui-script minSpecVersion=\"1\">"); |
246 |
238 |
247 xml.writeStartDocument("UTF-8", "1.0"); |
239 out.println("<title>" + APP_NAME.fetchFrom(params) + "</title>"); |
248 |
240 out.println("<background" + " file=\"" |
249 xml.writeStartElement("installer-gui-script"); |
241 + getConfig_BackgroundImage(params).getName() |
250 xml.writeAttribute("minSpecVersion", "1"); |
242 + "\"" |
251 |
243 + " mime-type=\"image/png\"" |
252 xml.writeStartElement("title"); |
244 + " alignment=\"bottomleft\" " |
253 xml.writeCharacters(APP_NAME.fetchFrom(params)); |
245 + " scaling=\"none\"" |
254 xml.writeEndElement(); |
246 + "/>"); |
255 |
|
256 xml.writeStartElement("background"); |
|
257 xml.writeAttribute("file", getConfig_BackgroundImage(params).getName()); |
|
258 xml.writeAttribute("mime-type", "image/png"); |
|
259 xml.writeAttribute("alignment", "bottomleft"); |
|
260 xml.writeAttribute("scaling", "none"); |
|
261 xml.writeEndElement(); |
|
262 |
|
263 xml.writeStartElement("background-darkAqua"); |
|
264 xml.writeAttribute("file", getConfig_BackgroundImageDarkAqua(params).getName()); |
|
265 xml.writeAttribute("mime-type", "image/png"); |
|
266 xml.writeAttribute("alignment", "bottomleft"); |
|
267 xml.writeAttribute("scaling", "none"); |
|
268 xml.writeEndElement(); |
247 |
269 |
248 String licFileStr = LICENSE_FILE.fetchFrom(params); |
270 String licFileStr = LICENSE_FILE.fetchFrom(params); |
249 if (licFileStr != null) { |
271 if (licFileStr != null) { |
250 File licFile = new File(licFileStr); |
272 File licFile = new File(licFileStr); |
251 out.println("<license" |
273 xml.writeStartElement("license"); |
252 + " file=\"" + licFile.getAbsolutePath() + "\"" |
274 xml.writeAttribute("file", licFile.getAbsolutePath()); |
253 + " mime-type=\"text/rtf\"" |
275 xml.writeAttribute("mime-type", "text/rtf"); |
254 + "/>"); |
276 xml.writeEndElement(); |
255 } |
277 } |
256 |
278 |
257 /* |
279 /* |
258 * Note that the content of the distribution file |
280 * Note that the content of the distribution file |
259 * below is generated by productbuild --synthesize |
281 * below is generated by productbuild --synthesize |
260 */ |
282 */ |
261 |
|
262 String appId = getAppIdentifier(params); |
283 String appId = getAppIdentifier(params); |
263 |
284 |
264 out.println("<pkg-ref id=\"" + appId + "\"/>"); |
285 xml.writeStartElement("pkg-ref"); |
265 out.println( |
286 xml.writeAttribute("id", appId); |
266 "<options customize=\"never\" require-scripts=\"false\"/>"); |
287 xml.writeEndElement(); // </pkg-ref> |
267 out.println("<choices-outline>"); |
288 xml.writeStartElement("options"); |
268 out.println(" <line choice=\"default\">"); |
289 xml.writeAttribute("customize", "never"); |
269 out.println(" <line choice=\"" + appId + "\"/>"); |
290 xml.writeAttribute("require-scripts", "false"); |
270 out.println(" </line>"); |
291 xml.writeEndElement(); // </options> |
271 out.println("</choices-outline>"); |
292 xml.writeStartElement("choices-outline"); |
272 out.println("<choice id=\"default\"/>"); |
293 xml.writeStartElement("line"); |
273 out.println("<choice id=\"" + appId + "\" visible=\"false\">"); |
294 xml.writeAttribute("choice", "default"); |
274 out.println(" <pkg-ref id=\"" + appId + "\"/>"); |
295 xml.writeStartElement("line"); |
275 out.println("</choice>"); |
296 xml.writeAttribute("choice", appId); |
276 out.println("<pkg-ref id=\"" + appId + "\" version=\"" |
297 xml.writeEndElement(); // </line> |
277 + VERSION.fetchFrom(params) + "\" onConclusion=\"none\">" |
298 xml.writeEndElement(); // </line> |
278 + URLEncoder.encode( |
299 xml.writeEndElement(); // </choices-outline> |
279 getPackages_AppPackage(params).getName(), |
300 xml.writeStartElement("choice"); |
280 "UTF-8") + "</pkg-ref>"); |
301 xml.writeAttribute("id", "default"); |
281 |
302 xml.writeEndElement(); // </choice> |
282 out.println("</installer-gui-script>"); |
303 xml.writeStartElement("choice"); |
283 |
304 xml.writeAttribute("id", appId); |
|
305 xml.writeAttribute("visible", "false"); |
|
306 xml.writeStartElement("pkg-ref"); |
|
307 xml.writeAttribute("id", appId); |
|
308 xml.writeEndElement(); // </pkg-ref> |
|
309 xml.writeEndElement(); // </choice> |
|
310 xml.writeStartElement("pkg-ref"); |
|
311 xml.writeAttribute("id", appId); |
|
312 xml.writeAttribute("version", VERSION.fetchFrom(params)); |
|
313 xml.writeAttribute("onConclusion", "none"); |
|
314 xml.writeCharacters(URLEncoder.encode( |
|
315 getPackages_AppPackage(params).getName(), "UTF-8")); |
|
316 xml.writeEndElement(); // </pkg-ref> |
|
317 |
|
318 xml.writeEndElement(); // </installer-gui-script> |
|
319 |
|
320 xml.writeEndDocument(); |
|
321 xml.flush(); |
|
322 xml.close(); |
|
323 |
|
324 } catch (XMLStreamException ex) { |
|
325 Log.verbose(ex); |
|
326 throw new IOException(ex); |
284 } |
327 } |
285 } |
328 } |
286 |
329 |
287 private boolean prepareConfigFiles(Map<String, ? super Object> params) |
330 private boolean prepareConfigFiles(Map<String, ? super Object> params) |
288 throws IOException { |
331 throws IOException { |
289 File imageTarget = getConfig_BackgroundImage(params); |
332 File imageTarget = getConfig_BackgroundImage(params); |
|
333 fetchResource(imageTarget.getName(), |
|
334 I18N.getString("resource.pkg-background-image"), |
|
335 DEFAULT_BACKGROUND_IMAGE, |
|
336 imageTarget, |
|
337 VERBOSE.fetchFrom(params), |
|
338 RESOURCE_DIR.fetchFrom(params)); |
|
339 |
|
340 imageTarget = getConfig_BackgroundImageDarkAqua(params); |
290 fetchResource(imageTarget.getName(), |
341 fetchResource(imageTarget.getName(), |
291 I18N.getString("resource.pkg-background-image"), |
342 I18N.getString("resource.pkg-background-image"), |
292 DEFAULT_BACKGROUND_IMAGE, |
343 DEFAULT_BACKGROUND_IMAGE, |
293 imageTarget, |
344 imageTarget, |
294 VERBOSE.fetchFrom(params), |
345 VERBOSE.fetchFrom(params), |