47 private static final ResourceBundle I18N = ResourceBundle.getBundle( |
47 private static final ResourceBundle I18N = ResourceBundle.getBundle( |
48 "jdk.jpackage.internal.resources.LinuxResources"); |
48 "jdk.jpackage.internal.resources.LinuxResources"); |
49 |
49 |
50 public static final BundlerParamInfo<LinuxAppBundler> APP_BUNDLER = |
50 public static final BundlerParamInfo<LinuxAppBundler> APP_BUNDLER = |
51 new StandardBundlerParam<>( |
51 new StandardBundlerParam<>( |
52 I18N.getString("param.rpm-app-bundler.name"), |
|
53 I18N.getString("param.rpm-app-bundler.description"), |
|
54 "linux.app.bundler", |
52 "linux.app.bundler", |
55 LinuxAppBundler.class, |
53 LinuxAppBundler.class, |
56 params -> new LinuxAppBundler(), |
54 params -> new LinuxAppBundler(), |
57 null); |
55 null); |
58 |
56 |
59 public static final BundlerParamInfo<File> RPM_IMAGE_DIR = |
57 public static final BundlerParamInfo<File> RPM_IMAGE_DIR = |
60 new StandardBundlerParam<>( |
58 new StandardBundlerParam<>( |
61 I18N.getString("param.image-dir.name"), |
|
62 I18N.getString("param.image-dir.description"), |
|
63 "linux.rpm.imageDir", |
59 "linux.rpm.imageDir", |
64 File.class, |
60 File.class, |
65 params -> { |
61 params -> { |
66 File imagesRoot = IMAGES_ROOT.fetchFrom(params); |
62 File imagesRoot = IMAGES_ROOT.fetchFrom(params); |
67 if (!imagesRoot.exists()) imagesRoot.mkdirs(); |
63 if (!imagesRoot.exists()) imagesRoot.mkdirs(); |
80 private static final Pattern RPM_BUNDLE_NAME_PATTERN = |
76 private static final Pattern RPM_BUNDLE_NAME_PATTERN = |
81 Pattern.compile("[a-z\\d\\+\\-\\.\\_]+", Pattern.CASE_INSENSITIVE); |
77 Pattern.compile("[a-z\\d\\+\\-\\.\\_]+", Pattern.CASE_INSENSITIVE); |
82 |
78 |
83 public static final BundlerParamInfo<String> BUNDLE_NAME = |
79 public static final BundlerParamInfo<String> BUNDLE_NAME = |
84 new StandardBundlerParam<> ( |
80 new StandardBundlerParam<> ( |
85 I18N.getString("param.bundle-name.name"), |
|
86 I18N.getString("param.bundle-name.description"), |
|
87 Arguments.CLIOptions.LINUX_BUNDLE_NAME.getId(), |
81 Arguments.CLIOptions.LINUX_BUNDLE_NAME.getId(), |
88 String.class, |
82 String.class, |
89 params -> { |
83 params -> { |
90 String nm = APP_NAME.fetchFrom(params); |
84 String nm = APP_NAME.fetchFrom(params); |
91 if (nm == null) return null; |
85 if (nm == null) return null; |
106 |
100 |
107 return s; |
101 return s; |
108 } |
102 } |
109 ); |
103 ); |
110 |
104 |
|
105 public static final BundlerParamInfo<String> MENU_GROUP = |
|
106 new StandardBundlerParam<>( |
|
107 Arguments.CLIOptions.LINUX_MENU_GROUP.getId(), |
|
108 String.class, |
|
109 params -> I18N.getString("param.menu-group.default"), |
|
110 (s, p) -> s |
|
111 ); |
|
112 |
111 public static final BundlerParamInfo<String> LICENSE_TYPE = |
113 public static final BundlerParamInfo<String> LICENSE_TYPE = |
112 new StandardBundlerParam<>( |
114 new StandardBundlerParam<>( |
113 I18N.getString("param.license-type.name"), |
|
114 I18N.getString("param.license-type.description"), |
|
115 Arguments.CLIOptions.LINUX_RPM_LICENSE_TYPE.getId(), |
115 Arguments.CLIOptions.LINUX_RPM_LICENSE_TYPE.getId(), |
116 String.class, |
116 String.class, |
117 params -> I18N.getString("param.license-type.default"), |
117 params -> I18N.getString("param.license-type.default"), |
118 (s, p) -> s |
118 (s, p) -> s |
119 ); |
119 ); |
120 |
120 |
121 public static final BundlerParamInfo<String> XDG_FILE_PREFIX = |
121 public static final BundlerParamInfo<String> XDG_FILE_PREFIX = |
122 new StandardBundlerParam<> ( |
122 new StandardBundlerParam<> ( |
123 I18N.getString("param.xdg-prefix.name"), |
|
124 I18N.getString("param.xdg-prefix.description"), |
|
125 "linux.xdg-prefix", |
123 "linux.xdg-prefix", |
126 String.class, |
124 String.class, |
127 params -> { |
125 params -> { |
128 try { |
126 try { |
129 String vendor; |
127 String vendor; |
314 LinuxAppBundler.getRootDir(RPM_IMAGE_DIR.fetchFrom(params), params); |
312 LinuxAppBundler.getRootDir(RPM_IMAGE_DIR.fetchFrom(params), params); |
315 |
313 |
316 // prepare installer icon |
314 // prepare installer icon |
317 File iconTarget = getConfig_IconFile(rootDir, params); |
315 File iconTarget = getConfig_IconFile(rootDir, params); |
318 File icon = LinuxAppBundler.ICON_PNG.fetchFrom(params); |
316 File icon = LinuxAppBundler.ICON_PNG.fetchFrom(params); |
319 if (!RUNTIME_INSTALLER.fetchFrom(params)) { |
317 if (!StandardBundlerParam.isRuntimeInstaller(params)) { |
320 if (icon == null || !icon.exists()) { |
318 if (icon == null || !icon.exists()) { |
321 fetchResource(iconTarget.getName(), |
319 fetchResource(iconTarget.getName(), |
322 I18N.getString("resource.menu-icon"), |
320 I18N.getString("resource.menu-icon"), |
323 DEFAULT_ICON, |
321 DEFAULT_ICON, |
324 iconTarget, |
322 iconTarget, |
334 } |
332 } |
335 } |
333 } |
336 |
334 |
337 StringBuilder installScripts = new StringBuilder(); |
335 StringBuilder installScripts = new StringBuilder(); |
338 StringBuilder removeScripts = new StringBuilder(); |
336 StringBuilder removeScripts = new StringBuilder(); |
339 for (Map<String, ? super Object> secondaryLauncher : |
337 for (Map<String, ? super Object> addLauncher : |
340 SECONDARY_LAUNCHERS.fetchFrom(params)) { |
338 ADD_LAUNCHERS.fetchFrom(params)) { |
341 Map<String, String> secondaryLauncherData = |
339 Map<String, String> addLauncherData = |
342 createReplacementData(secondaryLauncher); |
340 createReplacementData(addLauncher); |
343 secondaryLauncherData.put("APPLICATION_FS_NAME", |
341 addLauncherData.put("APPLICATION_FS_NAME", |
344 data.get("APPLICATION_FS_NAME")); |
342 data.get("APPLICATION_FS_NAME")); |
345 secondaryLauncherData.put("DESKTOP_MIMES", ""); |
343 addLauncherData.put("DESKTOP_MIMES", ""); |
346 |
344 |
347 // prepare desktop shortcut |
345 // prepare desktop shortcut |
348 Writer w = new BufferedWriter(new FileWriter( |
346 Writer w = new BufferedWriter(new FileWriter( |
349 getConfig_DesktopShortcutFile(rootDir, secondaryLauncher))); |
347 getConfig_DesktopShortcutFile(rootDir, addLauncher))); |
350 String content = preprocessTextResource( |
348 String content = preprocessTextResource( |
351 getConfig_DesktopShortcutFile(rootDir, |
349 getConfig_DesktopShortcutFile(rootDir, |
352 secondaryLauncher).getName(), |
350 addLauncher).getName(), |
353 I18N.getString("resource.menu-shortcut-descriptor"), |
351 I18N.getString("resource.menu-shortcut-descriptor"), |
354 DEFAULT_DESKTOP_FILE_TEMPLATE, secondaryLauncherData, |
352 DEFAULT_DESKTOP_FILE_TEMPLATE, addLauncherData, |
355 VERBOSE.fetchFrom(params), |
353 VERBOSE.fetchFrom(params), |
356 RESOURCE_DIR.fetchFrom(params)); |
354 RESOURCE_DIR.fetchFrom(params)); |
357 w.write(content); |
355 w.write(content); |
358 w.close(); |
356 w.close(); |
359 |
357 |
360 // prepare installer icon |
358 // prepare installer icon |
361 iconTarget = getConfig_IconFile(rootDir, secondaryLauncher); |
359 iconTarget = getConfig_IconFile(rootDir, addLauncher); |
362 icon = LinuxAppBundler.ICON_PNG.fetchFrom(secondaryLauncher); |
360 icon = LinuxAppBundler.ICON_PNG.fetchFrom(addLauncher); |
363 if (icon == null || !icon.exists()) { |
361 if (icon == null || !icon.exists()) { |
364 fetchResource(iconTarget.getName(), |
362 fetchResource(iconTarget.getName(), |
365 I18N.getString("resource.menu-icon"), |
363 I18N.getString("resource.menu-icon"), |
366 DEFAULT_ICON, |
364 DEFAULT_ICON, |
367 iconTarget, |
365 iconTarget, |
380 installScripts.append("xdg-desktop-menu install --novendor "); |
378 installScripts.append("xdg-desktop-menu install --novendor "); |
381 installScripts.append(LINUX_INSTALL_DIR.fetchFrom(params)); |
379 installScripts.append(LINUX_INSTALL_DIR.fetchFrom(params)); |
382 installScripts.append("/"); |
380 installScripts.append("/"); |
383 installScripts.append(data.get("APPLICATION_FS_NAME")); |
381 installScripts.append(data.get("APPLICATION_FS_NAME")); |
384 installScripts.append("/"); |
382 installScripts.append("/"); |
385 installScripts.append(secondaryLauncherData.get( |
383 installScripts.append(addLauncherData.get( |
386 "APPLICATION_LAUNCHER_FILENAME")); |
384 "APPLICATION_LAUNCHER_FILENAME")); |
387 installScripts.append(".desktop\n"); |
385 installScripts.append(".desktop\n"); |
388 |
386 |
389 // preun cleanup of desktop icon |
387 // preun cleanup of desktop icon |
390 removeScripts.append("xdg-desktop-menu uninstall --novendor "); |
388 removeScripts.append("xdg-desktop-menu uninstall --novendor "); |
391 removeScripts.append(LINUX_INSTALL_DIR.fetchFrom(params)); |
389 removeScripts.append(LINUX_INSTALL_DIR.fetchFrom(params)); |
392 removeScripts.append("/"); |
390 removeScripts.append("/"); |
393 removeScripts.append(data.get("APPLICATION_FS_NAME")); |
391 removeScripts.append(data.get("APPLICATION_FS_NAME")); |
394 removeScripts.append("/"); |
392 removeScripts.append("/"); |
395 removeScripts.append(secondaryLauncherData.get( |
393 removeScripts.append(addLauncherData.get( |
396 "APPLICATION_LAUNCHER_FILENAME")); |
394 "APPLICATION_LAUNCHER_FILENAME")); |
397 removeScripts.append(".desktop\n"); |
395 removeScripts.append(".desktop\n"); |
398 |
396 |
399 } |
397 } |
400 data.put("SECONDARY_LAUNCHERS_INSTALL", installScripts.toString()); |
398 data.put("ADD_LAUNCHERS_INSTALL", installScripts.toString()); |
401 data.put("SECONDARY_LAUNCHERS_REMOVE", removeScripts.toString()); |
399 data.put("ADD_LAUNCHERS_REMOVE", removeScripts.toString()); |
402 |
400 |
403 StringBuilder cdsScript = new StringBuilder(); |
401 StringBuilder cdsScript = new StringBuilder(); |
404 |
402 |
405 data.put("APP_CDS_CACHE", cdsScript.toString()); |
403 data.put("APP_CDS_CACHE", cdsScript.toString()); |
406 |
404 |
542 data.put("FILE_ASSOCIATION_REMOVE", deregistrations.toString()); |
540 data.put("FILE_ASSOCIATION_REMOVE", deregistrations.toString()); |
543 data.put("DESKTOP_MIMES", desktopMimes.toString()); |
541 data.put("DESKTOP_MIMES", desktopMimes.toString()); |
544 } |
542 } |
545 } |
543 } |
546 |
544 |
547 if (!RUNTIME_INSTALLER.fetchFrom(params)) { |
545 if (!StandardBundlerParam.isRuntimeInstaller(params)) { |
548 //prepare desktop shortcut |
546 //prepare desktop shortcut |
549 Writer w = new BufferedWriter(new FileWriter( |
547 Writer w = new BufferedWriter(new FileWriter( |
550 getConfig_DesktopShortcutFile(rootDir, params))); |
548 getConfig_DesktopShortcutFile(rootDir, params))); |
551 String content = preprocessTextResource( |
549 String content = preprocessTextResource( |
552 getConfig_DesktopShortcutFile(rootDir, params).getName(), |
550 getConfig_DesktopShortcutFile(rootDir, params).getName(), |
583 data.put("APPLICATION_VENDOR", VENDOR.fetchFrom(params)); |
581 data.put("APPLICATION_VENDOR", VENDOR.fetchFrom(params)); |
584 data.put("APPLICATION_VERSION", VERSION.fetchFrom(params)); |
582 data.put("APPLICATION_VERSION", VERSION.fetchFrom(params)); |
585 data.put("APPLICATION_LAUNCHER_FILENAME", APP_NAME.fetchFrom(params)); |
583 data.put("APPLICATION_LAUNCHER_FILENAME", APP_NAME.fetchFrom(params)); |
586 data.put("INSTALLATION_DIRECTORY", LINUX_INSTALL_DIR.fetchFrom(params)); |
584 data.put("INSTALLATION_DIRECTORY", LINUX_INSTALL_DIR.fetchFrom(params)); |
587 data.put("XDG_PREFIX", XDG_FILE_PREFIX.fetchFrom(params)); |
585 data.put("XDG_PREFIX", XDG_FILE_PREFIX.fetchFrom(params)); |
588 data.put("DEPLOY_BUNDLE_CATEGORY", CATEGORY.fetchFrom(params)); |
586 data.put("DEPLOY_BUNDLE_CATEGORY", MENU_GROUP.fetchFrom(params)); |
589 // TODO rpm categories |
587 // TODO rpm categories |
590 data.put("APPLICATION_DESCRIPTION", DESCRIPTION.fetchFrom(params)); |
588 data.put("APPLICATION_DESCRIPTION", DESCRIPTION.fetchFrom(params)); |
591 data.put("APPLICATION_SUMMARY", APP_NAME.fetchFrom(params)); |
589 data.put("APPLICATION_SUMMARY", APP_NAME.fetchFrom(params)); |
592 data.put("APPLICATION_LICENSE_TYPE", LICENSE_TYPE.fetchFrom(params)); |
590 data.put("APPLICATION_LICENSE_TYPE", LICENSE_TYPE.fetchFrom(params)); |
593 data.put("APPLICATION_LICENSE_FILE", getLicenseFileString(params)); |
591 data.put("APPLICATION_LICENSE_FILE", getLicenseFileString(params)); |
594 String deps = LINUX_PACKAGE_DEPENDENCIES.fetchFrom(params); |
592 String deps = LINUX_PACKAGE_DEPENDENCIES.fetchFrom(params); |
595 data.put("PACKAGE_DEPENDENCIES", |
593 data.put("PACKAGE_DEPENDENCIES", |
596 deps.isEmpty() ? "" : "Requires: " + deps); |
594 deps.isEmpty() ? "" : "Requires: " + deps); |
597 data.put("RUNTIME_INSTALLER", |
595 data.put("RUNTIME_INSTALLER", "" + |
598 RUNTIME_INSTALLER.fetchFrom(params).toString()); |
596 StandardBundlerParam.isRuntimeInstaller(params)); |
599 return data; |
597 return data; |
600 } |
598 } |
601 |
599 |
602 private File getConfig_DesktopShortcutFile(File rootDir, |
600 private File getConfig_DesktopShortcutFile(File rootDir, |
603 Map<String, ? super Object> params) { |
601 Map<String, ? super Object> params) { |
618 File outdir) throws IOException { |
616 File outdir) throws IOException { |
619 Log.verbose(MessageFormat.format(I18N.getString( |
617 Log.verbose(MessageFormat.format(I18N.getString( |
620 "message.outputting-bundle-location"), |
618 "message.outputting-bundle-location"), |
621 outdir.getAbsolutePath())); |
619 outdir.getAbsolutePath())); |
622 |
620 |
623 File broot = new File(BUILD_ROOT.fetchFrom(params), "rmpbuildroot"); |
621 File broot = new File(TEMP_ROOT.fetchFrom(params), "rmpbuildroot"); |
624 |
622 |
625 outdir.mkdirs(); |
623 outdir.mkdirs(); |
626 |
624 |
627 //run rpmbuild |
625 //run rpmbuild |
628 ProcessBuilder pb = new ProcessBuilder( |
626 ProcessBuilder pb = new ProcessBuilder( |