Skip to content

Commit d5a3820

Browse files
DEB packaging bugfix
1 parent 3be543e commit d5a3820

File tree

9 files changed

+49
-36
lines changed

9 files changed

+49
-36
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ private void prepareProjectConfig(Map<String, String> data, BuildEnv env, LinuxP
326326
"resource.deb-postrm-script").setExecutable());
327327

328328
((LinuxDebPackage)pkg).relativeCopyrightFilePath().ifPresent(copyrightFile -> {
329-
debianFiles.add(new DebianFile(Path.of("/").resolve(copyrightFile),
329+
debianFiles.add(new DebianFile(env.appImageDir().resolve(copyrightFile),
330330
"resource.copyright-file"));
331331
});
332332

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@
2727
import java.util.Objects;
2828
import java.util.Optional;
2929
import jdk.jpackage.internal.model.ConfigException;
30-
import jdk.jpackage.internal.model.LinuxRpmPackage;
31-
import jdk.jpackage.internal.model.LinuxRpmPackageMixin;
30+
import jdk.jpackage.internal.model.LinuxDebPackage;
31+
import jdk.jpackage.internal.model.LinuxDebPackageMixin;
3232

3333
final class LinuxDebPackageBuilder {
3434

3535
LinuxDebPackageBuilder(LinuxPackageBuilder pkgBuilder) {
3636
this.pkgBuilder = Objects.requireNonNull(pkgBuilder);
3737
}
3838

39-
LinuxRpmPackage create() throws ConfigException {
39+
LinuxDebPackage create() throws ConfigException {
4040
var pkg = pkgBuilder.create();
41-
return LinuxRpmPackage.create(pkg, new LinuxRpmPackageMixin.Stub(
41+
return LinuxDebPackage.create(pkg, new LinuxDebPackageMixin.Stub(
4242
Optional.ofNullable(maintainerEmail).orElseGet(
4343
DEFAULTS::maintainerEmail)));
4444
}

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private LinuxPackage create(Package pkg, AppImageLayout pkgLayout) throws Config
7373
Optional.ofNullable(menuGroupName).orElseGet(DEFAULTS::menuGroupName),
7474
Optional.ofNullable(category).orElseGet(DEFAULTS::category),
7575
Optional.ofNullable(additionalDependencies),
76-
Optional.ofNullable(release).orElseGet(DEFAULTS::release),
76+
Optional.ofNullable(release),
7777
pkg.asStandardPackageType().map(LinuxPackageArch::getValue).orElseThrow()));
7878
}
7979

@@ -102,6 +102,10 @@ LinuxPackageBuilder release(String v) {
102102
return this;
103103
}
104104

105+
Optional<String> release() {
106+
return Optional.ofNullable(release);
107+
}
108+
105109
private static LinuxApplicationLayout usrTreePackageLayout(Path prefix, String packageName) {
106110
final var lib = prefix.resolve(Path.of("lib", packageName));
107111
return LinuxApplicationLayout.create(
@@ -155,10 +159,12 @@ private static void validatePackageName(String packageName,
155159
.create();
156160
}
157161
}
162+
default -> {
163+
}
158164
}
159165
}
160166

161-
private record Defaults(String release, String menuGroupName, String category) {
167+
private record Defaults(String menuGroupName, String category) {
162168
}
163169

164170
private String literalName;
@@ -169,7 +175,7 @@ private record Defaults(String release, String menuGroupName, String category) {
169175

170176
private final PackageBuilder pkgBuilder;
171177

172-
private static final Defaults DEFAULTS = new Defaults("1", I18N.getString(
178+
private static final Defaults DEFAULTS = new Defaults(I18N.getString(
173179
"param.menu-group.default"), "misc");
174180

175181
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private static Path installPrefix(LinuxPackage pkg) {
119119
protected Map<String, String> createReplacementData(BuildEnv env, LinuxPackage pkg) throws IOException {
120120
Map<String, String> data = new HashMap<>();
121121

122-
data.put("APPLICATION_RELEASE", pkg.release());
122+
data.put("APPLICATION_RELEASE", pkg.release().orElseThrow());
123123
data.put("APPLICATION_PREFIX", installPrefix(pkg).toString());
124124
data.put("APPLICATION_DIRECTORY", Path.of("/").resolve(pkg.relativeInstallDir()).toString());
125125
data.put("APPLICATION_SUMMARY", pkg.packageName());
@@ -159,7 +159,7 @@ protected List<ConfigException> verifyOutputBundle(BuildEnv env, LinuxPackage pk
159159
"APPLICATION_PACKAGE", specFileName),
160160
new PackageProperty("Version", pkg.version(),
161161
"APPLICATION_VERSION", specFileName),
162-
new PackageProperty("Release", pkg.release(),
162+
new PackageProperty("Release", pkg.release().orElseThrow(),
163163
"APPLICATION_RELEASE", specFileName),
164164
new PackageProperty("Arch", pkg.arch(), null, specFileName));
165165

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ final class LinuxRpmPackageBuilder {
3737
}
3838

3939
LinuxRpmPackage create() throws ConfigException {
40+
if (pkgBuilder.release().isEmpty()) {
41+
pkgBuilder.release("1");
42+
}
4043
var pkg = pkgBuilder.create();
4144
return LinuxRpmPackage.create(pkg, new LinuxRpmPackageMixin.Stub(
4245
Optional.ofNullable(licenseType).orElseGet(DEFAULTS::licenseType)));

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

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import java.nio.file.Path;
2828
import java.util.Optional;
29-
3029
import jdk.jpackage.internal.util.CompositeProxy;
3130

3231
/**
@@ -50,30 +49,19 @@ default String maintainer() {
5049
return String.format("%s <%s>", app().vendor(), maintainerEmail());
5150
}
5251

53-
/**
54-
* Gets the version with the release number of this DEB package.
55-
*
56-
* @see <a href=
57-
* "https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-version">https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-version</a>
58-
* @return the version with the release number of this DEB package
59-
*/
60-
default String versionWithRelease() {
61-
return String.format("%s-%s", version(), release());
62-
}
63-
6452
/**
6553
* Gets the relative path to this DEB package's copyright file. Returns empty
6654
* {@link Optional} instance if this DEB package has no copyright file.
6755
*
6856
* @return the relative path to the copyright file of this DEB package
6957
*/
7058
default Optional<Path> relativeCopyrightFilePath() {
71-
if (isRuntimeInstaller()) {
72-
return Optional.empty();
73-
} else if (isInstallDirInUsrTree() || Path.of("/").resolve(relativeInstallDir()).startsWith("/usr/")) {
74-
return Optional.of(Path.of("/usr/share/doc/", packageName(), "copyright"));
75-
} else {
59+
if (isInstallDirInUsrTree() || Path.of("/").resolve(relativeInstallDir()).startsWith("/usr/")) {
60+
return Optional.of(Path.of("usr/share/doc/", packageName(), "copyright"));
61+
} else if (!isRuntimeInstaller()) {
7662
return Optional.of(relativeInstallDir().resolve("share/doc/copyright"));
63+
} else {
64+
return Optional.empty();
7765
}
7866
}
7967

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ public interface LinuxDebPackageMixin {
3939
/**
4040
* Default implementation of {@link LinuxDebPackageMixin} interface.
4141
*/
42-
record Stub(String maintainerEmail) {
42+
record Stub(String maintainerEmail) implements LinuxDebPackageMixin {
4343
}
4444
}

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
package jdk.jpackage.internal.model;
2626

2727
import java.nio.file.Path;
28-
2928
import jdk.jpackage.internal.util.CompositeProxy;
3029

3130
/**
@@ -43,18 +42,27 @@ default String packageFileName() {
4342
String packageFileNameTemlate = asStandardPackageType().map(stdType -> {
4443
switch (stdType) {
4544
case LINUX_DEB -> {
46-
return "%s_%s-%s_%s";
45+
return "%s_%s_%s";
4746
}
4847
case LINUX_RPM -> {
49-
return "%s-%s-%s.%s";
48+
return "%s-%s.%s";
5049
}
5150
default -> {
5251
throw new IllegalStateException();
5352
}
5453
}
5554
}).orElseThrow(UnsupportedOperationException::new);
5655

57-
return String.format(packageFileNameTemlate, packageName(), version(), release(), arch());
56+
return String.format(packageFileNameTemlate, packageName(), versionWithRelease(), arch());
57+
}
58+
59+
/**
60+
* Gets the version with the release component of this Linux package.
61+
*
62+
* @return the version with the release component of this Linux package
63+
*/
64+
default String versionWithRelease() {
65+
return String.format("%s%s", version(), release().map(r -> "-" + r).orElse(""));
5866
}
5967

6068
/**

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,19 @@ public interface LinuxPackageMixin {
6464
Optional<String> additionalDependencies();
6565

6666
/**
67-
* Gets the release of this package.
67+
* Gets the release of this package. Returns an empty {@link Optional} instance
68+
* if this package doesn't have a release.
69+
* <p>
70+
* For RPM packages, this is the value of a "Release" property in spec file. RPM
71+
* packages always have a release.
72+
* <p>
73+
* For DEB packages, this is an optional {@code debian_revision} component of a
74+
* package version. See <a href=
75+
* "https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-version#">https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-version#</a>.
6876
*
6977
* @return the release of this package
7078
*/
71-
String release();
79+
Optional<String> release();
7280

7381
/**
7482
* Gets the platform architecture of this package.
@@ -81,7 +89,7 @@ public interface LinuxPackageMixin {
8189
* Default implementation of {@link LinuxPackageMixin} interface.
8290
*/
8391
record Stub(AppImageLayout packageLayout, String menuGroupName,
84-
String category, Optional<String> additionalDependencies, String release,
85-
String arch) implements LinuxPackageMixin {
92+
String category, Optional<String> additionalDependencies,
93+
Optional<String> release, String arch) implements LinuxPackageMixin {
8694
}
8795
}

0 commit comments

Comments
 (0)