Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8266603: jpackage: Add missing copyright file in Java runtime .deb in…
…stallers

Reviewed-by: almatvee, herrick
  • Loading branch information
Alexey Semenyuk committed May 10, 2021
1 parent c494efc commit c8b7447
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
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

1 comment on commit c8b7447

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.