#!/usr/bin/env bash set -euo pipefail # Usage: prepare_rpm.sh [PROJECT] [OS_VERSION] [LTS_VERSION] [GUEZ_MODE] # If PROJECT omitted, runs for Legatus, Guez, DemoTablet (in that order). PROJECTS=("Legatus" "Guez" "DemoTablet") PROJECT=${1:-} OS_VERSION=${2:-ubuntu24} LTS_VERSION=${3:-1.2.0} GUEZ_MODE=${4:-ON} REPO_DIR="$(pwd)" run_for_project() { local proj="$1" echo "Preparing RPM for project: $proj (OS=$OS_VERSION, LTS=$LTS_VERSION, GUEZ_MODE=$GUEZ_MODE)" export PROJECT_BASE_DIR="/tmp/${proj}_staging" rm -rf "$PROJECT_BASE_DIR" mkdir -p "$PROJECT_BASE_DIR" # Stage workspace similar to Jenkins: exclude rpms, .git, build tar --exclude='./rpms' --exclude='./.git' --exclude='./build' -cf - -C "$REPO_DIR" . | tar -xf - -C "$PROJECT_BASE_DIR" mkdir -p "$REPO_DIR/rpmbuild" pushd "$REPO_DIR/rpmbuild" >/dev/null python3 make_rpm.py -c LTS \ --project_name "$proj" \ --version "$LTS_VERSION" \ --output_dir "$REPO_DIR/rpms/${proj}/${OS_VERSION}/" \ --cmake_build_flags "-DUSE_IPO=ON -DUSE_UNITY_BUILD=ON -DGUEZ_MODE=${GUEZ_MODE} -DBUILD_WLS=ON -DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/pgsql/" popd >/dev/null echo "RPMs placed in: $REPO_DIR/rpms/${proj}/${OS_VERSION}/" } if [[ -n "$PROJECT" ]]; then run_for_project "$PROJECT" else for p in "${PROJECTS[@]}"; do run_for_project "$p" done fi