8228660: .deb files generated by jpackage don't follow naming convention
Submitted-by: asemenyuk
Reviewed-by: kcr, almatvee
--- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebBundler.java Wed Aug 28 11:30:40 2019 -0400
+++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebBundler.java Wed Aug 28 11:41:49 2019 -0400
@@ -96,15 +96,21 @@
return s;
});
- public static final BundlerParamInfo<String> FULL_PACKAGE_NAME =
- new StandardBundlerParam<> (
- "linux.deb.fullPackageName",
- String.class,
- params -> BUNDLE_NAME.fetchFrom(params) + "-"
- + VERSION.fetchFrom(params),
- (s, p) -> s);
+ private static final BundlerParamInfo<String> FULL_PACKAGE_NAME =
+ new StandardBundlerParam<>(
+ "linux.deb.fullPackageName", String.class, params -> {
+ try {
+ return BUNDLE_NAME.fetchFrom(params)
+ + "_" + VERSION.fetchFrom(params)
+ + "-" + RELEASE.fetchFrom(params)
+ + "_" + getDebArch();
+ } catch (IOException ex) {
+ Log.verbose(ex);
+ return null;
+ }
+ }, (s, p) -> s);
- public static final BundlerParamInfo<File> DEB_IMAGE_DIR =
+ private static final BundlerParamInfo<File> DEB_IMAGE_DIR =
new StandardBundlerParam<>(
"linux.deb.imageDir",
File.class,
--- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.control Wed Aug 28 11:30:40 2019 -0400
+++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.control Wed Aug 28 11:41:49 2019 -0400
@@ -1,6 +1,5 @@
Package: APPLICATION_PACKAGE
-Version: APPLICATION_VERSION
-Release: APPLICATION_RELEASE
+Version: APPLICATION_VERSION-APPLICATION_RELEASE
Section: APPLICATION_SECTION
Maintainer: APPLICATION_MAINTAINER
Priority: optional
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources.properties Wed Aug 28 11:30:40 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources.properties Wed Aug 28 11:41:49 2019 -0400
@@ -256,7 +256,8 @@
\ --linux-rpm-license-type <type string>\n\
\ Type of the license ("License: <value>" of the RPM .spec)\n\
\ --linux-app-release <release value>\n\
-\ Release value of the RPM <name>.spec file or DEB control file.\n\
+\ Release value of the RPM <name>.spec file or \n\
+\ Debian revision value of the DEB control file.\n\
\ --linux-app-category <category value>\n\
\ Group value of the RPM <name>.spec file or \n\
\ Section value of DEB control file.\n\
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_ja.properties Wed Aug 28 11:30:40 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_ja.properties Wed Aug 28 11:41:49 2019 -0400
@@ -256,7 +256,8 @@
\ --linux-rpm-license-type <type string>\n\
\ Type of the license ("License: <value>" of the RPM .spec)\n\
\ --linux-app-release <release value>\n\
-\ Release value of the RPM <name>.spec file or DEB control file.\n\
+\ Release value of the RPM <name>.spec file or \n\
+\ Debian revision value of the DEB control file.\n\
\ --linux-app-category <category value>\n\
\ Group value of the RPM <name>.spec file or \n\
\ Section value of DEB control file.\n\
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_zh_CN.properties Wed Aug 28 11:30:40 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_zh_CN.properties Wed Aug 28 11:41:49 2019 -0400
@@ -256,7 +256,8 @@
\ --linux-rpm-license-type <type string>\n\
\ Type of the license ("License: <value>" of the RPM .spec)\n\
\ --linux-app-release <release value>\n\
-\ Release value of the RPM <name>.spec file or DEB control file.\n\
+\ Release value of the RPM <name>.spec file or \n\
+\ Debian revision value of the DEB control file.\n\
\ --linux-app-category <category value>\n\
\ Group value of the RPM <name>.spec file or \n\
\ Section value of DEB control file.\n\
--- a/test/jdk/tools/jpackage/linux/base/Base.java Wed Aug 28 11:30:40 2019 -0400
+++ b/test/jdk/tools/jpackage/linux/base/Base.java Wed Aug 28 11:41:49 2019 -0400
@@ -23,6 +23,7 @@
import java.io.File;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
@@ -58,24 +59,37 @@
}
}
- static String getRpmArch() throws Exception {
- File out = File.createTempFile("rpmbuild", ".out");
+ private static String getArch(String[] commandLine) throws Exception {
+ File out = File.createTempFile(commandLine[0], ".out");
out.deleteOnExit();
- int code = JPackageHelper.execute(out, "rpmbuild", "--eval=%{_target_cpu}");
+ int code = JPackageHelper.execute(out, commandLine);
if (code != 0) {
- throw new AssertionError("Error: unable to get rpm arch");
+ throw new AssertionError("Error: unable to get arch");
}
- return Files.readAllLines(out.toPath()).get(0);
+ return Files.readString(out.toPath()).strip();
+ }
+
+ static String getBundlePath(String basename, String ext) throws Exception {
+ return getBundlePath(basename, "1.0", "1", ext);
+ }
+
+ static String getBundlePath(String basename, String version, String release, String ext)
+ throws Exception {
+ String name;
+ if (ext.equals("rpm")) {
+ String arch = getArch(new String[] { "rpmbuild", "--eval=%{_target_cpu}" });
+ name = basename + "-" + version + "-" + release + "." + arch;
+ } else {
+ String arch = getArch(new String[] { "dpkg", "--print-architecture" });
+ name = basename + "_" + version + "-" + release + "_" + arch;
+ }
+ return Path.of("output", name + "." + ext).toString();
}
private static void init(String name, String ext) throws Exception {
TEST_NAME = name;
EXT = ext;
- if (EXT.equals("rpm")) {
- OUTPUT = "output" + File.separator + TEST_NAME + "-1.0-1." + getRpmArch() + "." + EXT;
- } else {
- OUTPUT = "output" + File.separator + TEST_NAME + "-1.0." + EXT;
- }
+ OUTPUT = getBundlePath(TEST_NAME, EXT);
CMD = new String[]{
"--package-type", EXT,
"--input", "input",
--- a/test/jdk/tools/jpackage/linux/base/BundleNameBase.java Wed Aug 28 11:30:40 2019 -0400
+++ b/test/jdk/tools/jpackage/linux/base/BundleNameBase.java Wed Aug 28 11:41:49 2019 -0400
@@ -62,11 +62,7 @@
TEST_NAME = name;
BUNDLE_NAME = "jpackage-test-bundle-name";
EXT = ext;
- if (EXT.equals("rpm")) {
- OUTPUT = "output" + File.separator + BUNDLE_NAME + "-1.0-1." + Base.getRpmArch() + "." + EXT;
- } else {
- OUTPUT = "output" + File.separator + BUNDLE_NAME + "-1.0." + EXT;
- }
+ OUTPUT = Base.getBundlePath(BUNDLE_NAME, EXT);
CMD = new String[]{
"--package-type", EXT,
"--input", "input",
--- a/test/jdk/tools/jpackage/linux/base/FileAssociationsBase.java Wed Aug 28 11:30:40 2019 -0400
+++ b/test/jdk/tools/jpackage/linux/base/FileAssociationsBase.java Wed Aug 28 11:41:49 2019 -0400
@@ -124,11 +124,7 @@
TEST_NAME = name;
EXT = ext;
TEST_EXT = "jptest1";
- if (EXT.equals("rpm")) {
- OUTPUT = "output" + File.separator + TEST_NAME + "-1.0-1." + Base.getRpmArch() + "." + EXT;
- } else {
- OUTPUT = "output" + File.separator + TEST_NAME + "-1.0." + EXT;
- }
+ OUTPUT = Base.getBundlePath(TEST_NAME, EXT);
CMD = new String[]{
"--package-type", EXT,
"--input", "input",
--- a/test/jdk/tools/jpackage/linux/base/InstallDirBase.java Wed Aug 28 11:30:40 2019 -0400
+++ b/test/jdk/tools/jpackage/linux/base/InstallDirBase.java Wed Aug 28 11:41:49 2019 -0400
@@ -66,11 +66,7 @@
private static void init(String name, String ext) throws Exception {
TEST_NAME = name;
EXT = ext;
- if (EXT.equals("rpm")) {
- OUTPUT = "output" + File.separator + TEST_NAME + "-1.0-1." + Base.getRpmArch() + "." + EXT;
- } else {
- OUTPUT = "output" + File.separator + TEST_NAME + "-1.0." + EXT;
- }
+ OUTPUT = Base.getBundlePath(TEST_NAME, EXT);
CMD = new String[]{
"--package-type", EXT,
"--input", "input",
--- a/test/jdk/tools/jpackage/linux/base/LicenseBase.java Wed Aug 28 11:30:40 2019 -0400
+++ b/test/jdk/tools/jpackage/linux/base/LicenseBase.java Wed Aug 28 11:41:49 2019 -0400
@@ -117,11 +117,7 @@
private static void init(String name, String ext) throws Exception {
TEST_NAME = name;
EXT = ext;
- if (EXT.equals("rpm")) {
- OUTPUT = "output" + File.separator + TEST_NAME + "-1.0-1." + Base.getRpmArch() + "." + EXT;
- } else {
- OUTPUT = "output" + File.separator + TEST_NAME + "-1.0." + EXT;
- }
+ OUTPUT = Base.getBundlePath(TEST_NAME, EXT);
CMD = new String [] {
"--package-type", EXT,
"--input", "input",
--- a/test/jdk/tools/jpackage/linux/base/LicenseTypeBase.java Wed Aug 28 11:30:40 2019 -0400
+++ b/test/jdk/tools/jpackage/linux/base/LicenseTypeBase.java Wed Aug 28 11:41:49 2019 -0400
@@ -83,11 +83,7 @@
TEST_NAME = name;
EXT = ext;
JP_LICENSE_TYPE = "JP_LICENSE_TYPE";
- if (EXT.equals("rpm")) {
- OUTPUT = "output" + File.separator + TEST_NAME + "-1.0-1." + Base.getRpmArch() + "." + EXT;
- } else {
- OUTPUT = "output" + File.separator + TEST_NAME + "-1.0." + EXT;
- }
+ OUTPUT = Base.getBundlePath(TEST_NAME, EXT);
CMD = new String[]{
"--package-type", EXT,
"--input", "input",
--- a/test/jdk/tools/jpackage/linux/base/MaintainerBase.java Wed Aug 28 11:30:40 2019 -0400
+++ b/test/jdk/tools/jpackage/linux/base/MaintainerBase.java Wed Aug 28 11:41:49 2019 -0400
@@ -62,7 +62,6 @@
}
}
}
-
if (!maintainerFound) {
throw new AssertionError("Maintainer field not found");
}
@@ -92,7 +91,7 @@
TEST_NAME = name;
EMAIL = "jpackage-test@java.com";
EXT = ext;
- OUTPUT = "output" + File.separator + TEST_NAME + "-1.0." + EXT;
+ OUTPUT = Base.getBundlePath(TEST_NAME, EXT);
CMD = new String[]{
"--package-type", EXT,
"--input", "input",
--- a/test/jdk/tools/jpackage/linux/base/PackageDepsBase.java Wed Aug 28 11:30:40 2019 -0400
+++ b/test/jdk/tools/jpackage/linux/base/PackageDepsBase.java Wed Aug 28 11:41:49 2019 -0400
@@ -105,13 +105,8 @@
TEST_NAME = name;
DEP_NAME = name + "Dep";
EXT = ext;
- if (EXT.equals("rpm")) {
- OUTPUT = "output" + File.separator + TEST_NAME + "-1.0-1." + Base.getRpmArch() + "." + EXT;
- OUTPUT_DEP = "output" + File.separator + DEP_NAME + "-1.0-1." + Base.getRpmArch() + "." + EXT;
- } else {
- OUTPUT = "output" + File.separator + TEST_NAME + "-1.0." + EXT;
- OUTPUT_DEP = "output" + File.separator + DEP_NAME + "-1.0." + EXT;
- }
+ OUTPUT = Base.getBundlePath(TEST_NAME, EXT);
+ OUTPUT_DEP = Base.getBundlePath(DEP_NAME, EXT);
CMD = new String[]{
"--package-type", EXT,
"--input", "input",
--- a/test/jdk/tools/jpackage/linux/deb/install.sh Wed Aug 28 11:30:40 2019 -0400
+++ b/test/jdk/tools/jpackage/linux/deb/install.sh Wed Aug 28 11:41:49 2019 -0400
@@ -1,8 +1,9 @@
-sudo dpkg -i test-1.0.deb
-sudo dpkg -i fileassociationstest-1.0.deb
-sudo dpkg -i licensetest-1.0.deb
-sudo dpkg -i installdirtest-1.0.deb
-sudo dpkg -i jpackage-test-bundle-name-1.0.deb
-sudo dpkg -i maintainertest-1.0.deb
-sudo dpkg -i packagedepstestdep-1.0.deb
-sudo dpkg -i packagedepstest-1.0.deb
+ARCH=$(dpkg --print-architecture)
+sudo dpkg -i test_1.0-*_${ARCH}.deb
+sudo dpkg -i fileassociationstest_1.0-*_${ARCH}.deb
+sudo dpkg -i licensetest_1.0-*_${ARCH}.deb
+sudo dpkg -i installdirtest_1.0-*_${ARCH}.deb
+sudo dpkg -i jpackage-test-bundle-name_1.0-*_${ARCH}.deb
+sudo dpkg -i maintainertest_1.0-*_${ARCH}.deb
+sudo dpkg -i packagedepstestdep_1.0-*_${ARCH}.deb
+sudo dpkg -i packagedepstest_1.0-*_${ARCH}.deb