Files
rme-jenkins/jenkins_builder.sh
T
2026-08-18 21:17:51 +02:00

55 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Build an LTS RPM for one project flavor (ahtc / guez).
# Driven by rpmbuild/make_rpm.py — see also jenkins/Jenkinsfile.
#
# Required environment (set by the Jenkinsfile or `docker run -e ...`):
# PROJECT LTS flavor: qatar | ahtc | guez (cmake -D_pname)
# OS_VERSION Ubuntu base version, e.g. 26.04
# LTS_VERSION Major.minor LTS version, e.g. 1.0
# GUEZ_MODE ON | OFF — cmake -DGUEZ_MODE
# WORKSPACE Jenkins workspace path (set automatically by Jenkins)
# PROJECT_BASE_DIR Path used by make_rpm.py as the source tree (basename must be 'legatus')
# BUILD_VERSION Spec suffix selector for make_rpm.py (lts${BUILD_VERSION}.spec)
# BUILD_NUMBER Jenkins build number (used as @RELEASE@ in the spec)
# BUILD_TAG Jenkins build tag (used as @JENKINS_BUILD_TAG@ in the spec)
#
set -eo pipefail
: "${PROJECT:?PROJECT must be set}"
: "${OS_VERSION:?OS_VERSION must be set}"
: "${LTS_VERSION:?LTS_VERSION must be set}"
: "${GUEZ_MODE:?GUEZ_MODE must be set}"
: "${WORKSPACE:?WORKSPACE must be set}"
: "${PROJECT_BASE_DIR:?PROJECT_BASE_DIR must be set}"
echo "Building LTS ${LTS_VERSION}-${BUILD_NUMBER:-?} RPM for project '${PROJECT}' (OS ${OS_VERSION})."
echo "Spec selector : lts${BUILD_VERSION:-}.spec"
echo "PROJECT_BASE_DIR=${PROJECT_BASE_DIR}"
mkdir -p /shd/CTC/TOOLS/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
# openSUSE's rpmbuild defaults %_topdir to /usr/src/packages and ignores HOME
echo "%_topdir /shd/CTC/TOOLS/rpmbuild" > "${HOME}/.rpmmacros"
# Stage workspace as a clean copy under PROJECT_BASE_DIR
rm -rf "${PROJECT_BASE_DIR}"
mkdir -p "${PROJECT_BASE_DIR}"
tar --exclude='./rpms' --exclude='./.git' --exclude='./build' \
-cf - -C "${WORKSPACE}" . | tar -xf - -C "${PROJECT_BASE_DIR}"
export VERSION_DATE
VERSION_DATE=$(date +%Y-%m-%d)
# Output is isolated per OS version so parallel OS builds of the same project
cd "${WORKSPACE}/rpmbuild"
python make_rpm.py -c LTS \
--project_name "${PROJECT}" \
--version "${LTS_VERSION}" \
--output_dir "${WORKSPACE}/rpms/${PROJECT}/${OS_VERSION}/" \
--cmake_build_flags "-DUSE_IPO=ON -DUSE_UNITY_BUILD=ON -DGUEZ_MODE=${GUEZ_MODE} -DBUILD_WLS=ON -DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/pgsql/"
echo "RPMs produced for '${PROJECT}' (OS ${OS_VERSION}):"
ls -lhR "${WORKSPACE}/rpms/${PROJECT}/${OS_VERSION}/"