JDK-8241713 : Linux desktop shortcuts with spaces make postinst/prerm fail
  • Type: Bug
  • Component: tools
  • Sub-Component: jpackage
  • Affected Version: 14,15
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2020-03-22
  • Updated: 2020-11-13
  • Resolved: 2020-04-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15
15 b18Fixed
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE PROBLEM :
When application name contains spaces, jpackage generates invalid `xdg-desktop-menu` invocations: it does not escape spaces in name, so they become different args to `xdg-desktop-menu`, for example:

`xdg-desktop-menu install /opt/my-app/lib/My App.desktop`

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Invoke jpackage with `--name "My App"` and `--linux-shortcut`

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Produced deb can be installed/uninstalled
ACTUAL -
dpkg fails installs/uninstalls.

FREQUENCY : always



Comments
Requested the submitter verify the fix with latest version of JDK 15 and 16.
19-10-2020

URL: https://hg.openjdk.java.net/jdk/jdk/rev/34869f56f4c5 User: asemenyuk Date: 2020-04-06 19:37:07 +0000
06-04-2020

Review: http://cr.openjdk.java.net/~asemenyuk/8241713
02-04-2020

There are two solutions to the problem: 1. Enclose file names with space characters passed as arguments to xdg-... commands in quotes. 2. Replace space characters in file names passed as arguments on xdg-... commands with underscore characters (_). As these files will be copied in system folders the better option would be to avoid file names with space characters. So option #2 should be used for the fix.
02-04-2020

Here is a simple reproducer: $ mkdir some-dir $ cp ~/.m2/repository/junit/junit/4.12/junit-4.12.jar some-dir $ jpackage --input some-dir --main-jar junit-4.12.jar --name "App with spaces in name" --main-class whatever --linux-shortcut $ ls app-with-spaces-in-name_1.0-1_amd64.deb some-dir $ sudo dpkg -i app-with-spaces-in-name_1.0-1_amd64.deb [sudo] password for su: Selecting previously unselected package app-with-spaces-in-name. (Reading database ... 285015 files and directories currently installed.) Preparing to unpack app-with-spaces-in-name_1.0-1_amd64.deb ... Unpacking app-with-spaces-in-name (1.0-1) ... Setting up app-with-spaces-in-name (1.0-1) ... xdg-desktop-menu: file '/opt/app-with-spaces-in-name/lib/app-with-spaces-in-name-App' does not exist dpkg: error processing package app-with-spaces-in-name (--install): installed app-with-spaces-in-name package post-installation script subprocess returned error exit status 2 Errors were encountered while processing: app-with-spaces-in-name If you open generated deb file in archive manager and extract control.tar.xz, in postinst file you will see this on line 22: xdg-desktop-menu install /opt/app-with-spaces-in-name/lib/app-with-spaces-in-name-App with spaces in name.desktop This looks like it should be escaped or not include app name in desktop shortcut name.
30-03-2020

Move to JDK for further evaluation.
27-03-2020

Requesting the simple test case to reproduce the incident.
24-03-2020