Files
MX_Pmodule/olex2/build
T
duan_j 1eb66c483b olex2: rewrite recipe for RHEL9 - official archive with GUI + olex2c
The official olex2-linux64.zip already ships both the GUI (olex2) and the
console build (olex2c) plus cctbx and a private CPython 3.8, so nothing is
compiled. Default prep downloads + sha256-verifies the zip (rolling file,
version carries the upstream SVN revision), install copies the vendor tree
flat into PREFIX and adds bin/olex2 + bin/olex2c launchers that reproduce
the vendor start env without running the unirun auto-updater.
2026-10-16 17:19:04 +02:00

73 lines
3.8 KiB
Python
Executable File

#!/usr/bin/env modbuild
# Olex2 - official open-source (BSD) Linux x86_64 distribution from OlexSys.
# https://www.olexsys.org/olex2/docs/getting-started/installing-olex2/
#
# Upstream ships NO installer and NOTHING to compile for Linux: a single
# olex2-linux64.zip that already contains
# olex2 GUI (wxWidgets) olex2c console/"headless" Olex2
# unirun vendor auto-updater (NOT used here) start vendor launcher (NOT used here)
# cctbx/ lib/ (private CPython 3.8 + libs) ilib/ util/ etc/ sample_data/ ...
# Default pbuild::prep downloads the zip (urls: in files/config.yaml), checks
# the pinned sha256 (shasums:) and copies it into SRC_DIR (unpacker: none).
# configure unzips, install copies the vendor tree 1:1 into $PREFIX (Olex2's
# BaseDir() is wherever the binaries sit) and adds $PREFIX/bin launchers.
#
# No errexit in modbuild hooks -> every critical step is die-guarded.
pbuild::configure() {
local -r zip="${SRC_DIR}/olex2-${V}-linux64.zip"
[[ -s "${zip}" ]] || std::die 42 "olex2: ${zip} not found - prep did not fetch it. \
Pre-stage the archive by hand as <distdir>/olex2-${V}-linux64.zip (see README) and re-run."
command -v unzip >/dev/null || std::die 42 "olex2: 'unzip' not on PATH on this build host"
# partial downloads reused from distfiles are the classic failure: test the archive first
unzip -tq "${zip}" >/dev/null || \
std::die 42 "olex2: archive is corrupt/truncated - rm <distdir>/olex2-${V}-linux64.zip and re-run"
# ~1 GB unpacked (cctbx + python + sample data); SRC_DIR is under --tmpdir
unzip -q -o "${zip}" -d "${SRC_DIR}" || std::die 42 "olex2: unzip failed (disk/quota at --tmpdir?)"
[[ -f "${SRC_DIR}/olex2/olex2c" && -f "${SRC_DIR}/olex2/olex2" ]] || \
std::die 42 "olex2: unexpected archive layout - expected ${SRC_DIR}/olex2/{olex2,olex2c}"
rm -f "${zip}"
}
pbuild::compile() {
:
}
pbuild::install() {
local -r src="${SRC_DIR}/olex2"
# 1. vendor tree, flat into $PREFIX (= BaseDir). Slow on /opt/psi: 12k files.
cp -a "${src}/." "${PREFIX}/" || std::die 42 "olex2: copying the vendor tree into ${PREFIX} failed"
# 2. zip loses nothing, but make sure the ELF binaries are executable and
# everything is world-readable on the shared install
chmod 755 "${PREFIX}"/{olex2,olex2c,unirun,start,NoSpherA2,hart,hart_mpi} 2>/dev/null || true
chmod -R a+rX "${PREFIX}" || true
# 3. never auto-update a shared, read-only install (vendor default is
# update=Always + ask_update=true, driven by unirun). Best effort - the
# launchers never call unirun anyway.
if [[ -f "${PREFIX}/usettings.dat" ]]; then
sed -i -e 's/^update=.*/update=Never/' -e 's/^ask_update=.*/ask_update=false/' \
"${PREFIX}/usettings.dat" || true
fi
# 4. launchers: $PREFIX/bin/olex2 (GUI) and $PREFIX/bin/olex2c (console).
# Two copies of one script (it dispatches on basename $0, so no symlinks).
# Only $PREFIX/bin goes on PATH - the raw binaries and the vendor
# 'start' (auto-updater) stay off it.
mkdir -p "${PREFIX}/bin"
install -m 755 "${BUILDBLOCK_DIR}/files/olex2-launcher" "${PREFIX}/bin/olex2" || \
std::die 42 "olex2: installing bin/olex2 launcher failed"
install -m 755 "${BUILDBLOCK_DIR}/files/olex2-launcher" "${PREFIX}/bin/olex2c" || \
std::die 42 "olex2: installing bin/olex2c launcher failed"
# 5. what the modulefile / launchers rely on
local f
for f in olex2 olex2c cctbx/cctbx_build/lib lib/libpython3.8.so.1.0 lib/python3.8 util/pyUtil/initpy.py bin/olex2c; do
[[ -e "${PREFIX}/${f}" ]] || std::die 42 "olex2: ${PREFIX}/${f} missing after install - module would be broken"
done
echo "olex2: installed upstream build '$(cat "${PREFIX}/version.txt" 2>/dev/null)' (tag $(cat "${PREFIX}/olex2.tag" 2>/dev/null))"
}