Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8266603: jpackage: Add missing copyright file in Java runtime .deb installers #3894

Closed
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -46,7 +46,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static jdk.jpackage.internal.OverridableResource.createResource;
import static jdk.jpackage.internal.StandardBundlerParam.APP_NAME;
import static jdk.jpackage.internal.StandardBundlerParam.INSTALLER_NAME;
import static jdk.jpackage.internal.StandardBundlerParam.VERSION;
import static jdk.jpackage.internal.StandardBundlerParam.RELEASE;
Expand Down Expand Up @@ -412,7 +411,10 @@ private void prepareProjectConfig(Map<String, String> data,
configDir.resolve("postrm"),
"resource.deb-postrm-script").setExecutable());

if (!StandardBundlerParam.isRuntimeInstaller(params)) {
final String installDir = LINUX_INSTALL_DIR.fetchFrom(params);

if (!StandardBundlerParam.isRuntimeInstaller(params)
|| (isInstallDirInUsrTree(installDir) || installDir.startsWith("/usr/"))) {
debianFiles.add(new DebianFile(
getConfig_CopyrightFile(params),
"resource.copyright-file"));
Expand Down
23 changes: 22 additions & 1 deletion test/jdk/tools/jpackage/share/RuntimePackageTest.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -27,12 +27,16 @@
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import jdk.jpackage.test.PackageType;
import jdk.jpackage.test.PackageTest;
import jdk.jpackage.test.JPackageCommand;
import jdk.jpackage.test.TKit;
import jdk.jpackage.test.Annotations.Test;
import jdk.jpackage.test.LinuxHelper;
import static jdk.jpackage.test.TKit.assertTrue;
import static jdk.jpackage.test.TKit.assertFalse;

/**
* Test --runtime-image parameter.
Expand Down Expand Up @@ -121,6 +125,23 @@ private static PackageTest init(Set<PackageType> types) {

assertFileListEmpty(srcRuntime, "Missing");
assertFileListEmpty(dstRuntime, "Unexpected");
})
.forTypes(PackageType.LINUX_DEB)
.addInstallVerifier(cmd -> {
String installDir = cmd.getArgumentValue("--install-dir", () -> "/opt");
Path copyright = Path.of("/usr/share/doc",
LinuxHelper.getPackageName(cmd), "copyright");
boolean withCopyright = LinuxHelper.getPackageFiles(cmd).anyMatch(
Predicate.isEqual(copyright));
if (installDir.startsWith("/usr/") || installDir.equals("/usr")) {
assertTrue(withCopyright, String.format(
"Check the package delivers [%s] copyright file",
copyright));
} else {
assertFalse(withCopyright, String.format(
"Check the package doesn't deliver [%s] copyright file",
copyright));
}
});
}

Expand Down