Files
muSRFlow/packaging/runtime/build-runtime-rpm.sh
salman 882f594d5a Pass validated runtime artifacts between Gitea build workflows
Fetch an explicit musrfit revision, compile and validate the scientific runtime, and upload its descriptor, archive, and diagnostics. Require a selected runtime workflow run for Linux packaging, verify restoration through the existing offline installer, and upload a complete package set without implicit release publishing.

Fix clean-container ROOT discovery, allow scoped CI container cleanup, support both fpm cache layouts, and cover artifact restoration and build contracts with regression tests.
2026-10-29 16:42:30 +01:00

62 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build the standalone ROOT + musrfit runtime as an rpm that installs the tree
# into /opt/musrflow/runtime, where the lean muSRFlow app discovers it.
set -euo pipefail
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
root="$(cd "$here/../.." && pwd)"
runtime_dir="${RUNTIME_DIR:-$root/runtime}"
out_dir="${OUT_DIR:-$root/dist}"
version="$(node -p "require('$root/package.json').version")"
# rpm versions may not contain '-'; electron-builder maps it to '~' so that a
# release candidate sorts before the final release.
rpm_version="$(printf '%s' "$version" | tr '-' '~')"
# Reject an incomplete or unloadable runtime before touching existing artifacts.
bash "$here/validate-runtime.sh" "$runtime_dir" --arch x86_64
cache="${ELECTRON_BUILDER_CACHE:-${XDG_CACHE_HOME:-$HOME/.cache}/electron-builder}"
find_fpm() {
if [ -n "${FPM_BIN:-}" ]; then
echo "$FPM_BIN"
return 0
fi
if command -v fpm >/dev/null 2>&1 && fpm --version >/dev/null 2>&1; then
command -v fpm
return 0
fi
local cached
cached="$(ls -1d "$cache"/fpm@*/fpm-*/fpm "$cache"/fpm/fpm-*/fpm 2>/dev/null | head -n1 || true)"
if [ -z "$cached" ]; then
echo "error: no working fpm found; run 'npm run dist:rpm' first or set FPM_BIN" >&2
return 1
fi
echo "$cached"
}
fpm="$(find_fpm)"
out="$out_dir/musrflow-runtime-${version}-x86_64.rpm"
mkdir -p "$out_dir"
rm -f "$out"
"$fpm" -s dir -t rpm \
--architecture x86_64 \
--name musrflow-runtime \
--version "$rpm_version" \
--iteration 1 \
--license "GPL-3.0-or-later" \
--vendor "Paul Scherrer Institute" \
--rpm-summary "ROOT + musrfit runtime for muSRFlow" \
--description "Relocatable ROOT and musrfit runtime used by muSRFlow when no system musrfit is installed. Installs into /opt/musrflow/runtime." \
--category "Applications/Science" \
--exclude .gitkeep \
--rpm-rpmbuild-define "_build_id_links none" \
--rpm-rpmbuild-define "_missing_build_ids_terminate_build 0" \
--package "$out" \
"$runtime_dir/=/opt/musrflow/runtime"
echo "Built $out"