Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/new_docker_build.sh
T
berrux-dev 679e7a8a9c Consolidate the Release 2 driver into new_docker_build.sh
- new_docker_build.sh is now the Release 2 scope driver (4 build groups,
  61 targets, Ninja/RelWithDebInfo, /repo mount, 22-test ctest, DEB via
  rpmbuild/make_rpm_ubuntu26_release2.py); the separate
  new_docker_build_release2.sh driver is removed.
- The Docker image recipe is the in-tree Dockerfile (single source of
  truth): Ubuntu 26.04 + apt deps (incl. libbz2-dev, libkf6texttemplate-dev)
  + Qt 6.10.2 via aqtinstall + KDReports from source + ENV
  PATH/CMAKE_PREFIX_PATH. The driver builds the image from it when it is
  missing; --no-prebuilt-image now forces a rebuild (the in-container apt
  path and the inline recipe are gone). Default image: legatus-qt6:1.0.
- rpmbuild/make_rpm_ubuntu26_release2.py: bundle new_docker_build.sh in
  the build-pipeline DEB.
- jenkins-ci-rme/release-16-10-2026.sh: drop the --build-prebuilt-image
  step (no longer an option; the driver auto-builds the image when
  missing).
- README.md: document the Release 2 driver, the 22-test ctest baseline,
  the real DEB layout, the options and the known quirks.
2026-11-18 08:39:04 +01:00

