author | herrick |
Thu, 06 Dec 2018 16:45:26 -0500 | |
branch | JDK-8200758-branch |
changeset 57062 | 044e7a644ee3 |
parent 57059 | 9bb2a4dc3af7 |
child 57067 | 9c17d779808e |
permissions | -rw-r--r-- |
57038 | 1 |
/* |
2 |
* Copyright (c) 2017, 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 |
|
57039 | 28 |
import jdk.jpackage.internal.*; |
29 |
import jdk.jpackage.internal.ConfigException; |
|
30 |
import jdk.jpackage.internal.Arguments; |
|
31 |
import jdk.jpackage.internal.UnsupportedPlatformException; |
|
32 |
import jdk.jpackage.internal.resources.WinResources; |
|
57038 | 33 |
|
34 |
import java.io.*; |
|
35 |
import java.nio.charset.Charset; |
|
36 |
import java.nio.file.Files; |
|
37 |
import java.text.MessageFormat; |
|
38 |
import java.util.*; |
|
39 |
import java.util.regex.Matcher; |
|
40 |
import java.util.regex.Pattern; |
|
41 |
||
57039 | 42 |
import static jdk.jpackage.internal.WindowsBundlerParam.*; |
57038 | 43 |
|
44 |
public class WinExeBundler extends AbstractBundler { |
|
45 |
||
46 |
private static final ResourceBundle I18N = ResourceBundle.getBundle( |
|
57059 | 47 |
"jdk.jpackage.internal.resources.WinResources"); |
57038 | 48 |
|
49 |
public static final BundlerParamInfo<WinAppBundler> APP_BUNDLER = |
|
50 |
new WindowsBundlerParam<>( |
|
57059 | 51 |
getString("param.exe-bundler.name"), |
52 |
getString("param.exe-bundler.description"), |
|
57038 | 53 |
"win.app.bundler", |
54 |
WinAppBundler.class, |
|
55 |
params -> new WinAppBundler(), |
|
56 |
null); |
|
57 |
||
58 |
public static final BundlerParamInfo<File> CONFIG_ROOT = |
|
59 |
new WindowsBundlerParam<>( |
|
60 |
getString("param.config-root.name"), |
|
61 |
getString("param.config-root.description"), |
|
62 |
"configRoot", |
|
63 |
File.class, |
|
64 |
params -> { |
|
65 |
File imagesRoot = |
|
66 |
new File(BUILD_ROOT.fetchFrom(params), "windows"); |
|
67 |
imagesRoot.mkdirs(); |
|
68 |
return imagesRoot; |
|
69 |
}, |
|
70 |
(s, p) -> null); |
|
71 |
||
72 |
public static final BundlerParamInfo<File> EXE_IMAGE_DIR = |
|
73 |
new WindowsBundlerParam<>( |
|
74 |
getString("param.image-dir.name"), |
|
75 |
getString("param.image-dir.description"), |
|
76 |
"win.exe.imageDir", |
|
77 |
File.class, |
|
78 |
params -> { |
|
79 |
File imagesRoot = IMAGES_ROOT.fetchFrom(params); |
|
80 |
if (!imagesRoot.exists()) imagesRoot.mkdirs(); |
|
81 |
return new File(imagesRoot, "win-exe.image"); |
|
82 |
}, |
|
83 |
(s, p) -> null); |
|
84 |
||
85 |
public static final BundlerParamInfo<File> WIN_APP_IMAGE = |
|
86 |
new WindowsBundlerParam<>( |
|
87 |
getString("param.app-dir.name"), |
|
88 |
getString("param.app-dir.description"), |
|
89 |
"win.app.image", |
|
90 |
File.class, |
|
91 |
null, |
|
92 |
(s, p) -> null); |
|
93 |
||
57062
044e7a644ee3
8214575: Exe installers will install application to already existing instalation
herrick
parents:
57059
diff
changeset
|
94 |
public static final BundlerParamInfo<UUID> UPGRADE_UUID = |
044e7a644ee3
8214575: Exe installers will install application to already existing instalation
herrick
parents:
57059
diff
changeset
|
95 |
new WindowsBundlerParam<>( |
044e7a644ee3
8214575: Exe installers will install application to already existing instalation
herrick
parents:
57059
diff
changeset
|
96 |
I18N.getString("param.upgrade-uuid.name"), |
044e7a644ee3
8214575: Exe installers will install application to already existing instalation
herrick
parents:
57059
diff
changeset
|
97 |
I18N.getString("param.upgrade-uuid.description"), |
044e7a644ee3
8214575: Exe installers will install application to already existing instalation
herrick
parents:
57059
diff
changeset
|
98 |
Arguments.CLIOptions.WIN_UPGRADE_UUID.getId(), |
044e7a644ee3
8214575: Exe installers will install application to already existing instalation
herrick
parents:
57059
diff
changeset
|
99 |
UUID.class, |
044e7a644ee3
8214575: Exe installers will install application to already existing instalation
herrick
parents:
57059
diff
changeset
|
100 |
params -> UUID.randomUUID(), |
044e7a644ee3
8214575: Exe installers will install application to already existing instalation
herrick
parents:
57059
diff
changeset
|
101 |
(s, p) -> UUID.fromString(s)); |
57038 | 102 |
|
103 |
public static final StandardBundlerParam<Boolean> EXE_SYSTEM_WIDE = |
|
104 |
new StandardBundlerParam<>( |
|
105 |
getString("param.system-wide.name"), |
|
106 |
getString("param.system-wide.description"), |
|
107 |
Arguments.CLIOptions.WIN_PER_USER_INSTALLATION.getId(), |
|
108 |
Boolean.class, |
|
109 |
params -> true, // default to system wide |
|
110 |
(s, p) -> (s == null || "null".equalsIgnoreCase(s))? null |
|
111 |
: Boolean.valueOf(s) |
|
112 |
); |
|
113 |
public static final StandardBundlerParam<String> PRODUCT_VERSION = |
|
114 |
new StandardBundlerParam<>( |
|
115 |
getString("param.product-version.name"), |
|
116 |
getString("param.product-version.description"), |
|
117 |
"win.msi.productVersion", |
|
118 |
String.class, |
|
119 |
VERSION::fetchFrom, |
|
120 |
(s, p) -> s |
|
121 |
); |
|
122 |
||
123 |
public static final StandardBundlerParam<Boolean> MENU_HINT = |
|
124 |
new WindowsBundlerParam<>( |
|
125 |
getString("param.menu-shortcut-hint.name"), |
|
126 |
getString("param.menu-shortcut-hint.description"), |
|
127 |
Arguments.CLIOptions.WIN_MENU_HINT.getId(), |
|
128 |
Boolean.class, |
|
129 |
params -> false, |
|
130 |
(s, p) -> (s == null || |
|
131 |
"null".equalsIgnoreCase(s))? true : Boolean.valueOf(s) |
|
132 |
); |
|
133 |
||
134 |
public static final StandardBundlerParam<Boolean> SHORTCUT_HINT = |
|
135 |
new WindowsBundlerParam<>( |
|
136 |
getString("param.desktop-shortcut-hint.name"), |
|
137 |
getString("param.desktop-shortcut-hint.description"), |
|
138 |
Arguments.CLIOptions.WIN_SHORTCUT_HINT.getId(), |
|
139 |
Boolean.class, |
|
140 |
params -> false, |
|
141 |
(s, p) -> (s == null || |
|
142 |
"null".equalsIgnoreCase(s))? false : Boolean.valueOf(s) |
|
143 |
); |
|
144 |
||
145 |
private final static String DEFAULT_EXE_PROJECT_TEMPLATE = "template.iss"; |
|
146 |
private final static String DEFAULT_JRE_EXE_TEMPLATE = "template.jre.iss"; |
|
147 |
private static final String TOOL_INNO_SETUP_COMPILER = "iscc.exe"; |
|
148 |
||
149 |
public static final BundlerParamInfo<String> |
|
150 |
TOOL_INNO_SETUP_COMPILER_EXECUTABLE = new WindowsBundlerParam<>( |
|
151 |
getString("param.iscc-path.name"), |
|
152 |
getString("param.iscc-path.description"), |
|
153 |
"win.exe.iscc.exe", |
|
154 |
String.class, |
|
155 |
params -> { |
|
156 |
for (String dirString : (System.getenv("PATH") |
|
157 |
+ ";C:\\Program Files (x86)\\Inno Setup 5;" |
|
158 |
+ "C:\\Program Files\\Inno Setup 5").split(";")) { |
|
159 |
File f = new File(dirString.replace("\"", ""), |
|
160 |
TOOL_INNO_SETUP_COMPILER); |
|
161 |
if (f.isFile()) { |
|
162 |
return f.toString(); |
|
163 |
} |
|
164 |
} |
|
165 |
return null; |
|
166 |
}, |
|
167 |
null); |
|
168 |
||
169 |
public WinExeBundler() { |
|
170 |
super(); |
|
171 |
baseResourceLoader = WinResources.class; |
|
172 |
} |
|
173 |
||
174 |
@Override |
|
175 |
public String getName() { |
|
57059 | 176 |
return getString("exe.bundler.name"); |
57038 | 177 |
} |
178 |
||
179 |
@Override |
|
180 |
public String getDescription() { |
|
57059 | 181 |
return getString("exe.bundler.description"); |
57038 | 182 |
} |
183 |
||
184 |
@Override |
|
185 |
public String getID() { |
|
186 |
return "exe"; |
|
187 |
} |
|
188 |
||
189 |
@Override |
|
190 |
public String getBundleType() { |
|
191 |
return "INSTALLER"; |
|
192 |
} |
|
193 |
||
194 |
@Override |
|
195 |
public Collection<BundlerParamInfo<?>> getBundleParameters() { |
|
196 |
Collection<BundlerParamInfo<?>> results = new LinkedHashSet<>(); |
|
197 |
results.addAll(WinAppBundler.getAppBundleParameters()); |
|
198 |
results.addAll(getExeBundleParameters()); |
|
199 |
return results; |
|
200 |
} |
|
201 |
||
202 |
public static Collection<BundlerParamInfo<?>> getExeBundleParameters() { |
|
203 |
return Arrays.asList( |
|
204 |
DESCRIPTION, |
|
205 |
COPYRIGHT, |
|
206 |
LICENSE_FILE, |
|
207 |
MENU_GROUP, |
|
208 |
MENU_HINT, |
|
209 |
SHORTCUT_HINT, |
|
210 |
EXE_SYSTEM_WIDE, |
|
211 |
TITLE, |
|
212 |
VENDOR, |
|
213 |
INSTALLDIR_CHOOSER |
|
214 |
); |
|
215 |
} |
|
216 |
||
217 |
@Override |
|
218 |
public File execute( |
|
219 |
Map<String, ? super Object> p, File outputParentDir) { |
|
220 |
return bundle(p, outputParentDir); |
|
221 |
} |
|
222 |
||
223 |
@Override |
|
224 |
public boolean supported() { |
|
225 |
return (Platform.getPlatform() == Platform.WINDOWS); |
|
226 |
} |
|
227 |
||
228 |
static class VersionExtractor extends PrintStream { |
|
229 |
double version = 0f; |
|
230 |
||
231 |
public VersionExtractor() { |
|
232 |
super(new ByteArrayOutputStream()); |
|
233 |
} |
|
234 |
||
235 |
double getVersion() { |
|
236 |
if (version == 0f) { |
|
237 |
String content = |
|
238 |
new String(((ByteArrayOutputStream) out).toByteArray()); |
|
239 |
Pattern pattern = Pattern.compile("Inno Setup (\\d+.?\\d*)"); |
|
240 |
Matcher matcher = pattern.matcher(content); |
|
241 |
if (matcher.find()) { |
|
242 |
String v = matcher.group(1); |
|
243 |
version = Double.parseDouble(v); |
|
244 |
} |
|
245 |
} |
|
246 |
return version; |
|
247 |
} |
|
248 |
} |
|
249 |
||
250 |
private static double findToolVersion(String toolName) { |
|
251 |
try { |
|
252 |
if (toolName == null || "".equals(toolName)) return 0f; |
|
253 |
||
254 |
ProcessBuilder pb = new ProcessBuilder( |
|
255 |
toolName, |
|
256 |
"/?"); |
|
257 |
VersionExtractor ve = new VersionExtractor(); |
|
258 |
IOUtils.exec(pb, Log.isDebug(), true, ve); |
|
259 |
// not interested in the output |
|
260 |
double version = ve.getVersion(); |
|
261 |
Log.verbose(MessageFormat.format( |
|
262 |
getString("message.tool-version"), toolName, version)); |
|
263 |
return version; |
|
264 |
} catch (Exception e) { |
|
265 |
if (Log.isDebug()) { |
|
266 |
Log.verbose(e); |
|
267 |
} |
|
268 |
return 0f; |
|
269 |
} |
|
270 |
} |
|
271 |
||
272 |
@Override |
|
273 |
public boolean validate(Map<String, ? super Object> p) |
|
274 |
throws UnsupportedPlatformException, ConfigException { |
|
275 |
try { |
|
276 |
if (p == null) throw new ConfigException( |
|
277 |
getString("error.parameters-null"), |
|
278 |
getString("error.parameters-null.advice")); |
|
279 |
||
280 |
// run basic validation to ensure requirements are met |
|
281 |
// we are not interested in return code, only possible exception |
|
282 |
APP_BUNDLER.fetchFrom(p).validate(p); |
|
283 |
||
284 |
// make sure some key values don't have newlines |
|
285 |
for (BundlerParamInfo<String> pi : Arrays.asList( |
|
286 |
APP_NAME, |
|
287 |
COPYRIGHT, |
|
288 |
DESCRIPTION, |
|
289 |
MENU_GROUP, |
|
290 |
TITLE, |
|
291 |
VENDOR, |
|
292 |
VERSION) |
|
293 |
) { |
|
294 |
String v = pi.fetchFrom(p); |
|
295 |
if (v.contains("\n") | v.contains("\r")) { |
|
296 |
throw new ConfigException("Parmeter '" + pi.getID() + |
|
297 |
"' cannot contain a newline.", |
|
298 |
" Change the value of '" + pi.getID() + |
|
299 |
" so that it does not contain any newlines"); |
|
300 |
} |
|
301 |
} |
|
302 |
||
303 |
// exe bundlers trim the copyright to 100 characters, |
|
304 |
// tell them this will happen |
|
305 |
if (COPYRIGHT.fetchFrom(p).length() > 100) { |
|
306 |
throw new ConfigException( |
|
307 |
getString("error.copyright-is-too-long"), |
|
308 |
getString("error.copyright-is-too-long.advice")); |
|
309 |
} |
|
310 |
||
311 |
double innoVersion = findToolVersion( |
|
312 |
TOOL_INNO_SETUP_COMPILER_EXECUTABLE.fetchFrom(p)); |
|
313 |
||
314 |
//Inno Setup 5+ is required |
|
315 |
double minVersion = 5.0f; |
|
316 |
||
317 |
if (innoVersion < minVersion) { |
|
318 |
Log.error(MessageFormat.format( |
|
319 |
getString("message.tool-wrong-version"), |
|
320 |
TOOL_INNO_SETUP_COMPILER, innoVersion, minVersion)); |
|
321 |
throw new ConfigException( |
|
322 |
getString("error.iscc-not-found"), |
|
323 |
getString("error.iscc-not-found.advice")); |
|
324 |
} |
|
325 |
||
326 |
/********* validate bundle parameters *************/ |
|
327 |
||
328 |
// only one mime type per association, at least one file extension |
|
329 |
List<Map<String, ? super Object>> associations = |
|
330 |
FILE_ASSOCIATIONS.fetchFrom(p); |
|
331 |
if (associations != null) { |
|
332 |
for (int i = 0; i < associations.size(); i++) { |
|
333 |
Map<String, ? super Object> assoc = associations.get(i); |
|
334 |
List<String> mimes = FA_CONTENT_TYPE.fetchFrom(assoc); |
|
335 |
if (mimes.size() > 1) { |
|
336 |
throw new ConfigException(MessageFormat.format( |
|
337 |
getString("error.too-many-content-" |
|
338 |
+ "types-for-file-association"), i), |
|
339 |
getString("error.too-many-content-" |
|
340 |
+ "types-for-file-association.advice")); |
|
341 |
} |
|
342 |
} |
|
343 |
} |
|
344 |
||
345 |
// validate license file, if used, exists in the proper place |
|
346 |
if (p.containsKey(LICENSE_FILE.getID())) { |
|
347 |
List<RelativeFileSet> appResourcesList = |
|
348 |
APP_RESOURCES_LIST.fetchFrom(p); |
|
349 |
for (String license : LICENSE_FILE.fetchFrom(p)) { |
|
350 |
boolean found = false; |
|
351 |
for (RelativeFileSet appResources : appResourcesList) { |
|
352 |
found = found || appResources.contains(license); |
|
353 |
} |
|
354 |
if (!found) { |
|
355 |
throw new ConfigException( |
|
356 |
MessageFormat.format(getString( |
|
357 |
"error.license-missing"), license), |
|
358 |
MessageFormat.format(getString( |
|
359 |
"error.license-missing.advice"), license)); |
|
360 |
} |
|
361 |
} |
|
362 |
} |
|
363 |
||
364 |
return true; |
|
365 |
} catch (RuntimeException re) { |
|
366 |
if (re.getCause() instanceof ConfigException) { |
|
367 |
throw (ConfigException) re.getCause(); |
|
368 |
} else { |
|
369 |
throw new ConfigException(re); |
|
370 |
} |
|
371 |
} |
|
372 |
} |
|
373 |
||
374 |
private boolean prepareProto(Map<String, ? super Object> p) |
|
375 |
throws IOException { |
|
376 |
File appImage = StandardBundlerParam.getPredefinedAppImage(p); |
|
377 |
File appDir = null; |
|
378 |
||
379 |
// we either have an application image or need to build one |
|
380 |
if (appImage != null) { |
|
381 |
appDir = new File( |
|
382 |
EXE_IMAGE_DIR.fetchFrom(p), APP_NAME.fetchFrom(p)); |
|
383 |
// copy everything from appImage dir into appDir/name |
|
384 |
IOUtils.copyRecursive(appImage.toPath(), appDir.toPath()); |
|
385 |
} else { |
|
386 |
appDir = APP_BUNDLER.fetchFrom(p).doBundle(p, |
|
387 |
EXE_IMAGE_DIR.fetchFrom(p), true); |
|
388 |
} |
|
389 |
||
390 |
if (appDir == null) { |
|
391 |
return false; |
|
392 |
} |
|
393 |
||
394 |
p.put(WIN_APP_IMAGE.getID(), appDir); |
|
395 |
||
396 |
List<String> licenseFiles = LICENSE_FILE.fetchFrom(p); |
|
397 |
if (licenseFiles != null) { |
|
398 |
// need to copy license file to the root of win.app.image |
|
399 |
outerLoop: |
|
400 |
for (RelativeFileSet rfs : APP_RESOURCES_LIST.fetchFrom(p)) { |
|
401 |
for (String s : licenseFiles) { |
|
402 |
if (rfs.contains(s)) { |
|
403 |
File lfile = new File(rfs.getBaseDirectory(), s); |
|
404 |
File destFile = |
|
405 |
new File(appDir.getParentFile(), lfile.getName()); |
|
406 |
IOUtils.copyFile(lfile, destFile); |
|
407 |
ensureByMutationFileIsRTF(destFile); |
|
408 |
break outerLoop; |
|
409 |
} |
|
410 |
} |
|
411 |
} |
|
412 |
} |
|
413 |
||
414 |
// copy file association icons |
|
415 |
List<Map<String, ? super Object>> fileAssociations = |
|
416 |
FILE_ASSOCIATIONS.fetchFrom(p); |
|
417 |
||
418 |
for (Map<String, ? super Object> fa : fileAssociations) { |
|
419 |
File icon = FA_ICON.fetchFrom(fa); // TODO FA_ICON_ICO |
|
420 |
if (icon == null) { |
|
421 |
continue; |
|
422 |
} |
|
423 |
||
424 |
File faIconFile = new File(appDir, icon.getName()); |
|
425 |
||
426 |
if (icon.exists()) { |
|
427 |
try { |
|
428 |
IOUtils.copyFile(icon, faIconFile); |
|
429 |
} catch (IOException e) { |
|
430 |
e.printStackTrace(); |
|
431 |
} |
|
432 |
} |
|
433 |
} |
|
434 |
||
435 |
return true; |
|
436 |
} |
|
437 |
||
438 |
public File bundle(Map<String, ? super Object> p, File outdir) { |
|
439 |
if (!outdir.isDirectory() && !outdir.mkdirs()) { |
|
440 |
throw new RuntimeException(MessageFormat.format( |
|
441 |
getString("error.cannot-create-output-dir"), |
|
442 |
outdir.getAbsolutePath())); |
|
443 |
} |
|
444 |
if (!outdir.canWrite()) { |
|
445 |
throw new RuntimeException(MessageFormat.format( |
|
446 |
getString("error.cannot-write-to-output-dir"), |
|
447 |
outdir.getAbsolutePath())); |
|
448 |
} |
|
449 |
||
450 |
if (WindowsDefender.isThereAPotentialWindowsDefenderIssue()) { |
|
451 |
Log.error(MessageFormat.format( |
|
452 |
getString("message.potential.windows.defender.issue"), |
|
453 |
WindowsDefender.getUserTempDirectory())); |
|
454 |
} |
|
455 |
||
456 |
// validate we have valid tools before continuing |
|
457 |
String iscc = TOOL_INNO_SETUP_COMPILER_EXECUTABLE.fetchFrom(p); |
|
458 |
if (iscc == null || !new File(iscc).isFile()) { |
|
459 |
Log.error(getString("error.iscc-not-found")); |
|
460 |
Log.error(MessageFormat.format( |
|
461 |
getString("message.iscc-file-string"), iscc)); |
|
462 |
return null; |
|
463 |
} |
|
464 |
||
465 |
File imageDir = EXE_IMAGE_DIR.fetchFrom(p); |
|
466 |
try { |
|
467 |
imageDir.mkdirs(); |
|
468 |
||
469 |
boolean menuShortcut = MENU_HINT.fetchFrom(p); |
|
470 |
boolean desktopShortcut = SHORTCUT_HINT.fetchFrom(p); |
|
471 |
if (!menuShortcut && !desktopShortcut) { |
|
472 |
// both can not be false - user will not find the app |
|
473 |
Log.verbose(getString("message.one-shortcut-required")); |
|
474 |
p.put(MENU_HINT.getID(), true); |
|
475 |
} |
|
476 |
||
477 |
if (prepareProto(p) && prepareProjectConfig(p)) { |
|
478 |
File configScript = getConfig_Script(p); |
|
479 |
if (configScript.exists()) { |
|
480 |
Log.verbose(MessageFormat.format( |
|
481 |
getString("message.running-wsh-script"), |
|
482 |
configScript.getAbsolutePath())); |
|
483 |
IOUtils.run("wscript", configScript, VERBOSE.fetchFrom(p)); |
|
484 |
} |
|
485 |
return buildEXE(p, outdir); |
|
486 |
} |
|
487 |
return null; |
|
488 |
} catch (IOException ex) { |
|
489 |
ex.printStackTrace(); |
|
490 |
return null; |
|
491 |
} finally { |
|
492 |
try { |
|
493 |
if (imageDir != null && |
|
494 |
PREDEFINED_APP_IMAGE.fetchFrom(p) == null && |
|
495 |
(PREDEFINED_RUNTIME_IMAGE.fetchFrom(p) == null || |
|
496 |
!Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) && |
|
497 |
!Log.isDebug() && |
|
498 |
!Log.isVerbose()) { |
|
499 |
IOUtils.deleteRecursive(imageDir); |
|
500 |
} else if (imageDir != null) { |
|
501 |
Log.verbose(MessageFormat.format( |
|
502 |
I18N.getString("message.debug-working-directory"), |
|
503 |
imageDir.getAbsolutePath())); |
|
504 |
} |
|
505 |
} catch (IOException ex) { |
|
506 |
// noinspection ReturnInsideFinallyBlock |
|
507 |
Log.debug(ex.getMessage()); |
|
508 |
return null; |
|
509 |
} |
|
510 |
} |
|
511 |
} |
|
512 |
||
513 |
// name of post-image script |
|
514 |
private File getConfig_Script(Map<String, ? super Object> p) { |
|
515 |
return new File(EXE_IMAGE_DIR.fetchFrom(p), |
|
516 |
APP_NAME.fetchFrom(p) + "-post-image.wsf"); |
|
517 |
} |
|
518 |
||
519 |
private String getAppIdentifier(Map<String, ? super Object> p) { |
|
57062
044e7a644ee3
8214575: Exe installers will install application to already existing instalation
herrick
parents:
57059
diff
changeset
|
520 |
String nm = UPGRADE_UUID.fetchFrom(p).toString(); |
57038 | 521 |
|
522 |
// limitation of innosetup |
|
523 |
if (nm.length() > 126) { |
|
524 |
Log.error(getString("message-truncating-id")); |
|
525 |
nm = nm.substring(0, 126); |
|
526 |
} |
|
527 |
||
528 |
return nm; |
|
529 |
} |
|
530 |
||
531 |
private String getLicenseFile(Map<String, ? super Object> p) { |
|
532 |
List<String> licenseFiles = LICENSE_FILE.fetchFrom(p); |
|
533 |
if (licenseFiles == null || licenseFiles.isEmpty()) { |
|
534 |
return ""; |
|
535 |
} else { |
|
536 |
return licenseFiles.get(0); |
|
537 |
} |
|
538 |
} |
|
539 |
||
540 |
void validateValueAndPut(Map<String, String> data, String key, |
|
541 |
BundlerParamInfo<String> param, |
|
542 |
Map<String, ? super Object> p) throws IOException { |
|
543 |
String value = param.fetchFrom(p); |
|
544 |
if (value.contains("\r") || value.contains("\n")) { |
|
545 |
throw new IOException("Configuration Parameter " + |
|
546 |
param.getID() + " cannot contain multiple lines of text"); |
|
547 |
} |
|
548 |
data.put(key, innosetupEscape(value)); |
|
549 |
} |
|
550 |
||
551 |
private String innosetupEscape(String value) { |
|
552 |
if (value.contains("\"") || !value.trim().equals(value)) { |
|
553 |
value = "\"" + value.replace("\"", "\"\"") + "\""; |
|
554 |
} |
|
555 |
return value; |
|
556 |
} |
|
557 |
||
558 |
boolean prepareMainProjectFile(Map<String, ? super Object> p) |
|
559 |
throws IOException { |
|
560 |
Map<String, String> data = new HashMap<>(); |
|
561 |
data.put("PRODUCT_APP_IDENTIFIER", |
|
562 |
innosetupEscape(getAppIdentifier(p))); |
|
563 |
||
564 |
||
565 |
validateValueAndPut(data, "INSTALLER_NAME", APP_NAME, p); |
|
566 |
validateValueAndPut(data, "APPLICATION_VENDOR", VENDOR, p); |
|
567 |
validateValueAndPut(data, "APPLICATION_VERSION", VERSION, p); |
|
568 |
validateValueAndPut(data, "INSTALLER_FILE_NAME", |
|
569 |
INSTALLER_FILE_NAME, p); |
|
570 |
||
571 |
data.put("LAUNCHER_NAME", |
|
572 |
innosetupEscape(WinAppBundler.getAppName(p))); |
|
573 |
||
574 |
data.put("APPLICATION_LAUNCHER_FILENAME", |
|
575 |
innosetupEscape(WinAppBundler.getLauncherName(p))); |
|
576 |
||
577 |
data.put("APPLICATION_DESKTOP_SHORTCUT", |
|
578 |
SHORTCUT_HINT.fetchFrom(p) ? "returnTrue" : "returnFalse"); |
|
579 |
data.put("APPLICATION_MENU_SHORTCUT", |
|
580 |
MENU_HINT.fetchFrom(p) ? "returnTrue" : "returnFalse"); |
|
581 |
validateValueAndPut(data, "APPLICATION_GROUP", MENU_GROUP, p); |
|
582 |
validateValueAndPut(data, "APPLICATION_COMMENTS", TITLE, p); |
|
583 |
validateValueAndPut(data, "APPLICATION_COPYRIGHT", COPYRIGHT, p); |
|
584 |
||
585 |
data.put("APPLICATION_LICENSE_FILE", |
|
586 |
innosetupEscape(getLicenseFile(p))); |
|
587 |
data.put("DISABLE_DIR_PAGE", |
|
588 |
INSTALLDIR_CHOOSER.fetchFrom(p) ? "No" : "Yes"); |
|
589 |
||
590 |
Boolean isSystemWide = EXE_SYSTEM_WIDE.fetchFrom(p); |
|
591 |
||
592 |
if (isSystemWide) { |
|
593 |
data.put("APPLICATION_INSTALL_ROOT", "{pf}"); |
|
594 |
data.put("APPLICATION_INSTALL_PRIVILEGE", "admin"); |
|
595 |
} else { |
|
596 |
data.put("APPLICATION_INSTALL_ROOT", "{localappdata}"); |
|
597 |
data.put("APPLICATION_INSTALL_PRIVILEGE", "lowest"); |
|
598 |
} |
|
599 |
||
600 |
if (BIT_ARCH_64.fetchFrom(p)) { |
|
601 |
data.put("ARCHITECTURE_BIT_MODE", "x64"); |
|
602 |
} else { |
|
603 |
data.put("ARCHITECTURE_BIT_MODE", ""); |
|
604 |
} |
|
605 |
validateValueAndPut(data, "RUN_FILENAME", APP_NAME, p); |
|
606 |
||
607 |
validateValueAndPut(data, "APPLICATION_DESCRIPTION", |
|
608 |
DESCRIPTION, p); |
|
609 |
||
610 |
data.put("APPLICATION_SERVICE", "returnFalse"); |
|
611 |
data.put("APPLICATION_NOT_SERVICE", "returnFalse"); |
|
612 |
data.put("APPLICATION_APP_CDS_INSTALL", "returnFalse"); |
|
613 |
data.put("START_ON_INSTALL", ""); |
|
614 |
data.put("STOP_ON_UNINSTALL", ""); |
|
615 |
data.put("RUN_AT_STARTUP", ""); |
|
616 |
||
617 |
StringBuilder secondaryLaunchersCfg = new StringBuilder(); |
|
618 |
for (Map<String, ? super Object> |
|
619 |
launcher : SECONDARY_LAUNCHERS.fetchFrom(p)) { |
|
620 |
String application_name = APP_NAME.fetchFrom(launcher); |
|
621 |
if (MENU_HINT.fetchFrom(launcher)) { |
|
622 |
// Name: "{group}\APPLICATION_NAME"; |
|
623 |
// Filename: "{app}\APPLICATION_NAME.exe"; |
|
624 |
// IconFilename: "{app}\APPLICATION_NAME.ico" |
|
625 |
secondaryLaunchersCfg.append("Name: \"{group}\\"); |
|
626 |
secondaryLaunchersCfg.append(application_name); |
|
627 |
secondaryLaunchersCfg.append("\"; Filename: \"{app}\\"); |
|
628 |
secondaryLaunchersCfg.append(application_name); |
|
629 |
secondaryLaunchersCfg.append(".exe\"; IconFilename: \"{app}\\"); |
|
630 |
secondaryLaunchersCfg.append(application_name); |
|
631 |
secondaryLaunchersCfg.append(".ico\"\r\n"); |
|
632 |
} |
|
633 |
if (SHORTCUT_HINT.fetchFrom(launcher)) { |
|
634 |
// Name: "{commondesktop}\APPLICATION_NAME"; |
|
635 |
// Filename: "{app}\APPLICATION_NAME.exe"; |
|
636 |
// IconFilename: "{app}\APPLICATION_NAME.ico" |
|
637 |
secondaryLaunchersCfg.append("Name: \"{commondesktop}\\"); |
|
638 |
secondaryLaunchersCfg.append(application_name); |
|
639 |
secondaryLaunchersCfg.append("\"; Filename: \"{app}\\"); |
|
640 |
secondaryLaunchersCfg.append(application_name); |
|
641 |
secondaryLaunchersCfg.append(".exe\"; IconFilename: \"{app}\\"); |
|
642 |
secondaryLaunchersCfg.append(application_name); |
|
643 |
secondaryLaunchersCfg.append(".ico\"\r\n"); |
|
644 |
} |
|
645 |
} |
|
646 |
data.put("SECONDARY_LAUNCHERS", secondaryLaunchersCfg.toString()); |
|
647 |
||
648 |
StringBuilder registryEntries = new StringBuilder(); |
|
649 |
String regName = APP_REGISTRY_NAME.fetchFrom(p); |
|
650 |
List<Map<String, ? super Object>> fetchFrom = |
|
651 |
FILE_ASSOCIATIONS.fetchFrom(p); |
|
652 |
for (int i = 0; i < fetchFrom.size(); i++) { |
|
653 |
Map<String, ? super Object> fileAssociation = fetchFrom.get(i); |
|
654 |
String description = FA_DESCRIPTION.fetchFrom(fileAssociation); |
|
655 |
File icon = FA_ICON.fetchFrom(fileAssociation); //TODO FA_ICON_ICO |
|
656 |
||
657 |
List<String> extensions = FA_EXTENSIONS.fetchFrom(fileAssociation); |
|
658 |
String entryName = regName + "File"; |
|
659 |
if (i > 0) { |
|
660 |
entryName += "." + i; |
|
661 |
} |
|
662 |
||
663 |
if (extensions == null) { |
|
664 |
Log.verbose(getString( |
|
665 |
"message.creating-association-with-null-extension")); |
|
666 |
} else { |
|
667 |
for (String ext : extensions) { |
|
668 |
if (isSystemWide) { |
|
669 |
// "Root: HKCR; Subkey: \".myp\"; |
|
670 |
// ValueType: string; ValueName: \"\"; |
|
671 |
// ValueData: \"MyProgramFile\"; |
|
672 |
// Flags: uninsdeletevalue" |
|
673 |
registryEntries.append("Root: HKCR; Subkey: \".") |
|
674 |
.append(ext) |
|
675 |
.append("\"; ValueType: string;" |
|
676 |
+ " ValueName: \"\"; ValueData: \"") |
|
677 |
.append(entryName) |
|
678 |
.append("\"; Flags: uninsdeletevalue\r\n"); |
|
679 |
} else { |
|
680 |
registryEntries.append( |
|
681 |
"Root: HKCU; Subkey: \"Software\\Classes\\.") |
|
682 |
.append(ext) |
|
683 |
.append("\"; ValueType: string;" |
|
684 |
+ " ValueName: \"\"; ValueData: \"") |
|
685 |
.append(entryName) |
|
686 |
.append("\"; Flags: uninsdeletevalue\r\n"); |
|
687 |
} |
|
688 |
} |
|
689 |
} |
|
690 |
||
691 |
if (extensions != null && !extensions.isEmpty()) { |
|
692 |
String ext = extensions.get(0); |
|
693 |
List<String> mimeTypes = |
|
694 |
FA_CONTENT_TYPE.fetchFrom(fileAssociation); |
|
695 |
for (String mime : mimeTypes) { |
|
696 |
if (isSystemWide) { |
|
697 |
// "Root: HKCR; |
|
698 |
// Subkey: HKCR\\Mime\\Database\\ |
|
699 |
// Content Type\\application/chaos; |
|
700 |
// ValueType: string; |
|
701 |
// ValueName: Extension; |
|
702 |
// ValueData: .chaos; |
|
703 |
// Flags: uninsdeletevalue" |
|
704 |
registryEntries.append("Root: HKCR; Subkey: " + |
|
705 |
"\"Mime\\Database\\Content Type\\") |
|
706 |
.append(mime) |
|
707 |
.append("\"; ValueType: string; ValueName: " + |
|
708 |
"\"Extension\"; ValueData: \".") |
|
709 |
.append(ext) |
|
710 |
.append("\"; Flags: uninsdeletevalue\r\n"); |
|
711 |
} else { |
|
712 |
registryEntries.append( |
|
713 |
"Root: HKCU; Subkey: \"Software\\" + |
|
714 |
"Classes\\Mime\\Database\\Content Type\\") |
|
715 |
.append(mime) |
|
716 |
.append("\"; ValueType: string; " + |
|
717 |
"ValueName: \"Extension\"; ValueData: \".") |
|
718 |
.append(ext) |
|
719 |
.append("\"; Flags: uninsdeletevalue\r\n"); |
|
720 |
} |
|
721 |
} |
|
722 |
} |
|
723 |
||
724 |
if (isSystemWide) { |
|
725 |
// "Root: HKCR; |
|
726 |
// Subkey: \"MyProgramFile\"; |
|
727 |
// ValueType: string; |
|
728 |
// ValueName: \"\"; |
|
729 |
// ValueData: \"My Program File\"; |
|
730 |
// Flags: uninsdeletekey" |
|
731 |
registryEntries.append("Root: HKCR; Subkey: \"") |
|
732 |
.append(entryName) |
|
733 |
.append( |
|
734 |
"\"; ValueType: string; ValueName: \"\"; ValueData: \"") |
|
735 |
.append(removeQuotes(description)) |
|
736 |
.append("\"; Flags: uninsdeletekey\r\n"); |
|
737 |
} else { |
|
738 |
registryEntries.append( |
|
739 |
"Root: HKCU; Subkey: \"Software\\Classes\\") |
|
740 |
.append(entryName) |
|
741 |
.append( |
|
742 |
"\"; ValueType: string; ValueName: \"\"; ValueData: \"") |
|
743 |
.append(removeQuotes(description)) |
|
744 |
.append("\"; Flags: uninsdeletekey\r\n"); |
|
745 |
} |
|
746 |
||
747 |
if (icon != null && icon.exists()) { |
|
748 |
if (isSystemWide) { |
|
749 |
// "Root: HKCR; |
|
750 |
// Subkey: \"MyProgramFile\\DefaultIcon\"; |
|
751 |
// ValueType: string; |
|
752 |
// ValueName: \"\"; |
|
753 |
// ValueData: \"{app}\\MYPROG.EXE,0\"\n" + |
|
754 |
registryEntries.append("Root: HKCR; Subkey: \"") |
|
755 |
.append(entryName) |
|
756 |
.append("\\DefaultIcon\"; ValueType: string; " + |
|
757 |
"ValueName: \"\"; ValueData: \"{app}\\") |
|
758 |
.append(icon.getName()) |
|
759 |
.append("\"\r\n"); |
|
760 |
} else { |
|
761 |
registryEntries.append( |
|
762 |
"Root: HKCU; Subkey: \"Software\\Classes\\") |
|
763 |
.append(entryName) |
|
764 |
.append("\\DefaultIcon\"; ValueType: string; " + |
|
765 |
"ValueName: \"\"; ValueData: \"{app}\\") |
|
766 |
.append(icon.getName()) |
|
767 |
.append("\"\r\n"); |
|
768 |
} |
|
769 |
} |
|
770 |
||
771 |
if (isSystemWide) { |
|
772 |
// "Root: HKCR; |
|
773 |
// Subkey: \"MyProgramFile\\shell\\open\\command\"; |
|
774 |
// ValueType: string; |
|
775 |
// ValueName: \"\"; |
|
776 |
// ValueData: \"\"\"{app}\\MYPROG.EXE\"\" \"\"%1\"\"\"\n" |
|
777 |
registryEntries.append("Root: HKCR; Subkey: \"") |
|
778 |
.append(entryName) |
|
779 |
.append("\\shell\\open\\command\"; ValueType: " + |
|
780 |
"string; ValueName: \"\"; ValueData: \"\"\"{app}\\") |
|
781 |
.append(APP_NAME.fetchFrom(p)) |
|
782 |
.append("\"\" \"\"%1\"\"\"\r\n"); |
|
783 |
} else { |
|
784 |
registryEntries.append( |
|
785 |
"Root: HKCU; Subkey: \"Software\\Classes\\") |
|
786 |
.append(entryName) |
|
787 |
.append("\\shell\\open\\command\"; ValueType: " + |
|
788 |
"string; ValueName: \"\"; ValueData: \"\"\"{app}\\") |
|
789 |
.append(APP_NAME.fetchFrom(p)) |
|
790 |
.append("\"\" \"\"%1\"\"\"\r\n"); |
|
791 |
} |
|
792 |
} |
|
793 |
if (registryEntries.length() > 0) { |
|
794 |
data.put("FILE_ASSOCIATIONS", |
|
795 |
"ChangesAssociations=yes\r\n\r\n[Registry]\r\n" + |
|
796 |
registryEntries.toString()); |
|
797 |
} else { |
|
798 |
data.put("FILE_ASSOCIATIONS", ""); |
|
799 |
} |
|
800 |
||
801 |
// TODO - alternate template for JRE installer |
|
802 |
String iss = Arguments.CREATE_JRE_INSTALLER.fetchFrom(p) ? |
|
803 |
DEFAULT_JRE_EXE_TEMPLATE : DEFAULT_EXE_PROJECT_TEMPLATE; |
|
804 |
||
805 |
Writer w = new BufferedWriter(new FileWriter( |
|
806 |
getConfig_ExeProjectFile(p))); |
|
807 |
||
808 |
String content = preprocessTextResource( |
|
809 |
WinAppBundler.WIN_BUNDLER_PREFIX + |
|
810 |
getConfig_ExeProjectFile(p).getName(), |
|
811 |
getString("resource.inno-setup-project-file"), |
|
812 |
iss, data, VERBOSE.fetchFrom(p), |
|
813 |
DROP_IN_RESOURCES_ROOT.fetchFrom(p)); |
|
814 |
w.write(content); |
|
815 |
w.close(); |
|
816 |
return true; |
|
817 |
} |
|
818 |
||
819 |
private final static String removeQuotes(String s) { |
|
820 |
if (s.length() > 2 && s.startsWith("\"") && s.endsWith("\"")) { |
|
821 |
// special case for '"XXX"' return 'XXX' not '-XXX-' |
|
822 |
// note '"' and '""' are excluded from this special case |
|
823 |
s = s.substring(1, s.length() - 1); |
|
824 |
} |
|
825 |
// if there interior double quotes replace them with '-' |
|
826 |
return s.replaceAll("\"", "-"); |
|
827 |
} |
|
828 |
||
829 |
private final static String DEFAULT_INNO_SETUP_ICON = |
|
830 |
"icon_inno_setup.bmp"; |
|
831 |
||
832 |
private boolean prepareProjectConfig(Map<String, ? super Object> p) |
|
833 |
throws IOException { |
|
834 |
prepareMainProjectFile(p); |
|
835 |
||
836 |
// prepare installer icon |
|
837 |
File iconTarget = getConfig_SmallInnoSetupIcon(p); |
|
838 |
fetchResource(WinAppBundler.WIN_BUNDLER_PREFIX + iconTarget.getName(), |
|
839 |
getString("resource.setup-icon"), |
|
840 |
DEFAULT_INNO_SETUP_ICON, |
|
841 |
iconTarget, |
|
842 |
VERBOSE.fetchFrom(p), |
|
843 |
DROP_IN_RESOURCES_ROOT.fetchFrom(p)); |
|
844 |
||
845 |
fetchResource(WinAppBundler.WIN_BUNDLER_PREFIX + |
|
846 |
getConfig_Script(p).getName(), |
|
847 |
getString("resource.post-install-script"), |
|
848 |
(String) null, |
|
849 |
getConfig_Script(p), |
|
850 |
VERBOSE.fetchFrom(p), |
|
851 |
DROP_IN_RESOURCES_ROOT.fetchFrom(p)); |
|
852 |
return true; |
|
853 |
} |
|
854 |
||
855 |
private File getConfig_SmallInnoSetupIcon( |
|
856 |
Map<String, ? super Object> p) { |
|
857 |
return new File(EXE_IMAGE_DIR.fetchFrom(p), |
|
858 |
APP_NAME.fetchFrom(p) + "-setup-icon.bmp"); |
|
859 |
} |
|
860 |
||
861 |
private File getConfig_ExeProjectFile(Map<String, ? super Object> p) { |
|
862 |
return new File(EXE_IMAGE_DIR.fetchFrom(p), |
|
863 |
APP_NAME.fetchFrom(p) + ".iss"); |
|
864 |
} |
|
865 |
||
866 |
||
867 |
private File buildEXE(Map<String, ? super Object> p, File outdir) |
|
868 |
throws IOException { |
|
869 |
Log.verbose(MessageFormat.format( |
|
870 |
getString("message.outputting-to-location"), |
|
871 |
outdir.getAbsolutePath())); |
|
872 |
||
873 |
outdir.mkdirs(); |
|
874 |
||
875 |
// run Inno Setup |
|
876 |
ProcessBuilder pb = new ProcessBuilder( |
|
877 |
TOOL_INNO_SETUP_COMPILER_EXECUTABLE.fetchFrom(p), |
|
878 |
"/q", // turn off inno setup output |
|
879 |
"/o"+outdir.getAbsolutePath(), |
|
880 |
getConfig_ExeProjectFile(p).getAbsolutePath()); |
|
881 |
pb = pb.directory(EXE_IMAGE_DIR.fetchFrom(p)); |
|
882 |
IOUtils.exec(pb, VERBOSE.fetchFrom(p)); |
|
883 |
||
884 |
Log.verbose(MessageFormat.format( |
|
885 |
getString("message.output-location"), |
|
886 |
outdir.getAbsolutePath())); |
|
887 |
||
888 |
// presume the result is the ".exe" file with the newest modified time |
|
889 |
// not the best solution, but it is the most reliable |
|
890 |
File result = null; |
|
891 |
long lastModified = 0; |
|
892 |
File[] list = outdir.listFiles(); |
|
893 |
if (list != null) { |
|
894 |
for (File f : list) { |
|
895 |
if (f.getName().endsWith(".exe") && |
|
896 |
f.lastModified() > lastModified) { |
|
897 |
result = f; |
|
898 |
lastModified = f.lastModified(); |
|
899 |
} |
|
900 |
} |
|
901 |
} |
|
902 |
||
903 |
return result; |
|
904 |
} |
|
905 |
||
906 |
public static void ensureByMutationFileIsRTF(File f) { |
|
907 |
if (f == null || !f.isFile()) return; |
|
908 |
||
909 |
try { |
|
910 |
boolean existingLicenseIsRTF = false; |
|
911 |
||
912 |
try (FileInputStream fin = new FileInputStream(f)) { |
|
913 |
byte[] firstBits = new byte[7]; |
|
914 |
||
915 |
if (fin.read(firstBits) == firstBits.length) { |
|
916 |
String header = new String(firstBits); |
|
917 |
existingLicenseIsRTF = "{\\rtf1\\".equals(header); |
|
918 |
} |
|
919 |
} |
|
920 |
||
921 |
if (!existingLicenseIsRTF) { |
|
922 |
List<String> oldLicense = Files.readAllLines(f.toPath()); |
|
923 |
try (Writer w = Files.newBufferedWriter( |
|
924 |
f.toPath(), Charset.forName("Windows-1252"))) { |
|
925 |
w.write("{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033" |
|
926 |
+ "{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}}\n" |
|
927 |
+ "\\viewkind4\\uc1\\pard\\sa200\\sl276" |
|
928 |
+ "\\slmult1\\lang9\\fs20 "); |
|
929 |
oldLicense.forEach(l -> { |
|
930 |
try { |
|
931 |
for (char c : l.toCharArray()) { |
|
932 |
if (c < 0x10) { |
|
933 |
w.write("\\'0"); |
|
934 |
w.write(Integer.toHexString(c)); |
|
935 |
} else if (c > 0xff) { |
|
936 |
w.write("\\ud"); |
|
937 |
w.write(Integer.toString(c)); |
|
938 |
w.write("?"); |
|
939 |
} else if ((c < 0x20) || (c >= 0x80) || |
|
940 |
(c == 0x5C) || (c == 0x7B) || |
|
941 |
(c == 0x7D)) { |
|
942 |
w.write("\\'"); |
|
943 |
w.write(Integer.toHexString(c)); |
|
944 |
} else { |
|
945 |
w.write(c); |
|
946 |
} |
|
947 |
} |
|
948 |
if (l.length() < 1) { |
|
949 |
w.write("\\par"); |
|
950 |
} else { |
|
951 |
w.write(" "); |
|
952 |
} |
|
953 |
w.write("\r\n"); |
|
954 |
} catch (IOException e) { |
|
955 |
Log.verbose(e); |
|
956 |
} |
|
957 |
}); |
|
958 |
w.write("}\r\n"); |
|
959 |
} |
|
960 |
} |
|
961 |
} catch (IOException e) { |
|
962 |
Log.verbose(e); |
|
963 |
} |
|
964 |
} |
|
965 |
||
966 |
private static String getString(String key) |
|
967 |
throws MissingResourceException { |
|
968 |
return I18N.getString(key); |
|
969 |
} |
|
970 |
} |