src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxRpmBundler.java
branchJDK-8200758-branch
changeset 57390 1cb722a11ead
parent 57256 d7c27451f759
child 57391 970f28090a06
equal deleted inserted replaced
57389:cce526c681dc 57390:1cb722a11ead
   341             addLauncherData.put("APPLICATION_FS_NAME",
   341             addLauncherData.put("APPLICATION_FS_NAME",
   342                     data.get("APPLICATION_FS_NAME"));
   342                     data.get("APPLICATION_FS_NAME"));
   343             addLauncherData.put("DESKTOP_MIMES", "");
   343             addLauncherData.put("DESKTOP_MIMES", "");
   344 
   344 
   345             // prepare desktop shortcut
   345             // prepare desktop shortcut
   346             Writer w = new BufferedWriter(new FileWriter(
   346             try (Writer w = Files.newBufferedWriter(
   347                     getConfig_DesktopShortcutFile(rootDir, addLauncher)));
       
   348             String content = preprocessTextResource(
       
   349                     getConfig_DesktopShortcutFile(rootDir,
   347                     getConfig_DesktopShortcutFile(rootDir,
   350                     addLauncher).getName(),
   348                             addLauncher).toPath())) {
   351                     I18N.getString("resource.menu-shortcut-descriptor"),
   349                 String content = preprocessTextResource(
   352                     DEFAULT_DESKTOP_FILE_TEMPLATE, addLauncherData,
   350                         getConfig_DesktopShortcutFile(rootDir,
   353                     VERBOSE.fetchFrom(params),
   351                         addLauncher).getName(),
   354                     RESOURCE_DIR.fetchFrom(params));
   352                         I18N.getString("resource.menu-shortcut-descriptor"),
   355             w.write(content);
   353                         DEFAULT_DESKTOP_FILE_TEMPLATE, addLauncherData,
   356             w.close();
   354                         VERBOSE.fetchFrom(params),
       
   355                         RESOURCE_DIR.fetchFrom(params));
       
   356                 w.write(content);
       
   357             }
   357 
   358 
   358             // prepare installer icon
   359             // prepare installer icon
   359             iconTarget = getConfig_IconFile(rootDir, addLauncher);
   360             iconTarget = getConfig_IconFile(rootDir, addLauncher);
   360             icon = LinuxAppBundler.ICON_PNG.fetchFrom(addLauncher);
   361             icon = LinuxAppBundler.ICON_PNG.fetchFrom(addLauncher);
   361             if (icon == null || !icon.exists()) {
   362             if (icon == null || !icon.exists()) {
   530                 }
   531                 }
   531             }
   532             }
   532             mimeInfo.append("</mime-info>");
   533             mimeInfo.append("</mime-info>");
   533 
   534 
   534             if (addedEntry) {
   535             if (addedEntry) {
   535                 Writer w = new BufferedWriter(new FileWriter(
   536                 try (Writer w = Files.newBufferedWriter(
   536                         new File(rootDir, mimeInfoFile)));
   537                         new File(rootDir, mimeInfoFile).toPath())) {
   537                 w.write(mimeInfo.toString());
   538                     w.write(mimeInfo.toString());
   538                 w.close();
   539                 }
   539                 data.put("FILE_ASSOCIATION_INSTALL", registrations.toString());
   540                 data.put("FILE_ASSOCIATION_INSTALL", registrations.toString());
   540                 data.put("FILE_ASSOCIATION_REMOVE", deregistrations.toString());
   541                 data.put("FILE_ASSOCIATION_REMOVE", deregistrations.toString());
   541                 data.put("DESKTOP_MIMES", desktopMimes.toString());
   542                 data.put("DESKTOP_MIMES", desktopMimes.toString());
   542             }
   543             }
   543         }
   544         }
   544 
   545 
   545         if (!StandardBundlerParam.isRuntimeInstaller(params)) {
   546         if (!StandardBundlerParam.isRuntimeInstaller(params)) {
   546             //prepare desktop shortcut
   547             //prepare desktop shortcut
   547             Writer w = new BufferedWriter(new FileWriter(
   548             try (Writer w = Files.newBufferedWriter(
   548                     getConfig_DesktopShortcutFile(rootDir, params)));
   549                     getConfig_DesktopShortcutFile(rootDir, params).toPath())) {
       
   550                 String content = preprocessTextResource(
       
   551                         getConfig_DesktopShortcutFile(rootDir,
       
   552                                                       params).getName(),
       
   553                         I18N.getString("resource.menu-shortcut-descriptor"),
       
   554                         DEFAULT_DESKTOP_FILE_TEMPLATE, data,
       
   555                         VERBOSE.fetchFrom(params),
       
   556                         RESOURCE_DIR.fetchFrom(params));
       
   557                 w.write(content);
       
   558             }
       
   559         }
       
   560 
       
   561         // prepare spec file
       
   562         try (Writer w = Files.newBufferedWriter(
       
   563                 getConfig_SpecFile(params).toPath())) {
   549             String content = preprocessTextResource(
   564             String content = preprocessTextResource(
   550                     getConfig_DesktopShortcutFile(rootDir, params).getName(),
   565                     getConfig_SpecFile(params).getName(),
   551                     I18N.getString("resource.menu-shortcut-descriptor"),
   566                     I18N.getString("resource.rpm-spec-file"),
   552                     DEFAULT_DESKTOP_FILE_TEMPLATE, data,
   567                     DEFAULT_SPEC_TEMPLATE, data,
   553                     VERBOSE.fetchFrom(params),
   568                     VERBOSE.fetchFrom(params),
   554                     RESOURCE_DIR.fetchFrom(params));
   569                     RESOURCE_DIR.fetchFrom(params));
   555             w.write(content);
   570             w.write(content);
   556             w.close();
   571         }
   557         }
       
   558 
       
   559         // prepare spec file
       
   560         Writer w = new BufferedWriter(
       
   561                 new FileWriter(getConfig_SpecFile(params)));
       
   562         String content = preprocessTextResource(
       
   563                 getConfig_SpecFile(params).getName(),
       
   564                 I18N.getString("resource.rpm-spec-file"),
       
   565                 DEFAULT_SPEC_TEMPLATE, data,
       
   566                 VERBOSE.fetchFrom(params),
       
   567                 RESOURCE_DIR.fetchFrom(params));
       
   568         w.write(content);
       
   569         w.close();
       
   570 
   572 
   571         return true;
   573         return true;
   572     }
   574     }
   573 
   575 
   574     private Map<String, String> createReplacementData(
   576     private Map<String, String> createReplacementData(