Build RPMs with the CI; enable ccache on CI

This commit is contained in:
Ariel Abreu 2023-05-02 22:30:18 -04:00 committed by Thomas A
parent f1153d9b1a
commit be134fcbec
7 changed files with 121 additions and 33 deletions

View File

@ -1,5 +1,5 @@
# this Dockerfile must be built using the following command:
# docker build -f ../ci/Dockerfile .
# docker build -f ../ci/Debian.Dockerfile .
# this command must be run while in the `debian` directory in the root of the repo.
FROM ubuntu:jammy
LABEL name=darling-build-image version=0.1.0
@ -14,4 +14,8 @@ RUN apt-get -y install devscripts equivs debhelper && apt clean -y
COPY control /control
RUN mk-build-deps -i -r -t "apt-get --no-install-recommends -y" /control && apt clean -y
RUN rm /control
RUN apt-get -y install ccache && apt clean -y
RUN mkdir -p /ccache
RUN mkdir -p /src/mnt
RUN chown -R ci:ci /src
USER ci

82
ci/Jenkinsfile vendored
View File

@ -1,21 +1,26 @@
pipeline {
agent {
docker {
image 'registry.git.facekapow.dev/darling-build-image:latest'
image 'registry.git.facekapow.dev/darling-build-image-top:latest'
registryUrl 'https://registry.git.facekapow.dev'
alwaysPull true
args '-u ci:ci'
args '-u ci:ci -v /var/run/docker.sock:/var/run/docker.sock --group-add docker'
label 'darling'
}
}
parameters {
booleanParam(name: 'DEB', defaultValue: true, description: 'If true, build Debian packages.')
booleanParam(name: 'RPM', defaultValue: false, description: 'If true, build RPM packages.')
}
triggers {
githubPush()
}
environment {
DEB_DISTRO = sh(script: 'lsb_release -cs', returnStdout: true).trim()
ESCAPED_JOB_NAME = sh(script: 'echo "${JOB_NAME}" | sed \'s/\\//-/g\'', returnStdout: true).trim()
CCACHE_DIR = credentials('darling-ccache-dir')
}
options {
@ -34,26 +39,79 @@ pipeline {
}
}
stage('Build') {
stage('Prepare') {
steps {
dir('source') {
sh 'git submodule update --init --recursive'
sh 'cd src/external/swift && git lfs install && git lfs pull'
touch '../.submodules-cloned'
}
}
}
//sh 'tools/debian/make-deb --dsc'
sh 'tools/debian/make-deb'
stage('Build Debian') {
when { expression { params.DEB } }
agent {
docker {
image 'registry.git.facekapow.dev/darling-build-image:latest'
registryUrl 'https://registry.git.facekapow.dev'
alwaysPull true
args '-u ci:ci -v ${WORKSPACE}/source:/src/mnt:rw -v ${CCACHE_DIR}:/ccache:rw'
label 'darling'
reuseNode true
}
}
environment {
DEB_DISTRO = sh(script: 'lsb_release -cs', returnStdout: true).trim()
CCACHE_DIR = '/ccache'
CCACHE_BASEDIR = '/src/mnt'
}
steps {
//sh 'tools/debian/make-deb --dsc'
sh '''#!/bin/bash
pushd /src/mnt
tools/debian/make-deb
popd
'''
sh 'rm -rf out-deb'
sh 'mkdir out-deb'
dir('out-deb') {
sh 'mv /src/*.deb ./'
}
sh 'rm -rf out'
sh 'mkdir out'
archiveArtifacts artifacts: 'out-deb/**/*', fingerprint: true
}
}
dir('out') {
sh 'mv ../*.deb ./'
sh 'rm ../*.*'
stage('Build RPM') {
when { expression { params.RPM } }
agent {
docker {
image 'registry.git.facekapow.dev/darling-build-image-fedora:latest'
registryUrl 'https://registry.git.facekapow.dev'
alwaysPull true
args '-v ${WORKSPACE}/source:/src:ro -v ${CCACHE_DIR}:/ccache:rw'
label 'darling'
reuseNode true
}
}
environment {
CCACHE_DIR = '/ccache'
CCACHE_BASEDIR = '/home/ci/rpmbuild/BUILD/darling'
}
steps {
sh 'bash -xv /src/rpm/build.bsh'
sh 'rm -rf out-rpm'
sh 'mkdir out-rpm'
dir('out-rpm') {
sh 'mv ${HOME}/rpmbuild/RPMS/x86_64/*.rpm ./'
}
archiveArtifacts artifacts: 'out/**/*', fingerprint: true
archiveArtifacts artifacts: 'out-rpm/**/*', fingerprint: true
}
}
}

23
ci/RPM.Dockerfile Normal file
View File

@ -0,0 +1,23 @@
# this Dockerfile must be built using the following command:
# docker build -f ../ci/RPM.Dockerfile .
# this command must be run while in the `rpm` directory in the root of the repo.
FROM fedora:37
LABEL name=darling-build-image-fedora version=0.1.0
RUN dnf install -y rpm-build dnf-utils rpmdevtools git; \
source /etc/os-release; \
dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-${VERSION_ID}.noarch.rpm; \
dnf clean all
RUN groupadd -g 1001 ci
RUN useradd -u 1001 -g 1001 -m ci
COPY SPECS/darling.spec /darling.spec
RUN yum-builddep -y /darling.spec; \
dnf clean all
RUN rm /darling.spec
RUN dnf install -y sudo; \
dnf clean all
RUN echo 'ci ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN mkdir -p /src
RUN dnf install -y ccache; \
dnf clean all
RUN mkdir -p /ccache
USER ci

9
ci/top.Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM alpine:latest
LABEL name=darling-build-image-top version=0.1.0
ARG DOCKER_GID=975
RUN addgroup -g ${DOCKER_GID} -S docker
RUN apk add docker git git-lfs sed
RUN addgroup -g 1001 ci
RUN adduser -u 1001 -G ci --disabled-password ci
RUN addgroup ci docker
USER ci

View File

@ -3,26 +3,19 @@ FROM ${OS}
SHELL ["bash", "-euxvc"]
RUN dnf install -y rpm-build dnf-utils rpmdevtools; \
RUN dnf install -y rpm-build dnf-utils rpmdevtools git; \
source /etc/os-release; \
dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-${VERSION_ID}.noarch.rpm; \
dnf clean all
COPY SPECS/darling.spec /darling.spec
# Bootstrap
RUN dnf install -y bison cairo-devel clang cmake flex fontconfig-devel.x86_64 \
fontconfig-devel.i686 freetype-devel.x86_64 freetype-devel.i686 \
fuse-devel glibc-devel glibc-devel.i686 \
libglvnd-devel libjpeg-turbo-devel libjpeg-turbo-devel.i686 \
libtiff-devel libtiff-devel.i686 mesa-libGL-devel mesa-libEGL-devel \
python2 systemd-devel make libxml2-devel elfutils-libelf-devel \
libbsd-devel ffmpeg-devel pulseaudio-libs-devel openssl-devel \
giflib-devel libXrandr-devel libXcursor-devel libxkbfile-devel \
dbus-devel mesa-libGLU-devel vulkan-headers llvm-devel libcap-devel \
vulkan-loader-devel \
# git - so I can determine the describe of the last commit, not an rpm dependency
git; \
RUN yum-builddep -y /darling.spec; \
dnf clean all
RUN rm /darling.spec
RUN mkdir -p /root/rpmbuild/SOURCES
CMD bash -xv /src/rpm/build.bsh

View File

@ -2,18 +2,19 @@
set -eu
yum-builddep -y /src/rpm/SPECS/darling.spec
mkdir -p $HOME/rpmbuild/SOURCES
if [ -e "/src/rpm/SOURCES/darling.tar.gz" ]; then
ln -sf /src/rpm/SOURCES/darling.tar.gz /root/rpmbuild/SOURCES/
ln -sf /src/rpm/SOURCES/darling.tar.gz $HOME/rpmbuild/SOURCES/
else
# Preparing tarball
tar --transform "s|^\./|./darling/|" -cf /root/rpmbuild/SOURCES/darling.tar.gz -C /src --exclude=.git --exclude SOURCES --exclude SRPMS --exclude RPMS --exclude BUILD .
tar --transform "s|^\./|./darling/|" -cf $HOME/rpmbuild/SOURCES/darling.tar.gz -C /src --exclude=.git --exclude SOURCES --exclude SRPMS --exclude RPMS --exclude BUILD .
fi
if [ -e "/src/rpm/SOURCES/darling-macho-deps.tar.gz" ]; then
ln -sf /src/rpm/SOURCES/darling-macho-deps.tar.gz /root/rpmbuild/SOURCES/
ln -sf /src/rpm/SOURCES/darling-macho-deps.tar.gz $HOME/rpmbuild/SOURCES/
else
tar --transform "s|^\./|darling-macho-deps/|" -cf /root/rpmbuild/SOURCES/darling-macho-deps.tar.gz -C /src/tools/rpm .
tar --transform "s|^\./|darling-macho-deps/|" -cf $HOME/rpmbuild/SOURCES/darling-macho-deps.tar.gz -C /src/tools/rpm .
fi
if (cd /src && git describe --tags HEAD); then
@ -25,7 +26,7 @@ else
fi
rpmbuild -ba /src/rpm/SPECS/darling-macho-deps.spec
rpm -U --force /root/rpmbuild/RPMS/x86_64/darling-macho-deps*.rpm
sudo rpm -U --force $HOME/rpmbuild/RPMS/x86_64/darling-macho-deps*.rpm
#spectool -g -R /src/rpm/SPECS/darling.spec
rpmbuild -ba /src/rpm/SPECS/darling.spec

View File

@ -17,4 +17,4 @@ else
ARG='-b'
fi
debuild --no-lintian -us -uc ${ARG}
debuild --preserve-envvar 'CCACHE_*' --no-lintian -us -uc ${ARG}