93 .addUninstallVerifier(cmd -> {
94 verifyLicenseFileNotInstalledLinux(rpmLicenseFile(cmd));
95 })
96 .run();
97 });
98 }
99
100 private static Path rpmLicenseFile(JPackageCommand cmd) {
101 final Path licenseRoot = Path.of(
102 new Executor()
103 .setExecutable("rpm")
104 .addArguments("--eval", "%{_defaultlicensedir}")
105 .executeAndGetFirstLineOfOutput());
106 final Path licensePath = licenseRoot.resolve(String.format("%s-%s",
107 LinuxHelper.getPackageName(cmd), cmd.version())).resolve(
108 LICENSE_FILE.getFileName());
109 return licensePath;
110 }
111
112 private static Path debLicenseFile(JPackageCommand cmd) {
113 final Path licensePath = Path.of("/usr", "share", "doc",
114 LinuxHelper.getPackageName(cmd), "copyright");
115 return licensePath;
116 }
117
118 private static void verifyLicenseFileInLinuxPackage(JPackageCommand cmd,
119 Path expectedLicensePath) {
120 Test.assertTrue(LinuxHelper.getPackageFiles(cmd).filter(path -> path.equals(
121 expectedLicensePath)).findFirst().orElse(null) != null,
122 String.format("Check license file [%s] is in %s package",
123 expectedLicensePath, LinuxHelper.getPackageName(cmd)));
124 }
125
126 private static void verifyLicenseFileInstalledRpm(Path licenseFile) {
127 Test.assertTrue(Files.isReadable(licenseFile), String.format(
128 "Check license file [%s] is readable", licenseFile));
129 try {
130 Test.assertTrue(Files.readAllLines(licenseFile).equals(
131 Files.readAllLines(LICENSE_FILE)), String.format(
132 "Check contents of package license file [%s] are the same as contents of source license file [%s]",
133 licenseFile, LICENSE_FILE));
134 } catch (IOException ex) {
135 throw new RuntimeException(ex);
|
93 .addUninstallVerifier(cmd -> {
94 verifyLicenseFileNotInstalledLinux(rpmLicenseFile(cmd));
95 })
96 .run();
97 });
98 }
99
100 private static Path rpmLicenseFile(JPackageCommand cmd) {
101 final Path licenseRoot = Path.of(
102 new Executor()
103 .setExecutable("rpm")
104 .addArguments("--eval", "%{_defaultlicensedir}")
105 .executeAndGetFirstLineOfOutput());
106 final Path licensePath = licenseRoot.resolve(String.format("%s-%s",
107 LinuxHelper.getPackageName(cmd), cmd.version())).resolve(
108 LICENSE_FILE.getFileName());
109 return licensePath;
110 }
111
112 private static Path debLicenseFile(JPackageCommand cmd) {
113 return cmd.appInstallationDirectory().resolve("share/doc/copyright");
114 }
115
116 private static void verifyLicenseFileInLinuxPackage(JPackageCommand cmd,
117 Path expectedLicensePath) {
118 Test.assertTrue(LinuxHelper.getPackageFiles(cmd).filter(path -> path.equals(
119 expectedLicensePath)).findFirst().orElse(null) != null,
120 String.format("Check license file [%s] is in %s package",
121 expectedLicensePath, LinuxHelper.getPackageName(cmd)));
122 }
123
124 private static void verifyLicenseFileInstalledRpm(Path licenseFile) {
125 Test.assertTrue(Files.isReadable(licenseFile), String.format(
126 "Check license file [%s] is readable", licenseFile));
127 try {
128 Test.assertTrue(Files.readAllLines(licenseFile).equals(
129 Files.readAllLines(LICENSE_FILE)), String.format(
130 "Check contents of package license file [%s] are the same as contents of source license file [%s]",
131 licenseFile, LICENSE_FILE));
132 } catch (IOException ex) {
133 throw new RuntimeException(ex);
|