/**
- * Copyright (C) 2016-2017 - Michael Jeanson <mjeanson@efficios.com>
+ * Copyright (C) 2016-2020 Michael Jeanson <mjeanson@efficios.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
}
}
+class ElKVersion implements Comparable<ElKVersion> {
+ Integer major = 0
+ Integer minor = 0
+ Integer patch = 0
+ Integer elmajor = 0
+ Integer elminor = 0
+ Integer elpatch = 0
+ Integer el_release_major = 0
+ Integer el_release_minor = 0
+ Boolean append_zero_el_release_minor = false
+ String version_prefix = ""
+
+ ElKVersion() {}
+
+ ElKVersion(version) {
+ this.parse(version)
+ }
+
+ static ElKVersion minKVersion() {
+ return new ElKVersion("kernel-0.0.0-0.0.0.el0_0")
+ }
+
+ static ElKVersion maxKVersion() {
+ return new ElKVersion("kernel-" + Integer.MAX_VALUE + ".0.0-0.0.0.el0_0")
+ }
+
+ static ElKVersion factory(version) {
+ return new ElKVersion(version)
+ }
+
+ def parse(version) {
+ this.major = 0
+ this.minor = 0
+ this.patch = 0
+ this.elmajor = 0
+ this.elminor = 0
+ this.elpatch = 0
+ this.el_release_major = 0
+ this.el_release_minor = 0
+ this.append_zero_el_release_minor = false
+ this.version_prefix = ""
+
+ if (!version) {
+ throw new EmptyKVersionException("Empty kernel version")
+ }
+
+ // Eg. imports/r8/kernel-4.18.0-513.18.1.el8_9
+ // Eg. imports/r9/kernel-5.14.0-362.13.1.el9_3
+ // Eg. imports/r8s/kernel-4.18.0-528.el8
+ // Eg. imports/r8/kernel-4.18.0-80.1.2.el8_0
+ // Eg. imports/r8/kernel-4.18.0-348.el8
+ def match = version =~ /^([\w\d\/]*kernel-)??(\d+)\.(\d+)\.(\d+)-(\d+)(\.(\d+))??(\.(\d+))??\.el(\d+)(_(\d+))??$/
+ if (!match) {
+ throw new InvalidKVersionException("Invalid kernel version: ${version}")
+ }
+
+ if (match.group(1)) {
+ this.version_prefix = match.group(1)
+ }
+ this.major = Integer.parseInt(match.group(2))
+ this.minor = Integer.parseInt(match.group(3))
+ this.patch = Integer.parseInt(match.group(4))
+ this.elmajor = Integer.parseInt(match.group(5))
+ if (match.group(7)) {
+ this.elminor = Integer.parseInt(match.group(7))
+ }
+ if (match.group(9)) {
+ this.elpatch = Integer.parseInt(match.group(9))
+ }
+ if (match.group(10)) {
+ this.el_release_major = Integer.parseInt(match.group(10))
+ }
+ if (match.group(12)) {
+ this.el_release_minor = Integer.parseInt(match.group(12))
+ this.append_zero_el_release_minor = true
+ }
+ }
+
+ Boolean isRC() {
+ return false
+ }
+
+ Boolean isSameStable(ElKVersion o) {
+ def properties = ['major', 'minor', 'patch', 'elmajor', 'elminor', 'elpatch', 'el_release_major', 'el_release_minor']
+ for (property in properties) {
+ if (this."$property" != o."$property") {
+ return false
+ }
+ }
+ return true
+ }
+
+ @Override int compareTo(ElKVersion o) {
+ def properties = ['major', 'minor', 'patch', 'elmajor', 'elminor', 'elpatch', 'el_release_major', 'el_release_minor']
+ for (property in properties) {
+ if (this."$property" != o."$property") {
+ return Integer.compare(this."$property", o."$property")
+ }
+ }
+ return 0
+ }
+
+ String toString() {
+ String vString = "${this.version_prefix}${this.major}.${this.minor}.${this.patch}-${this.elmajor}"
+ // Sometimes a tag can have no elminor, eg. imports/r8/kernel-4.18.0-80.el8
+ if (this.elminor != 0) {
+ vString = vString.concat(".${this.elminor}")
+ }
+ if (this.elpatch != 0) {
+ vString = vString.concat(".${this.elpatch}")
+ }
+ vString = vString.concat(".el${this.el_release_major}")
+ // Some tags have a trailing el_release_minor that is 0, eg.
+ // imports/r8/kernel-4.18.0-80.1.2.el8
+ if (this.el_release_minor != 0 || (this.el_release_minor == 0 && this.append_zero_el_release_minor)) {
+ vString = vString.concat("_${this.el_release_minor}")
+ }
+ return vString
+ }
+}
+
+class SlesKVersion implements Comparable<SlesKVersion> {
+ Integer major = 0
+ Integer minor = 0
+ Integer patch = 0
+ Integer slesrelease = 0
+ Integer slesmajor = 0
+ Integer slesminor = 0
+
+ SlesKVersion() {}
+
+ SlesKVersion(version) {
+ this.parse(version)
+ }
+
+ static SlesKVersion minKVersion() {
+ return new SlesKVersion("rpm-0.0.0-0.0.0")
+ }
+
+ static SlesKVersion maxKVersion() {
+ return new SlesKVersion("rpm-" + Integer.MAX_VALUE + ".0.0-0.0.0")
+ }
+
+ static SlesKVersion factory(version) {
+ return new SlesKVersion(version)
+ }
+
+ def parse(version) {
+ this.major = 0
+ this.minor = 0
+ this.patch = 0
+ this.slesrelease = 0
+ this.slesmajor = 0
+ this.slesminor = 0
+
+ if (!version) {
+ throw new EmptyKVersionException("Empty kernel version")
+ }
+
+ // Eg. 5.14.21-150400.22
+ // Eg. 5.14.21-150400.24.100.2
+ // From tag: rpm-5.14.21-150400.24.100 -> 5.14.21-150400.24.100
+ def match = version =~ /^(rpm-)??(\d+)\.(\d+)\.(\d+)-(\d+)\.(\d+)(\.\d+)??$/
+ if (!match) {
+ throw new InvalidKVersionException("Invalid kernel version: ${version}")
+ }
+
+ this.major = Integer.parseInt(match.group(2))
+ this.minor = Integer.parseInt(match.group(3))
+ this.patch = Integer.parseInt(match.group(4))
+ this.slesrelease = Integer.parseInt(match.group(5))
+ this.slesmajor = Integer.parseInt(match.group(6))
+
+ if (match.group(7) != null) {
+ this.slesminor = Integer.parseInt(match.group(7).drop(1))
+ }
+ }
+
+ Boolean isRC() {
+ return false
+ }
+
+ Boolean isSameStable(SlesKVersion o) {
+ if (this.major != o.major) {
+ return false
+ }
+ if (this.minor != o.minor) {
+ return false
+ }
+ if (this.patch != o.patch) {
+ return false
+ }
+ if (this.slesrelease != o.slesrelease) {
+ return false
+ }
+ if (this.slesmajor != o.slesmajor) {
+ return false
+ }
+ if (this.slesminor != o.slesminor) {
+ return false
+ }
+ return true
+ }
+
+ @Override int compareTo(SlesKVersion o) {
+ if (this.major != o.major) {
+ return Integer.compare(this.major, o.major)
+ }
+ if (this.minor != o.minor) {
+ return Integer.compare(this.minor, o.minor)
+ }
+ if (this.patch != o.patch) {
+ return Integer.compare(this.patch, o.patch)
+ }
+ if (this.slesrelease != o.slesrelease) {
+ return Integer.compare(this.slesrelease, o.slesrelease)
+ }
+ if (this.slesmajor != o.slesmajor) {
+ return Integer.compare(this.slesmajor, o.slesmajor)
+ }
+ if (this.slesminor != o.slesminor) {
+ return Integer.compare(this.slesminor, o.slesminor)
+ }
+ return 0
+ }
+
+ String toString() {
+ String vString = "rpm-${this.major}.${this.minor}.${patch}-${this.slesrelease}.${this.slesmajor}"
+ if (this.slesminor != 0) {
+ vString = vString.concat(".${this.slesminor}")
+ }
+ return vString
+ }
+}
+
class UbuntuKVersion implements Comparable<UbuntuKVersion> {
Integer major = 0
Integer umajor = 0
Integer uminor = 0
String suffix = ""
+ String strLTS = ""
Boolean isLTS = false
UbuntuKVersion() {}
throw new EmptyKVersionException("Empty kernel version")
}
+ //'Ubuntu-hwe-5.8-5.8.0-19.20_20.04.3',
//'Ubuntu-lts-4.8.0-27.29_16.04.1',
//'Ubuntu-4.4.0-70.91',
- def match = version =~ /^Ubuntu-(lts-)??(\d+)\.(\d+)\.(\d+)-(\d+)\.(\d+)(.*)??$/
+ def match = version =~ /^Ubuntu-(lts-|hwe-)??(?:\d+\.\d+-)??(\d+)\.(\d+)\.(\d+)-(\d+)\.(\d+)(.*)??$/
if (!match) {
throw new InvalidKVersionException("Invalid kernel version: ${version}")
}
- this.isLTS = match.group(1) != null
+ if (match.group(1) != null) {
+ this.isLTS = true
+ this.strLTS = match.group(1)
+ }
// Major
this.major = Integer.parseInt(match.group(2))
String vString = "Ubuntu-"
if (this.isLTS) {
- vString = vString.concat("lts-")
+ vString = vString.concat("${this.strLTS}")
}
- vString = vString.concat("${this.major}.${this.minor}.${this.patch}-${this.umajor}.${this.uminor}${this.suffix}")
+ // The tag pattern changed for HWE kernels >= 5.0
+ if (this.isLTS && this.major >= 5) {
+ vString = vString.concat("${this.major}.${this.minor}-${this.major}.${this.minor}.${this.patch}-${this.umajor}.${this.uminor}${this.suffix}")
+ } else {
+ vString = vString.concat("${this.major}.${this.minor}.${this.patch}-${this.umajor}.${this.uminor}${this.suffix}")
+ }
return vString
}
// Retrieve parameters of the current build
-def mversion = build.buildVariableResolver.resolve('mversion')
+def mbranch = build.getEnvironment(listener).get('GIT_BRANCH').minus('origin/')
def maxConcurrentBuild = build.buildVariableResolver.resolve('maxConcurrentBuild')
def kgitrepo = build.buildVariableResolver.resolve('kgitrepo')
def kverfloor_raw = build.buildVariableResolver.resolve('kverfloor')
def kverceil_raw = build.buildVariableResolver.resolve('kverceil')
def kverfilter = build.buildVariableResolver.resolve('kverfilter')
+def kverrc = build.buildVariableResolver.resolve('kverrc')
+def elversion = build.buildVariableResolver.resolve('elversion')
+def slesversion = build.buildVariableResolver.resolve('slesversion')
def uversion = build.buildVariableResolver.resolve('uversion')
def job = Hudson.instance.getJob(build.buildVariableResolver.resolve('kbuildjob'))
def currentJobName = build.project.getFullDisplayName()
-
+def gitmodpath = build.getEnvironment(listener).get('WORKSPACE') + "/src/lttng-modules"
// Get the out variable
def config = new HashMap()
def out = config['out']
+// Get the lttng-modules git url
+def gitmodrepo = Git.open(new File(gitmodpath))
+def mgitrepo = gitmodrepo.getRepository().getConfig().getString("remote", "origin", "url")
+
// Get tags from git repository
-def refs = Git.lsRemoteRepository().setTags(true).setRemote(kgitrepo).call();
+def refs = Git.lsRemoteRepository().setTags(true).setRemote(kgitrepo).call()
// Get kernel versions to build
def kversions = []
def matchStrs = []
def blacklist = []
def kversionFactory = ""
+def distroversion = ""
-if (uversion != null) {
- kversionFactory = new UbuntuKVersion()
- switch (uversion) {
- case 'bionic':
+if (elversion != null) {
+ distroversion = elversion
+ kversionFactory = new ElKVersion()
+ switch (elversion) {
+ case 'el8':
+ matchStrs = [
+ // EL 8 (all)
+ // ~/^refs\/tags\/(imports\/r8\/kernel-[\d\.-]+.el8.*)$/,
+ // EL 8.4
+ ~/^refs\/tags\/(imports\/r8\/kernel-4\.18\.0-305\.[\d\.-]+.el8.*)$/,
+ // EL 8.6
+ ~/^refs\/tags\/(imports\/r8\/kernel-4\.18\.0-372\.[\d\.-]+.el8.*)$/,
+ ]
+ blacklist = []
+ break
+ default:
+ println ("Unsupport EL version: ${elversion}")
+ throw new InterruptedException()
+ break
+ }
+} else if (slesversion != null) {
+ distroversion = slesversion
+ kversionFactory = new SlesKVersion()
+ switch (slesversion) {
+ case 'sles15sp4':
matchStrs = [
- ~/^refs\/tags\/(Ubuntu-4\.15\.0-\d{1,3}?\.[\d]+)$/,
+ ~/^refs\/tags\/(rpm-5.14.21-150400\.22(\.\d+)?(\.\d+)?)$/,
+ ~/^refs\/tags\/(rpm-5.14.21-150400\.24(\.\d+)?(\.\d+)?)$/,
+ ]
+ blacklist = [
+ // "Retracted", @see https://www.suse.com/support/kb/doc/?id=000019587#SLE15SP4
+ 'rpm-5.14.21-150400.24.49',
+ 'rpm-5.14.21-150400.24.84',
]
break
- case 'xenial':
+ default:
+ println "Unsupported SLES version: ${slesversion}"
+ throw new InterruptedException()
+ break
+ }
+} else if (uversion != null) {
+ distroversion = uversion
+ kversionFactory = new UbuntuKVersion()
+ switch (uversion) {
+ case 'jammy':
matchStrs = [
- ~/^refs\/tags\/(Ubuntu-4\.4\.0-\d{1,3}?\.[\d]+)$/,
- ~/^refs\/tags\/(Ubuntu-lts-4\.8\.0-.*_16\.04\.\d+)$/,
- ~/^refs\/tags\/(Ubuntu-lts-4\.10\.0-.*_16\.04\.\d+)$/,
- ~/^refs\/tags\/(Ubuntu-lts-4\.15\.0-.*_16\.04\.\d+)$/,
+ ~/^refs\/tags\/(Ubuntu-5\.15\.0-\d{1,3}?\.[\d]+)$/,
+ ~/^refs\/tags\/(Ubuntu-hwe-6\.2-6\.2\.0-.*_22\.04\.\d+)$/,
+ ~/^refs\/tags\/(Ubuntu-hwe-6\.5-6\.5\.0-.*_22\.04\.\d+)$/,
]
+ break
- blacklist = [
- 'Ubuntu-lts-4.10.0-7.9_16.04.1',
+ case 'focal':
+ matchStrs = [
+ ~/^refs\/tags\/(Ubuntu-5\.4\.0-\d{1,3}?\.[\d]+)$/,
+ ~/^refs\/tags\/(Ubuntu-hwe-5\.13-5\.13\.0-.*_20\.04\.\d+)$/,
+ ~/^refs\/tags\/(Ubuntu-hwe-5\.15-5\.15\.0-.*_20\.04\.\d+)$/,
]
break
- case 'trusty':
+ case 'noble':
matchStrs = [
- ~/^refs\/tags\/(Ubuntu-3\.13\.0-[\d\.]+)$/,
- ~/^refs\/tags\/(Ubuntu-lts-.*_14\.04\.\d+)$/,
+ ~/^refs\/tags\/(Ubuntu-6\.8\.0-\d{1,3}?\.[\d]+)$/,
]
break
matchStrs = [
~/^refs\/tags\/(v[\d\.]+(-rc(\d+))?)$/,
]
+ blacklist = [
+ 'v3.2.3',
+ ]
}
// Parse kernel versions
}
}
+// The filtering step assumes the version lists are sorted
kversions.sort()
kversionsRC.sort()
}
break
+ case 'lts-head':
+ // Keep only the head of each LTS branch and the latest non-RC tag
+ println('Filter kernel versions to keep only the latest point release of each lts branch and the current stable.')
+
+ def lts_kversions = []
+ // Old LTS entries are kept so that "lts-head" is still meaningful in kernel
+ // version ranges that are supported by lttng-modules but no longer supported
+ // upstream, eg. lttng-modules stable-2.13 supports >= 3.0
+ lts_kversions.add(kversionFactory.factory("v3.0")) // LTS until October 2013
+ lts_kversions.add(kversionFactory.factory("v3.2")) // LTS until May 2018
+ lts_kversions.add(kversionFactory.factory("v3.4")) // LTS until October 2016
+ lts_kversions.add(kversionFactory.factory("v3.10")) // LTS until November 2017
+ lts_kversions.add(kversionFactory.factory("v3.12")) // LTS until May 2017
+ lts_kversions.add(kversionFactory.factory("v3.14")) // LTS until August 2016
+ lts_kversions.add(kversionFactory.factory("v3.16")) // LTS until October 2014
+ lts_kversions.add(kversionFactory.factory("v3.18")) // LTS until January 2017
+ lts_kversions.add(kversionFactory.factory("v4.1")) // LTS until May 2018
+ lts_kversions.add(kversionFactory.factory("v4.4")) // SLTS until 2026
+ lts_kversions.add(kversionFactory.factory("v4.9")) // LTS until January 2023
+ lts_kversions.add(kversionFactory.factory("v4.14")) // LTS until January 2024
+ lts_kversions.add(kversionFactory.factory("v4.19")) // LTS until December 2024
+ lts_kversions.add(kversionFactory.factory("v5.4")) // LTS until December 2025
+ lts_kversions.add(kversionFactory.factory("v5.10")) // LTS until December 2026
+ lts_kversions.add(kversionFactory.factory("v5.15")) // LTS until December 2026
+ lts_kversions.add(kversionFactory.factory("v6.1")) // LTS until December 2026
+ lts_kversions.add(kversionFactory.factory("v6.6")) // LTS until December 2026
+
+ // First filter the head of each branch
+ for (i = 0; i < kversions.size(); i++) {
+ def curr = kversions[i]
+ def next = i < kversions.size() - 1 ? kversions[i + 1] : null
+
+ if (next != null) {
+ if (curr.isSameStable(next)) {
+ kversions.remove(i)
+ i--
+ }
+ }
+ }
+
+ for (i = 0; i < kversions.size(); i++) {
+ def curr = kversions[i]
+
+ // Keep the newest tag
+ if (i == kversions.size() - 1) {
+ break
+ }
+
+ // Prune non-LTS versions
+ def keep = false
+ for (j = 0; j < lts_kversions.size(); j++) {
+ if (curr.isSameStable(lts_kversions[j])) {
+ keep = true
+ break
+ }
+ }
+
+ if (!keep) {
+ kversions.remove(i)
+ i--
+ }
+ }
+ break
+
default:
// No filtering of kernel versions
println('No kernel versions filtering selected.')
break
}
-// If the last RC version is newer than the last stable, add it to the build list
-if (kversionsRC.size() > 0 && kversionsRC.last() > kversions.last()) {
- kversions.add(kversionsRC.last())
+if (kverrc == "true") {
+ // If the last RC version is newer than the last stable, add it to the build list
+ if (kversionsRC.size() > 0 && kversionsRC.last() > kversions.last()) {
+ kversions.add(kversionsRC.last())
+ }
}
println "Building the following kernel versions:"
if(ongoingBuild.size() < maxConcurrentBuild.toInteger() && kversions.size() != 0) {
def kversion = kversions.pop()
def job_params = [
- new StringParameterValue('mversion', mversion),
+ new StringParameterValue('mversion', mbranch),
+ new StringParameterValue('mgitrepo', mgitrepo),
new StringParameterValue('ktag', kversion.toString()),
new StringParameterValue('kgitrepo', kgitrepo),
+ new StringParameterValue('distroversion', distroversion),
+ new StringParameterValue('getsrc_repo', build.buildVariableResolver.resolve('getsrc_repo')),
+ new StringParameterValue('getsrc_version', build.buildVariableResolver.resolve('getsrc_version'))
]
// Launch the parametrized build
def param_build = job.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(job_params))
- println "triggering ${joburl} for the ${mversion} branch on kernel ${kversion}"
+ println "triggering ${joburl} for the ${mbranch} branch on kernel ${kversion}"
// Add it to the ongoing build queue
ongoingBuild.push(param_build)
}
// Abort job if a newer instance is queued
- similarJobQueued = Hudson.instance.queue.items.count{it.task.getFullDisplayName() == currentJobName}
- if ( similarJobQueued > 0 ) {
+ if (!currentJobName.contains("gerrit")) {
+ similarJobQueued = Hudson.instance.queue.items.count{it.task.getFullDisplayName() == currentJobName}
+ if (similarJobQueued > 0) {
+ println "Abort, a newer instance of the job was queued"
build.setResult(hudson.model.Result.ABORTED)
throw new InterruptedException()
+ }
}
def i = ongoingBuild.iterator()