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
26 package jdk.incubator.jpackage.internal;
27
28 import java.io.*;
29 import java.nio.file.Files;
30 import java.text.MessageFormat;
31 import java.util.*;
32 import static jdk.incubator.jpackage.internal.OverridableResource.createResource;
33
34 import static jdk.incubator.jpackage.internal.StandardBundlerParam.*;
35
36 public class MacDmgBundler extends MacBaseInstallerBundler {
37
38 private static final ResourceBundle I18N = ResourceBundle.getBundle(
39 "jdk.incubator.jpackage.internal.resources.MacResources");
40
41 static final String DEFAULT_BACKGROUND_IMAGE="background_dmg.tiff";
42 static final String DEFAULT_DMG_SETUP_SCRIPT="DMGsetup.scpt";
43 static final String TEMPLATE_BUNDLE_ICON = "java.icns";
44
45 static final String DEFAULT_LICENSE_PLIST="lic_template.plist";
46
47 public static final BundlerParamInfo<String> INSTALLER_SUFFIX =
48 new StandardBundlerParam<> (
49 "mac.dmg.installerName.suffix",
50 String.class,
51 params -> "",
143
144 createResource(DEFAULT_LICENSE_PLIST, params)
145 .setCategory(I18N.getString("resource.license-setup"))
146 .setSubstitutionData(data)
147 .saveToFile(getConfig_LicenseFile(params));
148
149 } catch (IOException ex) {
150 Log.verbose(ex);
151 }
152 }
153
154 private boolean prepareConfigFiles(Map<String, ? super Object> params)
155 throws IOException {
156
157 createResource(DEFAULT_BACKGROUND_IMAGE, params)
158 .setCategory(I18N.getString("resource.dmg-background"))
159 .saveToFile(getConfig_VolumeBackground(params));
160
161 createResource(TEMPLATE_BUNDLE_ICON, params)
162 .setCategory(I18N.getString("resource.volume-icon"))
163 .setExternal(MacAppBundler.ICON_ICNS.fetchFrom(params))
164 .saveToFile(getConfig_VolumeIcon(params));
165
166 createResource(null, params)
167 .setCategory(I18N.getString("resource.post-install-script"))
168 .saveToFile(getConfig_Script(params));
169
170 prepareLicense(params);
171
172 // In theory we need to extract name from results of attach command
173 // However, this will be a problem for customization as name will
174 // possibly change every time and developer will not be able to fix it
175 // As we are using tmp dir chance we get "different" name are low =>
176 // Use fixed name we used for bundle
177 prepareDMGSetupScript(APP_NAME.fetchFrom(params), params);
178
179 return true;
180 }
181
182 // name of post-image script
183 private File getConfig_Script(Map<String, ? super Object> params) {
|
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
26 package jdk.incubator.jpackage.internal;
27
28 import java.io.*;
29 import java.nio.file.Files;
30 import java.text.MessageFormat;
31 import java.util.*;
32 import static jdk.incubator.jpackage.internal.MacAppImageBuilder.ICON_ICNS;
33 import static jdk.incubator.jpackage.internal.OverridableResource.createResource;
34
35 import static jdk.incubator.jpackage.internal.StandardBundlerParam.*;
36
37 public class MacDmgBundler extends MacBaseInstallerBundler {
38
39 private static final ResourceBundle I18N = ResourceBundle.getBundle(
40 "jdk.incubator.jpackage.internal.resources.MacResources");
41
42 static final String DEFAULT_BACKGROUND_IMAGE="background_dmg.tiff";
43 static final String DEFAULT_DMG_SETUP_SCRIPT="DMGsetup.scpt";
44 static final String TEMPLATE_BUNDLE_ICON = "java.icns";
45
46 static final String DEFAULT_LICENSE_PLIST="lic_template.plist";
47
48 public static final BundlerParamInfo<String> INSTALLER_SUFFIX =
49 new StandardBundlerParam<> (
50 "mac.dmg.installerName.suffix",
51 String.class,
52 params -> "",
144
145 createResource(DEFAULT_LICENSE_PLIST, params)
146 .setCategory(I18N.getString("resource.license-setup"))
147 .setSubstitutionData(data)
148 .saveToFile(getConfig_LicenseFile(params));
149
150 } catch (IOException ex) {
151 Log.verbose(ex);
152 }
153 }
154
155 private boolean prepareConfigFiles(Map<String, ? super Object> params)
156 throws IOException {
157
158 createResource(DEFAULT_BACKGROUND_IMAGE, params)
159 .setCategory(I18N.getString("resource.dmg-background"))
160 .saveToFile(getConfig_VolumeBackground(params));
161
162 createResource(TEMPLATE_BUNDLE_ICON, params)
163 .setCategory(I18N.getString("resource.volume-icon"))
164 .setExternal(ICON_ICNS.fetchFrom(params))
165 .saveToFile(getConfig_VolumeIcon(params));
166
167 createResource(null, params)
168 .setCategory(I18N.getString("resource.post-install-script"))
169 .saveToFile(getConfig_Script(params));
170
171 prepareLicense(params);
172
173 // In theory we need to extract name from results of attach command
174 // However, this will be a problem for customization as name will
175 // possibly change every time and developer will not be able to fix it
176 // As we are using tmp dir chance we get "different" name are low =>
177 // Use fixed name we used for bundle
178 prepareDMGSetupScript(APP_NAME.fetchFrom(params), params);
179
180 return true;
181 }
182
183 // name of post-image script
184 private File getConfig_Script(Map<String, ? super Object> params) {
|