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.
This commit is contained in:
berrux-dev committed 2026-11-18 08:39:04 +01:00
1 parent b18ac87565
commit 679e7a8a9c
6 files changed
+365 -1271

No files matched your search

+37 -18
View File
@@ -1,25 +1,43 @@
# Prebuilt build image for the release validation-scope branch # Prebuilt build image for the Release 2 scope
# (Ubuntu 26.04 + Qt6 + all dependencies for the legatus release build). # (Ubuntu 26.04 + Qt 6.10.2 + all dependencies for the legatus release 2 build).
# #
# Built by new_docker_build.sh --build-prebuilt-image, which passes the # This is the single source of truth for the image recipe:
# package list and Qt settings as build args (see build_prebuilt_image()). # new_docker_build.sh builds the image from this file when the image is
# missing (--use-prebuilt-image, the default) or must be rebuilt
# (--no-prebuilt-image).
#
# Note: libbz2-dev (BZip2) is required by Z/src/nglcompression.
FROM ubuntu:26.04 FROM ubuntu:26.04
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
ARG APT_PACKAGES
ARG QT_VERSION=6.10.2 ARG QT_VERSION=6.10.2
ARG QT_ARCH=linux_gcc_64 ARG QT_ARCH=linux_gcc_64
ARG QT_BASE_DIR=/opt/Qt ARG QT_BASE_DIR=/opt/Qt
RUN apt-get update -qq && \ RUN apt-get update -qq && \
apt-get install -y -qq \ apt-get install -y -qq \
${APT_PACKAGES} \ build-essential \
libqt6svg6-dev \ cmake \
ninja-build \
git \
python3-pip \
libboost-dev \
libbz2-dev \
libgl1-mesa-dev \
pkg-config \
libkf6texttemplate-dev \
libgtest-dev \ libgtest-dev \
libgmock-dev \ libgmock-dev \
python3-pip && \ libpq-dev \
postgresql-server-dev-all \
libvlc-dev \
vlc-plugin-base \
libssl-dev \
libxml2-dev \
libxerces-c-dev \
&& \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
# Install Qt6 packages via aqtinstall # Install Qt6 packages via aqtinstall
@@ -30,18 +48,19 @@ RUN pip3 install --break-system-packages --quiet aqtinstall && \
--outputdir ${QT_BASE_DIR} && \ --outputdir ${QT_BASE_DIR} && \
rm -rf /root/.cache/Aqt rm -rf /root/.cache/Aqt
# Install KDReports from source (apt package not available in Ubuntu 22.04/26.04) # Install KDReports from source (no apt package on Ubuntu 26.04)
# Try apt install first (will fail), then build from KDAB GitHub mirror RUN git clone --depth 1 https://github.com/KDAB/KDReports.git /tmp/KDReports && \
RUN apt-get install -y -qq libkdreports-dev 2>/dev/null || \ cd /tmp/KDReports && \
(git clone --depth 1 https://github.com/KDAB/KDReports.git /tmp/KDReports && \ mkdir build && cd build && \
cd /tmp/KDReports && \ cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_PREFIX_PATH=${QT_BASE_DIR} .. && \
mkdir build && cd build && \ make -j$(nproc) && \
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_PREFIX_PATH=${QT_BASE_DIR} .. && \ make install && \
make -j$(nproc) && \ cd / && rm -rf /tmp/KDReports
make install && \
cd / && rm -rf /tmp/KDReports)
# Legacy sources include <KDReports/...> # Legacy sources include <KDReports/...>
RUN ln -sfn KDReports-qt6 /usr/local/include/KDReports RUN ln -sfn KDReports-qt6 /usr/local/include/KDReports
ENV PATH="${QT_BASE_DIR}/${QT_VERSION}/gcc_64/bin:${PATH}"
ENV CMAKE_PREFIX_PATH="${QT_BASE_DIR}/${QT_VERSION}/gcc_64"
CMD ["/bin/bash"] CMD ["/bin/bash"]
+17 -20
View File
@@ -6,7 +6,7 @@ needs Docker.
## Scope ## Scope
`new_docker_build_release2.sh` builds the Release 2 scope in four `new_docker_build.sh` builds the Release 2 scope in four
groups (all ON by default, toggle with `--groupN` / `--no-groupN`): groups (all ON by default, toggle with `--groupN` / `--no-groupN`):
| Group | Area | Contents | | Group | Area | Contents |
@@ -21,9 +21,9 @@ groups (all ON by default, toggle with `--groupN` / `--no-groupN`):
Entries at the tree root: Entries at the tree root:
- `new_docker_build_release2.sh` — build driver (compile, ctest, DEB packaging) - `new_docker_build.sh` — build driver (compile, ctest, DEB packaging)
- `rpmbuild/make_rpm_ubuntu26_release2.py` — in-tree DEB package producer (self-contained) - `rpmbuild/make_rpm_ubuntu26_release2.py` — in-tree DEB package producer (self-contained)
- `Dockerfile` — image recipe kept for the legacy validation-scope driver and for the `qt6-release-build-pipeline` DEB; the Release 2 driver carries the same recipe built in and builds the image automatically when it is missing - `Dockerfile` — the image recipe (single source of truth); the driver builds the image from it when the image is missing or when `--no-prebuilt-image` forces a rebuild (also bundled into the `qt6-release-build-pipeline` DEB)
- `rti_license.dat` — RTI Connext DDS license, required by the DDS group (GROUP1) - `rti_license.dat` — RTI Connext DDS license, required by the DDS group (GROUP1)
- `jenkins-ci-rme/` — in-tree copy of the Jenkins CI flow (see its own `README.md`; still wired to the legacy driver, see Step 5) - `jenkins-ci-rme/` — in-tree copy of the Jenkins CI flow (see its own `README.md`; still wired to the legacy driver, see Step 5)
- `../build/` — build tree, created by the driver **next to the tree** (`qt6-after/build`), never inside it (git-ignored scratch area) - `../build/` — build tree, created by the driver **next to the tree** (`qt6-after/build`), never inside it (git-ignored scratch area)
@@ -60,21 +60,23 @@ All commands below are run **from this directory**
## Step 1 — Build the prebuilt Docker image (once) ## Step 1 — Build the prebuilt Docker image (once)
```bash ```bash
./new_docker_build_release2.sh --docker-image legatus-qt6:1.0 ./new_docker_build.sh --docker-image legatus-qt6:1.0
``` ```
`--docker-image` selects the prebuilt-image mode: if the named image `--docker-image` selects the prebuilt-image mode: if the named image
does not exist yet, the driver builds it automatically from its does not exist yet, the driver builds it automatically from the
built-in recipe (Ubuntu 26.04 base, apt deps, Qt 6.10.2 via in-tree `./Dockerfile` (Ubuntu 26.04 base, apt deps, Qt 6.10.2 via
`aqtinstall`, KDReports from source) and continues with the build. `aqtinstall`, KDReports from source) and continues with the build.
The default image name is `qt6-migrated-legatus-release2`. This driver `--no-prebuilt-image` forces a (re)build of the image from
`./Dockerfile` before running.
The default image name is `legatus-qt6:1.0`. This driver
has no `--build-prebuilt-image` / `--delete-prebuilt-image` options — has no `--build-prebuilt-image` / `--delete-prebuilt-image` options —
manage the image with plain `docker` if needed. manage the image with plain `docker` if needed.
## Step 2 — Build the Release 2 scope ## Step 2 — Build the Release 2 scope
```bash ```bash
./new_docker_build_release2.sh --docker-image legatus-qt6:1.0 \ ./new_docker_build.sh --docker-image legatus-qt6:1.0 \
> build.log 2>&1 > build.log 2>&1
``` ```
@@ -203,7 +205,7 @@ prefix** the configure used (the driver mounts the pipeline root at
## Step 4 — Produce the release DEB packages ## Step 4 — Produce the release DEB packages
```bash ```bash
./new_docker_build_release2.sh --docker-image legatus-qt6:1.0 \ ./new_docker_build.sh --docker-image legatus-qt6:1.0 \
--run-jenkins-builder \ --run-jenkins-builder \
> /path/to/build.log 2>&1 > /path/to/build.log 2>&1
``` ```
@@ -244,10 +246,9 @@ dpkg -c "<pipeline-root>/rpms/guez/26.04/qt6-release-ctest-runtime_1.0-1_amd64.d
## Step 5 — CI / Jenkins flow (optional) ## Step 5 — CI / Jenkins flow (optional)
The in-tree `jenkins-ci-rme/` directory contains the full Jenkins The in-tree `jenkins-ci-rme/` directory contains the full Jenkins
pipeline (`Jenkinsfile`, builder, publisher) adapted to this tree. pipeline (`Jenkinsfile`, builder, publisher) adapted to this tree; the
**Note:** it is still wired to the legacy `new_docker_build.sh` in-tree flow calls `new_docker_build.sh` (the Release 2 driver). See
driver and has not been switched to `new_docker_build_release2.sh` `jenkins-ci-rme/README.md` for the pipeline details.
yet. See `jenkins-ci-rme/README.md` for the pipeline details.
## Step 6 — Code coverage (lcov) ## Step 6 — Code coverage (lcov)
@@ -260,7 +261,7 @@ coverage step.
## Options reference ## Options reference
`./new_docker_build_release2.sh --help` prints the full option list. `./new_docker_build.sh --help` prints the full option list.
The main ones: The main ones:
| Option | Default | Purpose | | Option | Default | Purpose |
@@ -271,8 +272,8 @@ The main ones:
| `--group6` / `--no-group6` | ON | Generators (AP9) | | `--group6` / `--no-group6` | ON | Generators (AP9) |
| `--no-ctest` | — | skip the ctest step | | `--no-ctest` | — | skip the ctest step |
| `--tests-only` | — | see Known quirks | | `--tests-only` | — | see Known quirks |
| `--use-prebuilt-image` / `--no-prebuilt-image` | off | prebuilt image mode (`--docker-image` turns it on) | | `--use-prebuilt-image` / `--no-prebuilt-image` | on | use the image (build from `./Dockerfile` if missing) / force a rebuild from `./Dockerfile` |
| `--docker-image IMAGE` | `qt6-migrated-legatus-release2` | image to use (auto-built if missing) | | `--docker-image IMAGE` | `legatus-qt6:1.0` | image to use (auto-built if missing) |
| `--cmake_build_flags FLAGS` | — | extra `-D` flags appended to the configure | | `--cmake_build_flags FLAGS` | — | extra `-D` flags appended to the configure |
| `--docker-mount-root PATH` | `/repo` | container-side mount root | | `--docker-mount-root PATH` | `/repo` | container-side mount root |
| `--run-jenkins-builder` | off | produce the DEB packages (Step 4) | | `--run-jenkins-builder` | off | produce the DEB packages (Step 4) |
@@ -318,7 +319,3 @@ Environment overrides: `BUILD_GROUP1/3/5/6`, `RUN_CTEST`, `TESTS_ONLY`,
- `--tests-only` is documented in `--help` as "run only ctest, skip all - `--tests-only` is documented in `--help` as "run only ctest, skip all
build groups", but the current implementation only skips the ctest build groups", but the current implementation only skips the ctest
step; the group builds still run. step; the group builds still run.
- The legacy driver `new_docker_build.sh` (validation scope) is kept in
the tree and is still used by `jenkins-ci-rme/`; its in-tree
`Dockerfile` recipe does not include `libbz2-dev` (BZip2), which the
Release 2 driver's built-in recipe does.
@@ -1,11 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# #
# Local release pipeline for the Qt6-migrated legatus validation scope # Local release pipeline for the Qt6-migrated legatus Release 2 scope
# (TetraIF, Z, Lts/Common + Lts/Proxies/TrainingAreaBase). # (AP3 Lts services + core stack, AP4 DDS, AP9 Viewer/tools/generators).
# #
# Runs the in-tree new_docker_build.sh: # Runs the in-tree new_docker_build.sh (Release 2 driver):
# - builds the prebuilt Docker image from the in-tree Dockerfile when the # - builds the prebuilt Docker image from the in-tree Dockerfile
# image is not present yet # when the image is not present yet
# - builds the release scope, runs ctest and produces the release DEB # - builds the release scope, runs ctest and produces the release DEB
# packages with the in-tree rpmbuild script # packages with the in-tree rpmbuild script
# - collects the lcov code-coverage report (--run-coverage; set # - collects the lcov code-coverage report (--run-coverage; set
@@ -45,14 +45,10 @@ log_info "Package output: ${WORKSPACE}/rpms/${PROJECT}/${OS_VERSION}/"
cd "${LEGATUS_ROOT}" cd "${LEGATUS_ROOT}"
# Build the prebuilt image from the in-tree Dockerfile when not present yet # (The driver auto-builds the prebuilt image from the in-tree Dockerfile
# (--build-prebuilt-image builds the image and exits) # when the image is not present yet.)
if ! docker image inspect "${DOCKER_IMAGE}" >/dev/null 2>&1; then
log_info "Prebuilt image not found - building it from the in-tree Dockerfile..."
bash ./new_docker_build.sh --build-prebuilt-image --docker-image "${DOCKER_IMAGE}"
fi
# Release scope build + ctest + DEB production (in-tree rpmbuild) # Release 2 scope build + ctest + DEB production (in-tree rpmbuild)
bash ./new_docker_build.sh \ bash ./new_docker_build.sh \
--docker-image "${DOCKER_IMAGE}" \ --docker-image "${DOCKER_IMAGE}" \
--run-jenkins-builder \ --run-jenkins-builder \
+302 -560
View File
@@ -2,565 +2,339 @@
set -euo pipefail set -euo pipefail
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Build helper for the release validation-scope branch of qt-migrated-legatus # Build helper for qt-migrated-legatus inside Docker - RELEASE 2 VERSION
# #
# Builds only the release scope (TetraIF, Z/src, Lts/Common + # Release 2 Scope:
# Lts/Proxies/TrainingAreaBase) inside the prebuilt Docker image and # - AP3: Shared libraries (LtsUtils, Widgets, Session, Krypto, PluginManager)
# optionally runs the Jenkins builder to produce the release DEB packages. # - AP4: DDS middleware (Core, DDSConnector, Routing, QosProfile, RTI layer)
# - AP9: Tools and translations (DdsView, LogViewer, SqlBrowser, generators,
# lupdate)
# #
# - Resolves MIGRATE_PIPELINE_ROOT (exported variable, .envrc, or derived # The Docker image recipe lives in ./Dockerfile (single source of truth:
# from the script location = repo root) for the workspace mount # Ubuntu 26.04 + apt deps + Qt 6.10.2 via aqtinstall + KDReports from
# - Uses a prebuilt Docker image with all build dependencies installed # source). The image is built from it when missing or when
# (build it from ./Dockerfile via --build-prebuilt-image) # --no-prebuilt-image forces a rebuild.
# - Optional deletion of the prebuilt Docker image via --delete-prebuilt-image
# - Optional DEB package production via the in-tree rpmbuild/
# make_rpm_ubuntu26.py (self-contained - no outer-repo dependencies)
# - Uses a temporary container-side script for robust execution
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
usage() { usage() {
cat <<'EOF' cat <<'EOF'
Usage: ./new_docker_build.sh [options] Usage: ./new_docker_build.sh [options]
Builds the release validation scope inside the prebuilt Docker image: Build groups (Release 2 scope, all ON by default):
RELEASE_BUILD=ON (fixed) - TetraIF, Z, Lts/Common (+ TrainingAreaBase) --group1 / --no-group1 DDS middleware (AP4)
ctest runs for the release scope test executables (Lts/Common + Z) --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)
Options: Docker image:
--docker-image IMAGE Docker image name to use/build/delete --use-prebuilt-image Use the image; build it from ./Dockerfile if missing
(default: legatus-qt6:1.0) (default)
--build-prebuilt-image Build the prebuilt Docker image (from ./Dockerfile) --no-prebuilt-image Force a (re)build of the image from ./Dockerfile
and exit. To run the build with it, run the script --docker-image IMAGE Image name (default: legatus-qt6:1.0);
again with --docker-image implies --use-prebuilt-image
--delete-prebuilt-image Delete the configured Docker image and exit --docker-mount-root PATH Container-side mount root (default: /repo)
--cmake_build_flags FLAGS Extra -D flags appended to the configure
Package production options (RPM/DEB): Tests:
--run-jenkins-builder Build the release DEB packages inside the container --no-ctest Skip the ctest step
using the in-tree rpmbuild/make_rpm_ubuntu26.py --tests-only See README.md "Known quirks"
--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)
Coverage options (lcov): Packages (DEB, via in-tree rpmbuild/make_rpm_ubuntu26_release2.py):
--run-coverage Build the release scope with -O0 --coverage, run ctest --run-jenkins-builder Produce the release DEB packages
and collect an lcov coverage report (mutually --package-output-dir DIR Directory for package output (default: ./packages-out)
exclusive with --run-jenkins-builder) --lts-version VERSION LTS version for the package (default: 1.0)
--coverage-output-dir DIR Directory to mount for coverage output --project NAME Project name for the package (default: guez)
(default: ./coverage-out) --build-number NUM Build number for the package (default: 1)
--build-tag TAG Build tag for the package (default: manual-build)
Environment variable overrides: Coverage (lcov):
BUILD_PREBUILT_IMAGE=ON|OFF --run-coverage Coverage build + lcov report (README.md Step 6)
DELETE_PREBUILT_IMAGE=ON|OFF --coverage-output-dir DIR Directory for coverage output (default: ./coverage-out)
DOCKER_IMAGE=<image-name>
RUN_JENKINS_BUILDER=ON|OFF
PACKAGE_OUTPUT_DIR=<dir>
LTS_VERSION=<version>
PROJECT=<name>
GUEZ_MODE=ON|OFF
BUILD_NUMBER=<num>
BUILD_TAG=<tag>
RUN_COVERAGE=ON|OFF
COVERAGE_OUTPUT_DIR=<dir>
MIGRATE_PIPELINE_ROOT resolution (highest precedence first): Environment overrides: BUILD_GROUP1/3/5/6, RUN_CTEST, TESTS_ONLY,
1. exported MIGRATE_PIPELINE_ROOT (e.g. from a Jenkinsfile) USE_PREBUILT_IMAGE, DOCKER_IMAGE, CMAKE_BUILD_FLAGS, DOCKER_MOUNT_ROOT,
2. MIGRATE_PIPELINE_ROOT set by .envrc in this directory GUEZ_MODE, RUN_JENKINS_BUILDER, PACKAGE_OUTPUT_DIR, LTS_VERSION, PROJECT,
3. derived from the script location (the DLBO Qt6 repo root) BUILD_NUMBER, BUILD_TAG, RUN_COVERAGE, COVERAGE_OUTPUT_DIR.
Examples: MIGRATE_PIPELINE_ROOT (highest precedence first): exported environment
./new_docker_build.sh --build-prebuilt-image --docker-image legatus-qt6:1.0 variable > .envrc in this directory > the script's own location.
./new_docker_build.sh --docker-image legatus-qt6:1.0
./new_docker_build.sh --delete-prebuilt-image --docker-image legatus-qt6:1.0
./new_docker_build.sh --docker-image legatus-qt6:1.0 \
--run-jenkins-builder \
--package-output-dir "${WORKSPACE}/rpms/${PROJECT}/${OS_VERSION}/"
./new_docker_build.sh --docker-image legatus-qt6:1.0 \
--run-coverage \
--coverage-output-dir "${WORKSPACE}/coverage/${PROJECT}/${OS_VERSION}/"
EOF EOF
}
log_info() {
printf 'INFO: %s\n' "$*"
}
log_error() {
printf 'ERROR: %s\n' "$*" >&2
}
die() {
log_error "$*"
exit 1 exit 1
} }
require_command() { log_info() {
local cmd="$1" echo "[INFO] $*"
command -v "$cmd" >/dev/null 2>&1 || die "Required command not found: ${cmd}"
} }
require_file() { die() {
local path="$1" echo "[ERROR] $*" >&2
local label="$2" exit 1
[[ -f "$path" ]] || die "${label} not found: ${path}"
} }
require_directory() { # -----------------------------------------------------------------------------
local path="$1" # Default values
local label="$2" BUILD_GROUP1="${BUILD_GROUP1:-ON}" # AP4: DDS
[[ -d "$path" ]] || die "${label} directory not found: ${path}" 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
require_non_empty() { # Jenkins builder options for DEB package production
local value="$1" GUEZ_MODE="${GUEZ_MODE:-ON}"
local name="$2" RUN_JENKINS_BUILDER="${RUN_JENKINS_BUILDER:-OFF}"
[[ -n "$value" ]] || die "Required variable ${name} is not set or empty" 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}"
normalize_on_off() { # Code coverage (lcov)
local value="$1" RUN_COVERAGE="${RUN_COVERAGE:-OFF}"
local name="$2" COVERAGE_OUTPUT_DIR="${COVERAGE_OUTPUT_DIR:-./coverage-out}"
case "${value^^}" in # Export variables for Docker container
ON|OFF) export BUILD_GROUP1 BUILD_GROUP3 BUILD_GROUP5 BUILD_GROUP6 RUN_CTEST TESTS_ONLY \
printf '%s\n' "${value^^}" USE_PREBUILT_IMAGE RUN_JENKINS_BUILDER PACKAGE_OUTPUT_DIR LTS_VERSION \
;; PROJECT BUILD_NUMBER BUILD_TAG RUN_COVERAGE COVERAGE_OUTPUT_DIR
*)
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
git
python3-pip
# Code coverage (genhtml ships in the same package)
lcov
# Packaging tools for RPM/DEB build
rpm
debhelper
dpkg-dev
fakeroot
devscripts
)
# Release scope targets: TetraIF + Z components + Lts/Common libraries
# and the release-scope test executables (Lts/Common + Z)
RELEASE_BUILD_TARGETS=(
# TetraIF module targets (CoPrtCnv / LogView / PrtCnv)
CoPrtCnv
LogViewLogger
LogView
PrtCnvLib
PrtCnv
# 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: 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
# TetraIF unit tests (TetraIF/unit-test)
coprtcnv_unit_test
logview_unit_test
prtcnv_unit_test
)
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
# -----------------------------------------------------------------------------
# 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)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
MIGRATE_PIPELINE_ROOT_DEFAULT="${SCRIPT_DIR}"
PIPELINE_ROOT_EXPORTED="${MIGRATE_PIPELINE_ROOT:-}" PIPELINE_ROOT_EXPORTED="${MIGRATE_PIPELINE_ROOT:-}"
if [[ -f ".envrc" ]]; then if [[ -f ".envrc" ]]; then
set -a set -a
source ".envrc" source .envrc
set +a set +a
fi fi
# An explicitly exported MIGRATE_PIPELINE_ROOT (Jenkinsfile) wins over .envrc MIGRATE_PIPELINE_ROOT="${PIPELINE_ROOT_EXPORTED:-${MIGRATE_PIPELINE_ROOT:-${SCRIPT_DIR}}}"
if [[ -n "${PIPELINE_ROOT_EXPORTED}" ]]; then export MIGRATE_PIPELINE_ROOT
MIGRATE_PIPELINE_ROOT="${PIPELINE_ROOT_EXPORTED}"
else
MIGRATE_PIPELINE_ROOT="${MIGRATE_PIPELINE_ROOT:-${MIGRATE_PIPELINE_ROOT_DEFAULT}}"
fi
# Fixed configuration for the release validation-scope branch
RELEASE_BUILD=ON
RUN_CTEST=ON
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}"
# Code coverage (lcov)
RUN_COVERAGE="${RUN_COVERAGE:-OFF}"
COVERAGE_OUTPUT_DIR="${COVERAGE_OUTPUT_DIR:-./coverage-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}"
# -----------------------------------------------------------------------------
# Parse arguments
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case "$1" in case "$1" in
--build-prebuilt-image) --group1) BUILD_GROUP1="ON"; shift;;
BUILD_PREBUILT_IMAGE=ON --no-group1) BUILD_GROUP1="OFF"; shift;;
;; --group3) BUILD_GROUP3="ON"; shift;;
--delete-prebuilt-image) --no-group3) BUILD_GROUP3="OFF"; shift;;
DELETE_PREBUILT_IMAGE=ON --group5) BUILD_GROUP5="ON"; shift;;
;; --no-group5) BUILD_GROUP5="OFF"; shift;;
--docker-image) --group6) BUILD_GROUP6="ON"; shift;;
shift --no-group6) BUILD_GROUP6="OFF"; shift;;
[[ $# -gt 0 ]] || die "--docker-image requires an image name" --no-ctest) RUN_CTEST="OFF"; shift;;
DOCKER_IMAGE="$1" --tests-only) TESTS_ONLY="ON"; shift;;
;; --use-prebuilt-image) USE_PREBUILT_IMAGE="ON"; shift;;
--run-jenkins-builder) --no-prebuilt-image) USE_PREBUILT_IMAGE="OFF"; shift;;
RUN_JENKINS_BUILDER=ON --docker-image) DOCKER_IMAGE="$2"; USE_PREBUILT_IMAGE="ON"; shift 2;;
;; --cmake_build_flags) CMAKE_BUILD_FLAGS="$2"; shift 2;;
--package-output-dir) --docker-mount-root) DOCKER_MOUNT_ROOT="$2"; shift 2;;
shift --run-jenkins-builder) RUN_JENKINS_BUILDER="ON"; shift;;
[[ $# -gt 0 ]] || die "--package-output-dir requires a directory path" --package-output-dir) PACKAGE_OUTPUT_DIR="$2"; shift 2;;
PACKAGE_OUTPUT_DIR="$1" --lts-version) LTS_VERSION="$2"; shift 2;;
;; --project) PROJECT="$2"; shift 2;;
--run-coverage) --build-number) BUILD_NUMBER="$2"; shift 2;;
RUN_COVERAGE=ON --build-tag) BUILD_TAG="$2"; shift 2;;
;; --run-coverage) RUN_COVERAGE="ON"; shift;;
--coverage-output-dir) --coverage-output-dir) COVERAGE_OUTPUT_DIR="$2"; shift 2;;
shift -h|--help) usage;;
[[ $# -gt 0 ]] || die "--coverage-output-dir requires a directory path" *) die "Unknown option: $1";;
COVERAGE_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 esac
shift
done done
BUILD_PREBUILT_IMAGE="$(normalize_on_off "$BUILD_PREBUILT_IMAGE" "BUILD_PREBUILT_IMAGE")" # Validate mutually exclusive options
DELETE_PREBUILT_IMAGE="$(normalize_on_off "$DELETE_PREBUILT_IMAGE" "DELETE_PREBUILT_IMAGE")" if [[ "${RUN_JENKINS_BUILDER}" == "ON" ]] && [[ "${RUN_COVERAGE}" == "ON" ]]; then
RUN_JENKINS_BUILDER="$(normalize_on_off "$RUN_JENKINS_BUILDER" "RUN_JENKINS_BUILDER")" die "Error: --run-jenkins-builder and --run-coverage are mutually exclusive"
RUN_COVERAGE="$(normalize_on_off "$RUN_COVERAGE" "RUN_COVERAGE")"
if [[ "${RUN_COVERAGE}" == "ON" && "${RUN_JENKINS_BUILDER}" == "ON" ]]; then
die "--run-coverage is mutually exclusive with --run-jenkins-builder"
fi fi
# Default for the Docker image name require_command() {
DOCKER_IMAGE="${DOCKER_IMAGE:-legatus-qt6:1.0}" if ! command -v "$1" &> /dev/null; then
die "Required command not found: $1"
# Export variables for Docker container
export RELEASE_BUILD RUN_CTEST BUILD_PREBUILT_IMAGE DELETE_PREBUILT_IMAGE DOCKER_IMAGE RUN_JENKINS_BUILDER PACKAGE_OUTPUT_DIR RUN_COVERAGE COVERAGE_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"
WORKSPACE_ROOT_HOST="${MIGRATE_PIPELINE_ROOT}"
PROJECT_DIR_HOST="${WORKSPACE_ROOT_HOST}"
require_directory "${PROJECT_DIR_HOST}" "Project directory"
log_info "RELEASE_BUILD=${RELEASE_BUILD}"
log_info "RUN_CTEST=${RUN_CTEST}"
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 "RUN_COVERAGE=${RUN_COVERAGE}"
log_info "COVERAGE_OUTPUT_DIR=${COVERAGE_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 "PROJECT_DIR_HOST=${PROJECT_DIR_HOST}"
if [[ "${BUILD_PREBUILT_IMAGE}" == "ON" ]]; then
build_prebuilt_image "${DOCKER_IMAGE}"
log_info "Prebuilt image was built successfully."
log_info "To run the build with it, run:"
printf ' ./new_docker_build.sh --docker-image %q\n' "${DOCKER_IMAGE}"
exit 0
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}"
RUN_CTEST="${RUN_CTEST:-ON}"
# Packaging variables
RUN_JENKINS_BUILDER="${RUN_JENKINS_BUILDER:-OFF}"
RUN_COVERAGE="${RUN_COVERAGE:-OFF}"
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}"
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
}
log_info "Using prebuilt Docker image: all build dependencies are baked in"
export QT_QPA_PLATFORM=offscreen
cd /workspace/qt6-migrated-legatus
# The build tree is ../build: next to the source tree, outside it.
rm -rf ../build
mkdir -p ../build
cd ../build
COV_CMAKE_ARGS=()
if [[ "${RUN_COVERAGE}" == "ON" ]]; then
COV_CMAKE_ARGS=(
"-DCMAKE_C_FLAGS_RELEASE=-O0 -g --coverage -DNDEBUG -fPIC"
"-DCMAKE_CXX_FLAGS_RELEASE=-O0 -g --coverage -DNDEBUG -fPIC"
"-DCMAKE_EXE_LINKER_FLAGS=--coverage"
"-DCMAKE_SHARED_LINKER_FLAGS=--coverage"
)
fi
cmake /workspace/qt6-migrated-legatus \
-DBUILD_TESTING=ON \
-DRELEASE_BUILD="${RELEASE_BUILD}" \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="${QT_BASE_DIR}/${QT_VERSION}/${QT_ARCH_DIR}:/usr/local" \
"${COV_CMAKE_ARGS[@]}"
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 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 else
log_info "Skipping CTest" if ! docker image inspect "${DOCKER_IMAGE}" &> /dev/null; then
build_image
else
log_info "Prebuilt image already exists: ${DOCKER_IMAGE}"
fi
fi fi
if [[ "${RUN_COVERAGE}" == "ON" ]]; then # -----------------------------------------------------------------------------
log_info "=== Code coverage (lcov) ===" # Prepare Docker run command
COVOUT=/workspace/coverage-out DOCKER_RUN_ARGS=(
SRCROOT=/workspace/qt6-migrated-legatus --rm
mkdir -p "${COVOUT}" -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
COV_IGNORE=(--ignore-errors mismatch,inconsistent,unused) log_info() { echo "[INFO] $*"; }
lcov --capture --directory . --external "${COV_IGNORE[@]}" \ die() { echo "[ERROR] $*" >&2; exit 1; }
--rc branch_coverage=1 \
--output-file "${COVOUT}/raw.info" # Point RTI Connext DDS at the license file (checked in at the source tree
lcov --extract "${COVOUT}/raw.info" \ # root) so DDS processes started during the build/ctest can find it.
"${SRCROOT}/TetraIF/*" \ if [[ -f "${DOCKER_MOUNT_ROOT}/qt-migration-legatus/qt6-after/qt6-migrated-legatus/rti_license.dat" ]]; then
"${SRCROOT}/Z/src/*" \ export RTI_LICENSE="${DOCKER_MOUNT_ROOT}/qt-migration-legatus/qt6-after/qt6-migrated-legatus/rti_license.dat"
"${SRCROOT}/Lts/Common/*" \ log_info "RTI_LICENSE=${RTI_LICENSE}"
"${SRCROOT}/Lts/Proxies/TrainingAreaBase/*" \
"${COV_IGNORE[@]}" \
--rc branch_coverage=1 \
--output-file "${COVOUT}/scoped.info"
lcov --remove "${COVOUT}/scoped.info" \
"*/unit-test/*" \
"*CommonUnitTestsPlaceholder*" \
"*/UnitTests/*" \
"*/tests/*" \
"*/test_*" \
"*_test.cpp" \
"*_test.h" \
"*_unit_test*" \
"${COV_IGNORE[@]}" \
--rc branch_coverage=1 \
--output-file "${COVOUT}/coverage.info"
lcov --summary "${COVOUT}/coverage.info" "${COV_IGNORE[@]}" --rc branch_coverage=1 \
> "${COVOUT}/coverage_summary.txt"
genhtml "${COVOUT}/coverage.info" \
--output-directory "${COVOUT}/html" \
"${COV_IGNORE[@]}" \
--branch-coverage --legend \
--rc branch_coverage=1
log_info "Coverage report written to ${COVOUT} (host: ${COVERAGE_OUTPUT_DIR})"
cat "${COVOUT}/coverage_summary.txt"
fi fi
# DEB package production with the in-tree rpmbuild script # 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 if [[ "${RUN_JENKINS_BUILDER}" == "ON" ]]; then
log_info "=== DEB Package Production (in-tree rpmbuild) ===" log_info "=== DEB Package Production (in-tree rpmbuild) ==="
OS_VERSION=$(cat /etc/os-release | grep "^VERSION_ID=" | cut -d'"' -f2) # Extract OS version for package naming
STAGE_DIR=/workspace/qt6-migrated-legatus/deb_stage OS_VERSION=$(eval $(grep "^VERSION_ID=" /etc/os-release) && echo "$VERSION_ID")
STAGED_SOURCE_DIR="${STAGE_DIR}" 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}" log_info "Staging workspace to ${STAGE_DIR}"
rm -rf "${STAGE_DIR}" rm -rf "${STAGE_DIR}"
@@ -568,41 +342,34 @@ if [[ "${RUN_JENKINS_BUILDER}" == "ON" ]]; then
tar --exclude='./rpms' --exclude='./.git' --exclude='./build' \ tar --exclude='./rpms' --exclude='./.git' --exclude='./build' \
--exclude='./deb_build_tmp' --exclude='./deb_stage' --exclude='./packages-out' \ --exclude='./deb_build_tmp' --exclude='./deb_stage' --exclude='./packages-out' \
--exclude='./legatus-qt6_1.0.tar.gz' \ --exclude='./legatus-qt6_1.0.tar.gz' \
-cf - -C /workspace/qt6-migrated-legatus . | tar -xf - -C "${STAGE_DIR}" -cf - -C "${WORKSPACE_DIR}" . | tar -xf - -C "${STAGE_DIR}"
if [[ ! -f "${STAGED_SOURCE_DIR}/CMakeLists.txt" || ! -f "${STAGED_SOURCE_DIR}/rpmbuild/make_rpm_ubuntu26.py" ]]; then if [[ ! -f "${STAGE_DIR}/CMakeLists.txt" || ! -f "${STAGE_DIR}/rpmbuild/make_rpm_ubuntu26_release2.py" ]]; then
log_error "Staged source incomplete under ${STAGED_SOURCE_DIR} (CMakeLists.txt or rpmbuild/make_rpm_ubuntu26.py missing)" die "Staged source incomplete under ${STAGE_DIR} (CMakeLists.txt or make_rpm_ubuntu26_release2.py missing)"
exit 1
fi fi
log_info "Running ${STAGED_SOURCE_DIR}/rpmbuild/make_rpm_ubuntu26.py with:" 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})"
log_info " PROJECT=${PROJECT}" cd "${STAGE_DIR}/rpmbuild"
log_info " OS_VERSION=${OS_VERSION}" if python3 make_rpm_ubuntu26_release2.py -c LTS \
log_info " LTS_VERSION=${LTS_VERSION}"
log_info " GUEZ_MODE=${GUEZ_MODE}"
log_info " BUILD_NUMBER=${BUILD_NUMBER}"
log_info " BUILD_TAG=${BUILD_TAG}"
cd "${STAGED_SOURCE_DIR}/rpmbuild"
if python3 make_rpm_ubuntu26.py -c LTS \
--project_name "${PROJECT}" \ --project_name "${PROJECT}" \
--version "${LTS_VERSION}" \ --version "${LTS_VERSION}" \
--output_dir "/workspace/qt6-migrated-legatus/rpms/${PROJECT}/${OS_VERSION}/" \ --output_dir "${DOCKER_MOUNT_ROOT}/rpms/${PROJECT}/${OS_VERSION}/" \
--source_dir "${STAGED_SOURCE_DIR}" \ --source_dir "${STAGE_DIR}" \
--cmake_build_flags "-DUSE_IPO=ON -DUSE_UNITY_BUILD=ON -DGUEZ_MODE=${GUEZ_MODE} -DBUILD_WLS=ON -DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/postgresql/ -DRELEASE_BUILD=ON" \ --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}" \ --build_number "${BUILD_NUMBER}" \
--release_scope; then --release_scope; then
log_info "Package build completed successfully" log_info "Package build completed successfully"
else else
log_error "Package build failed (exit code: $?)" echo "[ERROR] Package build failed (exit code: $?)" >&2
exit 1 exit 1
fi fi
# Copy produced DEB packages to the packages-out # Copy produced DEB packages to packages-out (same-file skip by device:inode)
DEST_DIR=/workspace/packages-out DEST_DIR="${DOCKER_MOUNT_ROOT}/packages-out"
mkdir -p "${DEST_DIR}" mkdir -p "${DEST_DIR}"
shopt -s nullglob shopt -s nullglob
for deb in "/workspace/qt6-migrated-legatus/rpms/${PROJECT}/${OS_VERSION}/"*.deb; do for deb in "${DOCKER_MOUNT_ROOT}/rpms/${PROJECT}/${OS_VERSION}/"*.deb; do
base="$(basename "${deb}")" base="$(basename "${deb}")"
if [[ -e "${DEST_DIR}/${base}" ]] && if [[ -e "${DEST_DIR}/${base}" ]] &&
[[ "$(stat -c '%d:%i' "${deb}")" == "$(stat -c '%d:%i' "${DEST_DIR}/${base}")" ]]; then [[ "$(stat -c '%d:%i' "${deb}")" == "$(stat -c '%d:%i' "${DEST_DIR}/${base}")" ]]; then
@@ -616,37 +383,12 @@ if [[ "${RUN_JENKINS_BUILDER}" == "ON" ]]; then
else else
log_info "Skipping DEB package production" log_info "Skipping DEB package production"
fi fi
EOF
chmod +x "${CONTAINER_SCRIPT_HOST}" log_info "Release 2 build completed successfully!"
'
)
# The workspace mount is the tree's parent (not the tree): the build tree log_info "Starting Docker container..."
# ../build then lands next to the tree on the host (qt6-after/build), not docker run "${DOCKER_RUN_ARGS[@]}"
# inside it. NOTE: no # comment lines inside the backslash-continued docker
# run below - they break the continuation and drop the remaining arguments. log_info "Build script completed."
docker run --rm \
-e MIGRATE_PIPELINE_ROOT \
-e LANG \
-e LC_ALL \
-e RELEASE_BUILD \
-e RUN_CTEST \
-e RUN_JENKINS_BUILDER \
-e RUN_COVERAGE \
-e COVERAGE_OUTPUT_DIR \
-e PACKAGE_OUTPUT_DIR \
-e LTS_VERSION \
-e PROJECT \
-e GUEZ_MODE \
-e BUILD_NUMBER \
-e BUILD_TAG \
-e QT_VERSION \
-e QT_ARCH \
-e QT_ARCH_DIR \
-e QT_BASE_DIR \
-e RELEASE_BUILD_TARGETS="${RELEASE_BUILD_TARGETS_STRING}" \
-v "${WORKSPACE_ROOT_HOST}/..:/workspace" \
-v "${CONTAINER_SCRIPT_HOST}:/tmp/run-build-inside-container.sh:ro" \
-v "${PACKAGE_OUTPUT_DIR}:/workspace/packages-out" \
-v "${COVERAGE_OUTPUT_DIR}:/workspace/coverage-out" \
"${DOCKER_IMAGE}" \
bash /tmp/run-build-inside-container.sh
@@ -1,660 +0,0 @@
#!/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)
#
# This is the Release 2 scope driver (the full-tree driver of the earlier
# validation scope has been removed from this branch).
# -----------------------------------------------------------------------------
usage() {
cat <<'EOF'
Usage: ./new_docker_build_release2.sh [options]
Build groups (Release 2 scope):
--group1 / --no-group1 Enable/disable DDS core libraries build (AP4)
--group3 / --no-group3 Enable/disable Lts services build (AP3)
--group5 / --no-group5 Enable/disable Lts/Viewer module targets and tests (AP9)
--group6 / --no-group6 Enable/disable LTS Tools - generators and lupdate (AP9)
Test execution:
--no-ctest Skip ctest execution
--tests-only Run only ctest, skip all make build groups
Prebuilt Docker image usage:
--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
--cmake_build_flags FLAGS Extra CMake flags passed to the in-container configure
(space-separated -D flags)
Package production options (DEB):
--run-jenkins-builder Build the release DEB packages inside the container
using the in-tree rpmbuild/make_rpm_ubuntu26_release2.py
--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)
Coverage options (lcov):
--run-coverage Build with -O0 --coverage, run ctest and collect lcov
--coverage-output-dir DIR Directory to mount for coverage output (default: ./coverage-out)
Docker mount configuration:
--docker-mount-root PATH Container-side mount root path (default: /repo)
Changes where host directories are mounted in container
Environment variable overrides:
BUILD_GROUP1=ON|OFF DDS core libraries (AP4)
BUILD_GROUP3=ON|OFF Lts services (AP3)
BUILD_GROUP5=ON|OFF Viewer module (AP9)
BUILD_GROUP6=ON|OFF Tools/generators (AP9)
RUN_CTEST=ON|OFF
TESTS_ONLY=ON|OFF
USE_PREBUILT_IMAGE=ON|OFF
RUN_JENKINS_BUILDER=ON|OFF
PACKAGE_OUTPUT_DIR=<dir>
LTS_VERSION=<version>
PROJECT=<name>
BUILD_NUMBER=<num>
BUILD_TAG=<tag>
RUN_COVERAGE=ON|OFF
COVERAGE_OUTPUT_DIR=<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)
Examples:
./new_docker_build_release2.sh --group1 --group3 --group5 --group6
BUILD_GROUP1=ON BUILD_GROUP3=ON ./new_docker_build_release2.sh
./new_docker_build_release2.sh --use-prebuilt-image --no-ctest
./new_docker_build_release2.sh --group3 --run-jenkins-builder \
--package-output-dir "${WORKSPACE}/rpms/guez/release2/"
./new_docker_build_release2.sh --group3 --run-coverage \
--coverage-output-dir "${WORKSPACE}/coverage/guez/release2/"
EOF
exit 1
}
log_info() {
echo "[INFO] $*"
}
log_error() {
printf "ERROR: %s\n" "$*" >&2
}
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:-OFF}"
DOCKER_IMAGE="${DOCKER_IMAGE:-qt6-migrated-legatus-release2}"
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
export RUN_JENKINS_BUILDER PACKAGE_OUTPUT_DIR LTS_VERSION PROJECT BUILD_NUMBER BUILD_TAG
export 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)"
MIGRATE_PIPELINE_ROOT_DEFAULT="${SCRIPT_DIR}"
PIPELINE_ROOT_EXPORTED="${MIGRATE_PIPELINE_ROOT:-}"
if [[ -f ".envrc" ]]; then
set -a
source ".envrc"
set +a
fi
# An explicitly exported MIGRATE_PIPELINE_ROOT (Jenkinsfile) wins over .envrc
if [[ -n "${PIPELINE_ROOT_EXPORTED}" ]]; then
MIGRATE_PIPELINE_ROOT="${PIPELINE_ROOT_EXPORTED}"
else
MIGRATE_PIPELINE_ROOT="${MIGRATE_PIPELINE_ROOT:-${MIGRATE_PIPELINE_ROOT_DEFAULT}}"
fi
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"
shift 2
USE_PREBUILT_IMAGE="ON"
;;
--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
set -a
# shellcheck disable=SC1091
source ".envrc"
set +a
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 "======================================"
# Build prebuilt image if requested
if [[ "${USE_PREBUILT_IMAGE}" == "ON" ]]; then
if ! docker image inspect "${DOCKER_IMAGE}" &> /dev/null; then
log_info "Prebuilt image ${DOCKER_IMAGE} not found. Building it now..."
# Create temporary directory for Dockerfile
tmp_dir="$(mktemp -d)"
trap 'rm -rf "${tmp_dir}"' EXIT
cat > "${tmp_dir}/Dockerfile" <<'DOCKERFILE'
FROM ubuntu:26.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq && \
apt-get install -y -qq \
build-essential \
cmake \
ninja-build \
git \
python3-pip \
libboost-dev \
libbz2-dev \
libgl1-mesa-dev \
pkg-config \
libkf6texttemplate-dev \
libgtest-dev \
libgmock-dev \
libpq-dev \
postgresql-server-dev-all \
libvlc-dev \
vlc-plugin-base \
libssl-dev \
libxml2-dev \
libxerces-c-dev \
&& \
rm -rf /var/lib/apt/lists/*
# Install Qt6 packages via aqtinstall
RUN pip3 install --break-system-packages --quiet aqtinstall && \
aqt install-qt linux desktop 6.10.2 linux_gcc_64 \
-m qtmultimedia qtserialport qtimageformats qtwebsockets qtwebengine \
qtpdf qtwebview qt5compat qtwebchannel qtpositioning qtlocation qtsensors \
--outputdir /opt/Qt && \
rm -rf /root/.cache/Aqt
# Install KDReports from source
RUN git clone --depth 1 https://github.com/KDAB/KDReports.git /tmp/KDReports && \
cd /tmp/KDReports && \
mkdir build && cd build && \
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_PREFIX_PATH=/opt/Qt .. && \
make -j$(nproc) && \
make install && \
cd / && rm -rf /tmp/KDReports
# Create symlink for KDReports headers
RUN ln -sfn KDReports-qt6 /usr/local/include/KDReports
CMD ["/bin/bash"]
DOCKERFILE
docker build -t "${DOCKER_IMAGE}" "${tmp_dir}"
log_info "Prebuilt image created: ${DOCKER_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"
)
if [[ "${USE_PREBUILT_IMAGE}" == "ON" ]]; then
DOCKER_RUN_ARGS+=("${DOCKER_IMAGE}")
else
DOCKER_RUN_ARGS+=("ubuntu:26.04")
fi
# When not using prebuilt image, we need to install dependencies first
if [[ "${USE_PREBUILT_IMAGE}" == "OFF" ]]; then
# Prepend dependency installation to the build command
INSTALL_DEPS='
set -e
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq && \
apt-get install -y -qq \
build-essential \
cmake \
ninja-build \
git \
python3-pip \
libboost-dev \
libbz2-dev \
libgl1-mesa-dev \
pkg-config \
libkf6texttemplate-dev \
libgtest-dev \
libgmock-dev \
libpq-dev \
postgresql-server-dev-all \
libvlc-dev \
vlc-plugin-base \
libssl-dev \
libxml2-dev \
libxerces-c-dev \
&& \
rm -rf /var/lib/apt/lists/*
# Install Qt6 packages via aqtinstall
pip3 install --break-system-packages --quiet aqtinstall && \
aqt install-qt linux desktop 6.10.2 linux_gcc_64 \
-m qtmultimedia qtserialport qtimageformats qtwebsockets qtwebengine \
qtpdf qtwebview qt5compat qtwebchannel qtpositioning qtlocation qtsensors \
--outputdir /opt/Qt && \
rm -rf /root/.cache/Aqt
# Install KDReports from source
git clone --depth 1 https://github.com/KDAB/KDReports.git /tmp/KDReports && \
cd /tmp/KDReports && \
mkdir build && cd build && \
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_PREFIX_PATH=/opt/Qt .. && \
make -j$(nproc) && \
make install && \
cd / && rm -rf /tmp/KDReports
# Create symlink for KDReports headers
ln -sfn KDReports-qt6 /usr/local/include/KDReports
export PATH="/opt/Qt/6.10.2/gcc_64/bin:$PATH"
export CMAKE_PREFIX_PATH="/opt/Qt/6.10.2/gcc_64"
log_info() {
echo "[INFO] $*"
}
die() {
echo "[ERROR] $*" >&2
exit 1
}
log_info "Dependencies installed successfully"
# Return to project directory
cd "${DOCKER_MOUNT_ROOT}/qt-migration-legatus/qt6-after/qt6-migrated-legatus"
'
else
INSTALL_DEPS=''
fi
# Build command
DOCKER_RUN_ARGS+=(
/bin/bash
-c
'
set -e
log_info() {
echo "[INFO] $*"
}
log_error() {
printf "ERROR: %s\n" "$*" >&2
}
die() {
echo "[ERROR] $*" >&2
exit 1
}
'"${INSTALL_DEPS}"'
# 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
log_info "Configuring CMake..."
# Fixed build dir next to the tree (../build), outside the source tree.
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 (Release 1 + Release 2 scope)
GROUP1_TARGETS=(ddscore ddsftccore ddsfts ddsgen ddsQoS ddsconnector ddscore_unit_test ddsqos_unit_test)
# AP3: Shared libraries + TetraIF + Lts/Common + Tests (Release 1 + Release 2 scope)
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)
GROUP5_TARGETS=(ddsview LogViewer sqlbrowser logviewer_unit_test sqlbrowser_unit_test)
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}"
# KF6 TextTemplate plugins (ktexttemplate_defaulttags, used by
# GrantleeParserSmoke) are installed by the system libkf6texttemplate-dev
# package under the multiarch plugin dir, which the /opt/Qt install does
# not search by default. Prepend it so Qt can load them.
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"
STAGED_SOURCE_DIR="${STAGE_DIR}"
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 "${STAGED_SOURCE_DIR}/CMakeLists.txt" || ! -f "${STAGED_SOURCE_DIR}/rpmbuild/make_rpm_ubuntu26_release2.py" ]]; then
log_error "Staged source incomplete under ${STAGED_SOURCE_DIR} (CMakeLists.txt or rpmbuild/make_rpm_ubuntu26_release2.py missing)"
exit 1
fi
log_info "Running ${STAGED_SOURCE_DIR}/rpmbuild/make_rpm_ubuntu26_release2.py 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 " BUILD_NUMBER=${BUILD_NUMBER}"
log_info " BUILD_TAG=${BUILD_TAG}"
# DEB cmake flags: -DBUILD_RTI=ON is required
cd "${STAGED_SOURCE_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 "${STAGED_SOURCE_DIR}" \
--cmake_build_flags "-DUSE_IPO=ON -DUSE_UNITY_BUILD=ON -DGUEZ_MODE=${GUEZ_MODE} -DBUILD_WLS=ON -DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/postgresql/ -DBUILD_RTI=ON -DRELEASE_BUILD=ON" \
--build_targets "${GROUP1_TARGETS[*]} ${GROUP3_TARGETS[*]} ${GROUP5_TARGETS[*]} ${GROUP6_TARGETS[*]}" \
--build_number "${BUILD_NUMBER}" \
--release_scope; then
log_info "Package build completed successfully"
else
log_error "Package build failed (exit code: $?)"
exit 1
fi
# Copy produced DEB packages to the packages-out
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."
@@ -21,7 +21,7 @@ from email.utils import formatdate
SKIP_DIRS = {'build', 'cmake-build-debug', 'cmake-build-release', 'deb_build_tmp'} SKIP_DIRS = {'build', 'cmake-build-debug', 'cmake-build-release', 'deb_build_tmp'}
SOURCE_EXTENSIONS = ('.cpp', '.h', '.hpp', '.cc', '.cxx', '.hxx') SOURCE_EXTENSIONS = ('.cpp', '.h', '.hpp', '.cc', '.cxx', '.hxx')
PIPELINE_FILES = [ PIPELINE_FILES = [
"new_docker_build_release2.sh", "new_docker_build.sh",
"Dockerfile", "Dockerfile",
"jenkins-ci-rme/Jenkinsfile", "jenkins-ci-rme/Jenkinsfile",
"jenkins-ci-rme/jenkins/Jenkinsfile", "jenkins-ci-rme/jenkins/Jenkinsfile",