Skip to content

Commit be9c4cb

Browse files
committed
[ci] Add debian-12 to matrix in packaging and platform jobs (#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. (cherry picked from commit 2ac267d) # Conflicts: # distribution/packages/src/deb/lintian/elasticsearch # qa/os/src/test/java/org/elasticsearch/packaging/util/LintianResultParser.java # qa/packaging/src/test/java/org/elasticsearch/packaging/test/DebMetadataTests.java
1 parent db8aecf commit be9c4cb

File tree

8 files changed

+202
-23
lines changed

8 files changed

+202
-23
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
@@ -359,7 +359,6 @@ Closure commonDebConfig(boolean oss, boolean jdk, String architecture) {
359359

360360
// versions found on oldest supported distro, centos-6
361361
requires('bash', '4.1', GREATER | EQUAL)
362-
requires('lsb-base', '4', GREATER | EQUAL)
363362
requires 'libc6'
364363
requires 'adduser'
365364

distribution/packages/src/deb/lintian/elasticsearch

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# we don't have a changelog, but we put our copyright file
22
# under /usr/share/doc/elasticsearch, which triggers this warning
3+
# Note that this is renamed to `no-changelog` in newer versions of
4+
# lintian, but we still support Debian 8+, so we can't change this.
35
changelog-file-missing-in-native-package
46

57
# we intentionally copy our copyright file for all deb packages
6-
copyright-file-contains-full-apache-2-license
7-
copyright-should-refer-to-common-license-file-for-apache-2
88
copyright-without-copyright-notice
99

1010
# we still put all our files under /usr/share/elasticsearch even after transition to platform dependent packages
@@ -13,37 +13,59 @@ arch-dependent-file-in-usr-share
1313
# we have a bundled jdk, so don't use jarwrapper
1414
missing-dep-on-jarwrapper
1515

16+
# we prefer to not make our config and log files world readable
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/]
23+
non-standard-executable-perm 0750 != 0755 [etc/init.d/elasticsearch]
24+
executable-is-not-world-readable 0750 [etc/init.d/elasticsearch]
25+
non-standard-file-permissions-for-etc-init.d-script 0750 != 0755 [etc/init.d/elasticsearch]
26+
27+
# the package scripts handle systemd directly and don't need to use deb helpers
28+
maintainer-script-calls-systemctl
29+
prerm-calls-updaterc.d elasticsearch [prerm:94]
30+
31+
# we do not automatically enable the service in init.d or systemd
32+
script-in-etc-init.d-not-registered-via-update-rc.d [etc/init.d/elasticsearch]
33+
34+
# bundled JDK
35+
embedded-library
36+
unstripped-binary-or-object [usr/share/elasticsearch/jdk/*]
37+
38+
# the system java version that lintian assumes is far behind what elasticsearch uses
39+
unknown-java-class-version
40+
41+
# There's no `License` field in Debian control files, but earlier versions
42+
# of `lintian` were more permissive. Override this warning so that we can
43+
# run `lintian` on different releases of Debian. The format of this override
44+
# varies between `lintian` versions.
45+
unknown-field elasticsearch-*.deb License
46+
unknown-field License
47+
48+
49+
# Below is the copy of some of the above rules in format for Lintian versions <= 2.104 (Debian 11)
50+
# Override syntax changes between Lintian versions in a non-backwards compatible way, so we handle it with
51+
# duplication and ignoring some issues in the test code.
52+
1653
# we prefer to not make our config and log files world readable
1754
non-standard-file-perm etc/default/elasticsearch 0660 != 0644
1855
non-standard-dir-perm etc/elasticsearch/ 2750 != 0755
1956
non-standard-dir-perm etc/elasticsearch/jvm.options.d/ 2750 != 0755
2057
non-standard-file-perm etc/elasticsearch/*
2158
non-standard-dir-perm var/lib/elasticsearch/ 2750 != 0755
2259
non-standard-dir-perm var/log/elasticsearch/ 2750 != 0755
60+
non-standard-executable-perm etc/init.d/elasticsearch 0750 != 0755
2361
executable-is-not-world-readable etc/init.d/elasticsearch 0750
2462
non-standard-file-permissions-for-etc-init.d-script etc/init.d/elasticsearch 0750 != 0755
2563

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
29-
3064
# we do not automatically enable the service in init.d or systemd
3165
script-in-etc-init.d-not-registered-via-update-rc.d etc/init.d/elasticsearch
3266

3367
# the package scripts handle init.d/systemd directly and don't need to use deb helpers
34-
maintainer-script-calls-systemctl
3568
prerm-calls-updaterc.d elasticsearch
3669

3770
# bundled JDK
38-
embedded-library
39-
arch-dependent-file-in-usr-share usr/share/elasticsearch/jdk/*
4071
unstripped-binary-or-object usr/share/elasticsearch/jdk/*
41-
extra-license-file usr/share/elasticsearch/jdk/legal/*
42-
hardening-no-pie usr/share/elasticsearch/jdk/bin/*
43-
hardening-no-pie usr/share/elasticsearch/jdk/lib/*
44-
45-
# the system java version that lintian assumes is far behind what elasticsearch uses
46-
unknown-java-class-version
47-
48-
# elastic licensed modules contain elastic license
49-
extra-license-file usr/share/elasticsearch/modules/*

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

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,63 @@
1111
import junit.framework.TestCase;
1212

1313
import org.elasticsearch.packaging.util.Distribution;
14-
import org.elasticsearch.packaging.util.FileUtils;
14+
import org.elasticsearch.packaging.util.LintianResultParser;
15+
import org.elasticsearch.packaging.util.LintianResultParser.Issue;
16+
import org.elasticsearch.packaging.util.LintianResultParser.Result;
1517
import org.elasticsearch.packaging.util.Shell;
1618
import org.junit.BeforeClass;
1719

20+
import java.util.Arrays;
21+
import java.util.List;
22+
import java.util.Locale;
1823
import java.util.regex.Pattern;
24+
import java.util.stream.Collectors;
1925

2026
import static org.elasticsearch.packaging.util.FileUtils.getDistributionFile;
2127
import static org.junit.Assume.assumeTrue;
2228

2329
public class DebMetadataTests extends PackagingTestCase {
2430

31+
private final LintianResultParser lintianParser = new LintianResultParser();
32+
private static final List<String> IGNORED_TAGS = Arrays.asList(
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+
2540
@BeforeClass
2641
public static void filterDistros() {
2742
assumeTrue("only deb", distribution.packaging == Distribution.Packaging.DEB);
2843
}
2944

3045
public void test05CheckLintian() {
3146
String extraArgs = "";
32-
if (sh.run("lintian --help").stdout.contains("fail-on-warnings")) {
33-
extraArgs = "--fail-on-warnings ";
47+
final String helpText = sh.run("lintian --help").stdout;
48+
if (helpText.contains("--fail-on-warnings")) {
49+
extraArgs = "--fail-on-warnings";
50+
} else if (helpText.contains("--fail-on error")) {
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+
.collect(Collectors.toList());
64+
if (importantIssues.isEmpty() == false) {
65+
fail(
66+
"Issues for DEB package found by Lintian:\n"
67+
+ importantIssues.stream().map(Issue::toString).collect(Collectors.joining("\n"))
68+
);
69+
}
3470
}
35-
sh.run("lintian " + extraArgs + FileUtils.getDistributionFile(distribution()));
3671
}
3772

3873
public void test06Dependencies() {
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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+
import java.util.stream.Collectors;
21+
22+
public class LintianResultParser {
23+
24+
private static final Logger logger = LogManager.getLogger(LintianResultParser.class);
25+
private static final Pattern RESULT_PATTERN = Pattern.compile("(?<severity>[EW]): (?<package>\\S+): (?<tag>\\S+) (?<message>.+)");
26+
27+
public Result parse(String output) {
28+
String[] lines = output.split("\n");
29+
List<Issue> issues = Arrays.stream(lines).map(line -> {
30+
Matcher matcher = RESULT_PATTERN.matcher(line);
31+
if (matcher.matches() == false) {
32+
logger.info("Lintian output not matching expected pattern: {}", line);
33+
return null;
34+
}
35+
Severity severity;
36+
switch (matcher.group("severity")) {
37+
case "E":
38+
severity = Severity.ERROR;
39+
break;
40+
case "W":
41+
severity = Severity.WARNING;
42+
break;
43+
default:
44+
severity = Severity.UNKNOWN;
45+
break;
46+
}
47+
return new Issue(severity, matcher.group("tag"), matcher.group("message"));
48+
}).filter(Objects::nonNull).collect(Collectors.toList());
49+
50+
return new Result(issues.stream().noneMatch(it -> it.severity == Severity.ERROR || it.severity == Severity.WARNING), issues);
51+
}
52+
53+
public static final class Result{
54+
private final boolean isSuccess;
55+
private final List<Issue> issues;
56+
57+
public Result(boolean isSuccess, List<Issue> issues) {
58+
this.isSuccess = isSuccess;
59+
this.issues = issues;
60+
}
61+
62+
public boolean isSuccess() {
63+
return isSuccess;
64+
}
65+
66+
public List<Issue> issues() {
67+
return issues;
68+
}
69+
70+
@Override
71+
public String toString() {
72+
return "Result{" +
73+
"isSuccess=" + isSuccess +
74+
", issues=" + issues +
75+
'}';
76+
}
77+
}
78+
79+
public static final class Issue {
80+
private final Severity severity;
81+
private final String tag;
82+
private final String message;
83+
84+
public Issue(Severity severity, String tag, String message) {
85+
this.severity = severity;
86+
this.tag = tag;
87+
this.message = message;
88+
}
89+
90+
public Severity severity() {
91+
return severity;
92+
}
93+
94+
public String tag() {
95+
return tag;
96+
}
97+
98+
public String message() {
99+
return message;
100+
}
101+
102+
@Override
103+
public String toString() {
104+
return "Issue{" +
105+
"severity=" + severity +
106+
", tag='" + tag + '\'' +
107+
", message='" + message + '\'' +
108+
'}';
109+
}
110+
}
111+
112+
public enum Severity {
113+
ERROR,
114+
WARNING,
115+
UNKNOWN
116+
}
117+
}

0 commit comments

Comments
 (0)