Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/new_docker_build.sh
T
berrux-dev 65ca0d8b5e Split the prebuilt-image recipe out of new_docker_build.sh into a Dockerfile
- Dockerfile: the prebuilt build image recipe (Ubuntu 26.04 + apt deps +
  aqtinstall Qt6 + KDReports), parameterized via ARG APT_PACKAGES /
  QT_VERSION / QT_ARCH / QT_BASE_DIR.
- new_docker_build.sh: build_prebuilt_image() now runs
  docker build -f Dockerfile with the package list and Qt settings passed
  as build args, using an empty build context (the Dockerfile has no
  COPY/ADD).
2026-10-13 21:47:38 +02:00

666 lines
21 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# -----------------------------------------------------------------------------
# Build helper for the release validation-scope branch of qt-migrated-legatus
#
# Builds only the release scope (TetraIF, Z/src, Lts/Common +
# Lts/Proxies/TrainingAreaBase) inside Docker and optionally runs the Jenkins
# builder to produce the release DEB packages.
#
# - Loads environment from .envrc
# - Validates MIGRATE_PIPELINE_ROOT and rti_license.dat
# - Optional usage of a prebuilt Docker image with installed dependencies
# - Optional creation of that prebuilt Docker image via --build-prebuilt-image
# (Dockerfile lives next to this script; the package list and Qt settings
# are passed as build args)
# - Optional deletion of that prebuilt Docker image via --delete-prebuilt-image
# - Optional Jenkins builder run for RPM/DEB package production
# - Uses a temporary container-side script for robust execution
# -----------------------------------------------------------------------------
usage() {
cat <<'EOF'
Usage: ./new_docker_build.sh [options]
Builds the release validation scope inside Docker:
RELEASE_BUILD=ON (fixed) - TetraIF, Z, Lts/Common (+ TrainingAreaBase)
BUILD_RTI=OFF (fixed) - uses the ProjectDataManagement stubs
Options:
--use-prebuilt-image Use a Docker image with dependencies already installed
--no-prebuilt-image Use base image and run apt-get install inside the container
--docker-image IMAGE Docker image name to use/build/delete
(default: legatus-qt6-prebuilt:latest)
--build-prebuilt-image Build the prebuilt Docker image (from ./Dockerfile)
before running the build. If used alone, the script
builds the image and exits
If combined with --use-prebuilt-image, the built image is used immediately
--delete-prebuilt-image Delete the configured Docker image and exit
--cmake_build_flags FLAGS Extra CMake flags passed to the in-container configure
(space-separated -D flags, e.g. "-DBUILD_WLS=ON")
Jenkins builder options (for RPM/DEB package production):
--run-jenkins-builder Run jenkins_builder_ubuntu26.sh inside container to produce packages
--package-output-dir DIR Directory to mount for package output (default: ./packages-out)
--lts-version VERSION LTS version for package (default: 1.0)
--project NAME Project name for package (default: guez)
--build-number NUM Build number for package (default: 1)
--build-tag TAG Build tag for package (default: manual-build)
Environment variable overrides:
USE_PREBUILT_IMAGE=ON|OFF
BUILD_PREBUILT_IMAGE=ON|OFF
DELETE_PREBUILT_IMAGE=ON|OFF
DOCKER_IMAGE=<image-name>
CMAKE_BUILD_FLAGS=<flags>
RUN_JENKINS_BUILDER=ON|OFF
PACKAGE_OUTPUT_DIR=<dir>
LTS_VERSION=<version>
PROJECT=<name>
GUEZ_MODE=ON|OFF
BUILD_NUMBER=<num>
BUILD_TAG=<tag>
Required .envrc variable:
MIGRATE_PIPELINE_ROOT=<absolute-path>
Expected file:
${MIGRATE_PIPELINE_ROOT}/rti_license.dat
Examples:
./new_docker_build.sh --build-prebuilt-image --docker-image legatus-qt6:1.0
./new_docker_build.sh --use-prebuilt-image --docker-image legatus-qt6:1.0
./new_docker_build.sh --build-prebuilt-image --use-prebuilt-image --docker-image legatus-qt6:1.0
./new_docker_build.sh --delete-prebuilt-image --docker-image legatus-qt6:1.0
./new_docker_build.sh --use-prebuilt-image --docker-image legatus-qt6:1.0 \
--run-jenkins-builder --package-output-dir /path/to/rpms/guez/26.04
EOF
}
log_info() {
printf 'INFO: %s\n' "$*"
}
log_error() {
printf 'ERROR: %s\n' "$*" >&2
}
die() {
log_error "$*"
exit 1
}
require_command() {
local cmd="$1"
command -v "$cmd" >/dev/null 2>&1 || die "Required command not found: ${cmd}"
}
require_file() {
local path="$1"
local label="$2"
[[ -f "$path" ]] || die "${label} not found: ${path}"
}
require_directory() {
local path="$1"
local label="$2"
[[ -d "$path" ]] || die "${label} directory not found: ${path}"
}
require_non_empty() {
local value="$1"
local name="$2"
[[ -n "$value" ]] || die "Required variable ${name} is not set or empty"
}
normalize_on_off() {
local value="$1"
local name="$2"
case "${value^^}" in
ON|OFF)
printf '%s\n' "${value^^}"
;;
*)
die "Invalid value for ${name}: ${value}. Expected ON or OFF"
;;
esac
}
join_by() {
local delimiter="$1"
shift || true
local first=1
local arg
for arg in "$@"; do
if [[ $first -eq 1 ]]; then
printf '%s' "$arg"
first=0
else
printf '%s%s' "$delimiter" "$arg"
fi
done
}
cleanup_temp_dir() {
local dir="${1:-}"
if [[ -n "$dir" && -d "$dir" ]]; then
rm -rf "$dir"
fi
}
delete_prebuilt_image() {
local image_name="$1"
if docker image inspect "$image_name" >/dev/null 2>&1; then
log_info "Deleting Docker image: ${image_name}"
docker rmi "$image_name"
log_info "Docker image deleted successfully: ${image_name}"
else
log_info "Docker image does not exist, nothing to delete: ${image_name}"
fi
}
APT_PACKAGES=(
build-essential
cmake
libboost-dev
libboost-all-dev
libjson-glib-dev
libgeographiclib-dev
ninja-build
libkf6texttemplate-dev
libpoppler-dev
libpoppler-qt6-dev
libqt6core6
libqt6gui6
libqt6widgets6
libqt6sql6
libqt6sql6-psql
libqt6test6
qt6-base-dev
qt6-l10n-tools
qt6-serialport-dev
qt6-svg-dev
qt6-tools-dev-tools
qt6-tools-dev
qt6-websockets-dev
libgtest-dev
libpq-dev
postgresql-server-dev-all
libvlc-dev
vlc-plugin-base
git
python3-pip
# Packaging tools for RPM/DEB build
rpm
debhelper
dpkg-dev
fakeroot
devscripts
)
# Release scope targets: Z components + Lts/Common libraries and the
# release-scope test executables (Lts/Common + Z)
RELEASE_BUILD_TARGETS=(
# Z module targets
NGLLogger
nglapplication
nglcompression
nglcoreapplication
ngldb
nglguiapplication
nglsettings
nglsingleapplication
nglsinglecoreapplication
ngltools
ngltranslator
nglwidgets
qtsingleapplication
qtsinglecoreapplication
wms_json_ds
tcpserver
# Lts/Common library targets (for tests)
LtsCoordTrans
LtsLicence
MockCoordTrans
# Test executables for release scope modules
# Note: nglcomp_test excluded - compression "Unknown error" in Qt6 (requires investigation)
# Note: grantlee_parser_smoke excluded - requires ktexttemplate_defaulttags plugin (not in release scope)
aes_crypt_test
ngltools_qt_smoke
lts_coord_trans_unit_test
test_nglpdfwidget
)
APT_PACKAGES_STRING="$(join_by ' ' "${APT_PACKAGES[@]}")"
build_prebuilt_image() {
local image_name="$1"
local dockerfile="Dockerfile"
require_file "${dockerfile}" "Prebuilt-image Dockerfile"
# The Dockerfile has no COPY/ADD, so an empty build context is fine -
# this avoids tarring the source tree into the build context.
local tmp_dir
tmp_dir="$(mktemp -d)"
trap 'cleanup_temp_dir "$tmp_dir"' RETURN
log_info "Building prebuilt Docker image: ${image_name} (Dockerfile: ${dockerfile})"
docker build -t "${image_name}" \
-f "${dockerfile}" \
--build-arg APT_PACKAGES="${APT_PACKAGES_STRING}" \
--build-arg QT_VERSION="${QT_VERSION}" \
--build-arg QT_ARCH="${QT_ARCH}" \
--build-arg QT_BASE_DIR="${QT_BASE_DIR}" \
"${tmp_dir}"
log_info "Prebuilt Docker image created successfully: ${image_name}"
}
require_command docker
if [[ ! -f ".envrc" ]]; then
die ".envrc not found in current directory. Please create .envrc with required environment variables (e.g., MIGRATE_PIPELINE_ROOT)"
fi
set -a
# shellcheck disable=SC1091
source ".envrc"
set +a
# Fixed configuration for the release validation-scope branch
RELEASE_BUILD=ON
BUILD_RTI=OFF
BUILD_GRANTLEE=ON
BUILD_ARCGIS=OFF
BUILD_VIEWER_ONLY=OFF
BUILD_CODIFICATION=OFF
BUILD_ALL=ON
BUILD_SV=ON
BUILD_WS=ON
BUILD_AAR=ON
RUN_CTEST=ON
USE_PREBUILT_IMAGE="${USE_PREBUILT_IMAGE:-OFF}"
BUILD_PREBUILT_IMAGE="${BUILD_PREBUILT_IMAGE:-OFF}"
DELETE_PREBUILT_IMAGE="${DELETE_PREBUILT_IMAGE:-OFF}"
# Jenkins builder options for RPM/DEB package production
RUN_JENKINS_BUILDER="${RUN_JENKINS_BUILDER:-OFF}"
PACKAGE_OUTPUT_DIR="${PACKAGE_OUTPUT_DIR:-./packages-out}"
LTS_VERSION="${LTS_VERSION:-1.0}"
PROJECT="${PROJECT:-guez}"
GUEZ_MODE="${GUEZ_MODE:-ON}"
BUILD_NUMBER="${BUILD_NUMBER:-1}"
BUILD_TAG="${BUILD_TAG:-manual-build}"
export QT_VERSION="${QT_VERSION:-6.10.2}"
export QT_ARCH="${QT_ARCH:-linux_gcc_64}"
# aqtinstall uses 'linux_gcc_64' but creates directory 'gcc_64'
export QT_ARCH_DIR="${QT_ARCH_DIR:-gcc_64}"
export QT_BASE_DIR="${QT_BASE_DIR:-/opt/Qt}"
while [[ $# -gt 0 ]]; do
case "$1" in
--use-prebuilt-image)
USE_PREBUILT_IMAGE=ON
;;
--no-prebuilt-image)
USE_PREBUILT_IMAGE=OFF
;;
--build-prebuilt-image)
BUILD_PREBUILT_IMAGE=ON
;;
--delete-prebuilt-image)
DELETE_PREBUILT_IMAGE=ON
;;
--docker-image)
shift
[[ $# -gt 0 ]] || die "--docker-image requires an image name"
DOCKER_IMAGE="$1"
;;
--cmake_build_flags)
shift
[[ $# -gt 0 ]] || die "--cmake_build_flags requires a flag string"
CMAKE_BUILD_FLAGS="$1"
;;
--run-jenkins-builder)
RUN_JENKINS_BUILDER=ON
;;
--package-output-dir)
shift
[[ $# -gt 0 ]] || die "--package-output-dir requires a directory path"
PACKAGE_OUTPUT_DIR="$1"
;;
--lts-version)
shift
[[ $# -gt 0 ]] || die "--lts-version requires a version string"
LTS_VERSION="$1"
;;
--project)
shift
[[ $# -gt 0 ]] || die "--project requires a project name"
PROJECT="$1"
;;
--build-number)
shift
[[ $# -gt 0 ]] || die "--build-number requires a build number"
BUILD_NUMBER="$1"
;;
--build-tag)
shift
[[ $# -gt 0 ]] || die "--build-tag requires a build tag"
BUILD_TAG="$1"
;;
-h|--help)
usage
exit 0
;;
*)
usage
die "Unknown option: $1"
;;
esac
shift
done
USE_PREBUILT_IMAGE="$(normalize_on_off "$USE_PREBUILT_IMAGE" "USE_PREBUILT_IMAGE")"
BUILD_PREBUILT_IMAGE="$(normalize_on_off "$BUILD_PREBUILT_IMAGE" "BUILD_PREBUILT_IMAGE")"
DELETE_PREBUILT_IMAGE="$(normalize_on_off "$DELETE_PREBUILT_IMAGE" "DELETE_PREBUILT_IMAGE")"
RUN_JENKINS_BUILDER="$(normalize_on_off "$RUN_JENKINS_BUILDER" "RUN_JENKINS_BUILDER")"
# Default for the Docker image name
DOCKER_IMAGE="${DOCKER_IMAGE:-legatus-qt6-prebuilt:latest}"
# Default for extra CMake flags (set via --cmake_build_flags or environment)
CMAKE_BUILD_FLAGS="${CMAKE_BUILD_FLAGS:-}"
# Export variables for Docker container
export RELEASE_BUILD BUILD_RTI BUILD_GRANTLEE BUILD_CODIFICATION BUILD_ALL BUILD_SV BUILD_WS BUILD_AAR RUN_CTEST USE_PREBUILT_IMAGE BUILD_PREBUILT_IMAGE DELETE_PREBUILT_IMAGE DOCKER_IMAGE CMAKE_BUILD_FLAGS RUN_JENKINS_BUILDER PACKAGE_OUTPUT_DIR LTS_VERSION PROJECT GUEZ_MODE BUILD_NUMBER BUILD_TAG
require_non_empty "${DOCKER_IMAGE}" "DOCKER_IMAGE"
if [[ "${DELETE_PREBUILT_IMAGE}" == "ON" ]]; then
delete_prebuilt_image "${DOCKER_IMAGE}"
exit 0
fi
require_non_empty "${MIGRATE_PIPELINE_ROOT:-}" "MIGRATE_PIPELINE_ROOT"
require_directory "${MIGRATE_PIPELINE_ROOT}" "MIGRATE_PIPELINE_ROOT"
RTI_LICENSE_FILE_HOST="${MIGRATE_PIPELINE_ROOT}/rti_license.dat"
WORKSPACE_ROOT_HOST="${MIGRATE_PIPELINE_ROOT}"
PROJECT_DIR_HOST="${WORKSPACE_ROOT_HOST}/qt-migration-legatus/qt6-after/qt6-migrated-legatus"
require_file "${RTI_LICENSE_FILE_HOST}" "RTI license file"
require_directory "${PROJECT_DIR_HOST}" "Project directory"
log_info "RELEASE_BUILD=${RELEASE_BUILD}"
log_info "BUILD_RTI=${BUILD_RTI}"
log_info "RUN_CTEST=${RUN_CTEST}"
log_info "USE_PREBUILT_IMAGE=${USE_PREBUILT_IMAGE}"
log_info "BUILD_PREBUILT_IMAGE=${BUILD_PREBUILT_IMAGE}"
log_info "DELETE_PREBUILT_IMAGE=${DELETE_PREBUILT_IMAGE}"
log_info "DOCKER_IMAGE=${DOCKER_IMAGE}"
log_info "RUN_JENKINS_BUILDER=${RUN_JENKINS_BUILDER}"
log_info "PACKAGE_OUTPUT_DIR=${PACKAGE_OUTPUT_DIR}"
log_info "LTS_VERSION=${LTS_VERSION}"
log_info "PROJECT=${PROJECT}"
log_info "GUEZ_MODE=${GUEZ_MODE}"
log_info "BUILD_NUMBER=${BUILD_NUMBER}"
log_info "BUILD_TAG=${BUILD_TAG}"
log_info "MIGRATE_PIPELINE_ROOT=${MIGRATE_PIPELINE_ROOT}"
log_info "RTI_LICENSE_FILE_HOST=${RTI_LICENSE_FILE_HOST}"
log_info "PROJECT_DIR_HOST=${PROJECT_DIR_HOST}"
if [[ "${BUILD_PREBUILT_IMAGE}" == "ON" ]]; then
build_prebuilt_image "${DOCKER_IMAGE}"
if [[ "${USE_PREBUILT_IMAGE}" != "ON" ]]; then
log_info "Prebuilt image was built successfully."
log_info "Exiting because --use-prebuilt-image was not requested."
log_info "To use it, run:"
printf ' ./new_docker_build.sh --use-prebuilt-image --docker-image %q\n' "${DOCKER_IMAGE}"
exit 0
fi
log_info "Continuing with freshly built prebuilt image: ${DOCKER_IMAGE}"
fi
RELEASE_BUILD_TARGETS_STRING="$(join_by ' ' "${RELEASE_BUILD_TARGETS[@]}")"
HOST_TEMP_DIR="$(mktemp -d)"
CONTAINER_SCRIPT_HOST="${HOST_TEMP_DIR}/run-build-inside-container.sh"
cleanup_all() {
cleanup_temp_dir "${HOST_TEMP_DIR}"
}
trap cleanup_all EXIT
cat > "${CONTAINER_SCRIPT_HOST}" <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
# Fixed configuration for the release validation-scope branch
RELEASE_BUILD="${RELEASE_BUILD:-ON}"
BUILD_RTI="${BUILD_RTI:-OFF}"
BUILD_GRANTLEE="${BUILD_GRANTLEE:-ON}"
BUILD_ARCGIS="${BUILD_ARCGIS:-OFF}"
BUILD_VIEWER_ONLY="${BUILD_VIEWER_ONLY:-OFF}"
BUILD_CODIFICATION="${BUILD_CODIFICATION:-OFF}"
BUILD_ALL="${BUILD_ALL:-ON}"
BUILD_SV="${BUILD_SV:-ON}"
BUILD_WS="${BUILD_WS:-ON}"
BUILD_AAR="${BUILD_AAR:-ON}"
RUN_CTEST="${RUN_CTEST:-ON}"
USE_PREBUILT_IMAGE="${USE_PREBUILT_IMAGE:-OFF}"
APT_PACKAGES_STRING="${APT_PACKAGES_STRING:-}"
# Jenkins builder and packaging variables
RUN_JENKINS_BUILDER="${RUN_JENKINS_BUILDER:-OFF}"
MIGRATE_PIPELINE_ROOT="/workspace"
PACKAGE_OUTPUT_DIR="${PACKAGE_OUTPUT_DIR:-/workspace/packages-out}"
LTS_VERSION="${LTS_VERSION:-1.0}"
PROJECT="${PROJECT:-guez}"
GUEZ_MODE="${GUEZ_MODE:-ON}"
BUILD_NUMBER="${BUILD_NUMBER:-1}"
BUILD_TAG="${BUILD_TAG:-manual-build}"
CMAKE_BUILD_FLAGS="${CMAKE_BUILD_FLAGS:-}"
RELEASE_BUILD_TARGETS="${RELEASE_BUILD_TARGETS:-}"
QT_VERSION="${QT_VERSION:-6.10.2}"
QT_ARCH="${QT_ARCH:-linux_gcc_64}"
QT_ARCH_DIR="${QT_ARCH_DIR:-gcc_64}"
QT_BASE_DIR="${QT_BASE_DIR:-/opt/Qt}"
log_info() {
printf 'INFO: %s\n' "$*"
}
log_error() {
printf 'ERROR: %s\n' "$*" >&2
}
install_qt6_packages() {
log_info "Installing Qt6 packages via aqtinstall"
# Install aqtinstall if not available
if ! command -v aqt &> /dev/null; then
log_info "Installing aqtinstall via pip3"
pip3 install --break-system-packages --quiet aqtinstall
fi
# Install Qt6 modules (same as the prebuilt-image Dockerfile)
# Note: qtsvg is NOT available via aqtinstall - it's provided by libqt6svg6-dev apt package
aqt install-qt linux desktop "${QT_VERSION}" "${QT_ARCH}" \
-m qtmultimedia qtserialport qtimageformats qtwebsockets qtwebengine \
qtpdf qtwebview qt5compat qtwebchannel qtpositioning qtlocation qtsensors \
--outputdir "${QT_BASE_DIR}"
log_info "Qt6 packages installed successfully"
}
# Ensure a local PostgreSQL DB is available.
# Entirely non-fatal: a DB problem must never abort the build.
ensure_database() {
log_info "Checking for a pre-installed PostgreSQL server..."
if ls /usr/lib/postgresql/*/bin/postgres >/dev/null 2>&1; then
log_info "PostgreSQL server already installed - skipping apt install"
else
log_info "PostgreSQL server not found - installing postgresql-18"
apt-get update -qq || true
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq postgresql-18 >/dev/null 2>&1 || true
fi
# Map the app's DB hostnames to the local server + start the cluster (idempotent).
grep -qE 'EXCDBS01' /etc/hosts || echo '127.0.0.1 EXCDBS01 EXCADB01' >> /etc/hosts
pg_ctlcluster 18 main start >/dev/null 2>&1 || true
sleep 1
# Ensure the roles + databases the DB tools use (idempotent; login password is 'postgres').
su postgres -c "psql -c \"ALTER USER postgres PASSWORD 'postgres'\"" >/dev/null 2>&1 || true
if ! su postgres -c "psql -tAc \"SELECT 1 FROM pg_roles WHERE rolname='ctc_sv'\"" 2>/dev/null | grep -q 1; then
su postgres -c "psql -c \"CREATE ROLE ctc_sv LOGIN PASSWORD 'postgres' CREATEDB\"" >/dev/null 2>&1 || true
fi
if ! su postgres -c "psql -tAc \"SELECT 1 FROM pg_database WHERE datname='lts_ets_pro'\"" 2>/dev/null | grep -q 1; then
su postgres -c "createdb -O postgres lts_ets_pro" >/dev/null 2>&1 || true
fi
if ! su postgres -c "psql -tAc \"SELECT 1 FROM pg_database WHERE datname='dbAdmin'\"" 2>/dev/null | grep -q 1; then
su postgres -c "createdb -O postgres dbAdmin" >/dev/null 2>&1 || true
fi
if pg_isready -h 127.0.0.1 -p 5432 >/dev/null 2>&1; then
log_info "PostgreSQL ready on 127.0.0.1:5432 (roles postgres/ctc_sv, dbs lts_ets_pro/dbAdmin)"
else
log_info "PostgreSQL not ready on 127.0.0.1:5432 (install may have failed)"
fi
}
if [[ "${USE_PREBUILT_IMAGE}" == "ON" ]]; then
log_info "Using prebuilt Docker image - skipping apt-get install and Qt6 package installation"
else
log_info "Using base image - installing apt packages"
apt-get update -qq
# shellcheck disable=SC2086
apt-get install -y -qq ${APT_PACKAGES_STRING} > /dev/null 2>&1
# Install Qt6 packages via aqtinstall for non-prebuilt-image builds
install_qt6_packages
fi
# Ensure the local PostgreSQL DB is available before the build.
ensure_database
export RTI_LICENSE_FILE=/workspace/rti_license.dat
export QT_QPA_PLATFORM=offscreen
cd /workspace/qt-migration-legatus/qt6-after/qt6-migrated-legatus
rm -rf build4
mkdir -p build4
cd build4
cmake .. \
-DBUILD_TESTING=ON \
-DBUILD_ALL="${BUILD_ALL}" \
-DBUILD_SV="${BUILD_SV}" \
-DBUILD_WS="${BUILD_WS}" \
-DBUILD_AAR="${BUILD_AAR}" \
-DBUILD_RTI="${BUILD_RTI}" \
-DBUILD_VIEWER_ONLY="${BUILD_VIEWER_ONLY}" \
-DBUILD_GRANTLEE="${BUILD_GRANTLEE}" \
-DBUILD_ARCGIS="${BUILD_ARCGIS}" \
-DBUILD_CODIFICATION="${BUILD_CODIFICATION}" \
-DRELEASE_BUILD="${RELEASE_BUILD}" \
${CMAKE_BUILD_FLAGS:-} \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="${QT_BASE_DIR}/${QT_VERSION}/${QT_ARCH_DIR}:/usr/local"
read -r -a RELEASE_TARGETS_ARRAY <<< "${RELEASE_BUILD_TARGETS}"
log_info "Building release scope targets: ${RELEASE_TARGETS_ARRAY[*]}"
make -j8 "${RELEASE_TARGETS_ARRAY[@]}" 2>&1 | tee release_build.log
if [[ "${RUN_CTEST}" == "ON" ]]; then
log_info "Running CTest"
ctest --test-dir . --output-on-failure || CTEST_RESULT=$?
if [[ "${CTEST_RESULT:-0}" -ne 0 ]]; then
log_info "CTest completed with failures (exit code: ${CTEST_RESULT})"
fi
else
log_info "Skipping CTest"
fi
# Jenkins builder execution (produces the release DEB packages)
if [[ "${RUN_JENKINS_BUILDER}" == "ON" ]]; then
log_info "=== Jenkins Builder Execution (RPM/DEB Package Production) ==="
# Set up environment variables for jenkins_builder_ubuntu26.sh
export OS_VERSION=$(cat /etc/os-release | grep "^VERSION_ID=" | cut -d'"' -f2)
export WORKSPACE=/workspace
export PROJECT_BASE_DIR=/workspace
log_info "Running jenkins_builder_ubuntu26.sh with:"
log_info " PROJECT=${PROJECT}"
log_info " OS_VERSION=${OS_VERSION}"
log_info " LTS_VERSION=${LTS_VERSION}"
log_info " GUEZ_MODE=${GUEZ_MODE}"
log_info " WORKSPACE=${WORKSPACE}"
log_info " PROJECT_BASE_DIR=${PROJECT_BASE_DIR}"
log_info " BUILD_NUMBER=${BUILD_NUMBER}"
log_info " BUILD_TAG=${BUILD_TAG}"
# Execute jenkins_builder_ubuntu26.sh
if [[ -f "${MIGRATE_PIPELINE_ROOT}/jenkins-ci-rme/jenkins_builder_ubuntu26.sh" ]]; then
bash "${MIGRATE_PIPELINE_ROOT}/jenkins-ci-rme/jenkins_builder_ubuntu26.sh" || JENKINS_BUILDER_RESULT=$?
if [[ "${JENKINS_BUILDER_RESULT:-0}" -ne 0 ]]; then
log_info "Jenkins builder completed with errors (exit code: ${JENKINS_BUILDER_RESULT})"
else
log_info "Jenkins builder completed successfully"
fi
else
log_error "jenkins_builder_ubuntu26.sh not found at ${MIGRATE_PIPELINE_ROOT}/jenkins-ci-rme/jenkins_builder_ubuntu26.sh"
JENKINS_BUILDER_RESULT=1
fi
else
log_info "Skipping Jenkins builder execution"
fi
EOF
chmod +x "${CONTAINER_SCRIPT_HOST}"
docker run --rm \
-e MIGRATE_PIPELINE_ROOT \
-e LANG \
-e LC_ALL \
-e RELEASE_BUILD \
-e BUILD_RTI \
-e BUILD_GRANTLEE \
-e BUILD_CODIFICATION \
-e BUILD_ALL \
-e BUILD_SV \
-e BUILD_WS \
-e BUILD_AAR \
-e RUN_CTEST \
-e USE_PREBUILT_IMAGE \
-e RUN_JENKINS_BUILDER \
-e PACKAGE_OUTPUT_DIR \
-e LTS_VERSION \
-e PROJECT \
-e GUEZ_MODE \
-e BUILD_NUMBER \
-e BUILD_TAG \
-e CMAKE_BUILD_FLAGS \
-e QT_VERSION \
-e QT_ARCH \
-e QT_ARCH_DIR \
-e QT_BASE_DIR \
-e APT_PACKAGES_STRING="${APT_PACKAGES_STRING}" \
-e RELEASE_BUILD_TARGETS="${RELEASE_BUILD_TARGETS_STRING}" \
-v "${WORKSPACE_ROOT_HOST}:/workspace" \
-v "${RTI_LICENSE_FILE_HOST}:/workspace/rti_license.dat" \
-v "${MIGRATE_PIPELINE_ROOT}/external:/workspace/external:ro" \
-v "${CONTAINER_SCRIPT_HOST}:/tmp/run-build-inside-container.sh:ro" \
-v "${PACKAGE_OUTPUT_DIR}:/workspace/packages-out" \
"${DOCKER_IMAGE}" \
bash /tmp/run-build-inside-container.sh