#!/usr/bin/env bash set -euo pipefail # build_grantlee.sh - try installing grantlee via apt, otherwise build from source QT_ROOT=${QT_ROOT:-/opt/Qt/6.8.3/gcc_64} INSTALL_PREFIX=${INSTALL_PREFIX:-/usr/local} echo "Attempting to install libgrantlee5 via apt..." if apt-get update && apt-get install -y --no-install-recommends libgrantlee5 libgrantlee5-dev; then echo "Installed libgrantlee5 from apt" exit 0 fi echo "libgrantlee not available via apt; building from source (steveire/grantlee)..." TMPDIR=$(mktemp -d) trap 'rm -rf "$TMPDIR"' EXIT cd "$TMPDIR" if ! git clone --depth 1 https://github.com/steveire/grantlee.git grantlee; then echo "Warning: failed to clone grantlee from github; network or access issue. Exiting gracefully." >&2 exit 0 fi mkdir -p grantlee/build cd grantlee/build cmake -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \ -DCMAKE_PREFIX_PATH="${QT_ROOT}:${INSTALL_PREFIX}" .. cmake --build . -- -j$(nproc) || true cmake --install . || true echo "Grantlee build script finished." exit 0