Adds CI CD with deb for external deps
This commit is contained in:
82 files changed
+3547
-3
No files matched your search
+206
@@ -0,0 +1,206 @@
|
||||
#!/bin/bash
|
||||
# Build a single DEB package
|
||||
# Usage: ./build-package.sh <package-dir-name> [version]
|
||||
#
|
||||
# Package directory names and their corresponding DEB package names:
|
||||
# arcgis -> libarcgis-maps-sdk-qt-dev
|
||||
# avs -> libavs-dev
|
||||
# buildingmodels -> libbuildingmodels-dev
|
||||
# dtentity -> libdtentity-dev
|
||||
# geographiclib -> libgeographiclib-dev
|
||||
# rti-connext-dds -> librti-connext-dds-7.7.0-dev
|
||||
# schusstafel -> libschusstafel-dev
|
||||
# tmsif -> libtmsif-dev
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PACKAGE_DIR_NAME="$1"
|
||||
VERSION="${2:-1.0.0}"
|
||||
|
||||
if [ -z "${PACKAGE_DIR_NAME}" ]; then
|
||||
echo "Usage: ./build-package.sh <package-dir-name> [version]"
|
||||
echo "Example: ./build-package.sh geographiclib 1.0.0"
|
||||
echo ""
|
||||
echo "Available package directories:"
|
||||
echo " arcgis, avs, buildingmodels, dtentity, geographiclib, rti-connext-dds, schusstafel, tmsif"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PACKAGE_DIR="${SCRIPT_DIR}/${PACKAGE_DIR_NAME}"
|
||||
|
||||
if [ ! -d "${PACKAGE_DIR}/debian" ]; then
|
||||
echo "ERROR: Package directory not found: ${PACKAGE_DIR}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract actual package name from control file
|
||||
PACKAGE_NAME=$(grep "^Package:" "${PACKAGE_DIR}/debian/control" | cut -d' ' -f2)
|
||||
if [ -z "${PACKAGE_NAME}" ]; then
|
||||
echo "ERROR: Could not extract package name from control file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Package directory: ${PACKAGE_DIR_NAME}"
|
||||
echo "DEB package name: ${PACKAGE_NAME}"
|
||||
|
||||
# Determine expected /opt path and source path based on package directory
|
||||
case "${PACKAGE_DIR_NAME}" in
|
||||
arcgis)
|
||||
OPT_PATH="/opt/ArcGIS/MapsSDK_Qt_300.0.0"
|
||||
SRC_PATH="${SCRIPT_DIR}/../../external/ArcGIS"
|
||||
;;
|
||||
avs)
|
||||
OPT_PATH="/opt/AVS"
|
||||
SRC_PATH="${SCRIPT_DIR}/../../external/AVS"
|
||||
;;
|
||||
buildingmodels)
|
||||
OPT_PATH="/opt/BuildingModels"
|
||||
SRC_PATH="${SCRIPT_DIR}/../../external/BuildingModels"
|
||||
;;
|
||||
dtentity)
|
||||
OPT_PATH="/opt/dtEntity"
|
||||
SRC_PATH="${SCRIPT_DIR}/../../external/dtEntity"
|
||||
;;
|
||||
geographiclib)
|
||||
OPT_PATH="/opt/GeographicLib"
|
||||
SRC_PATH="${SCRIPT_DIR}/../../external/GeographicLib"
|
||||
;;
|
||||
rti-connext-dds)
|
||||
OPT_PATH="/opt/rti_connext_dds-7.7.0"
|
||||
SRC_PATH="${SCRIPT_DIR}/../../external/rti_connext_dds-7.7.0"
|
||||
;;
|
||||
schusstafel)
|
||||
OPT_PATH="/opt/Schusstafel"
|
||||
SRC_PATH="${SCRIPT_DIR}/../../external/Schusstafel"
|
||||
;;
|
||||
tmsif)
|
||||
OPT_PATH="/opt/tmsif"
|
||||
SRC_PATH="${SCRIPT_DIR}/../../external/tmsif"
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: Unknown package directory: ${PACKAGE_DIR_NAME}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Source path: ${SRC_PATH}"
|
||||
echo "Target /opt path: ${OPT_PATH}"
|
||||
echo "========================================"
|
||||
echo "Building DEB Package: ${PACKAGE_NAME}"
|
||||
echo "Version: ${VERSION}"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
# Check if dependency exists in source location
|
||||
if [ ! -d "${SRC_PATH}" ]; then
|
||||
echo "ERROR: Dependency not found at ${SRC_PATH}"
|
||||
echo ""
|
||||
echo "Ensure the dependency is present in the external directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create temporary /opt structure for build
|
||||
TEMP_OPT_BASE="/tmp/deb-build-opt"
|
||||
TEMP_OPT="${TEMP_OPT_BASE}${OPT_PATH}"
|
||||
mkdir -p "${TEMP_OPT}"
|
||||
|
||||
echo "Setting up temporary /opt structure..."
|
||||
cp -r "${SRC_PATH}"/* "${TEMP_OPT}/"
|
||||
|
||||
# For RTI, also copy license file if it exists
|
||||
if [ "${PACKAGE_DIR_NAME}" = "rti-connext-dds" ]; then
|
||||
LICENSE_FILE="${SCRIPT_DIR}/../../rti_license.dat"
|
||||
if [ -f "${LICENSE_FILE}" ]; then
|
||||
echo "Including RTI license file in build..."
|
||||
cp "${LICENSE_FILE}" "${TEMP_OPT}/rti_license.dat"
|
||||
else
|
||||
echo "WARNING: RTI license file not found at ${LICENSE_FILE}"
|
||||
echo "The package will be built without the license file."
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Temporary /opt structure created at: ${TEMP_OPT}"
|
||||
echo ""
|
||||
|
||||
cd "${PACKAGE_DIR}"
|
||||
|
||||
# Clean previous builds
|
||||
echo "Cleaning previous build artifacts..."
|
||||
rm -rf debian/.debhelper debian/*.debhelper debian/files debian/substvars 2>/dev/null || true
|
||||
rm -f ../${PACKAGE_NAME}_*.deb 2>/dev/null || true
|
||||
|
||||
# Build package with OPT_BASE environment variable
|
||||
echo "Building package..."
|
||||
export DEB_BUILD_OPT_PATH="${TEMP_OPT_BASE}"
|
||||
echo "Using OPT_BASE: ${DEB_BUILD_OPT_PATH}"
|
||||
|
||||
# Create package build directory structure
|
||||
PKG_BUILD_DIR="debian/${PACKAGE_NAME}"
|
||||
rm -rf "${PKG_BUILD_DIR}"
|
||||
mkdir -p "${PKG_BUILD_DIR}/opt"
|
||||
|
||||
# Copy files from temporary /opt to package structure
|
||||
echo "Copying files to package structure..."
|
||||
cp -r "${TEMP_OPT_BASE}/${DIR_NAME}"/* "${PKG_BUILD_DIR}/"
|
||||
|
||||
# Create DEBIAN control directory
|
||||
mkdir -p "${PKG_BUILD_DIR}/DEBIAN"
|
||||
|
||||
# Generate control file
|
||||
cat > "${PKG_BUILD_DIR}/DEBIAN/control" << EOF
|
||||
Package: ${PACKAGE_NAME}
|
||||
Version: ${VERSION}
|
||||
Section: devel
|
||||
Priority: optional
|
||||
Architecture: amd64
|
||||
Maintainer: Legatus Team <legatus@defence-elec.de>
|
||||
Description: ${PACKAGE_NAME} for air-gapped environment
|
||||
Built from source in ./external/ directory
|
||||
EOF
|
||||
|
||||
# Generate changelog
|
||||
cat > "${PKG_BUILD_DIR}/DEBIAN/changelog" << EOF
|
||||
${PACKAGE_NAME} (${VERSION}) stable; urgency=medium
|
||||
|
||||
* Initial release for air-gapped environment
|
||||
* Built from ./external/ source directory
|
||||
|
||||
-- Legatus Team <legatus@defence-elec.de> $(date -R)
|
||||
EOF
|
||||
|
||||
# Set proper permissions
|
||||
chmod -R 755 "${PKG_BUILD_DIR}/DEBIAN"
|
||||
find "${PKG_BUILD_DIR}/opt" -type d -exec chmod 755 {} \;
|
||||
find "${PKG_BUILD_DIR}/opt" -type f -exec chmod 644 {} \;
|
||||
|
||||
# Build the package
|
||||
echo "Creating DEB package..."
|
||||
dpkg-deb --root-owner-group --build "${PKG_BUILD_DIR}" ../${PACKAGE_NAME}_${VERSION}_amd64.deb
|
||||
|
||||
# Clean up temporary structure
|
||||
echo "Cleaning up temporary /opt structure..."
|
||||
rm -rf "${TEMP_OPT_BASE}"
|
||||
|
||||
# Clean up build directory
|
||||
rm -rf "${PKG_BUILD_DIR}"
|
||||
|
||||
# Verify output
|
||||
DEB_FILE="${SCRIPT_DIR}/${PACKAGE_NAME}_${VERSION}_amd64.deb"
|
||||
if [ -f "${DEB_FILE}" ]; then
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "Build Successful!"
|
||||
echo "========================================"
|
||||
echo "Package: ${DEB_FILE}"
|
||||
echo "Size: $(du -h "${DEB_FILE}" | cut -f1)"
|
||||
echo ""
|
||||
echo "Package contents:"
|
||||
dpkg -c "${DEB_FILE}" | head -20
|
||||
echo ""
|
||||
echo "To upload to SCM repository:"
|
||||
echo " curl -u <credentials> --upload-file ${DEB_FILE} http://remote-repo.sl.defence-elec.de:8081/repository/external-rpms/general/"
|
||||
else
|
||||
echo "ERROR: Package file not found: ${DEB_FILE}"
|
||||
exit 1
|
||||
fi
|
||||
Reference in new issue
Block a user