Skip to content
Permalink
Browse files

8241713: Linux desktop shortcuts with spaces make postinst/prerm fail

Reviewed-by: almatvee, herrick
  • Loading branch information
Alexey Semenyuk committed Apr 4, 2020
1 parent c1016d5 commit 3aa216ecdfcb7de783cc7ee3fff93b8d7aae39b4
@@ -84,19 +84,21 @@ private DesktopIntegration(PlatformPackage thePackage,
.setCategory(I18N.getString("resource.menu-shortcut-descriptor"))
.setPublicName(APP_NAME.fetchFrom(params) + ".desktop");

final String escapedAppFileName = APP_NAME.fetchFrom(params).replaceAll("\\s+", "_");

// XDG recommends to use vendor prefix in desktop file names as xdg
// commands copy files to system directories.
// Package name should be a good prefix.
final String desktopFileName = String.format("%s-%s.desktop",
thePackage.name(), APP_NAME.fetchFrom(params));
thePackage.name(), escapedAppFileName);
final String mimeInfoFileName = String.format("%s-%s-MimeInfo.xml",
thePackage.name(), APP_NAME.fetchFrom(params));
thePackage.name(), escapedAppFileName);

mimeInfoFile = new DesktopFile(mimeInfoFileName);

if (withDesktopFile) {
desktopFile = new DesktopFile(desktopFileName);
iconFile = new DesktopFile(APP_NAME.fetchFrom(params)
iconFile = new DesktopFile(escapedAppFileName
+ IOUtils.getSuffix(Path.of(DEFAULT_ICON)));

if (curIconResource == null) {
@@ -50,7 +50,7 @@ public static Path getDesktopFile(JPackageCommand cmd, String launcherName) {
cmd.verifyIsOfType(PackageType.LINUX);
String desktopFileName = String.format("%s-%s.desktop", getPackageName(
cmd), Optional.ofNullable(launcherName).orElseGet(
() -> cmd.name()));
() -> cmd.name()).replaceAll("\\s+", "_"));
return cmd.appLayout().destktopIntegrationDirectory().resolve(
desktopFileName);
}
@@ -91,8 +91,16 @@ private static PackageTest createTest() {
return new PackageTest()
.forTypes(PackageType.LINUX)
.configureHelloApp()
.addBundleDesktopIntegrationVerifier(true);

.addBundleDesktopIntegrationVerifier(true)
.addInitializer(cmd -> {
String defaultAppName = cmd.name();
String appName = defaultAppName.replace(
ShortcutHintTest.class.getSimpleName(),
"Shortcut Hint Test");
cmd.setArgumentValue("--name", appName);
cmd.addArguments("--linux-package-name",
defaultAppName.toLowerCase());
});
}

/**
@@ -163,9 +171,7 @@ public static void testDesktopFileFromResourceDir() throws IOException {
));
})
.addInstallVerifier(cmd -> {
Path desktopFile = cmd.appLayout().destktopIntegrationDirectory().resolve(
String.format("%s-%s.desktop",
LinuxHelper.getPackageName(cmd), cmd.name()));
Path desktopFile = LinuxHelper.getDesktopFile(cmd);
TKit.assertFileExists(desktopFile);
TKit.assertTextStream(expectedVersionString)
.label(String.format("[%s] file", desktopFile))

0 comments on commit 3aa216e

Please sign in to comment.