tools: jenkins: Add a Jenkinsfile to build kernels

Add a Jenkinsfile to build X86_64, ARM and ARM64 kernels.
Signed-off-by: 's avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
parent 38f4ae8d
#!/usr/bin/env groovy
/*
Copyright (C) 2017, 2018 Collabora Limited
Author: Guillaume Tucker <guillaume.tucker@collabora.com>
This module is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Note: docker_image.inside() needs to be called after dir(some_directory)
* otherwise it fails and stays at the root of the workspace. */
def KERNEL_URL = "git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git"
def KERNEL_BRANCH = "for-next"
def REGISTRY = "docker-registry.collabora.com"
def REGISTRY_CREDENTIALS = "ccu-docker-collabora-com"
def DOCKER_IMAGE = "linux-kernel"
def buildKernel(docker_image, kdir, out_dir, arch, xcompile, defconfig, image) {
echo "buildKernel ${kdir} ${out_dir} ${arch} ${xcompile} ${defconfig}"
def arch_dir = "${out_dir}/${arch}"
def build_dir = env.WORKSPACE + "/build-${arch}"
sh(script: "mkdir -p ${arch_dir}")
sh(script: "mkdir -p ${build_dir}")
docker_image.inside() {
if (xcompile != "") {
env.ARCH = arch
env.CROSS_COMPILE = xcompile
}
sh(script: """
cd ${kdir}
make O=${build_dir} ${defconfig}
make O=${build_dir} -j8
rm -rf ${arch_dir}/modules
mkdir -p ${arch_dir}/modules
INSTALL_MOD_PATH=${arch_dir}/modules INSTALL_MOD_STRIP=1 make O=${build_dir} modules_install
""")
}
dir(arch_dir) {
sh(script: """
cp ${build_dir}/arch/${arch}/boot/${image} .
tar -C modules -cJf modules.tar.xz .
rm -rf modules
""")
sh(script: """
mkdir dtbs
for f in \$(find ${build_dir} -name *.dtb); do cp \$f dtbs; done
ls dtbs/* && tar -C dtbs -czf dtbs.tar.gz . || rm -rf dtbs
""")
}
}
node("docker-slave") {
docker.withRegistry("https://${REGISTRY}", REGISTRY_CREDENTIALS) {
def docker_image = null
def checkout = env.WORKSPACE + "/checkout"
def kdir = env.WORKSPACE + '/linux'
def out_dir_top = env.WORKSPACE + '/output/kernel'
def out_dir = out_dir_top + "/${currentBuild.number}"
def git_describe = null
stage("job init") {
dir(checkout) {
git(url: env.gitlabSourceRepoHttpUrl,
branch: env.gitlabBranch,
poll: false)
}
docker_image = docker.image(DOCKER_IMAGE)
sh(script: "rm -rf ${out_dir_top}")
dir(out_dir) {
def params = """\
url: ${KERNEL_URL}
branch: ${KERNEL_BRANCH}
docker: ${DOCKER_IMAGE}
"""
sh(script: 'echo "' + "${params}" + '" > manifest.txt')
}
}
stage("check out") {
dir(kdir) {
docker_image.inside() {
git(url: KERNEL_URL,
branch: KERNEL_BRANCH,
poll: false)
sh(script: "make mrproper")
git_describe = sh(returnStdout: true,
script: "git describe").trim()
}
}
}
stage("build (native)") {
def arch = sh(returnStdout: true, script: "uname -m").trim()
buildKernel(docker_image,
kdir,
out_dir,
arch,
"",
"defconfig",
"bzImage")
}
stage("build (arm64)") {
buildKernel(docker_image,
kdir,
out_dir,
"arm64",
"aarch64-linux-gnu-",
"defconfig",
"Image")
}
stage("build (arm)") {
buildKernel(docker_image,
kdir,
out_dir,
"arm",
"arm-linux-gnueabihf-",
"defconfig",
"zImage")
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment