Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,17 @@ public class LinuxDebBundler extends LinuxPackageBundler {
DEB_ARCH = debArch;
}

private static final String releaseSuffix(Map<String, ? super Object> params) {
return Optional.ofNullable(RELEASE.fetchFrom(params, false)).map(
rel -> "-" + rel).orElse("");
}

private static final BundlerParamInfo<String> FULL_PACKAGE_NAME =
new StandardBundlerParam<>(
"linux.deb.fullPackageName", String.class, params -> {
return PACKAGE_NAME.fetchFrom(params)
+ "_" + VERSION.fetchFrom(params)
+ "-" + RELEASE.fetchFrom(params)
+ releaseSuffix(params)
+ "_" + DEB_ARCH;
}, (s, p) -> s);

Expand Down Expand Up @@ -275,9 +280,9 @@ protected List<ConfigException> verifyOutputBundle(
List<PackageProperty> properties = List.of(
new PackageProperty("Package", PACKAGE_NAME.fetchFrom(params),
"APPLICATION_PACKAGE", controlFileName),
new PackageProperty("Version", String.format("%s-%s",
VERSION.fetchFrom(params), RELEASE.fetchFrom(params)),
"APPLICATION_VERSION-APPLICATION_RELEASE",
new PackageProperty("Version", String.format("%s%s",
VERSION.fetchFrom(params), releaseSuffix(params)),
"APPLICATION_VERSION_WITH_RELEASE",
controlFileName),
new PackageProperty("Architecture", DEB_ARCH, "APPLICATION_ARCH",
controlFileName));
Expand Down Expand Up @@ -442,6 +447,8 @@ protected Map<String, String> createReplacementData(
data.put("APPLICATION_HOMEPAGE", Optional.ofNullable(
ABOUT_URL.fetchFrom(params)).map(value -> "Homepage: " + value).orElse(
""));
data.put("APPLICATION_VERSION_WITH_RELEASE", String.format("%s%s",
VERSION.fetchFrom(params), releaseSuffix(params)));

return data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ private Map<String, String> createDefaultReplacementData(
data.put("APPLICATION_VENDOR", VENDOR.fetchFrom(params));
data.put("APPLICATION_VERSION", VERSION.fetchFrom(params));
data.put("APPLICATION_DESCRIPTION", DESCRIPTION.fetchFrom(params));
data.put("APPLICATION_RELEASE", RELEASE.fetchFrom(params));

String defaultDeps = String.join(", ", getListOfNeededPackages(params));
String customDeps = LINUX_PACKAGE_DEPENDENCIES.fetchFrom(params).strip();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ protected Map<String, String> createReplacementData(
appDirectory = appDirectory.resolve(PACKAGE_NAME.fetchFrom(params));
}

data.put("APPLICATION_RELEASE", RELEASE.fetchFrom(params));
data.put("APPLICATION_PREFIX", prefix.toString());
data.put("APPLICATION_DIRECTORY", appDirectory.toString());
data.put("APPLICATION_SUMMARY", APP_NAME.fetchFrom(params));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: APPLICATION_PACKAGE
Version: APPLICATION_VERSION-APPLICATION_RELEASE
Version: APPLICATION_VERSION_WITH_RELEASE
Section: APPLICATION_SECTION
Maintainer: APPLICATION_MAINTAINER
Priority: optional
Expand Down
26 changes: 20 additions & 6 deletions test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LinuxHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,22 @@


public class LinuxHelper {
private static String getRelease(JPackageCommand cmd) {
return cmd.getArgumentValue("--linux-app-release", () -> "1");
private static String getReleaseSuffix(JPackageCommand cmd) {
String value = null;
final PackageType packageType = cmd.packageType();
switch (packageType) {
case LINUX_DEB:
value = Optional.ofNullable(cmd.getArgumentValue(
"--linux-app-release", () -> null)).map(v -> "-" + v).orElse(
"");
break;

case LINUX_RPM:
value = "-" + cmd.getArgumentValue("--linux-app-release",
() -> "1");
break;
}
return value;
}

public static String getPackageName(JPackageCommand cmd) {
Expand Down Expand Up @@ -74,18 +88,18 @@ static String getBundleName(JPackageCommand cmd) {
String format = null;
switch (packageType) {
case LINUX_DEB:
format = "%s_%s-%s_%s";
format = "%s_%s%s_%s";
break;

case LINUX_RPM:
format = "%s-%s-%s.%s";
format = "%s-%s%s.%s";
break;
}

final String release = getRelease(cmd);
final String releaseSuffix = getReleaseSuffix(cmd);
final String version = cmd.version();

return String.format(format, getPackageName(cmd), version, release,
return String.format(format, getPackageName(cmd), version, releaseSuffix,
getDefaultPackageArch(packageType)) + packageType.getSuffix();
}

Expand Down
2 changes: 1 addition & 1 deletion test/jdk/tools/jpackage/linux/LinuxResourceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static void testHardcodedProperties() throws IOException {
.predicate(String::contains)
.apply(result.getOutput().stream());
TKit.assertTextStream(
"Expected value of \"Version\" property is [1.0-1]. Actual value in output package is [1.2.3-R2]")
"Expected value of \"Version\" property is [1.0]. Actual value in output package is [1.2.3-R2]")
.predicate(String::contains)
.apply(result.getOutput().stream());
TKit.assertTextStream(String.format(
Expand Down
30 changes: 30 additions & 0 deletions test/jdk/tools/jpackage/linux/ReleaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import jdk.jpackage.test.PackageType;
import jdk.jpackage.test.PackageTest;
import jdk.jpackage.test.Annotations.Test;
import jdk.jpackage.test.JPackageCommand;


/**
Expand All @@ -47,10 +48,26 @@
* @build jdk.jpackage.test.*
* @build ReleaseTest
* @requires (os.family == "linux")
* @requires (jpackage.test.SQETest == null)
* @modules jdk.jpackage/jdk.jpackage.internal
* @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main
* --jpt-run=ReleaseTest
*/

/*
* @test
* @summary jpackage with --linux-app-release
* @library ../helpers
* @key jpackagePlatformPackage
* @build jdk.jpackage.test.*
* @build ReleaseTest
* @requires (os.family == "linux")
* @requires (jpackage.test.SQETest != null)
* @modules jdk.jpackage/jdk.jpackage.internal
* @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main
* --jpt-run=ReleaseTest.test
*/

public class ReleaseTest {

@Test
Expand All @@ -71,4 +88,17 @@ public static void test() {
}, "ends with")
.run();
}

@Test
public static void testNoExplitRelease() {
new PackageTest()
.forTypes(PackageType.LINUX)
.configureHelloApp()
.addInitializer(JPackageCommand::setFakeRuntime)
.forTypes(PackageType.LINUX_RPM)
.addBundlePropertyVerifier("Release", "1")
.forTypes(PackageType.LINUX_DEB)
.addBundlePropertyVerifier("Version", "1.0")
.run();
}
}