author | herrick |
Fri, 21 Dec 2018 07:40:47 -0500 | |
branch | JDK-8200758-branch |
changeset 57091 | 06bc4bd64599 |
parent 57080 | bd4ce7f9ea2c |
child 57096 | d06bec27f8c9 |
permissions | -rw-r--r-- |
57038 | 1 |
/* |
2 |
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. |
|
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 javax.imageio.ImageIO; |
|
29 |
import java.awt.image.BufferedImage; |
|
30 |
import java.io.*; |
|
31 |
import java.nio.file.Files; |
|
32 |
import java.nio.file.attribute.PosixFilePermission; |
|
33 |
import java.nio.file.attribute.PosixFilePermissions; |
|
34 |
import java.text.MessageFormat; |
|
35 |
import java.util.*; |
|
36 |
import java.util.logging.Level; |
|
37 |
import java.util.logging.Logger; |
|
38 |
import java.util.regex.Pattern; |
|
39 |
||
57039 | 40 |
import static jdk.jpackage.internal.StandardBundlerParam.*; |
41 |
import static jdk.jpackage.internal.LinuxAppBundler.ICON_PNG; |
|
42 |
import static jdk.jpackage.internal.LinuxAppBundler.LINUX_INSTALL_DIR; |
|
43 |
import static jdk.jpackage.internal.LinuxAppBundler.LINUX_PACKAGE_DEPENDENCIES; |
|
57038 | 44 |
|
45 |
public class LinuxDebBundler extends AbstractBundler { |
|
46 |
||
47 |
private static final ResourceBundle I18N = ResourceBundle.getBundle( |
|
57059 | 48 |
"jdk.jpackage.internal.resources.LinuxResources"); |
57038 | 49 |
|
50 |
public static final BundlerParamInfo<LinuxAppBundler> APP_BUNDLER = |
|
51 |
new StandardBundlerParam<>( |
|
57059 | 52 |
I18N.getString("param.deb-app-bundler.name"), |
53 |
I18N.getString("param.deb-app-bundler.description"), |
|
57038 | 54 |
"linux.app.bundler", |
55 |
LinuxAppBundler.class, |
|
56 |
params -> new LinuxAppBundler(), |
|
57 |
(s, p) -> null); |
|
58 |
||
59 |
// Debian rules for package naming are used here |
|
60 |
// https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source |
|
61 |
// |
|
62 |
// Package names must consist only of lower case letters (a-z), |
|
63 |
// digits (0-9), plus (+) and minus (-) signs, and periods (.). |
|
64 |
// They must be at least two characters long and |
|
65 |
// must start with an alphanumeric character. |
|
66 |
// |
|
67 |
private static final Pattern DEB_BUNDLE_NAME_PATTERN = |
|
68 |
Pattern.compile("^[a-z][a-z\\d\\+\\-\\.]+"); |
|
69 |
||
70 |
public static final BundlerParamInfo<String> BUNDLE_NAME = |
|
71 |
new StandardBundlerParam<> ( |
|
72 |
I18N.getString("param.bundle-name.name"), |
|
73 |
I18N.getString("param.bundle-name.description"), |
|
74 |
Arguments.CLIOptions.LINUX_BUNDLE_NAME.getId(), |
|
75 |
String.class, |
|
76 |
params -> { |
|
77 |
String nm = APP_NAME.fetchFrom(params); |
|
78 |
||
79 |
if (nm == null) return null; |
|
80 |
||
81 |
// make sure to lower case and spaces/underscores become dashes |
|
82 |
nm = nm.toLowerCase().replaceAll("[ _]", "-"); |
|
83 |
return nm; |
|
84 |
}, |
|
85 |
(s, p) -> { |
|
86 |
if (!DEB_BUNDLE_NAME_PATTERN.matcher(s).matches()) { |
|
87 |
throw new IllegalArgumentException(new ConfigException( |
|
88 |
MessageFormat.format(I18N.getString( |
|
89 |
"error.invalid-value-for-package-name"), s), |
|
90 |
I18N.getString( |
|
91 |
"error.invalid-value-for-package-name.advice"))); |
|
92 |
} |
|
93 |
||
94 |
return s; |
|
95 |
}); |
|
96 |
||
97 |
public static final BundlerParamInfo<String> FULL_PACKAGE_NAME = |
|
98 |
new StandardBundlerParam<> ( |
|
99 |
I18N.getString("param.full-package-name.name"), |
|
100 |
I18N.getString("param.full-package-name.description"), |
|
101 |
"linux.deb.fullPackageName", |
|
102 |
String.class, |
|
103 |
params -> BUNDLE_NAME.fetchFrom(params) + "-" |
|
104 |
+ VERSION.fetchFrom(params), |
|
105 |
(s, p) -> s); |
|
106 |
||
107 |
public static final BundlerParamInfo<File> CONFIG_ROOT = |
|
108 |
new StandardBundlerParam<>( |
|
109 |
I18N.getString("param.config-root.name"), |
|
110 |
I18N.getString("param.config-root.description"), |
|
111 |
"configRoot", |
|
112 |
File.class, |
|
113 |
params -> new File(BUILD_ROOT.fetchFrom(params), "linux"), |
|
114 |
(s, p) -> new File(s)); |
|
115 |
||
116 |
public static final BundlerParamInfo<File> DEB_IMAGE_DIR = |
|
117 |
new StandardBundlerParam<>( |
|
118 |
I18N.getString("param.image-dir.name"), |
|
119 |
I18N.getString("param.image-dir.description"), |
|
120 |
"linux.deb.imageDir", |
|
121 |
File.class, |
|
122 |
params -> { |
|
123 |
File imagesRoot = IMAGES_ROOT.fetchFrom(params); |
|
124 |
if (!imagesRoot.exists()) imagesRoot.mkdirs(); |
|
125 |
return new File(new File(imagesRoot, "linux-deb.image"), |
|
126 |
FULL_PACKAGE_NAME.fetchFrom(params)); |
|
127 |
}, |
|
128 |
(s, p) -> new File(s)); |
|
129 |
||
130 |
public static final BundlerParamInfo<File> APP_IMAGE_ROOT = |
|
131 |
new StandardBundlerParam<>( |
|
132 |
I18N.getString("param.app-image-root.name"), |
|
133 |
I18N.getString("param.app-image-root.description"), |
|
134 |
"linux.deb.imageRoot", |
|
135 |
File.class, |
|
136 |
params -> { |
|
137 |
File imageDir = DEB_IMAGE_DIR.fetchFrom(params); |
|
138 |
return new File(imageDir, LINUX_INSTALL_DIR.fetchFrom(params)); |
|
139 |
}, |
|
140 |
(s, p) -> new File(s)); |
|
141 |
||
142 |
public static final BundlerParamInfo<File> CONFIG_DIR = |
|
143 |
new StandardBundlerParam<>( |
|
144 |
I18N.getString("param.config-dir.name"), |
|
145 |
I18N.getString("param.config-dir.description"), |
|
146 |
"linux.deb.configDir", |
|
147 |
File.class, |
|
148 |
params -> new File(DEB_IMAGE_DIR.fetchFrom(params), "DEBIAN"), |
|
149 |
(s, p) -> new File(s)); |
|
150 |
||
151 |
public static final BundlerParamInfo<String> EMAIL = |
|
152 |
new StandardBundlerParam<> ( |
|
153 |
I18N.getString("param.maintainer-email.name"), |
|
154 |
I18N.getString("param.maintainer-email.description"), |
|
155 |
BundleParams.PARAM_EMAIL, |
|
156 |
String.class, |
|
157 |
params -> "Unknown", |
|
158 |
(s, p) -> s); |
|
159 |
||
160 |
public static final BundlerParamInfo<String> MAINTAINER = |
|
161 |
new StandardBundlerParam<> ( |
|
162 |
I18N.getString("param.maintainer-name.name"), |
|
163 |
I18N.getString("param.maintainer-name.description"), |
|
164 |
Arguments.CLIOptions.LINUX_DEB_MAINTAINER.getId(), |
|
165 |
String.class, |
|
166 |
params -> VENDOR.fetchFrom(params) + " <" |
|
167 |
+ EMAIL.fetchFrom(params) + ">", |
|
168 |
(s, p) -> s); |
|
169 |
||
170 |
public static final BundlerParamInfo<String> LICENSE_TEXT = |
|
171 |
new StandardBundlerParam<> ( |
|
172 |
I18N.getString("param.license-text.name"), |
|
173 |
I18N.getString("param.license-text.description"), |
|
174 |
"linux.deb.licenseText", |
|
175 |
String.class, |
|
176 |
params -> { |
|
177 |
try { |
|
57080 | 178 |
String licenseFile = LICENSE_FILE.fetchFrom(params); |
179 |
if (licenseFile != null) { |
|
180 |
return Files.readString(new File(licenseFile).toPath()); |
|
57038 | 181 |
} |
182 |
} catch (Exception e) { |
|
183 |
if (Log.isDebug()) { |
|
184 |
e.printStackTrace(); |
|
185 |
} |
|
186 |
} |
|
187 |
return "Unknown"; |
|
188 |
}, |
|
189 |
(s, p) -> s); |
|
190 |
||
191 |
public static final BundlerParamInfo<String> XDG_FILE_PREFIX = |
|
192 |
new StandardBundlerParam<> ( |
|
193 |
I18N.getString("param.xdg-prefix.name"), |
|
194 |
I18N.getString("param.xdg-prefix.description"), |
|
195 |
"linux.xdg-prefix", |
|
196 |
String.class, |
|
197 |
params -> { |
|
198 |
try { |
|
199 |
String vendor; |
|
200 |
if (params.containsKey(VENDOR.getID())) { |
|
201 |
vendor = VENDOR.fetchFrom(params); |
|
202 |
} else { |
|
57039 | 203 |
vendor = "jpackage"; |
57038 | 204 |
} |
205 |
String appName = APP_FS_NAME.fetchFrom(params); |
|
206 |
||
207 |
return (appName + "-" + vendor).replaceAll("\\s", ""); |
|
208 |
} catch (Exception e) { |
|
209 |
if (Log.isDebug()) { |
|
210 |
e.printStackTrace(); |
|
211 |
} |
|
212 |
} |
|
213 |
return "unknown-MimeInfo.xml"; |
|
214 |
}, |
|
215 |
(s, p) -> s); |
|
216 |
||
217 |
private final static String DEFAULT_ICON = "javalogo_white_32.png"; |
|
218 |
private final static String DEFAULT_CONTROL_TEMPLATE = "template.control"; |
|
219 |
private final static String DEFAULT_PRERM_TEMPLATE = "template.prerm"; |
|
220 |
private final static String DEFAULT_PREINSTALL_TEMPLATE = |
|
221 |
"template.preinst"; |
|
222 |
private final static String DEFAULT_POSTRM_TEMPLATE = "template.postrm"; |
|
223 |
private final static String DEFAULT_POSTINSTALL_TEMPLATE = |
|
224 |
"template.postinst"; |
|
225 |
private final static String DEFAULT_COPYRIGHT_TEMPLATE = |
|
226 |
"template.copyright"; |
|
227 |
private final static String DEFAULT_DESKTOP_FILE_TEMPLATE = |
|
228 |
"template.desktop"; |
|
229 |
||
230 |
public final static String TOOL_DPKG = "dpkg-deb"; |
|
231 |
||
232 |
public static boolean testTool(String toolName, String minVersion) { |
|
233 |
try { |
|
234 |
ProcessBuilder pb = new ProcessBuilder( |
|
235 |
toolName, |
|
236 |
"--version"); |
|
237 |
// not interested in the output |
|
238 |
IOUtils.exec(pb, Log.isDebug(), true); |
|
239 |
} catch (Exception e) { |
|
240 |
Log.verbose(MessageFormat.format(I18N.getString( |
|
241 |
"message.test-for-tool"), toolName, e.getMessage())); |
|
242 |
return false; |
|
243 |
} |
|
244 |
return true; |
|
245 |
} |
|
246 |
||
247 |
@Override |
|
248 |
public boolean validate(Map<String, ? super Object> p) |
|
249 |
throws UnsupportedPlatformException, ConfigException { |
|
250 |
try { |
|
251 |
if (p == null) throw new ConfigException( |
|
252 |
I18N.getString("error.parameters-null"), |
|
253 |
I18N.getString("error.parameters-null.advice")); |
|
254 |
||
255 |
//run basic validation to ensure requirements are met |
|
256 |
//we are not interested in return code, only possible exception |
|
57067
9c17d779808e
8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents:
57059
diff
changeset
|
257 |
APP_BUNDLER.fetchFrom(p).validate(p); |
57038 | 258 |
|
259 |
// NOTE: Can we validate that the required tools are available |
|
260 |
// before we start? |
|
261 |
if (!testTool(TOOL_DPKG, "1")){ |
|
262 |
throw new ConfigException(MessageFormat.format( |
|
263 |
I18N.getString("error.tool-not-found"), TOOL_DPKG), |
|
264 |
I18N.getString("error.tool-not-found.advice")); |
|
265 |
} |
|
266 |
||
267 |
||
57080 | 268 |
// Show warning is license file is missing |
269 |
String licenseFile = LICENSE_FILE.fetchFrom(p); |
|
270 |
if (licenseFile == null) { |
|
57038 | 271 |
Log.verbose(I18N.getString("message.debs-like-licenses")); |
272 |
} |
|
273 |
||
274 |
// only one mime type per association, at least one file extention |
|
275 |
List<Map<String, ? super Object>> associations = |
|
276 |
FILE_ASSOCIATIONS.fetchFrom(p); |
|
277 |
if (associations != null) { |
|
278 |
for (int i = 0; i < associations.size(); i++) { |
|
279 |
Map<String, ? super Object> assoc = associations.get(i); |
|
280 |
List<String> mimes = FA_CONTENT_TYPE.fetchFrom(assoc); |
|
281 |
if (mimes == null || mimes.isEmpty()) { |
|
282 |
String msgKey = |
|
283 |
"error.no-content-types-for-file-association"; |
|
284 |
throw new ConfigException( |
|
285 |
MessageFormat.format(I18N.getString(msgKey), i), |
|
286 |
I18N.getString(msgKey + ".advise")); |
|
287 |
||
288 |
} else if (mimes.size() > 1) { |
|
289 |
String msgKey = |
|
290 |
"error.too-many-content-types-for-file-association"; |
|
291 |
throw new ConfigException( |
|
292 |
MessageFormat.format(I18N.getString(msgKey), i), |
|
293 |
I18N.getString(msgKey + ".advise")); |
|
294 |
} |
|
295 |
} |
|
296 |
} |
|
297 |
||
298 |
// bundle name has some restrictions |
|
299 |
// the string converter will throw an exception if invalid |
|
300 |
BUNDLE_NAME.getStringConverter().apply(BUNDLE_NAME.fetchFrom(p), p); |
|
301 |
||
302 |
return true; |
|
303 |
} catch (RuntimeException re) { |
|
304 |
if (re.getCause() instanceof ConfigException) { |
|
305 |
throw (ConfigException) re.getCause(); |
|
306 |
} else { |
|
307 |
throw new ConfigException(re); |
|
308 |
} |
|
309 |
} |
|
310 |
} |
|
311 |
||
312 |
private boolean prepareProto(Map<String, ? super Object> p) |
|
313 |
throws IOException { |
|
314 |
File appImage = StandardBundlerParam.getPredefinedAppImage(p); |
|
315 |
File appDir = null; |
|
316 |
||
317 |
// we either have an application image or need to build one |
|
318 |
if (appImage != null) { |
|
319 |
appDir = new File(APP_IMAGE_ROOT.fetchFrom(p), |
|
320 |
APP_NAME.fetchFrom(p)); |
|
321 |
// copy everything from appImage dir into appDir/name |
|
322 |
IOUtils.copyRecursive(appImage.toPath(), appDir.toPath()); |
|
323 |
} else { |
|
324 |
appDir = APP_BUNDLER.fetchFrom(p).doBundle(p, |
|
325 |
APP_IMAGE_ROOT.fetchFrom(p), true); |
|
326 |
} |
|
327 |
return appDir != null; |
|
328 |
} |
|
329 |
||
330 |
//@Override |
|
331 |
public File bundle(Map<String, ? super Object> p, File outdir) { |
|
332 |
if (!outdir.isDirectory() && !outdir.mkdirs()) { |
|
333 |
throw new RuntimeException(MessageFormat.format( |
|
334 |
I18N.getString("error.cannot-create-output-dir"), |
|
335 |
outdir.getAbsolutePath())); |
|
336 |
} |
|
337 |
if (!outdir.canWrite()) { |
|
338 |
throw new RuntimeException(MessageFormat.format( |
|
339 |
I18N.getString("error.cannot-write-to-output-dir"), |
|
340 |
outdir.getAbsolutePath())); |
|
341 |
} |
|
342 |
||
343 |
// we want to create following structure |
|
344 |
// <package-name> |
|
345 |
// DEBIAN |
|
346 |
// control (file with main package details) |
|
347 |
// menu (request to create menu) |
|
348 |
// ... other control files if needed .... |
|
349 |
// opt (by default) |
|
350 |
// AppFolder (this is where app image goes) |
|
351 |
// launcher executable |
|
352 |
// app |
|
353 |
// runtime |
|
354 |
||
355 |
File imageDir = DEB_IMAGE_DIR.fetchFrom(p); |
|
356 |
File configDir = CONFIG_DIR.fetchFrom(p); |
|
357 |
||
358 |
try { |
|
359 |
||
360 |
imageDir.mkdirs(); |
|
361 |
configDir.mkdirs(); |
|
362 |
if (prepareProto(p) && prepareProjectConfig(p)) { |
|
363 |
return buildDeb(p, outdir); |
|
364 |
} |
|
365 |
return null; |
|
366 |
} catch (IOException ex) { |
|
367 |
ex.printStackTrace(); |
|
368 |
return null; |
|
369 |
} finally { |
|
370 |
try { |
|
371 |
if (imageDir != null && |
|
372 |
PREDEFINED_APP_IMAGE.fetchFrom(p) == null && |
|
373 |
(PREDEFINED_RUNTIME_IMAGE.fetchFrom(p) == null || |
|
374 |
!Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) && |
|
375 |
!Log.isDebug() && |
|
376 |
!Log.isVerbose()) { |
|
377 |
IOUtils.deleteRecursive(imageDir); |
|
378 |
} else if (imageDir != null) { |
|
379 |
Log.verbose(MessageFormat.format(I18N.getString( |
|
380 |
"message.debug-working-directory"), |
|
381 |
imageDir.getAbsolutePath())); |
|
382 |
} |
|
383 |
} catch (IOException ex) { |
|
384 |
//noinspection ReturnInsideFinallyBlock |
|
385 |
Log.debug(ex.getMessage()); |
|
386 |
return null; |
|
387 |
} |
|
388 |
} |
|
389 |
} |
|
390 |
||
391 |
/* |
|
392 |
* set permissions with a string like "rwxr-xr-x" |
|
393 |
* |
|
394 |
* This cannot be directly backport to 22u which is built with 1.6 |
|
395 |
*/ |
|
396 |
private void setPermissions(File file, String permissions) { |
|
397 |
Set<PosixFilePermission> filePermissions = |
|
398 |
PosixFilePermissions.fromString(permissions); |
|
399 |
try { |
|
400 |
if (file.exists()) { |
|
401 |
Files.setPosixFilePermissions(file.toPath(), filePermissions); |
|
402 |
} |
|
403 |
} catch (IOException ex) { |
|
404 |
Logger.getLogger(LinuxDebBundler.class.getName()).log( |
|
405 |
Level.SEVERE, null, ex); |
|
406 |
} |
|
407 |
||
408 |
} |
|
409 |
||
410 |
private String getArch() { |
|
411 |
String arch = System.getProperty("os.arch"); |
|
412 |
if ("i386".equals(arch)) |
|
413 |
return "i386"; |
|
414 |
else |
|
415 |
return "amd64"; |
|
416 |
} |
|
417 |
||
418 |
private long getInstalledSizeKB(Map<String, ? super Object> params) { |
|
419 |
return getInstalledSizeKB(APP_IMAGE_ROOT.fetchFrom(params)) >> 10; |
|
420 |
} |
|
421 |
||
422 |
private long getInstalledSizeKB(File dir) { |
|
423 |
long count = 0; |
|
424 |
File[] children = dir.listFiles(); |
|
425 |
if (children != null) { |
|
426 |
for (File file : children) { |
|
427 |
if (file.isFile()) { |
|
428 |
count += file.length(); |
|
429 |
} |
|
430 |
else if (file.isDirectory()) { |
|
431 |
count += getInstalledSizeKB(file); |
|
432 |
} |
|
433 |
} |
|
434 |
} |
|
435 |
return count; |
|
436 |
} |
|
437 |
||
438 |
private boolean prepareProjectConfig(Map<String, ? super Object> params) |
|
439 |
throws IOException { |
|
440 |
Map<String, String> data = createReplacementData(params); |
|
441 |
File rootDir = LinuxAppBundler.getRootDir(APP_IMAGE_ROOT.fetchFrom( |
|
442 |
params), params); |
|
443 |
||
444 |
File iconTarget = getConfig_IconFile(rootDir, params); |
|
445 |
File icon = ICON_PNG.fetchFrom(params); |
|
446 |
if (!Arguments.CREATE_JRE_INSTALLER.fetchFrom(params)) { |
|
447 |
// prepare installer icon |
|
448 |
if (icon == null || !icon.exists()) { |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
449 |
fetchResource(iconTarget.getName(), |
57038 | 450 |
I18N.getString("resource.menu-icon"), |
451 |
DEFAULT_ICON, |
|
452 |
iconTarget, |
|
453 |
VERBOSE.fetchFrom(params), |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
454 |
RESOURCE_DIR.fetchFrom(params)); |
57038 | 455 |
} else { |
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
456 |
fetchResource(iconTarget.getName(), |
57038 | 457 |
I18N.getString("resource.menu-icon"), |
458 |
icon, |
|
459 |
iconTarget, |
|
460 |
VERBOSE.fetchFrom(params), |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
461 |
RESOURCE_DIR.fetchFrom(params)); |
57038 | 462 |
} |
463 |
} |
|
464 |
||
465 |
StringBuilder installScripts = new StringBuilder(); |
|
466 |
StringBuilder removeScripts = new StringBuilder(); |
|
467 |
for (Map<String, ? super Object> secondaryLauncher : |
|
468 |
SECONDARY_LAUNCHERS.fetchFrom(params)) { |
|
469 |
Map<String, String> secondaryLauncherData = |
|
470 |
createReplacementData(secondaryLauncher); |
|
471 |
secondaryLauncherData.put("APPLICATION_FS_NAME", |
|
472 |
data.get("APPLICATION_FS_NAME")); |
|
473 |
secondaryLauncherData.put("DESKTOP_MIMES", ""); |
|
474 |
||
475 |
if (!Arguments.CREATE_JRE_INSTALLER.fetchFrom(params)) { |
|
476 |
// prepare desktop shortcut |
|
477 |
Writer w = new BufferedWriter(new FileWriter( |
|
478 |
getConfig_DesktopShortcutFile( |
|
479 |
rootDir, secondaryLauncher))); |
|
480 |
String content = preprocessTextResource( |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
481 |
getConfig_DesktopShortcutFile(rootDir, |
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
482 |
secondaryLauncher).getName(), |
57038 | 483 |
I18N.getString("resource.menu-shortcut-descriptor"), |
484 |
DEFAULT_DESKTOP_FILE_TEMPLATE, |
|
485 |
secondaryLauncherData, |
|
486 |
VERBOSE.fetchFrom(params), |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
487 |
RESOURCE_DIR.fetchFrom(params)); |
57038 | 488 |
w.write(content); |
489 |
w.close(); |
|
490 |
} |
|
491 |
||
492 |
// prepare installer icon |
|
493 |
iconTarget = getConfig_IconFile(rootDir, secondaryLauncher); |
|
494 |
icon = ICON_PNG.fetchFrom(secondaryLauncher); |
|
495 |
if (icon == null || !icon.exists()) { |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
496 |
fetchResource(iconTarget.getName(), |
57038 | 497 |
I18N.getString("resource.menu-icon"), |
498 |
DEFAULT_ICON, |
|
499 |
iconTarget, |
|
500 |
VERBOSE.fetchFrom(params), |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
501 |
RESOURCE_DIR.fetchFrom(params)); |
57038 | 502 |
} else { |
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
503 |
fetchResource(iconTarget.getName(), |
57038 | 504 |
I18N.getString("resource.menu-icon"), |
505 |
icon, |
|
506 |
iconTarget, |
|
507 |
VERBOSE.fetchFrom(params), |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
508 |
RESOURCE_DIR.fetchFrom(params)); |
57038 | 509 |
} |
510 |
||
511 |
// postinst copying of desktop icon |
|
512 |
installScripts.append( |
|
513 |
" xdg-desktop-menu install --novendor "); |
|
514 |
installScripts.append(LINUX_INSTALL_DIR.fetchFrom(params)); |
|
515 |
installScripts.append("/"); |
|
516 |
installScripts.append(data.get("APPLICATION_FS_NAME")); |
|
517 |
installScripts.append("/"); |
|
518 |
installScripts.append( |
|
519 |
secondaryLauncherData.get("APPLICATION_LAUNCHER_FILENAME")); |
|
520 |
installScripts.append(".desktop\n"); |
|
521 |
||
522 |
//postrm cleanup of desktop icon |
|
523 |
removeScripts.append( |
|
524 |
" xdg-desktop-menu uninstall --novendor "); |
|
525 |
removeScripts.append(LINUX_INSTALL_DIR.fetchFrom(params)); |
|
526 |
removeScripts.append("/"); |
|
527 |
removeScripts.append(data.get("APPLICATION_FS_NAME")); |
|
528 |
removeScripts.append("/"); |
|
529 |
removeScripts.append( |
|
530 |
secondaryLauncherData.get("APPLICATION_LAUNCHER_FILENAME")); |
|
531 |
removeScripts.append(".desktop\n"); |
|
532 |
} |
|
533 |
data.put("SECONDARY_LAUNCHERS_INSTALL", installScripts.toString()); |
|
534 |
data.put("SECONDARY_LAUNCHERS_REMOVE", removeScripts.toString()); |
|
535 |
||
536 |
List<Map<String, ? super Object>> associations = |
|
537 |
FILE_ASSOCIATIONS.fetchFrom(params); |
|
538 |
data.put("FILE_ASSOCIATION_INSTALL", ""); |
|
539 |
data.put("FILE_ASSOCIATION_REMOVE", ""); |
|
540 |
data.put("DESKTOP_MIMES", ""); |
|
541 |
if (associations != null) { |
|
542 |
String mimeInfoFile = XDG_FILE_PREFIX.fetchFrom(params) |
|
543 |
+ "-MimeInfo.xml"; |
|
544 |
StringBuilder mimeInfo = new StringBuilder( |
|
545 |
"<?xml version=\"1.0\"?>\n<mime-info xmlns=" |
|
546 |
+ "'http://www.freedesktop.org/standards/shared-mime-info'>\n"); |
|
547 |
StringBuilder registrations = new StringBuilder(); |
|
548 |
StringBuilder deregistrations = new StringBuilder(); |
|
549 |
StringBuilder desktopMimes = new StringBuilder("MimeType="); |
|
550 |
boolean addedEntry = false; |
|
551 |
||
552 |
for (Map<String, ? super Object> assoc : associations) { |
|
553 |
// <mime-type type="application/x-vnd.awesome"> |
|
554 |
// <comment>Awesome document</comment> |
|
555 |
// <glob pattern="*.awesome"/> |
|
556 |
// <glob pattern="*.awe"/> |
|
557 |
// </mime-type> |
|
558 |
||
559 |
if (assoc == null) { |
|
560 |
continue; |
|
561 |
} |
|
562 |
||
563 |
String description = FA_DESCRIPTION.fetchFrom(assoc); |
|
564 |
File faIcon = FA_ICON.fetchFrom(assoc); |
|
565 |
List<String> extensions = FA_EXTENSIONS.fetchFrom(assoc); |
|
566 |
if (extensions == null) { |
|
567 |
Log.error(I18N.getString( |
|
568 |
"message.creating-association-with-null-extension")); |
|
569 |
} |
|
570 |
||
571 |
List<String> mimes = FA_CONTENT_TYPE.fetchFrom(assoc); |
|
572 |
if (mimes == null || mimes.isEmpty()) { |
|
573 |
continue; |
|
574 |
} |
|
575 |
String thisMime = mimes.get(0); |
|
576 |
String dashMime = thisMime.replace('/', '-'); |
|
577 |
||
578 |
mimeInfo.append(" <mime-type type='") |
|
579 |
.append(thisMime) |
|
580 |
.append("'>\n"); |
|
581 |
if (description != null && !description.isEmpty()) { |
|
582 |
mimeInfo.append(" <comment>") |
|
583 |
.append(description) |
|
584 |
.append("</comment>\n"); |
|
585 |
} |
|
586 |
||
587 |
if (extensions != null) { |
|
588 |
for (String ext : extensions) { |
|
589 |
mimeInfo.append(" <glob pattern='*.") |
|
590 |
.append(ext) |
|
591 |
.append("'/>\n"); |
|
592 |
} |
|
593 |
} |
|
594 |
||
595 |
mimeInfo.append(" </mime-type>\n"); |
|
596 |
if (!addedEntry) { |
|
597 |
registrations.append(" xdg-mime install ") |
|
598 |
.append(LINUX_INSTALL_DIR.fetchFrom(params)) |
|
599 |
.append("/") |
|
600 |
.append(data.get("APPLICATION_FS_NAME")) |
|
601 |
.append("/") |
|
602 |
.append(mimeInfoFile) |
|
603 |
.append("\n"); |
|
604 |
||
605 |
deregistrations.append(" xdg-mime uninstall ") |
|
606 |
.append(LINUX_INSTALL_DIR.fetchFrom(params)) |
|
607 |
.append("/") |
|
608 |
.append(data.get("APPLICATION_FS_NAME")) |
|
609 |
.append("/") |
|
610 |
.append(mimeInfoFile) |
|
611 |
.append("\n"); |
|
612 |
addedEntry = true; |
|
613 |
} else { |
|
614 |
desktopMimes.append(";"); |
|
615 |
} |
|
616 |
desktopMimes.append(thisMime); |
|
617 |
||
618 |
if (faIcon != null && faIcon.exists()) { |
|
619 |
int size = getSquareSizeOfImage(faIcon); |
|
620 |
||
621 |
if (size > 0) { |
|
622 |
File target = new File(rootDir, |
|
623 |
APP_FS_NAME.fetchFrom(params) |
|
624 |
+ "_fa_" + faIcon.getName()); |
|
625 |
IOUtils.copyFile(faIcon, target); |
|
626 |
||
627 |
// xdg-icon-resource install --context mimetypes |
|
628 |
// --size 64 awesomeapp_fa_1.png |
|
629 |
// application-x.vnd-awesome |
|
630 |
registrations.append( |
|
631 |
" xdg-icon-resource install " |
|
632 |
+ "--context mimetypes --size ") |
|
633 |
.append(size) |
|
634 |
.append(" ") |
|
635 |
.append(LINUX_INSTALL_DIR.fetchFrom(params)) |
|
636 |
.append("/") |
|
637 |
.append(data.get("APPLICATION_FS_NAME")) |
|
638 |
.append("/") |
|
639 |
.append(target.getName()) |
|
640 |
.append(" ") |
|
641 |
.append(dashMime) |
|
642 |
.append("\n"); |
|
643 |
||
644 |
// x dg-icon-resource uninstall --context mimetypes |
|
645 |
// --size 64 awesomeapp_fa_1.png |
|
646 |
// application-x.vnd-awesome |
|
647 |
deregistrations.append( |
|
648 |
" xdg-icon-resource uninstall " |
|
649 |
+ "--context mimetypes --size ") |
|
650 |
.append(size) |
|
651 |
.append(" ") |
|
652 |
.append(LINUX_INSTALL_DIR.fetchFrom(params)) |
|
653 |
.append("/") |
|
654 |
.append(data.get("APPLICATION_FS_NAME")) |
|
655 |
.append("/") |
|
656 |
.append(target.getName()) |
|
657 |
.append(" ") |
|
658 |
.append(dashMime) |
|
659 |
.append("\n"); |
|
660 |
} |
|
661 |
} |
|
662 |
} |
|
663 |
mimeInfo.append("</mime-info>"); |
|
664 |
||
665 |
if (addedEntry) { |
|
666 |
Writer w = new BufferedWriter(new FileWriter( |
|
667 |
new File(rootDir, mimeInfoFile))); |
|
668 |
w.write(mimeInfo.toString()); |
|
669 |
w.close(); |
|
670 |
data.put("FILE_ASSOCIATION_INSTALL", registrations.toString()); |
|
671 |
data.put("FILE_ASSOCIATION_REMOVE", deregistrations.toString()); |
|
672 |
data.put("DESKTOP_MIMES", desktopMimes.toString()); |
|
673 |
} |
|
674 |
} |
|
675 |
||
676 |
if (!Arguments.CREATE_JRE_INSTALLER.fetchFrom(params)) { |
|
677 |
//prepare desktop shortcut |
|
678 |
Writer w = new BufferedWriter(new FileWriter( |
|
679 |
getConfig_DesktopShortcutFile(rootDir, params))); |
|
680 |
String content = preprocessTextResource( |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
681 |
getConfig_DesktopShortcutFile( |
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
682 |
rootDir, params).getName(), |
57038 | 683 |
I18N.getString("resource.menu-shortcut-descriptor"), |
684 |
DEFAULT_DESKTOP_FILE_TEMPLATE, |
|
685 |
data, |
|
686 |
VERBOSE.fetchFrom(params), |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
687 |
RESOURCE_DIR.fetchFrom(params)); |
57038 | 688 |
w.write(content); |
689 |
w.close(); |
|
690 |
} |
|
691 |
// prepare control file |
|
692 |
Writer w = new BufferedWriter(new FileWriter( |
|
693 |
getConfig_ControlFile(params))); |
|
694 |
String content = preprocessTextResource( |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
695 |
getConfig_ControlFile(params).getName(), |
57038 | 696 |
I18N.getString("resource.deb-control-file"), |
697 |
DEFAULT_CONTROL_TEMPLATE, |
|
698 |
data, |
|
699 |
VERBOSE.fetchFrom(params), |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
700 |
RESOURCE_DIR.fetchFrom(params)); |
57038 | 701 |
w.write(content); |
702 |
w.close(); |
|
703 |
||
704 |
w = new BufferedWriter(new FileWriter( |
|
705 |
getConfig_PreinstallFile(params))); |
|
706 |
content = preprocessTextResource( |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
707 |
getConfig_PreinstallFile(params).getName(), |
57038 | 708 |
I18N.getString("resource.deb-preinstall-script"), |
709 |
DEFAULT_PREINSTALL_TEMPLATE, |
|
710 |
data, |
|
711 |
VERBOSE.fetchFrom(params), |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
712 |
RESOURCE_DIR.fetchFrom(params)); |
57038 | 713 |
w.write(content); |
714 |
w.close(); |
|
715 |
setPermissions(getConfig_PreinstallFile(params), "rwxr-xr-x"); |
|
716 |
||
717 |
w = new BufferedWriter(new FileWriter(getConfig_PrermFile(params))); |
|
718 |
content = preprocessTextResource( |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
719 |
getConfig_PrermFile(params).getName(), |
57038 | 720 |
I18N.getString("resource.deb-prerm-script"), |
721 |
DEFAULT_PRERM_TEMPLATE, |
|
722 |
data, |
|
723 |
VERBOSE.fetchFrom(params), |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
724 |
RESOURCE_DIR.fetchFrom(params)); |
57038 | 725 |
w.write(content); |
726 |
w.close(); |
|
727 |
setPermissions(getConfig_PrermFile(params), "rwxr-xr-x"); |
|
728 |
||
729 |
w = new BufferedWriter(new FileWriter( |
|
730 |
getConfig_PostinstallFile(params))); |
|
731 |
content = preprocessTextResource( |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
732 |
getConfig_PostinstallFile(params).getName(), |
57038 | 733 |
I18N.getString("resource.deb-postinstall-script"), |
734 |
DEFAULT_POSTINSTALL_TEMPLATE, |
|
735 |
data, |
|
736 |
VERBOSE.fetchFrom(params), |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
737 |
RESOURCE_DIR.fetchFrom(params)); |
57038 | 738 |
w.write(content); |
739 |
w.close(); |
|
740 |
setPermissions(getConfig_PostinstallFile(params), "rwxr-xr-x"); |
|
741 |
||
742 |
w = new BufferedWriter(new FileWriter(getConfig_PostrmFile(params))); |
|
743 |
content = preprocessTextResource( |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
744 |
getConfig_PostrmFile(params).getName(), |
57038 | 745 |
I18N.getString("resource.deb-postrm-script"), |
746 |
DEFAULT_POSTRM_TEMPLATE, |
|
747 |
data, |
|
748 |
VERBOSE.fetchFrom(params), |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
749 |
RESOURCE_DIR.fetchFrom(params)); |
57038 | 750 |
w.write(content); |
751 |
w.close(); |
|
752 |
setPermissions(getConfig_PostrmFile(params), "rwxr-xr-x"); |
|
753 |
||
754 |
w = new BufferedWriter(new FileWriter(getConfig_CopyrightFile(params))); |
|
755 |
content = preprocessTextResource( |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
756 |
getConfig_CopyrightFile(params).getName(), |
57038 | 757 |
I18N.getString("resource.deb-copyright-file"), |
758 |
DEFAULT_COPYRIGHT_TEMPLATE, |
|
759 |
data, |
|
760 |
VERBOSE.fetchFrom(params), |
|
57091
06bc4bd64599
8215515: Add a command line option to override internal resources.
herrick
parents:
57080
diff
changeset
|
761 |
RESOURCE_DIR.fetchFrom(params)); |
57038 | 762 |
w.write(content); |
763 |
w.close(); |
|
764 |
||
765 |
return true; |
|
766 |
} |
|
767 |
||
768 |
private Map<String, String> createReplacementData( |
|
769 |
Map<String, ? super Object> params) { |
|
770 |
Map<String, String> data = new HashMap<>(); |
|
771 |
||
772 |
data.put("APPLICATION_NAME", APP_NAME.fetchFrom(params)); |
|
773 |
data.put("APPLICATION_FS_NAME", APP_FS_NAME.fetchFrom(params)); |
|
774 |
data.put("APPLICATION_PACKAGE", BUNDLE_NAME.fetchFrom(params)); |
|
775 |
data.put("APPLICATION_VENDOR", VENDOR.fetchFrom(params)); |
|
776 |
data.put("APPLICATION_MAINTAINER", MAINTAINER.fetchFrom(params)); |
|
777 |
data.put("APPLICATION_VERSION", VERSION.fetchFrom(params)); |
|
778 |
data.put("APPLICATION_LAUNCHER_FILENAME", |
|
779 |
APP_FS_NAME.fetchFrom(params)); |
|
780 |
data.put("INSTALLATION_DIRECTORY", LINUX_INSTALL_DIR.fetchFrom(params)); |
|
781 |
data.put("XDG_PREFIX", XDG_FILE_PREFIX.fetchFrom(params)); |
|
782 |
data.put("DEPLOY_BUNDLE_CATEGORY", CATEGORY.fetchFrom(params)); |
|
783 |
data.put("APPLICATION_DESCRIPTION", DESCRIPTION.fetchFrom(params)); |
|
784 |
data.put("APPLICATION_SUMMARY", TITLE.fetchFrom(params)); |
|
785 |
data.put("APPLICATION_COPYRIGHT", COPYRIGHT.fetchFrom(params)); |
|
786 |
data.put("APPLICATION_LICENSE_TEXT", LICENSE_TEXT.fetchFrom(params)); |
|
787 |
data.put("APPLICATION_ARCH", getArch()); |
|
788 |
data.put("APPLICATION_INSTALLED_SIZE", |
|
789 |
Long.toString(getInstalledSizeKB(params))); |
|
790 |
String deps = LINUX_PACKAGE_DEPENDENCIES.fetchFrom(params); |
|
791 |
data.put("PACKAGE_DEPENDENCIES", |
|
792 |
deps.isEmpty() ? "" : "Depends: " + deps); |
|
793 |
data.put("CREATE_JRE_INSTALLER", |
|
794 |
Arguments.CREATE_JRE_INSTALLER.fetchFrom(params).toString()); |
|
795 |
||
796 |
return data; |
|
797 |
} |
|
798 |
||
799 |
private File getConfig_DesktopShortcutFile(File rootDir, |
|
800 |
Map<String, ? super Object> params) { |
|
801 |
return new File(rootDir, |
|
802 |
APP_FS_NAME.fetchFrom(params) + ".desktop"); |
|
803 |
} |
|
804 |
||
805 |
private File getConfig_IconFile(File rootDir, |
|
806 |
Map<String, ? super Object> params) { |
|
807 |
return new File(rootDir, |
|
808 |
APP_FS_NAME.fetchFrom(params) + ".png"); |
|
809 |
} |
|
810 |
||
811 |
private File getConfig_InitScriptFile(Map<String, ? super Object> params) { |
|
812 |
return new File(LinuxAppBundler.getRootDir( |
|
813 |
APP_IMAGE_ROOT.fetchFrom(params), params), |
|
814 |
BUNDLE_NAME.fetchFrom(params) + ".init"); |
|
815 |
} |
|
816 |
||
817 |
private File getConfig_ControlFile(Map<String, ? super Object> params) { |
|
818 |
return new File(CONFIG_DIR.fetchFrom(params), "control"); |
|
819 |
} |
|
820 |
||
821 |
private File getConfig_PreinstallFile(Map<String, ? super Object> params) { |
|
822 |
return new File(CONFIG_DIR.fetchFrom(params), "preinst"); |
|
823 |
} |
|
824 |
||
825 |
private File getConfig_PrermFile(Map<String, ? super Object> params) { |
|
826 |
return new File(CONFIG_DIR.fetchFrom(params), "prerm"); |
|
827 |
} |
|
828 |
||
829 |
private File getConfig_PostinstallFile(Map<String, ? super Object> params) { |
|
830 |
return new File(CONFIG_DIR.fetchFrom(params), "postinst"); |
|
831 |
} |
|
832 |
||
833 |
private File getConfig_PostrmFile(Map<String, ? super Object> params) { |
|
834 |
return new File(CONFIG_DIR.fetchFrom(params), "postrm"); |
|
835 |
} |
|
836 |
||
837 |
private File getConfig_CopyrightFile(Map<String, ? super Object> params) { |
|
838 |
return new File(CONFIG_DIR.fetchFrom(params), "copyright"); |
|
839 |
} |
|
840 |
||
841 |
private File buildDeb(Map<String, ? super Object> params, |
|
842 |
File outdir) throws IOException { |
|
843 |
File outFile = new File(outdir, |
|
844 |
FULL_PACKAGE_NAME.fetchFrom(params)+".deb"); |
|
845 |
Log.verbose(MessageFormat.format(I18N.getString( |
|
846 |
"message.outputting-to-location"), outFile.getAbsolutePath())); |
|
847 |
||
848 |
outFile.getParentFile().mkdirs(); |
|
849 |
||
850 |
// run dpkg |
|
851 |
ProcessBuilder pb = new ProcessBuilder( |
|
852 |
"fakeroot", TOOL_DPKG, "-b", |
|
853 |
FULL_PACKAGE_NAME.fetchFrom(params), |
|
854 |
outFile.getAbsolutePath()); |
|
855 |
pb = pb.directory(DEB_IMAGE_DIR.fetchFrom(params).getParentFile()); |
|
856 |
IOUtils.exec(pb, false); |
|
857 |
||
858 |
Log.verbose(MessageFormat.format(I18N.getString( |
|
859 |
"message.output-to-location"), outFile.getAbsolutePath())); |
|
860 |
||
861 |
return outFile; |
|
862 |
} |
|
863 |
||
864 |
@Override |
|
865 |
public String getName() { |
|
57059 | 866 |
return I18N.getString("deb.bundler.name"); |
57038 | 867 |
} |
868 |
||
869 |
@Override |
|
870 |
public String getDescription() { |
|
57059 | 871 |
return I18N.getString("deb.bundler.description"); |
57038 | 872 |
} |
873 |
||
874 |
@Override |
|
875 |
public String getID() { |
|
876 |
return "deb"; |
|
877 |
} |
|
878 |
||
879 |
@Override |
|
880 |
public String getBundleType() { |
|
881 |
return "INSTALLER"; |
|
882 |
} |
|
883 |
||
884 |
@Override |
|
885 |
public Collection<BundlerParamInfo<?>> getBundleParameters() { |
|
886 |
Collection<BundlerParamInfo<?>> results = new LinkedHashSet<>(); |
|
887 |
results.addAll(LinuxAppBundler.getAppBundleParameters()); |
|
888 |
results.addAll(getDebBundleParameters()); |
|
889 |
return results; |
|
890 |
} |
|
891 |
||
892 |
public static Collection<BundlerParamInfo<?>> getDebBundleParameters() { |
|
893 |
return Arrays.asList( |
|
894 |
BUNDLE_NAME, |
|
895 |
COPYRIGHT, |
|
896 |
CATEGORY, |
|
897 |
DESCRIPTION, |
|
898 |
EMAIL, |
|
899 |
ICON_PNG, |
|
900 |
LICENSE_FILE, |
|
901 |
TITLE, |
|
902 |
VENDOR |
|
903 |
); |
|
904 |
} |
|
905 |
||
906 |
@Override |
|
907 |
public File execute(Map<String, ? super Object> params, |
|
908 |
File outputParentDir) { |
|
909 |
return bundle(params, outputParentDir); |
|
910 |
} |
|
911 |
||
912 |
@Override |
|
913 |
public boolean supported() { |
|
914 |
return (Platform.getPlatform() == Platform.LINUX); |
|
915 |
} |
|
916 |
||
917 |
public int getSquareSizeOfImage(File f) { |
|
918 |
try { |
|
919 |
BufferedImage bi = ImageIO.read(f); |
|
920 |
if (bi.getWidth() == bi.getHeight()) { |
|
921 |
return bi.getWidth(); |
|
922 |
} else { |
|
923 |
return 0; |
|
924 |
} |
|
925 |
} catch (Exception e) { |
|
926 |
e.printStackTrace(); |
|
927 |
return 0; |
|
928 |
} |
|
929 |
} |
|
930 |
} |