added DB
This commit is contained in:
1 parent
1e07bf76ba
commit
78253c60f4
2 files changed
+52
-10
No files matched your search
@@ -1216,6 +1216,45 @@ run_build_group() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Ensure a local PostgreSQL DB is available for the DB tools (dbUpdate, dbAdministration, ...).
|
||||
# Checks whether the server is pre-installed (baked into the image); if not, installs
|
||||
# postgresql-18. Then maps EXCDBS01/EXCADB01 -> 127.0.0.1 and starts the cluster, seeding
|
||||
# the roles (postgres, ctc_sv) + databases (lts_ets_pro, dbAdmin) the tools connect with.
|
||||
# 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 "WARNING: PostgreSQL not ready on 127.0.0.1:5432 (DB tools may not connect; 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
|
||||
@@ -1228,6 +1267,9 @@ else
|
||||
install_qt6_packages
|
||||
fi
|
||||
|
||||
# Ensure the local PostgreSQL DB (dbUpdate / dbAdministration, ...) is available before the build.
|
||||
ensure_database
|
||||
|
||||
export RTI_LICENSE_FILE=/workspace/rti_license.dat
|
||||
export QT_QPA_PLATFORM=offscreen
|
||||
|
||||
|
||||
@@ -101,34 +101,34 @@ if(BUILD_TESTING)
|
||||
endif()
|
||||
|
||||
# Exclude LTS Tools tests when corresponding targets aren't available
|
||||
if(NOT TARGET DBAdministration)
|
||||
if(NOT TARGET dbAdministration)
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_DBAdministration\\.cpp")
|
||||
endif()
|
||||
if(NOT TARGET DBOperatorSettingsRemover)
|
||||
if(NOT TARGET SettingsRemover)
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_DBOperatorSettingsRemover\\.cpp")
|
||||
endif()
|
||||
if(NOT TARGET DBUpdate)
|
||||
if(NOT TARGET dbUpdate)
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_DBUpdate\\.cpp")
|
||||
endif()
|
||||
if(NOT TARGET DataSampleGenerator)
|
||||
if(NOT TARGET tDataSampleGenerator)
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_DataSampleGenerator\\.cpp")
|
||||
endif()
|
||||
if(NOT TARGET DataSampleReceiver)
|
||||
if(NOT TARGET tDataSampleReceiver)
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_DataSampleReceiver\\.cpp")
|
||||
endif()
|
||||
if(NOT TARGET DateTimeSyncer)
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_DateTimeSyncer\\.cpp")
|
||||
endif()
|
||||
if(NOT TARGET DdsView)
|
||||
if(NOT TARGET ddsview)
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_DdsView\\.cpp")
|
||||
endif()
|
||||
if(NOT TARGET DotMatrixDisplay)
|
||||
if(NOT TARGET displayPanelSimulator)
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_DotMatrixDisplay\\.cpp")
|
||||
endif()
|
||||
if(NOT TARGET LicenceEditor)
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_LicenceEditor\\.cpp")
|
||||
endif()
|
||||
if(NOT TARGET LocalDomainFinder)
|
||||
if(NOT TARGET localDomainFinder)
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_LocalDomainFinder\\.cpp")
|
||||
endif()
|
||||
if(NOT TARGET LogViewer)
|
||||
@@ -160,10 +160,10 @@ if(BUILD_TESTING)
|
||||
if(NOT TARGET ProjectSettingsEditor)
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_ProjectSettingsEditor\\.cpp")
|
||||
endif()
|
||||
if(NOT TARGET QLedLine)
|
||||
if(NOT TARGET qledline)
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_QLedLine\\.cpp")
|
||||
endif()
|
||||
if(NOT TARGET QLedMatrix)
|
||||
if(NOT TARGET qledmatrix)
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_QLedMatrix\\.cpp")
|
||||
endif()
|
||||
# Group 9 (R,S,T,V,W) exclusions
|
||||
|
||||
Reference in new issue
Block a user