#!/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 /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 /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))" }