395 lines
16 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# -----------------------------------------------------------------------------
# Build helper for qt-migrated-legatus inside Docker - RELEASE 2 VERSION
#
# Release 2 Scope:
# - AP3: Shared libraries (LtsUtils, Widgets, Session, Krypto, PluginManager)
# - AP4: DDS middleware (Core, DDSConnector, Routing, QosProfile, RTI layer)
# - AP9: Tools and translations (DdsView, LogViewer, SqlBrowser, generators,
# lupdate)
#
# The Docker image recipe lives in ./Dockerfile (single source of truth:
# Ubuntu 26.04 + apt deps + Qt 6.10.2 via aqtinstall + KDReports from
# source). The image is built from it when missing or when
# --no-prebuilt-image forces a rebuild.
# -----------------------------------------------------------------------------
usage() {
cat <<'EOF'
Usage: ./new_docker_build.sh [options]
Build groups (Release 2 scope, all ON by default):
--group1 / --no-group1 DDS middleware (AP4)
--group3 / --no-group3 Lts services + core stack (AP3)
--group5 / --no-group5 Viewer module targets and tests (AP9)
--group6 / --no-group6 Tools - generators and lupdate (AP9)
Docker image:
--use-prebuilt-image Use the image; build it from ./Dockerfile if missing
(default)
--no-prebuilt-image Force a (re)build of the image from ./Dockerfile
--docker-image IMAGE Image name (default: legatus-qt6:1.0);
implies --use-prebuilt-image
--docker-mount-root PATH Container-side mount root (default: /repo)
--cmake_build_flags FLAGS Extra -D flags appended to the configure
Tests:
--no-ctest Skip the ctest step
--tests-only See README.md "Known quirks"
Packages (DEB, via in-tree rpmbuild/make_rpm_ubuntu26_release2.py):
--run-jenkins-builder Produce the release DEB packages
--package-output-dir DIR Directory for package output (default: ./packages-out)
--lts-version VERSION LTS version for the package (default: 1.0)
--project NAME Project name for the package (default: guez)
--build-number NUM Build number for the package (default: 1)
--build-tag TAG Build tag for the package (default: manual-build)
Coverage (lcov):
--run-coverage Coverage build + lcov report (README.md Step 6)
--coverage-output-dir DIR Directory for coverage output (default: ./coverage-out)
Environment overrides: BUILD_GROUP1/3/5/6, RUN_CTEST, TESTS_ONLY,
USE_PREBUILT_IMAGE, DOCKER_IMAGE, CMAKE_BUILD_FLAGS, DOCKER_MOUNT_ROOT,
GUEZ_MODE, RUN_JENKINS_BUILDER, PACKAGE_OUTPUT_DIR, LTS_VERSION, PROJECT,
BUILD_NUMBER, BUILD_TAG, RUN_COVERAGE, COVERAGE_OUTPUT_DIR.
MIGRATE_PIPELINE_ROOT (highest precedence first): exported environment
variable > .envrc in this directory > the script's own location.
EOF
exit 1
}
log_info() {
echo "[INFO] $*"
}
die() {
echo "[ERROR] $*" >&2
exit 1
}
# -----------------------------------------------------------------------------
# Default values
BUILD_GROUP1="${BUILD_GROUP1:-ON}" # AP4: DDS
BUILD_GROUP3="${BUILD_GROUP3:-ON}" # AP3: Lts services
BUILD_GROUP5="${BUILD_GROUP5:-ON}" # AP9: Viewer
BUILD_GROUP6="${BUILD_GROUP6:-ON}" # AP9: Tools/generators
RUN_CTEST="${RUN_CTEST:-ON}"
TESTS_ONLY="${TESTS_ONLY:-OFF}"
USE_PREBUILT_IMAGE="${USE_PREBUILT_IMAGE:-ON}"
DOCKER_IMAGE="${DOCKER_IMAGE:-legatus-qt6:1.0}"
CMAKE_BUILD_FLAGS="${CMAKE_BUILD_FLAGS:-}"
DOCKER_MOUNT_ROOT="${DOCKER_MOUNT_ROOT:-/repo}"
export DOCKER_MOUNT_ROOT
# Jenkins builder options for DEB package production
GUEZ_MODE="${GUEZ_MODE:-ON}"
RUN_JENKINS_BUILDER="${RUN_JENKINS_BUILDER:-OFF}"
PACKAGE_OUTPUT_DIR="${PACKAGE_OUTPUT_DIR:-./packages-out}"
LTS_VERSION="${LTS_VERSION:-1.0}"
PROJECT="${PROJECT:-guez}"
BUILD_NUMBER="${BUILD_NUMBER:-1}"
BUILD_TAG="${BUILD_TAG:-manual-build}"
# Code coverage (lcov)
RUN_COVERAGE="${RUN_COVERAGE:-OFF}"
COVERAGE_OUTPUT_DIR="${COVERAGE_OUTPUT_DIR:-./coverage-out}"
# Export variables for Docker container
export BUILD_GROUP1 BUILD_GROUP3 BUILD_GROUP5 BUILD_GROUP6 RUN_CTEST TESTS_ONLY \
USE_PREBUILT_IMAGE RUN_JENKINS_BUILDER PACKAGE_OUTPUT_DIR LTS_VERSION \
PROJECT BUILD_NUMBER BUILD_TAG RUN_COVERAGE COVERAGE_OUTPUT_DIR
# -----------------------------------------------------------------------------
# MIGRATE_PIPELINE_ROOT resolution (highest precedence first):
# 1. exported MIGRATE_PIPELINE_ROOT (e.g. from a Jenkinsfile)
# 2. MIGRATE_PIPELINE_ROOT set by .envrc in this directory
# 3. derived from the script location (the DLBO Qt6 repo root)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PIPELINE_ROOT_EXPORTED="${MIGRATE_PIPELINE_ROOT:-}"
if [[ -f ".envrc" ]]; then
set -a
source .envrc
set +a
fi
MIGRATE_PIPELINE_ROOT="${PIPELINE_ROOT_EXPORTED:-${MIGRATE_PIPELINE_ROOT:-${SCRIPT_DIR}}}"
export MIGRATE_PIPELINE_ROOT
# -----------------------------------------------------------------------------
# Parse arguments
while [[ $# -gt 0 ]]; do
case "$1" in
--group1) BUILD_GROUP1="ON"; shift;;
--no-group1) BUILD_GROUP1="OFF"; shift;;
--group3) BUILD_GROUP3="ON"; shift;;
--no-group3) BUILD_GROUP3="OFF"; shift;;
--group5) BUILD_GROUP5="ON"; shift;;
--no-group5) BUILD_GROUP5="OFF"; shift;;
--group6) BUILD_GROUP6="ON"; shift;;
--no-group6) BUILD_GROUP6="OFF"; shift;;
--no-ctest) RUN_CTEST="OFF"; shift;;
--tests-only) TESTS_ONLY="ON"; shift;;
--use-prebuilt-image) USE_PREBUILT_IMAGE="ON"; shift;;
--no-prebuilt-image) USE_PREBUILT_IMAGE="OFF"; shift;;
--docker-image) DOCKER_IMAGE="$2"; USE_PREBUILT_IMAGE="ON"; shift 2;;
--cmake_build_flags) CMAKE_BUILD_FLAGS="$2"; shift 2;;
--docker-mount-root) DOCKER_MOUNT_ROOT="$2"; shift 2;;
--run-jenkins-builder) RUN_JENKINS_BUILDER="ON"; shift;;
--package-output-dir) PACKAGE_OUTPUT_DIR="$2"; shift 2;;
--lts-version) LTS_VERSION="$2"; shift 2;;
--project) PROJECT="$2"; shift 2;;
--build-number) BUILD_NUMBER="$2"; shift 2;;
--build-tag) BUILD_TAG="$2"; shift 2;;
--run-coverage) RUN_COVERAGE="ON"; shift;;
--coverage-output-dir) COVERAGE_OUTPUT_DIR="$2"; shift 2;;
-h|--help) usage;;
*) die "Unknown option: $1";;
esac
done
# Validate mutually exclusive options
if [[ "${RUN_JENKINS_BUILDER}" == "ON" ]] && [[ "${RUN_COVERAGE}" == "ON" ]]; then
die "Error: --run-jenkins-builder and --run-coverage are mutually exclusive"
fi
require_command() {
if ! command -v "$1" &> /dev/null; then
die "Required command not found: $1"
fi
}
require_command docker
# -----------------------------------------------------------------------------
# Validate environment
if [[ ! -f ".envrc" ]]; then
die ".envrc not found in current directory. Please create .envrc with required environment variables (e.g., MIGRATE_PIPELINE_ROOT)"
fi
if [[ -z "${MIGRATE_PIPELINE_ROOT:-}" ]]; then
die "MIGRATE_PIPELINE_ROOT is not set in .envrc"
fi
if [[ ! -d "${MIGRATE_PIPELINE_ROOT}" ]]; then
die "MIGRATE_PIPELINE_ROOT directory does not exist: ${MIGRATE_PIPELINE_ROOT}"
fi
# Validate rti_license.dat exists (required for DDS builds).
if [[ "${BUILD_GROUP1}" == "ON" ]]; then
if [[ ! -f "${MIGRATE_PIPELINE_ROOT}/rti_license.dat" ]] && [[ ! -f "${SCRIPT_DIR}/rti_license.dat" ]]; then
die "rti_license.dat not found in ${MIGRATE_PIPELINE_ROOT} or ${SCRIPT_DIR}. Required for DDS builds."
fi
fi
log_info "=== Release 2 Build Configuration ==="
log_info "BUILD_GROUP1 (DDS/AP4): ${BUILD_GROUP1}"
log_info "BUILD_GROUP3 (Lts/AP3): ${BUILD_GROUP3}"
log_info "BUILD_GROUP5 (Viewer/AP9): ${BUILD_GROUP5}"
log_info "BUILD_GROUP6 (Tools/AP9): ${BUILD_GROUP6}"
log_info "RUN_CTEST: ${RUN_CTEST}"
log_info "TESTS_ONLY: ${TESTS_ONLY}"
log_info "USE_PREBUILT_IMAGE: ${USE_PREBUILT_IMAGE}"
log_info "DOCKER_IMAGE: ${DOCKER_IMAGE}"
log_info "DOCKER_MOUNT_ROOT: ${DOCKER_MOUNT_ROOT}"
log_info "CMAKE_BUILD_FLAGS: ${CMAKE_BUILD_FLAGS:-none}"
log_info "======================================"
# -----------------------------------------------------------------------------
# Docker image (recipe: the in-tree ./Dockerfile, single source of truth)
build_image() {
log_info "Building Docker image ${DOCKER_IMAGE} from ${SCRIPT_DIR}/Dockerfile ..."
docker build -t "${DOCKER_IMAGE}" -f "${SCRIPT_DIR}/Dockerfile" "${SCRIPT_DIR}"
}
if [[ "${USE_PREBUILT_IMAGE}" == "OFF" ]]; then
build_image # --no-prebuilt-image: always (re)build
else
if ! docker image inspect "${DOCKER_IMAGE}" &> /dev/null; then
build_image
else
log_info "Prebuilt image already exists: ${DOCKER_IMAGE}"
fi
fi
# -----------------------------------------------------------------------------
# Prepare Docker run command
DOCKER_RUN_ARGS=(
--rm
-e MIGRATE_PIPELINE_ROOT
-e DOCKER_MOUNT_ROOT="${DOCKER_MOUNT_ROOT}"
-e BUILD_GROUP1="${BUILD_GROUP1}"
-e BUILD_GROUP3="${BUILD_GROUP3}"
-e BUILD_GROUP5="${BUILD_GROUP5}"
-e BUILD_GROUP6="${BUILD_GROUP6}"
-e RUN_CTEST="${RUN_CTEST}"
-e TESTS_ONLY="${TESTS_ONLY}"
-e RUN_JENKINS_BUILDER="${RUN_JENKINS_BUILDER}"
-e GUEZ_MODE="${GUEZ_MODE}"
-e PACKAGE_OUTPUT_DIR="${PACKAGE_OUTPUT_DIR}"
-e LTS_VERSION="${LTS_VERSION}"
-e PROJECT="${PROJECT}"
-e BUILD_NUMBER="${BUILD_NUMBER}"
-e BUILD_TAG="${BUILD_TAG}"
-e RUN_COVERAGE="${RUN_COVERAGE}"
-e COVERAGE_OUTPUT_DIR="${COVERAGE_OUTPUT_DIR}"
-v "${MIGRATE_PIPELINE_ROOT}:${DOCKER_MOUNT_ROOT}"
-w "${DOCKER_MOUNT_ROOT}/qt-migration-legatus/qt6-after/qt6-migrated-legatus"
"${DOCKER_IMAGE}"
/bin/bash
-c
'
set -e
log_info() { echo "[INFO] $*"; }
die() { echo "[ERROR] $*" >&2; exit 1; }
# Point RTI Connext DDS at the license file (checked in at the source tree
# root) so DDS processes started during the build/ctest can find it.
if [[ -f "${DOCKER_MOUNT_ROOT}/qt-migration-legatus/qt6-after/qt6-migrated-legatus/rti_license.dat" ]]; then
export RTI_LICENSE="${DOCKER_MOUNT_ROOT}/qt-migration-legatus/qt6-after/qt6-migrated-legatus/rti_license.dat"
log_info "RTI_LICENSE=${RTI_LICENSE}"
fi
# Configure CMake (fixed build dir next to the tree, outside the source tree)
log_info "Configuring CMake..."
BUILD_DIR="../build"
log_info "Using build directory: ${BUILD_DIR}"
rm -rf "${BUILD_DIR}"
mkdir -p "${BUILD_DIR}"
cmake -B "${BUILD_DIR}" \
-G Ninja \
-DBUILD_TESTING=ON \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_PREFIX_PATH="/opt/Qt/6.10.2/gcc_64" \
-DCMAKE_CXX_FLAGS="-DRTI_LINUX -DRTI_UNIX" \
-DCMAKE_C_FLAGS="-DRTI_LINUX -DRTI_UNIX" \
-DBUILD_RTI=ON \
-DBUILD_GROUP1="${BUILD_GROUP1}" \
-DBUILD_GROUP3="${BUILD_GROUP3}" \
-DBUILD_GROUP5="${BUILD_GROUP5}" \
-DBUILD_GROUP6="${BUILD_GROUP6}" \
-DRUN_JENKINS_BUILDER="${RUN_JENKINS_BUILDER}" \
-DPACKAGE_OUTPUT_DIR="${PACKAGE_OUTPUT_DIR}" \
-DLTS_VERSION="${LTS_VERSION}" \
-DPROJECT="${PROJECT}" \
-DBUILD_NUMBER="${BUILD_NUMBER}" \
-DBUILD_TAG="${BUILD_TAG}" \
-DRUN_COVERAGE="${RUN_COVERAGE}" \
-DCOVERAGE_OUTPUT_DIR="${COVERAGE_OUTPUT_DIR}" \
'"${CMAKE_BUILD_FLAGS}"' \
.
# Build targets
log_info "Building Release 2 targets..."
# AP4: DDS middleware
GROUP1_TARGETS=(ddscore ddsftccore ddsfts ddsgen ddsQoS ddsconnector ddscore_unit_test ddsqos_unit_test)
# AP3: Shared libraries + TetraIF + Lts/Common + Tests
GROUP3_TARGETS=(NGLLogger nglapplication nglcompression nglcoreapplication ngldb nglguiapplication nglsettings nglsingleapplication nglsinglecoreapplication ngltools ngltranslator nglwidgets qtsingleapplication qtsinglecoreapplication wms_json_ds tcpserver LtsCoordinate LtsCoordTrans LtsSession LtsMultiMonitor DataPluginInterface GuiPluginInterface CoPrtCnv LogViewLogger LogView PrtCnvLib PrtCnv LtsLicence MockCoordTrans aes_crypt_test ngltools_qt_smoke lts_coord_trans_unit_test test_nglpdfwidget coprtcnv_unit_test logview_unit_test prtcnv_unit_test ngllogger_unit_test nglcoreapplication_unit_test nglsettings_unit_test ngltools_unit_test wms_json_ds_unit_test ltscoordinate_unit_test ltssession_unit_test commandlineparser_unit_test codegen_unit_test grantlee_parser_smoke utils_test)
# AP9: Viewer / tools
GROUP5_TARGETS=(ddsview LogViewer sqlbrowser logviewer_unit_test sqlbrowser_unit_test)
# AP9: generators
GROUP6_TARGETS=(ngl_codegen)
build_group() {
local group_name="$1"
local build_flag="$2"
shift 2
local targets=("$@")
if [[ "${build_flag}" != "ON" ]]; then
log_info "Skipping ${group_name} (disabled)"
return
fi
log_info "Building ${group_name}..."
for target in "${targets[@]}"; do
log_info " Building: ${target}"
cmake --build "${BUILD_DIR}" --target "${target}" -j$(nproc) || die "Failed to build ${target}"
done
}
build_group "GROUP1 (DDS/AP4)" "${BUILD_GROUP1}" "${GROUP1_TARGETS[@]}"
build_group "GROUP3 (Lts/AP3)" "${BUILD_GROUP3}" "${GROUP3_TARGETS[@]}"
build_group "GROUP5 (Viewer/AP9)" "${BUILD_GROUP5}" "${GROUP5_TARGETS[@]}"
build_group "GROUP6 (Tools/AP9)" "${BUILD_GROUP6}" "${GROUP6_TARGETS[@]}"
# Run tests if enabled
if [[ "${RUN_CTEST}" == "ON" ]] && [[ "${TESTS_ONLY}" != "ON" ]]; then
log_info "Running ctest..."
cd "${BUILD_DIR}"
export QT_QPA_PLATFORM="${QT_QPA_PLATFORM:-offscreen}"
export QT_PLUGIN_PATH="/usr/lib/x86_64-linux-gnu/qt6/plugins${QT_PLUGIN_PATH:+:${QT_PLUGIN_PATH}}"
ctest --output-on-failure -j$(nproc) || log_info "Some tests failed (continuing)"
cd ..
fi
# DEB Package Production (in-tree rpmbuild)
if [[ "${RUN_JENKINS_BUILDER}" == "ON" ]]; then
log_info "=== DEB Package Production (in-tree rpmbuild) ==="
# Extract OS version for package naming
OS_VERSION=$(eval $(grep "^VERSION_ID=" /etc/os-release) && echo "$VERSION_ID")
STAGE_DIR="${DOCKER_MOUNT_ROOT}/deb_stage"
WORKSPACE_DIR="${DOCKER_MOUNT_ROOT}/qt-migration-legatus/qt6-after/qt6-migrated-legatus"
log_info "Staging workspace to ${STAGE_DIR}"
rm -rf "${STAGE_DIR}"
mkdir -p "${STAGE_DIR}"
tar --exclude='./rpms' --exclude='./.git' --exclude='./build' \
--exclude='./deb_build_tmp' --exclude='./deb_stage' --exclude='./packages-out' \
--exclude='./legatus-qt6_1.0.tar.gz' \
-cf - -C "${WORKSPACE_DIR}" . | tar -xf - -C "${STAGE_DIR}"
if [[ ! -f "${STAGE_DIR}/CMakeLists.txt" || ! -f "${STAGE_DIR}/rpmbuild/make_rpm_ubuntu26_release2.py" ]]; then
die "Staged source incomplete under ${STAGE_DIR} (CMakeLists.txt or make_rpm_ubuntu26_release2.py missing)"
fi
log_info "Running rpmbuild/make_rpm_ubuntu26_release2.py (PROJECT=${PROJECT} OS_VERSION=${OS_VERSION} LTS_VERSION=${LTS_VERSION} GUEZ_MODE=${GUEZ_MODE} BUILD_NUMBER=${BUILD_NUMBER} BUILD_TAG=${BUILD_TAG})"
cd "${STAGE_DIR}/rpmbuild"
if python3 make_rpm_ubuntu26_release2.py -c LTS \
--project_name "${PROJECT}" \
--version "${LTS_VERSION}" \
--output_dir "${DOCKER_MOUNT_ROOT}/rpms/${PROJECT}/${OS_VERSION}/" \
--source_dir "${STAGE_DIR}" \
--cmake_build_flags "-DUSE_IPO=ON -DUSE_UNITY_BUILD=ON -DGUEZ_MODE=${GUEZ_MODE} -DBUILD_WLS=ON -DBUILD_RTI=ON -DRELEASE_BUILD=ON -DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/postgresql/ " \
--build_targets "${GROUP1_TARGETS[*]} ${GROUP3_TARGETS[*]} ${GROUP5_TARGETS[*]} ${GROUP6_TARGETS[*]}" \
--build_number "${BUILD_NUMBER}" \
--release_scope; then
log_info "Package build completed successfully"
else
echo "[ERROR] Package build failed (exit code: $?)" >&2
exit 1
fi
# Copy produced DEB packages to packages-out (same-file skip by device:inode)
DEST_DIR="${DOCKER_MOUNT_ROOT}/packages-out"
mkdir -p "${DEST_DIR}"
shopt -s nullglob
for deb in "${DOCKER_MOUNT_ROOT}/rpms/${PROJECT}/${OS_VERSION}/"*.deb; do
base="$(basename "${deb}")"
if [[ -e "${DEST_DIR}/${base}" ]] &&
[[ "$(stat -c '%d:%i' "${deb}")" == "$(stat -c '%d:%i' "${DEST_DIR}/${base}")" ]]; then
continue
fi
cp -f "${deb}" "${DEST_DIR}/"
done
shopt -u nullglob
log_info "DEB packages available in ${DEST_DIR} (host: ${PACKAGE_OUTPUT_DIR:-unknown}):"
ls -lh "${DEST_DIR}/"
else
log_info "Skipping DEB package production"
fi
log_info "Release 2 build completed successfully!"
'
)
log_info "Starting Docker container..."
docker run "${DOCKER_RUN_ARGS[@]}"
log_info "Build script completed."