Files
duan_j ef1951d42a olex2: bundle image libs, run the cctbx first start at build time
- sysroot += libwebp, libdeflate, libtiff 4.6 (+libjpeg-turbo, jbigkit-libs,
  liblerc): from a NEEDED scan of every ELF object in the zip these are the
  libs RHEL8/9 lack at the required version (PIL _imaging, vendor
  libtiff.so.5, GUI binary libtiff.so.6).
- install step 9: run olex2c once as the owner so Olex2 writes
  cctbx/cctbx_build/libtbx_env into the shared prefix (its first-start cold
  start; users cannot write there). The upstream fable/sdrive.f error on
  that run is expected and documented: libtbx_env is pickled before it.
- install step 10: second start + refine of the sucrose sample; die if
  cctbx is still reported broken, warn on other errors.
- launcher: PYTHONNOUSERSITE=1.
2026-10-16 18:21:46 +02:00

59 lines
2.5 KiB
Bash

#!/bin/bash
# Olex2 launcher, installed by the MX Pmodule as BOTH
# $PREFIX/bin/olex2 (GUI)
# $PREFIX/bin/olex2c (console / "headless" Olex2)
# One script, two copies: it dispatches on its own file name.
#
# It reproduces the environment of the vendor "start" script that ships in
# olex2-linux64.zip, but deliberately does NOT run the "unirun" auto-updater:
# /opt/psi/MX is shared and read-only for users, updates are done by
# rebuilding the module (see README.md, "Adding a new version").
set -u
# $PREFIX/bin/<name> -> base = $PREFIX (= Olex2 BaseDir(): olex2, olex2c,
# cctbx/, lib/, ilib/, util/, etc/ all live there, vendor layout untouched)
here="$(cd -P "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)"
base="${here%/bin}"
exe="$(basename "$0")"
case "$exe" in
olex2|olex2c) ;;
*) echo "olex2-launcher: must be invoked as 'olex2' or 'olex2c', not '$exe'" >&2; exit 2 ;;
esac
[[ -x "$base/$exe" ]] || { echo "olex2-launcher: $base/$exe is missing or not executable (broken install?)" >&2; exit 1; }
# --- bundled glibc ---------------------------------------------------------
# The executables were patchelf'ed at build time to use $base/sysroot's
# ld.so + libc + libstdc++ via DT_RPATH. Nothing to export for that, and
# NEVER add $base/sysroot/... to LD_LIBRARY_PATH: every system tool Olex2
# spawns (sh, shelxl, editors) would then load the foreign libc and crash.
# The bundled glibc has no locale archive -> use its built-in C.UTF-8.
export LANG=C.UTF-8
export LC_ALL=C.UTF-8
# --- vendor 'start' environment ------------------------------------------
export OLEX2_CCTBX_DIR="$base/cctbx"
# cctbx sets signal handlers for FPE and does not handle them
export BOOST_ADAPTBX_FPE_DEFAULT=1
export BOOST_ADAPTBX_SIGNALS_DEFAULT=1
export OLEX2_GL_STEREO=FALSE
export OLEX2_GL_MULTISAMPLE=FALSE
export OLEX2_GL_DEPTH_BITS=16
export LD_LIBRARY_PATH="$base/lib:$base/ilib:$OLEX2_CCTBX_DIR/cctbx_build/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
# embedded CPython 3.8 (lib/python3.8, lib/libpython3.8.so.1.0)
export PYTHONHOME="$base"
# a PYTHONPATH inherited from another module/conda env would be imported by
# the embedded 3.8 interpreter and break it - never let it leak in; same for
# the user's ~/.local/lib/python3.8/site-packages
unset PYTHONPATH
export PYTHONNOUSERSITE=1
if [[ "$exe" == "olex2" ]]; then
# GUI only: software OpenGL avoids "Vulkan drivers missing" / GLX errors
# on display-less cluster nodes; users may override by pre-setting it to 0
export LIBGL_ALWAYS_SOFTWARE="${LIBGL_ALWAYS_SOFTWARE:-1}"
fi
exec "$base/$exe" "$@"