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