Skip to content

Commit 2fdd728

Browse files
jozalasmalyshev
authored andcommitted
[ci] Add debian-12 to matrix in packaging and platform jobs (elastic#116172)
Lintian test has been changed to parse the result instead of using exit code. This was required, because now `mismatched-override` is non-erasable tag which cannot be ignored for exit code. Lintian introduced non-backward-compatible format change for overrides file. Because of that, some overrides are now duplicated in a format for older versions. Additionally, Lintian overrides file has been cleaned up to remove the tags which are no longer failing.
1 parent 579789b commit 2fdd728

File tree

8 files changed

+122
-36
lines changed

8 files changed

+122
-36
lines changed

.buildkite/pipelines/periodic-packaging.template.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ steps:
88
setup:
99
image:
1010
- debian-11
11+
- debian-12
1112
- opensuse-leap-15
1213
- oraclelinux-7
1314
- oraclelinux-8

.buildkite/pipelines/periodic-packaging.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ steps:
99
setup:
1010
image:
1111
- debian-11
12+
- debian-12
1213
- opensuse-leap-15
1314
- oraclelinux-7
1415
- oraclelinux-8

.buildkite/pipelines/periodic-platform-support.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ steps:
88
setup:
99
image:
1010
- debian-11
11+
- debian-12
1112
- opensuse-leap-15
1213
- oraclelinux-7
1314
- oraclelinux-8

.buildkite/pipelines/pull-request/packaging-tests-unix.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ steps:
1111
setup:
1212
image:
1313
- debian-11
14+
- debian-12
1415
- opensuse-leap-15
1516
- oraclelinux-7
1617
- oraclelinux-8
@@ -38,6 +39,7 @@ steps:
3839
setup:
3940
image:
4041
- debian-11
42+
- debian-12
4143
- opensuse-leap-15
4244
- oraclelinux-7
4345
- oraclelinux-8
@@ -65,6 +67,7 @@ steps:
6567
setup:
6668
image:
6769
- debian-11
70+
- debian-12
6871
- opensuse-leap-15
6972
- oraclelinux-7
7073
- oraclelinux-8

distribution/packages/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ Closure commonDebConfig(String architecture) {
335335

336336
// versions found on oldest supported distro, centos-6
337337
requires('bash', '4.1', GREATER | EQUAL)
338-
requires('lsb-base', '4', GREATER | EQUAL)
339338
requires 'libc6'
340339
requires 'adduser'
341340

distribution/packages/src/deb/lintian/elasticsearch

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
changelog-file-missing-in-native-package
66

77
# we intentionally copy our copyright file for all deb packages
8-
copyright-file-contains-full-apache-2-license
9-
copyright-not-using-common-license-for-apache2
108
copyright-without-copyright-notice
119

1210
# we still put all our files under /usr/share/elasticsearch even after transition to platform dependent packages
@@ -16,37 +14,23 @@ arch-dependent-file-in-usr-share
1614
missing-dep-on-jarwrapper
1715

1816
# we prefer to not make our config and log files world readable
19-
non-standard-file-perm etc/default/elasticsearch 0660 != 0644
20-
non-standard-dir-perm etc/elasticsearch/ 2750 != 0755
21-
non-standard-dir-perm etc/elasticsearch/jvm.options.d/ 2750 != 0755
22-
non-standard-file-perm etc/elasticsearch/*
23-
non-standard-dir-perm var/lib/elasticsearch/ 2750 != 0755
24-
non-standard-dir-perm var/log/elasticsearch/ 2750 != 0755
25-
26-
# this lintian tag is simply wrong; contrary to the explanation, Debian systemd
27-
# does actually look at /usr/lib/systemd/system
28-
systemd-service-file-outside-lib usr/lib/systemd/system/elasticsearch.service
17+
non-standard-file-perm 0660 != 0644 [etc/default/elasticsearch]
18+
non-standard-dir-perm 2750 != 0755 [etc/elasticsearch/]
19+
non-standard-dir-perm 2750 != 0755 [etc/elasticsearch/jvm.options.d/]
20+
non-standard-file-perm 0660 != 0644 [etc/elasticsearch/*]
21+
non-standard-dir-perm 2750 != 0755 [var/lib/elasticsearch/]
22+
non-standard-dir-perm 2750 != 0755 [var/log/elasticsearch/]
2923

3024
# the package scripts handle systemd directly and don't need to use deb helpers
3125
maintainer-script-calls-systemctl
3226

3327
# bundled JDK
3428
embedded-library
35-
unstripped-binary-or-object usr/share/elasticsearch/jdk/*
36-
extra-license-file usr/share/elasticsearch/jdk/legal/*
37-
hardening-no-pie usr/share/elasticsearch/jdk/bin/*
38-
hardening-no-pie usr/share/elasticsearch/jdk/lib/*
29+
unstripped-binary-or-object [usr/share/elasticsearch/jdk/*]
3930

4031
# the system java version that lintian assumes is far behind what elasticsearch uses
4132
unknown-java-class-version
4233

43-
# elastic licensed modules contain elastic license
44-
extra-license-file usr/share/elasticsearch/modules/*
45-
46-
# This dependency appears to have a packaging flaw, and includes a
47-
# generated source file alongside the compiled version
48-
jar-contains-source usr/share/elasticsearch/modules/repository-gcs/api-common*.jar *
49-
5034
# There's no `License` field in Debian control files, but earlier versions
5135
# of `lintian` were more permissive. Override this warning so that we can
5236
# run `lintian` on different releases of Debian. The format of this override
@@ -58,8 +42,27 @@ unknown-field License
5842
# indirectly to libc via libdl. This might not be best practice but we
5943
# don't build them ourselves and the license precludes us modifying them
6044
# to fix this.
61-
library-not-linked-against-libc usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/lib/libmkl_*.so
45+
library-not-linked-against-libc [usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/lib/libmkl_*.so*]
46+
47+
48+
# Below is the copy of some of the above rules in format for Lintian versions <= 2.104 (Debian 11)
49+
# Override syntax changes between Lintian versions in a non-backwards compatible way, so we handle it with
50+
# duplication and ignoring some issues in the test code.
51+
52+
53+
# we prefer to not make our config and log files world readable
54+
non-standard-file-perm etc/default/elasticsearch 0660 != 0644
55+
non-standard-dir-perm etc/elasticsearch/ 2750 != 0755
56+
non-standard-dir-perm etc/elasticsearch/jvm.options.d/ 2750 != 0755
57+
non-standard-file-perm etc/elasticsearch/*
58+
non-standard-dir-perm var/lib/elasticsearch/ 2750 != 0755
59+
non-standard-dir-perm var/log/elasticsearch/ 2750 != 0755
6260

63-
# shared-lib-without-dependency-information (now shared-library-lacks-prerequisites) is falsely reported for libvec.so
64-
# which has no dependencies (not even libc) besides the symbols in the base executable.
65-
shared-lib-without-dependency-information usr/share/elasticsearch/lib/platform/linux-x64/libvec.so
61+
# bundled JDK
62+
unstripped-binary-or-object usr/share/elasticsearch/jdk/*
63+
64+
# Intel MKL libraries are not linked directly to libc. They are linked
65+
# indirectly to libc via libdl. This might not be best practice but we
66+
# don't build them ourselves and the license precludes us modifying them
67+
# to fix this.
68+
library-not-linked-against-libc usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/lib/libmkl_*.so*

qa/packaging/src/test/java/org/elasticsearch/packaging/test/DebMetadataTests.java

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,31 @@
1212
import junit.framework.TestCase;
1313

1414
import org.elasticsearch.packaging.util.Distribution;
15-
import org.elasticsearch.packaging.util.FileUtils;
15+
import org.elasticsearch.packaging.util.LintianResultParser;
16+
import org.elasticsearch.packaging.util.LintianResultParser.Issue;
17+
import org.elasticsearch.packaging.util.LintianResultParser.Result;
1618
import org.elasticsearch.packaging.util.Shell;
1719
import org.junit.BeforeClass;
1820

21+
import java.util.List;
1922
import java.util.Locale;
2023
import java.util.regex.Pattern;
24+
import java.util.stream.Collectors;
2125

2226
import static org.elasticsearch.packaging.util.FileUtils.getDistributionFile;
2327
import static org.junit.Assume.assumeTrue;
2428

2529
public class DebMetadataTests extends PackagingTestCase {
2630

31+
private final LintianResultParser lintianParser = new LintianResultParser();
32+
private static final List<String> IGNORED_TAGS = List.of(
33+
// Override syntax changes between lintian versions in a non-backwards compatible way, so we have to tolerate these.
34+
// Tag mismatched-override is a non-erasable tag which cannot be ignored with overrides, so we handle it here.
35+
"mismatched-override",
36+
// systemd-service-file-outside-lib has been incorrect and removed in the newer version on Lintian
37+
"systemd-service-file-outside-lib"
38+
);
39+
2740
@BeforeClass
2841
public static void filterDistros() {
2942
assumeTrue("only deb", distribution.packaging == Distribution.Packaging.DEB);
@@ -35,15 +48,26 @@ public void test05CheckLintian() {
3548
if (helpText.contains("--fail-on-warnings")) {
3649
extraArgs = "--fail-on-warnings";
3750
} else if (helpText.contains("--fail-on error")) {
38-
extraArgs = "--fail-on warning";
39-
// Recent lintian versions are picky about malformed or mismatched overrides.
40-
// Unfortunately override syntax changes between lintian versions in a non-backwards compatible
41-
// way, so we have to tolerate these (or maintain separate override files per lintian version).
42-
if (helpText.contains("--suppress-tags")) {
43-
extraArgs += " --suppress-tags malformed-override,mismatched-override";
51+
extraArgs = "--fail-on error,warning";
52+
}
53+
Shell.Result result = sh.runIgnoreExitCode(
54+
String.format(Locale.ROOT, "lintian %s %s", extraArgs, getDistributionFile(distribution()))
55+
);
56+
Result lintianResult = lintianParser.parse(result.stdout());
57+
// Unfortunately Lintian overrides syntax changes between Lintian versions in a non-backwards compatible
58+
// way, so we have to manage some exclusions outside the overrides file.
59+
if (lintianResult.isSuccess() == false) {
60+
List<Issue> importantIssues = lintianResult.issues()
61+
.stream()
62+
.filter(issue -> IGNORED_TAGS.contains(issue.tag()) == false)
63+
.toList();
64+
if (importantIssues.isEmpty() == false) {
65+
fail(
66+
"Issues for DEB package found by Lintian:\n"
67+
+ importantIssues.stream().map(Record::toString).collect(Collectors.joining("\n"))
68+
);
4469
}
4570
}
46-
sh.run(String.format(Locale.ROOT, "lintian %s %s", extraArgs, FileUtils.getDistributionFile(distribution())));
4771
}
4872

4973
public void test06Dependencies() {
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.packaging.util;
11+
12+
import org.apache.logging.log4j.LogManager;
13+
import org.apache.logging.log4j.Logger;
14+
15+
import java.util.Arrays;
16+
import java.util.List;
17+
import java.util.Objects;
18+
import java.util.regex.Matcher;
19+
import java.util.regex.Pattern;
20+
21+
public class LintianResultParser {
22+
23+
private static final Logger logger = LogManager.getLogger(LintianResultParser.class);
24+
private static final Pattern RESULT_PATTERN = Pattern.compile("(?<severity>[EW]): (?<package>\\S+): (?<tag>\\S+) (?<message>.+)");
25+
26+
public Result parse(String output) {
27+
String[] lines = output.split("\n");
28+
List<Issue> issues = Arrays.stream(lines).map(line -> {
29+
Matcher matcher = RESULT_PATTERN.matcher(line);
30+
if (matcher.matches() == false) {
31+
logger.info("Lintian output not matching expected pattern: {}", line);
32+
return null;
33+
}
34+
Severity severity = switch (matcher.group("severity")) {
35+
case "E" -> Severity.ERROR;
36+
case "W" -> Severity.WARNING;
37+
default -> Severity.UNKNOWN;
38+
};
39+
return new Issue(severity, matcher.group("tag"), matcher.group("message"));
40+
}).filter(Objects::nonNull).toList();
41+
42+
return new Result(issues.stream().noneMatch(it -> it.severity == Severity.ERROR || it.severity == Severity.WARNING), issues);
43+
}
44+
45+
public record Result(boolean isSuccess, List<Issue> issues) {}
46+
47+
public record Issue(Severity severity, String tag, String message) {}
48+
49+
enum Severity {
50+
ERROR,
51+
WARNING,
52+
UNKNOWN
53+
}
54+
}

0 commit comments

Comments
 (0)