Skip to content

Commit a6c425f

Browse files
8364560: The default value of --linux-menu-group option is invalid
1 parent c8f5fd6 commit a6c425f

File tree

5 files changed

+41
-12
lines changed

5 files changed

+41
-12
lines changed

src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxPackageBuilder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ LinuxPackage create() throws ConfigException {
8484
private LinuxPackage create(Package pkg) throws ConfigException {
8585
return LinuxPackage.create(pkg, new LinuxPackageMixin.Stub(
8686
Optional.ofNullable(menuGroupName).orElseGet(DEFAULTS::menuGroupName),
87-
Optional.ofNullable(category),
87+
category(),
8888
Optional.ofNullable(additionalDependencies),
89-
Optional.ofNullable(release),
89+
release(),
9090
pkg.asStandardPackageType().map(LinuxPackageArch::getValue).orElseThrow()));
9191
}
9292

@@ -192,7 +192,7 @@ private record Defaults(String menuGroupName) {
192192

193193
private final PackageBuilder pkgBuilder;
194194

195-
private static final Defaults DEFAULTS = new Defaults(I18N.getString(
196-
"param.menu-group.default"));
197-
195+
// Should be one of https://specifications.freedesktop.org/menu/latest/category-registry.html#main-category-registry
196+
// The category is an ID, not a localizable string
197+
private static final Defaults DEFAULTS = new Defaults("Utility");
198198
}

src/jdk.jpackage/linux/classes/jdk/jpackage/internal/model/LinuxPackageMixin.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ public interface LinuxPackageMixin {
3434
/**
3535
* Gets the name of the start menu group where to create shortcuts for
3636
* application launchers of this package.
37+
* <p>
38+
* It sets the value of the "Categories" property in .desktop files of the
39+
* package.
40+
* <p>
41+
* Should be one of the values from <a href=
42+
* "https://specifications.freedesktop.org/menu/latest/category-registry.html">https://specifications.freedesktop.org/menu/latest/category-registry.html</a>
3743
*
3844
* @return the name of the start menu group where to create shortcuts for
3945
* application launchers of this package
@@ -44,6 +50,13 @@ public interface LinuxPackageMixin {
4450

4551
/**
4652
* Gets the category of this package.
53+
* <p>
54+
* For RPM packages this is the value of the optional "Group" property.
55+
* <p>
56+
* For DEB packages this is the value of the mandatory "Section" property.
57+
* <a href=
58+
* "https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections">The
59+
* present list of recognized values.</a>
4760
*
4861
* @return the category of this package
4962
*/
@@ -62,7 +75,7 @@ public interface LinuxPackageMixin {
6275
* Gets the release of this package. Returns an empty {@link Optional} instance
6376
* if this package doesn't have a release.
6477
* <p>
65-
* For RPM packages, this is the value of a "Release" property in spec file. RPM
78+
* For RPM packages, this is the value of the "Release" property in spec file. RPM
6679
* packages always have a release.
6780
* <p>
6881
* For DEB packages, this is an optional {@code debian_revision} component of a

src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/LinuxResources.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ deb.bundler.name=DEB Bundle
2828
rpm.bundler.name=RPM Bundle
2929

3030
param.license-type.default=Unknown
31-
param.menu-group.default=Unknown
3231

3332
resource.deb-control-file=DEB control file
3433
resource.deb-preinstall-script=DEB preinstall script

test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LinuxHelper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,8 @@ private static void verifyDesktopFile(JPackageCommand cmd, Optional<AppImageFile
564564
for (var e : List.of(
565565
Map.entry("Type", "Application"),
566566
Map.entry("Terminal", "false"),
567-
Map.entry("Comment", launcherDescription)
567+
Map.entry("Comment", launcherDescription),
568+
Map.entry("Categories", Optional.ofNullable(cmd.getArgumentValue("--linux-menu-group")).orElse("Utility"))
568569
)) {
569570
String key = e.getKey();
570571
TKit.assertEquals(e.getValue(), data.find(key).orElseThrow(), String.format(

test/jdk/tools/jpackage/linux/ShortcutHintTest.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@
2626
import java.nio.file.Path;
2727
import java.util.List;
2828
import jdk.jpackage.test.AdditionalLauncher;
29+
import jdk.jpackage.test.Annotations.Parameter;
30+
import jdk.jpackage.test.Annotations.Test;
2931
import jdk.jpackage.test.FileAssociations;
30-
import jdk.jpackage.test.PackageType;
31-
import jdk.jpackage.test.PackageTest;
32-
import jdk.jpackage.test.TKit;
3332
import jdk.jpackage.test.JPackageCommand;
3433
import jdk.jpackage.test.LinuxHelper;
35-
import jdk.jpackage.test.Annotations.Test;
34+
import jdk.jpackage.test.PackageTest;
35+
import jdk.jpackage.test.PackageType;
36+
import jdk.jpackage.test.RunnablePackageTest.Action;
37+
import jdk.jpackage.test.TKit;
3638

3739
/**
3840
* Test --linux-shortcut parameter. Output of the test should be
@@ -179,4 +181,18 @@ public static void testDesktopFileFromResourceDir() throws IOException {
179181
.apply(Files.readAllLines(desktopFile));
180182
}).run();
181183
}
184+
185+
/**
186+
* Test "--linux-menu-group" option.
187+
*
188+
* @param menuGroup value of "--linux-menu-group" option
189+
*/
190+
@Test
191+
// Values from https://specifications.freedesktop.org/menu/latest/category-registry.html#main-category-registry
192+
@Parameter("Development")
193+
public static void testMenuGroup(String menuGroup) {
194+
createTest().addInitializer(JPackageCommand::setFakeRuntime).addInitializer(cmd -> {
195+
cmd.addArgument("--linux-shortcut").setArgumentValue("--linux-menu-group", menuGroup);
196+
}).run(Action.CREATE_AND_UNPACK);
197+
}
182198
}

0 commit comments

Comments
 (0)