diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml index f20eb30a..6d49a58d 100644 --- a/.github/workflows/ci_test.yml +++ b/.github/workflows/ci_test.yml @@ -189,7 +189,6 @@ jobs: --test eb_robot_paths \ --test easyblock_layers \ --test easyblock_owed \ - --test eessi_extend_eb_script \ --test extension_provides \ --test family_site_layer \ --test fetch_prs_script \ diff --git a/changelog.d/+cargo-prelude-eprefix.bugfix.md b/changelog.d/+cargo-prelude-eprefix.bugfix.md new file mode 100644 index 00000000..c9c9d1d3 --- /dev/null +++ b/changelog.d/+cargo-prelude-eprefix.bugfix.md @@ -0,0 +1 @@ +A step of the Cargo prelude that fails stops EasyBuild's install command again: the host triple is read inside the prelude's `&&` chain, not after `_triple="";`, whose semicolon ended the chain. A missing or failing `rustc` still leaves the triple empty, even under `pipefail`. diff --git a/changelog.d/+cargo-prelude-quoting.bugfix.md b/changelog.d/+cargo-prelude-quoting.bugfix.md new file mode 100644 index 00000000..17dfd768 --- /dev/null +++ b/changelog.d/+cargo-prelude-quoting.bugfix.md @@ -0,0 +1 @@ +The cargo-on-EESSI prelude quotes `CC` and `LIBRARY_PATH`. `CC='gcc; echo pwned'` is stored as the linker, and it is not run. diff --git a/changelog.d/+doctor-eessi-extend.bugfix.md b/changelog.d/+doctor-eessi-extend.bugfix.md new file mode 100644 index 00000000..a06a0c4b --- /dev/null +++ b/changelog.d/+doctor-eessi-extend.bugfix.md @@ -0,0 +1 @@ +`target doctor` passes the EasyBuild probe of a target with `EB_LOCAL_EESSI_EXTEND` on only when `--version` prints `This is EasyBuild`. eb-local 2.4.0 has no extend mode, answered `--version` itself and passed; the failed check now carries a `reason`. diff --git a/changelog.d/+eb-local-extend-version.doc.md b/changelog.d/+eb-local-extend-version.doc.md new file mode 100644 index 00000000..1403dea5 --- /dev/null +++ b/changelog.d/+eb-local-extend-version.doc.md @@ -0,0 +1 @@ +The EESSI target in `docs/orgmode/reference/targets.org` and `examples/targets/eessi-extend.toml` needs eb-local 2.5.0 or later, the first release with `EB_LOCAL_EESSI_EXTEND`. diff --git a/changelog.d/+gap-bump-source.bugfix.md b/changelog.d/+gap-bump-source.bugfix.md new file mode 100644 index 00000000..593bee93 --- /dev/null +++ b/changelog.d/+gap-bump-source.bugfix.md @@ -0,0 +1 @@ +`stack gap` picks the bump source of a `no-recipe` row among builds of the newest version by toolchain family and generation instead of file name: a build on a toolchain family of the generation comes first, then the newest toolchain generation, so QuantumESPRESSO 7.5 is bumped from `foss-2025b` rather than `NVHPC-25.3-CUDA-12.8.0`, and a recipe on `GCCcore-14.3.0` is preferred to one on `GCCcore-11.3.0`. diff --git a/changelog.d/+use-eb-local-eessi.removal.md b/changelog.d/+use-eb-local-eessi.removal.md new file mode 100644 index 00000000..56574f98 --- /dev/null +++ b/changelog.d/+use-eb-local-eessi.removal.md @@ -0,0 +1 @@ +The EESSI target runs `eb-local` with `EB_LOCAL_EESSI_EXTEND=1` instead of `scripts/eessi-extend-eb.sh`, and the script is removed. eb-stack does not build eb-local; the container bind-mounts the binary the operator installed. A present empty `EESSI_*_INSTALL` still counts as that mode, which `eb-local` enforces. With no `EESSI_*_INSTALL` set, installs move from the script's `$HOME/EESSI` to EESSI-extend's own `$HOME/eessi`; set `EESSI_USER_INSTALL` in `[targets.easybuild.environment]` to keep the old prefix. diff --git a/docs/orgmode/howto/eon-eessi-extend.org b/docs/orgmode/howto/eon-eessi-extend.org index f4934900..538ab2d8 100644 --- a/docs/orgmode/howto/eon-eessi-extend.org +++ b/docs/orgmode/howto/eon-eessi-extend.org @@ -57,7 +57,7 @@ the dependencies installed, a rebuild of eOn alone takes about 2.5 minutes. * Build eOn with the robot -~scripts/eessi-extend-eb.sh~ sources EESSI's init, loads ~EESSI-extend~, +~eb-local eb~ sources EESSI's init, loads ~EESSI-extend~, isolates Cargo from host wrappers, and execs ~eb~. On this checkout the build runs through the local Podman target, which invokes ~eb --robot~ on the planned eOn bundle. The bundle path has to sit under diff --git a/docs/orgmode/howto/module-gap.org b/docs/orgmode/howto/module-gap.org index a4b8e07a..7bd1fb29 100644 --- a/docs/orgmode/howto/module-gap.org +++ b/docs/orgmode/howto/module-gap.org @@ -20,6 +20,12 @@ A toolchain whose version is the generation counts as on it, so generation in ~data/eessi-generations.toml~, such as ~llvm-compilers-21.1.8~. +When the newest version has several builds, the bump source is one on a +toolchain family the generation uses, ~foss~ for ~foss-2026.1~, and of +those the one on the newest toolchain generation. QuantumESPRESSO 7.5 is +bumped from ~foss-2025b~, not from ~NVHPC-25.3-CUDA-12.8.0~ or +~foss-2025a~. + * Capture the live inventories The helper uses the shell's ~module~ function. diff --git a/docs/orgmode/howto/pypi-extend.org b/docs/orgmode/howto/pypi-extend.org index 331971e4..81fcca89 100644 --- a/docs/orgmode/howto/pypi-extend.org +++ b/docs/orgmode/howto/pypi-extend.org @@ -124,7 +124,8 @@ a residual, not a silent SAT edge. A PEP 518 ~build_system~ block with ~build-backend = mesonpy~ adds the listed build requirements and emits ~wrap_mode=default~ plus the same cargo-on-EESSI isolation prelude used by Cargo leftovers: drop host rustc wrappers, set -~LINKER=${CC:-gcc}~, put the EESSI compat ~ld~ on ~PATH~, and point +~LINKER="$CC"~ (an empty ~CC~ becomes ~gcc~, and the value is not +evaluated), put the EESSI compat ~ld~ on ~PATH~, and point ~RUSTFLAGS -B~ at that ~ld~. The cargo target triple and compat arch come from the build host (~rustc -vV~, ~uname -m~), not from a plan-time x86_64 literal. Hatchling and ~meson-python~ already on @@ -173,7 +174,8 @@ eb-stack campaign run \ ~examples/targets/eessi-extend.toml~ is the target whose runtime command is ~eessi_container.sh~. The local target above is the one this checkout -runs. ~scripts/eessi-extend-eb.sh~ is the wrapper that target execs. +runs. That EESSI target execs ~eb-local~ with ~EB_LOCAL_EESSI_EXTEND=1~, +which loads ~EESSI-extend~ and execs ~eb~. User one-offs stay as ~python -m venv --system-site-packages~ on EESSI Python. This workflow is for a shared site or project extra. diff --git a/docs/orgmode/reference/cli.org b/docs/orgmode/reference/cli.org index b43536a5..38386c9b 100644 --- a/docs/orgmode/reference/cli.org +++ b/docs/orgmode/reference/cli.org @@ -181,7 +181,9 @@ it. Do not hand-edit the emitted recipe for those names. A PEP 518 ~build_system~ object with ~build-backend = mesonpy~ is the mesonpy hint: listed ~requires~ become build deps in the Boolean satisfiability (SAT) solve, and the emitter writes ~wrap_mode=default~ plus the shared cargo-on-EESSI isolation prelude -(host wrappers off, ~LINKER=${CC:-gcc}~, compat ~ld~ from ~uname -m~). +(host wrappers off, ~LINKER="$CC"~ after an empty ~CC~ becomes ~gcc~, +compat ~ld~ from ~uname -m~). ~CC~ and ~LIBRARY_PATH~ stay quoted, so a +value in either is not run as shell. Hatchling stays a ~Python-bundle-PyPI~ module when the robot provides it. See [[file:../howto/pypi-extend.org][site Python extras]]. @@ -783,7 +785,9 @@ toolchain whose version is that generation, or on the system toolchain), ~open-easyconfigs~ (an ~--open-easyconfigs~ pull request adds a recipe at that generation; the match is the filename, and a toolchain version equal to ~--generation~ counts), or ~no-recipe~ (the newest easyconfig on any -toolchain is named as the bump source). ~--eessi-version~ keeps +toolchain is named as the bump source; between builds of that version, one +on a toolchain family of the generation comes first, then the one on the +newest toolchain generation). ~--eessi-version~ keeps ~--open-layer~ easystacks of that version; without it every easystack version counts. The command writes ~gap.tsv~, one TSV per route (~site-only.tsv~ for ~excluded~, ~bump.tsv~ for ~no-recipe~, and @@ -1926,7 +1930,9 @@ Target layers are applied in argument order. A complete target contains: environment. ~target doctor~ probes each layer separately and reports the exact routed -command, exit code, stdout, and stderr. +command, exit code, stdout, and stderr, and a ~reason~ when a probe that +exited 0 still failed. With ~EB_LOCAL_EESSI_EXTEND~ on, the EasyBuild probe +passes only when ~--version~ prints ~This is EasyBuild~. See [[file:targets.org][build target configuration]] for complete layer schemas, replacement semantics, ABI isolation, and the runnable local Podman target. diff --git a/docs/orgmode/reference/targets.org b/docs/orgmode/reference/targets.org index a79bbd8e..b79dfb8d 100644 --- a/docs/orgmode/reference/targets.org +++ b/docs/orgmode/reference/targets.org @@ -31,7 +31,11 @@ eb-stack target doctor \ ~target doctor~ independently executes transport, executor, runtime, and EasyBuild probes. A reachable SSH host is not enough; all four checks must -succeed. +succeed. When ~[targets.easybuild.environment]~ turns on +~EB_LOCAL_EESSI_EXTEND~ (set, not empty, not ~0~), exit 0 is not enough +either: ~--version~ must print EasyBuild's ~This is EasyBuild~ line. An +eb-local without extend mode answers ~--version~ itself, and the check then +fails with a ~reason~. * Transport @@ -73,11 +77,15 @@ The ~eessi~ runtime is the install backend for site/user/project overlays. It launches ~eessi_container.sh --mode exec~, fuse-mounts CernVM File System (CVMFS) inside the image, and does not use the host CVMFS client. Plan ~package plan --format pypi|cran~ on the host: the host ~eb-stack~ binary need not run in the -Debian 12 image. ~scripts/eessi-extend-eb.sh~ sources the European Environment for Scientific Software Installations (EESSI) init script, loads -~EESSI-extend~, and execs ~eb~. See ~examples/targets/eessi-extend.toml~. +Debian 12 image. The EasyBuild command is ~eb-local~ with +~EB_LOCAL_EESSI_EXTEND=1~: that sources the European Environment for Scientific Software Installations (EESSI) init script, loads +~EESSI-extend~, and execs ~eb~. Bind the ~eb-local~ binary into the container; +eb-stack does not build it. That mode needs eb-local 2.5.0 or later: 2.4.0 +and older ignore ~EB_LOCAL_EESSI_EXTEND~ and answer ~--version~ themselves, +and ~target doctor~ fails the target. See ~examples/targets/eessi-extend.toml~. Set exactly one of ~EESSI_USER_INSTALL~, ~EESSI_PROJECT_INSTALL~, ~EESSI_SITE_INSTALL~, or ~EESSI_CVMFS_INSTALL~ in -~[targets.easybuild.environment]~. +~[targets.easybuild.environment]~. A present empty value counts as set. Compiled modules, build trees, and temporary files belong to one runtime ABI. Do not reuse a host or different-image install prefix inside a container. diff --git a/examples/targets/eessi-extend.toml b/examples/targets/eessi-extend.toml index 6e2875b0..e557cdbd 100644 --- a/examples/targets/eessi-extend.toml +++ b/examples/targets/eessi-extend.toml @@ -4,12 +4,20 @@ schema_version = 1 # Plan on the host (`package plan --format pypi|cran`). This target is the # install backend: the host eb-stack binary does not need to run in Debian 12. # -# Set exactly one prefix before campaign run, via environment here: +# Set exactly one prefix before campaign run, via environment here. +# A present empty value counts as set, as it does for EESSI-extend: # EESSI_USER_INSTALL (default below) # EESSI_PROJECT_INSTALL # EESSI_SITE_INSTALL=1 plus EESSI_SITE_SOFTWARE_PREFIX in the site layer +# EESSI_CVMFS_INSTALL # -# Bind the planned bundle and this install prefix into the container. +# Bind eb-local, the planned bundle and this install prefix into the +# container. eb-stack does not build eb-local; the operator installs it. +# EB_LOCAL_EESSI_EXTEND=1 makes that one program load EESSI-extend and +# exec eb, because a target command is a single executable. That mode +# needs eb-local 2.5.0 or later. 2.4.0 and older ignore the variable and +# answer --version themselves, so `eb-stack target doctor` fails the +# target until eb-local is upgraded. [[targets]] name = "eessi-extend-user" @@ -26,17 +34,18 @@ command = "eessi_container.sh" storage = "/tmp/eb-stack-eessi/storage" access = "ro" extra_bind_paths = [ - "scripts/eessi-extend-eb.sh:/usr/local/bin/eessi-extend-eb.sh:ro", + "/usr/local/bin/eb-local:/usr/local/bin/eb-local:ro", "/tmp/eb-stack-eessi:/tmp/eb-stack-eessi:rw", ] [targets.easybuild] -command = "/usr/local/bin/eessi-extend-eb.sh" +command = "/usr/local/bin/eb-local" robot_paths = [] work_root = "/tmp/eb-stack-eessi/work" tmp_root = "/tmp/eb-stack-eessi/tmp" [targets.easybuild.environment] +EB_LOCAL_EESSI_EXTEND = "1" EESSI_VERSION = "2026.06" EESSI_USER_INSTALL = "/tmp/eb-stack-eessi/install" WORKING_DIR = "/tmp" diff --git a/llms-full.txt b/llms-full.txt index 7cb9a62a..a8063562 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -1288,7 +1288,8 @@ a residual, not a silent SAT edge. A PEP 518 `build_system` block with `build-backend = mesonpy` adds the listed build requirements and emits `wrap_mode=default` plus the same cargo-on-EESSI isolation prelude used by Cargo leftovers: drop host rustc wrappers, set -`LINKER=${CC:-gcc}`, put the EESSI compat `ld` on `PATH`, and point +`LINKER="$CC"` (an empty `CC` becomes `gcc`, and the value is not +evaluated), put the EESSI compat `ld` on `PATH`, and point `RUSTFLAGS -B` at that `ld`. The cargo target triple and compat arch come from the build host (`rustc -vV`, `uname -m`), not from a plan-time x86_64 literal. Hatchling and `meson-python` already on @@ -1337,7 +1338,8 @@ eb-stack campaign run \ `examples/targets/eessi-extend.toml` is the target whose runtime command is `eessi_container.sh`. The local target above is the one this checkout -runs. `scripts/eessi-extend-eb.sh` is the wrapper that target execs. +runs. That EESSI target execs `eb-local` with `EB_LOCAL_EESSI_EXTEND=1`, +which loads `EESSI-extend` and execs `eb`. User one-offs stay as `python -m venv --system-site-packages` on EESSI Python. This workflow is for a shared site or project extra. @@ -1566,7 +1568,7 @@ the dependencies installed, a rebuild of eOn alone takes about 2.5 minutes. # Build eOn with the robot -`scripts/eessi-extend-eb.sh` sources EESSI's init, loads `EESSI-extend`, +`eb-local eb` sources EESSI's init, loads `EESSI-extend`, isolates Cargo from host wrappers, and execs `eb`. On this checkout the build runs through the local Podman target, which invokes `eb --robot` on the planned eOn bundle. The bundle path has to sit under @@ -4586,6 +4588,12 @@ A toolchain whose version is the generation counts as on it, so generation in `data/eessi-generations.toml`, such as `llvm-compilers-21.1.8`. +When the newest version has several builds, the bump source is one on a +toolchain family the generation uses, `foss` for `foss-2026.1`, and of +those the one on the newest toolchain generation. QuantumESPRESSO 7.5 is +bumped from `foss-2025b`, not from `NVHPC-25.3-CUDA-12.8.0` or +`foss-2025a`. + # Capture the live inventories The helper uses the shell's `module` function. @@ -6885,7 +6893,9 @@ it. Do not hand-edit the emitted recipe for those names. A PEP 518 `build_system` object with `build-backend = mesonpy` is the mesonpy hint: listed `requires` become build deps in the Boolean satisfiability (SAT) solve, and the emitter writes `wrap_mode=default` plus the shared cargo-on-EESSI isolation prelude -(host wrappers off, `LINKER=${CC:-gcc}`, compat `ld` from `uname -m`). +(host wrappers off, `LINKER="$CC"` after an empty `CC` becomes `gcc`, +compat `ld` from `uname -m`). `CC` and `LIBRARY_PATH` stay quoted, so a +value in either is not run as shell. Hatchling stays a `Python-bundle-PyPI` module when the robot provides it. See [site Python extras](https://eb-stack.rgoswami.me/../howto/pypi-extend.html.md). @@ -7486,7 +7496,9 @@ toolchain whose version is that generation, or on the system toolchain), `open-easyconfigs` (an `--open-easyconfigs` pull request adds a recipe at that generation; the match is the filename, and a toolchain version equal to `--generation` counts), or `no-recipe` (the newest easyconfig on any -toolchain is named as the bump source). `--eessi-version` keeps +toolchain is named as the bump source; between builds of that version, one +on a toolchain family of the generation comes first, then the one on the +newest toolchain generation). `--eessi-version` keeps `--open-layer` easystacks of that version; without it every easystack version counts. The command writes `gap.tsv`, one TSV per route (`site-only.tsv` for `excluded`, `bump.tsv` for `no-recipe`, and @@ -8629,7 +8641,9 @@ Target layers are applied in argument order. A complete target contains: environment. `target doctor` probes each layer separately and reports the exact routed -command, exit code, stdout, and stderr. +command, exit code, stdout, and stderr, and a `reason` when a probe that +exited 0 still failed. With `EB_LOCAL_EESSI_EXTEND` on, the EasyBuild probe +passes only when `--version` prints `This is EasyBuild`. See [build target configuration](https://eb-stack.rgoswami.me/targets.html.md) for complete layer schemas, replacement semantics, ABI isolation, and the runnable local Podman target. @@ -9854,7 +9868,11 @@ eb-stack target doctor \ `target doctor` independently executes transport, executor, runtime, and EasyBuild probes. A reachable SSH host is not enough; all four checks must -succeed. +succeed. When `[targets.easybuild.environment]` turns on +`EB_LOCAL_EESSI_EXTEND` (set, not empty, not `0`), exit 0 is not enough +either: `--version` must print EasyBuild's `This is EasyBuild` line. An +eb-local without extend mode answers `--version` itself, and the check then +fails with a `reason`. # Transport @@ -9896,11 +9914,15 @@ The `eessi` runtime is the install backend for site/user/project overlays. It launches `eessi_container.sh --mode exec`, fuse-mounts CernVM File System (CVMFS) inside the image, and does not use the host CVMFS client. Plan `package plan --format pypi|cran` on the host: the host `eb-stack` binary need not run in the -Debian 12 image. `scripts/eessi-extend-eb.sh` sources the European Environment for Scientific Software Installations (EESSI) init script, loads -`EESSI-extend`, and execs `eb`. See `examples/targets/eessi-extend.toml`. +Debian 12 image. The EasyBuild command is `eb-local` with +`EB_LOCAL_EESSI_EXTEND=1`: that sources the European Environment for Scientific Software Installations (EESSI) init script, loads +`EESSI-extend`, and execs `eb`. Bind the `eb-local` binary into the container; +eb-stack does not build it. That mode needs eb-local 2.5.0 or later: 2.4.0 +and older ignore `EB_LOCAL_EESSI_EXTEND` and answer `--version` themselves, +and `target doctor` fails the target. See `examples/targets/eessi-extend.toml`. Set exactly one of `EESSI_USER_INSTALL`, `EESSI_PROJECT_INSTALL`, `EESSI_SITE_INSTALL`, or `EESSI_CVMFS_INSTALL` in -`[targets.easybuild.environment]`. +`[targets.easybuild.environment]`. A present empty value counts as set. Compiled modules, build trees, and temporary files belong to one runtime ABI. Do not reuse a host or different-image install prefix inside a container. diff --git a/scripts/eessi-extend-eb.sh b/scripts/eessi-extend-eb.sh deleted file mode 100755 index a8adf797..00000000 --- a/scripts/eessi-extend-eb.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# Load EESSI-extend and exec EasyBuild. Runs inside eessi_container.sh. -# EESSI init is not nounset-safe. -set -eo pipefail - -# EESSI_CVMFS_REPO names a mirror or another EESSI repository. -repo=${EESSI_CVMFS_REPO:-/cvmfs/software.eessi.io} -ver=${EESSI_VERSION:-2026.06} -init=${repo}/versions/${ver}/init/lmod/bash -if [[ ! -e $init ]]; then - echo "eessi-extend-eb: missing ${init}" >&2 - exit 2 -fi -# shellcheck disable=SC1090 -source "$init" - -# Exactly one prefix variable; the module reads them at load time. -# EESSI-extend uses os.getenv(name) ~= nil, so a present empty value is -# set. An empty EESSI_SITE_INSTALL is site mode. Counting only non-empty -# values also exported EESSI_USER_INSTALL, and the module refused both. -n=0 -[[ -v EESSI_USER_INSTALL ]] && n=$((n + 1)) -[[ -v EESSI_PROJECT_INSTALL ]] && n=$((n + 1)) -[[ -v EESSI_SITE_INSTALL ]] && n=$((n + 1)) -[[ -v EESSI_CVMFS_INSTALL ]] && n=$((n + 1)) -if [[ $n -gt 1 ]]; then - echo "eessi-extend-eb: set exactly one of EESSI_USER_INSTALL, EESSI_PROJECT_INSTALL, EESSI_SITE_INSTALL, EESSI_CVMFS_INSTALL" >&2 - exit 3 -fi -# EESSI-extend refuses a user prefix that does not exist. Project and -# site prefixes need their group and modes set by an owner, so they are -# not created here. -if [[ $n -eq 0 ]]; then - export EESSI_USER_INSTALL=$HOME/EESSI -fi -if [[ -n ${EESSI_USER_INSTALL:-} ]]; then - mkdir -p "$EESSI_USER_INSTALL" -fi - -export WORKING_DIR=${WORKING_DIR:-/tmp} -# Host Cargo/CMake wrappers are not in the EESSI module graph. Same -# contract as cargo::eessi_cargo_host_isolation (triple and compat arch -# from the build host). CMAKE launchers stay here: they are not cargo. -unset RUSTC_WRAPPER CARGO_BUILD_RUSTC_WRAPPER RUSTC_WORKSPACE_WRAPPER RUSTFLAGS CARGO_ENCODED_RUSTFLAGS \ - CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER CMAKE_Fortran_COMPILER_LAUNCHER || true -eval "$(env | awk -F= '/^CARGO_TARGET_[A-Z0-9_]*_(LINKER|RUSTFLAGS)=/{print "unset "$1}')" -export LINKER=${CC:-gcc} -# rustc is absent for an ordinary EasyBuild run. A failing command -# substitution under pipefail would exit before module load. -_triple="" -if _host=$(rustc -vV 2>/dev/null); then - _triple=$(printf '%s\n' "$_host" | awk '/^host:/{print $2}') -fi -_triple_env=$(printf %s "${_triple}" | tr '[:lower:]-' '[:upper:]_') -if [[ -n ${_triple_env} ]]; then - eval "export CARGO_TARGET_${_triple_env}_LINKER=\${CC:-gcc}" -fi -# foss wrappers can drop the compat-layer ld that collect2 needs. The -# init above sets EESSI_EPREFIX to the compat layer it loaded. -_arch=$(uname -m) -export PATH="${EESSI_EPREFIX:-${repo}/versions/${ver}/compat/linux/${_arch}}/usr/bin:${PATH}" -module load EESSI-extend -exec eb "$@" diff --git a/skills/eessi-extend/SKILL.md b/skills/eessi-extend/SKILL.md index bb0008c9..0e3ab445 100644 --- a/skills/eessi-extend/SKILL.md +++ b/skills/eessi-extend/SKILL.md @@ -408,8 +408,8 @@ eb-stack campaign run \ --state /tmp/site-extra.campaign.json ``` -`kind = "eessi"` launches `eessi_container.sh`. `scripts/eessi-extend-eb.sh` -loads `EESSI-extend` and execs `eb`. Site installs set `EESSI_SITE_INSTALL=1` +`kind = "eessi"` launches `eessi_container.sh`. `eb-local` with +`EB_LOCAL_EESSI_EXTEND=1` loads `EESSI-extend` and execs `eb`. Site installs set `EESSI_SITE_INSTALL=1` in the target environment layer. `exts_list` on `SciPy-bundle` / `Python-bundle-PyPI` / `R-bundle-CRAN` is a Resolvo provide: do not reinstall numpy or a CRAN package the stack already ships. diff --git a/src/cargo.rs b/src/cargo.rs index d7179070..f511e3c9 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -22,22 +22,31 @@ use std::collections::BTreeMap; /// target triple and compat arch come from the build host (`rustc -vV`, /// `uname -m`), not from a plan-time x86_64 literal. Cargo leftovers and /// mesonpy wraps that invoke cargo both emit this string. +/// +/// The compat layer is `EESSI_EPREFIX`, which the EESSI init exports. +/// Without it the path is rebuilt from `EESSI_CVMFS_REPO`, so a mirror keeps +/// its own layer, and `EESSI_VERSION` (default 2026.06). The triple is +/// best-effort: a missing or failing `rustc` leaves it empty, even under +/// `pipefail`, instead of ending the chain before the compat `ld` is on +/// `PATH`. pub fn eessi_cargo_host_isolation() -> &'static str { concat!( "unset RUSTC_WRAPPER CARGO_BUILD_RUSTC_WRAPPER RUSTC_WORKSPACE_WRAPPER RUSTFLAGS CARGO_ENCODED_RUSTFLAGS && ", r#"eval $(env | awk -F= '/^CARGO_TARGET_[A-Z0-9_]*_(LINKER|RUSTFLAGS)=/{print "unset "$1}') && "#, "export CARGO_HOME=%(builddir)s/.cargohome && ", - "export LINKER=${CC:-gcc} && ", - // An ordinary recipe has no rustc. The host triple is best-effort, - // the same way scripts/eessi-extend-eb.sh discovers it, so a missing - // compiler does not drop the compat-layer linker from PATH. - r#"_triple=""; if _host=$(rustc -vV 2>/dev/null); then _triple=$(printf '%s\n' "$_host" | awk '/^host:/{print $2}'); fi && "#, - r#"_triple_env=$(printf %s "$_triple" | tr "[:lower:]-" "[:upper:]_") && "#, - r#"if [ -n "$_triple_env" ]; then eval export CARGO_TARGET_${_triple_env}_LINKER=${CC:-gcc}; fi && "#, + // CC and LIBRARY_PATH are data. An unquoted expansion is reparsed by + // `eval`, so `CC='gcc; echo pwned'` would run. Default an empty CC, + // keep the value quoted, and only allow a triple that is a variable name. + r#"if [ -z "${CC:-}" ]; then CC=gcc; fi && "#, + r#"export LINKER="$CC" && "#, + r#"_triple= && if _host=$(rustc -vV 2>/dev/null); then _triple=$(printf '%s\n' "$_host" | awk '/^host:/{print $2}'); fi && "#, + r#"_triple_env=$(printf %s "$_triple" | tr "[:lower:]-" "[:upper:]_" | tr -cd 'A-Z0-9_') && "#, + r#"if [ -n "$_triple_env" ]; then eval "export CARGO_TARGET_${_triple_env}_LINKER=\"\$CC\""; fi && "#, r#"_arch=$(uname -m) && "#, r#"_ebld=${EESSI_EPREFIX:-${EESSI_CVMFS_REPO:-/cvmfs/software.eessi.io}/versions/${EESSI_VERSION:-2026.06}/compat/linux/${_arch}}/usr/bin && "#, r#"export PATH="$_ebld:$PATH" && "#, - r#"export RUSTFLAGS="-C link-arg=-B$_ebld $(printf -- '-L %s ' $(echo ${LIBRARY_PATH:-} | tr ':' ' '))" && "#, + r#"_rlibs= && _ifs="$IFS" && IFS=: && set -f && for _dir in ${LIBRARY_PATH:-}; do [ -n "$_dir" ] || continue; _rlibs="${_rlibs} -L ${_dir}"; done && IFS="$_ifs" && set +f && "#, + r#"export RUSTFLAGS="-C link-arg=-B$_ebld${_rlibs}" && "#, ) } @@ -506,6 +515,44 @@ pyo3 = "0.22" assert!(!recipe.dependencies.iter().any(|dep| dep.name == "Python")); } + #[test] + fn eessi_cargo_isolation_puts_the_compat_layer_on_path_without_rustc() { + // A shell function, not a file on PATH: it shadows any installed rustc, + // and this multi-threaded test binary writes no executable to run. + let script = format!( + "set -o pipefail; rustc() {{ return 127; }}; {}printf '%s\\n' \"$PATH\"\n", + eessi_cargo_host_isolation().replace("%(builddir)s", "/tmp") + ); + let first_path_entry = |name: &str, value: &str| { + let out = std::process::Command::new("bash") + .arg("-c") + .arg(&script) + .env_remove("EESSI_EPREFIX") + .env_remove("EESSI_CVMFS_REPO") + .env_remove("EESSI_VERSION") + .env(name, value) + .output() + .expect("bash"); + assert!( + out.status.success(), + "a failing rustc ended the prelude:\n{}", + String::from_utf8_lossy(&out.stderr) + ); + let stdout = String::from_utf8_lossy(&out.stdout).into_owned(); + stdout.split(':').next().unwrap_or_default().to_string() + }; + assert_eq!( + first_path_entry("EESSI_EPREFIX", "/compat"), + "/compat/usr/bin" + ); + let mirror = first_path_entry("EESSI_CVMFS_REPO", "/mirror"); + assert!( + mirror.starts_with("/mirror/versions/2026.06/compat/linux/") + && mirror.ends_with("/usr/bin"), + "{mirror}" + ); + } + #[test] fn eessi_cargo_isolation_is_host_derived_not_x86_64() { let prelude = eessi_cargo_host_isolation(); @@ -518,10 +565,38 @@ pyo3 = "0.22" "a missing rustc must not abort the prelude" ); assert!(prelude.contains("link-arg=-B")); - assert!(prelude.contains("LINKER=${CC:-gcc}")); + assert!(prelude.contains("export LINKER=\"$CC\"")); + assert!(prelude.contains("tr -cd 'A-Z0-9_'")); + assert!(!prelude.contains("LINKER=${CC:-gcc}")); assert!( !prelude.contains("X86_64"), "triple and compat arch are runtime, not a plan-time x86_64 literal:\n{prelude}" ); } + + #[test] + fn eessi_cargo_isolation_does_not_run_a_command_hidden_in_cc() { + let prelude = eessi_cargo_host_isolation(); + // EasyBuild substitutes %(builddir)s before the shell sees the line. + // A raw parenthesis is a syntax error, so the substitution has to + // happen here too or the injection never runs. + let script = format!("{} true\n", prelude.replace("%(builddir)s", "/tmp")); + let out = std::process::Command::new("bash") + .arg("-c") + .arg(&script) + .env("CC", "gcc; echo CC_PWNED") + .env("LIBRARY_PATH", "/usr/lib") + .output() + .expect("bash"); + let text = format!( + "{}{}", + String::from_utf8_lossy(&out.stdout), + String::from_utf8_lossy(&out.stderr) + ); + assert!( + out.status.success() && !text.contains("CC_PWNED"), + "status {:?} prelude injected or failed:\nPRELUDE {prelude}\nOUT {text}", + out.status + ); + } } diff --git a/src/gap.rs b/src/gap.rs index d08856f1..66a5165f 100644 --- a/src/gap.rs +++ b/src/gap.rs @@ -34,7 +34,9 @@ pub struct GapRow { #[serde(skip_serializing_if = "Option::is_none")] pub recipe: Option, /// The newest easyconfig of the name on any toolchain, for `no-recipe`: - /// the source a bump starts from. + /// the source a bump starts from. Between builds of one version, one on + /// a toolchain family of the generation, then on the newest toolchain + /// generation, is named. #[serde(skip_serializing_if = "Option::is_none")] pub newest_elsewhere: Option, /// Why a name is `excluded` or `filtered`, or the pull requests that @@ -198,17 +200,62 @@ fn on_generation(candidate: &Candidate, generation: &str, members: &[String]) -> /// Order candidates newest first: version, then a recipe without a /// versionsuffix before one with, then by file name. fn newest_first(a: &&Candidate, b: &&Candidate) -> Ordering { - cmp_version(&b.version, &a.version) - .then_with(|| { - a.versionsuffix - .as_deref() - .unwrap_or("") - .len() - .cmp(&b.versionsuffix.as_deref().unwrap_or("").len()) + newer_build(a, b).then_with(|| file_of(a).cmp(&file_of(b))) +} + +/// Order bump sources as [`newest_first`], except that between builds of +/// one version a toolchain of a family the generation uses comes first, +/// then the newer toolchain generation, then the newer toolchain of one +/// name. Versions of two toolchain names are not compared: GCC 14.3.0 and +/// foss 2025b do not count the same way. +fn bump_source_first( + a: &Candidate, + b: &Candidate, + members: &[String], + generations: &BTreeMap>, +) -> Ordering { + let generation = |candidate: &Candidate| { + generations + .get(&toolchain_label(candidate)) + .cloned() + .flatten() + }; + newer_build(a, b) + .then_with(|| in_member_family(b, members).cmp(&in_member_family(a, members))) + .then_with(|| match (generation(a), generation(b)) { + (Some(left), Some(right)) => cmp_version(&right, &left), + (Some(_), None) => Ordering::Less, + (None, Some(_)) => Ordering::Greater, + (None, None) => Ordering::Equal, }) + .then_with(|| a.toolchain.name.cmp(&b.toolchain.name)) + .then_with(|| cmp_version(&b.toolchain.version, &a.toolchain.version)) .then_with(|| file_of(a).cmp(&file_of(b))) } +fn newer_build(a: &Candidate, b: &Candidate) -> Ordering { + cmp_version(&b.version, &a.version).then_with(|| { + a.versionsuffix + .as_deref() + .unwrap_or("") + .len() + .cmp(&b.versionsuffix.as_deref().unwrap_or("").len()) + }) +} + +/// Whether the candidate's toolchain name is the name of a member label, +/// `foss` for `foss-2026.1`. +fn in_member_family(candidate: &Candidate, members: &[String]) -> bool { + let name = candidate.toolchain.name.as_str(); + members.iter().any(|label| { + label == name + || label + .strip_prefix(name) + .and_then(|rest| rest.strip_prefix('-')) + .is_some_and(|version| version.starts_with(|c: char| c.is_ascii_digit())) + }) +} + fn reason_for<'a>(map: &'a BTreeMap, name: &str) -> Option<&'a str> { if let Some(reason) = map.get(name) { return Some(reason.as_str()); @@ -267,6 +314,8 @@ pub fn gap(input: &GapInput<'_>) -> Vec { .or_default() .push(candidate); } + let table = crate::generation_lint::GenerationTable::bundled().ok(); + let mut generations: BTreeMap> = BTreeMap::new(); let mut rows = Vec::new(); for name in input.site { if stack_lower.contains(&name.to_lowercase()) { @@ -316,13 +365,18 @@ pub fn gap(input: &GapInput<'_>) -> Vec { )); continue; } - rows.push(row( - name, - "no-recipe", - None, - all.first().map(|candidate| file_of(candidate)), - None, - )); + for candidate in &all { + generations + .entry(toolchain_label(candidate)) + .or_insert_with_key(|label| { + table.as_ref().and_then(|table| table.generation_of(label)) + }); + } + let source = all + .iter() + .copied() + .min_by(|a, b| bump_source_first(a, b, input.members, &generations)); + rows.push(row(name, "no-recipe", None, source.map(file_of), None)); } rows } @@ -791,6 +845,76 @@ mod tests { ); } + #[test] + fn an_equal_version_prefers_the_generation_toolchain_family() { + let site = names_from_listing("QuantumESPRESSO\n"); + let candidates = vec![ + cand( + "QuantumESPRESSO", + "7.5", + ("NVHPC", "25.3-CUDA-12.8.0"), + None, + ), + cand("QuantumESPRESSO", "7.5", ("foss", "2025a"), None), + cand("QuantumESPRESSO", "7.5", ("lfoss", "2025b"), None), + cand("QuantumESPRESSO", "7.5", ("foss", "2025b"), None), + cand("QuantumESPRESSO", "7.4.1", ("foss", "2025a"), None), + ]; + let rows = classify( + &site, + &BTreeSet::new(), + &candidates, + &BTreeMap::new(), + &BTreeSet::new(), + &BTreeMap::new(), + &BTreeMap::new(), + ); + assert_eq!(rows[0].route, "no-recipe"); + assert_eq!( + rows[0].newest_elsewhere.as_deref(), + Some("QuantumESPRESSO-7.5-foss-2025b.eb") + ); + } + + #[test] + fn an_equal_version_prefers_the_newest_toolchain_generation() { + let site = names_from_listing("X\n"); + let candidates = vec![ + cand("X", "1.0", ("foss", "2023a"), None), + cand("X", "1.0", ("GCCcore", "11.3.0"), None), + cand("X", "1.0", ("GCC", "14.3.0"), None), + cand("X", "1.0", ("GCC", "13.2.0"), None), + ]; + let rows = classify( + &site, + &BTreeSet::new(), + &candidates, + &BTreeMap::new(), + &BTreeSet::new(), + &BTreeMap::new(), + &BTreeMap::new(), + ); + assert_eq!( + rows[0].newest_elsewhere.as_deref(), + Some("X-1.0-GCC-14.3.0.eb") + ); + } + + #[test] + fn a_member_family_is_the_toolchain_name_of_a_member() { + let members = ["GCCcore-15.2.0", "foss-2026.1", "llvm-compilers-21.1.8"].map(String::from); + let on = |name: &str| { + in_member_family(&cand("X", "1", (name, "2025b"), None), members.as_slice()) + }; + assert!(on("foss")); + assert!(on("GCCcore")); + assert!(on("llvm-compilers")); + assert!(!on("GCC")); + assert!(!on("fos")); + assert!(!on("llvm")); + assert!(!on("NVHPC")); + } + #[test] fn routes_each_site_package() { let site = names_from_listing("BLAST+/2.16.0-gompi-2024a\nLAMMPS\nJulia/1.10.4\nCP2K/2025.2-foss-2025a\nMATLAB/2025b\nzlib/1.3.1\n"); diff --git a/src/target.rs b/src/target.rs index 674f8678..ac207d07 100644 --- a/src/target.rs +++ b/src/target.rs @@ -225,6 +225,9 @@ pub struct DoctorCheck { pub stdout: String, /// Captured standard error. pub stderr: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + /// Why a probe that exited 0 still failed. + pub reason: Option, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] @@ -669,6 +672,15 @@ printf 'arch=%s\ncpu_model=%s\n' "$arch" "$cpu_model" }) } + /// Whether the target sets eb-local's extend mode, read as eb-local + /// reads it: present, not empty, and not `0`. + fn engages_eb_local_eessi_extend(&self) -> bool { + self.easybuild + .environment + .get("EB_LOCAL_EESSI_EXTEND") + .is_some_and(|value| !value.is_empty() && value != "0") + } + fn compiler_wrapper_env_unsets(&self) -> Vec { let mut names: BTreeSet = BTreeSet::new(); names.insert("RUSTC_WRAPPER".into()); @@ -868,6 +880,7 @@ pub fn doctor_target(target: &BuildTarget) -> Result Result Result DoctorCheck { @@ -893,6 +931,7 @@ fn run_doctor_check(layer: &str, command: CommandPlan) -> DoctorCheck { exit_code: output.status.code(), stdout: String::from_utf8_lossy(&output.stdout).into_owned(), stderr: String::from_utf8_lossy(&output.stderr).into_owned(), + reason: None, command, }, Err(error) => DoctorCheck { @@ -901,6 +940,7 @@ fn run_doctor_check(layer: &str, command: CommandPlan) -> DoctorCheck { exit_code: None, stdout: String::new(), stderr: error.to_string(), + reason: None, command, }, } diff --git a/tests/eessi_extend_eb_script.rs b/tests/eessi_extend_eb_script.rs deleted file mode 100644 index df30d1d2..00000000 --- a/tests/eessi_extend_eb_script.rs +++ /dev/null @@ -1,173 +0,0 @@ -//! scripts/eessi-extend-eb.sh against a fake EESSI repository: an init -//! that defines `module` and sets EESSI_EPREFIX, and an `eb` that prints -//! the environment it was given. - -use std::fs; -use std::os::unix::fs::PermissionsExt; -use std::path::{Path, PathBuf}; -use std::process::{Command, Output}; - -fn script() -> PathBuf { - PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("scripts/eessi-extend-eb.sh") -} - -struct Fake { - dir: tempfile::TempDir, -} - -impl Fake { - fn new(version: &str, eprefix: Option<&str>) -> Self { - let dir = tempfile::tempdir().expect("tempdir"); - let init = dir - .path() - .join(format!("repo/versions/{version}/init/lmod")); - fs::create_dir_all(&init).expect("init dir"); - let mut text = String::from("module() { :; }\n"); - if let Some(e) = eprefix { - text.push_str(&format!("export EESSI_EPREFIX={e}\n")); - } - fs::write(init.join("bash"), text).expect("init"); - let bin = dir.path().join("bin"); - fs::create_dir_all(&bin).expect("bin"); - let eb = bin.join("eb"); - fs::write(&eb, "#!/bin/sh\nenv\n").expect("eb"); - fs::set_permissions(&eb, fs::Permissions::from_mode(0o755)).expect("chmod"); - fs::create_dir_all(dir.path().join("home")).expect("home"); - Self { dir } - } - - fn path(&self, rel: &str) -> PathBuf { - self.dir.path().join(rel) - } - - fn run(&self, env: &[(&str, &str)]) -> Output { - let mut cmd = Command::new("bash"); - cmd.arg(script()) - .env_clear() - .env( - "PATH", - format!("{}:/usr/bin:/bin", self.path("bin").display()), - ) - .env("HOME", self.path("home")) - .env("EESSI_CVMFS_REPO", self.path("repo")); - for (k, v) in env { - cmd.env(k, v); - } - cmd.output().expect("run script") - } -} - -fn var<'a>(out: &'a Output, name: &str) -> Option<&'a str> { - let text = std::str::from_utf8(&out.stdout).expect("utf8"); - let prefix = format!("{name}="); - text.lines().find_map(|l| l.strip_prefix(prefix.as_str())) -} - -fn ok(out: &Output) { - assert!( - out.status.success(), - "status {:?}\n{}", - out.status, - String::from_utf8_lossy(&out.stderr) - ); -} - -#[test] -fn without_a_version_it_loads_the_current_eessi() { - let fake = Fake::new("2026.06", None); - let out = fake.run(&[]); - ok(&out); - let arch = String::from_utf8(Command::new("uname").arg("-m").output().unwrap().stdout).unwrap(); - let compat = fake.path(&format!( - "repo/versions/2026.06/compat/linux/{}/usr/bin", - arch.trim() - )); - let path = var(&out, "PATH").expect("PATH"); - assert!( - path.starts_with(&format!("{}:", compat.display())), - "{path}" - ); -} - -#[test] -fn the_compat_layer_comes_from_the_init() { - let fake = Fake::new("2026.06", Some("/opt/eessi-compat")); - let out = fake.run(&[]); - ok(&out); - let path = var(&out, "PATH").expect("PATH"); - assert!(path.starts_with("/opt/eessi-compat/usr/bin:"), "{path}"); -} - -#[test] -fn a_named_user_prefix_is_created() { - let fake = Fake::new("2026.06", None); - let prefix = fake.path("home/eessi-mine"); - let out = fake.run(&[("EESSI_USER_INSTALL", prefix.to_str().unwrap())]); - ok(&out); - assert!(Path::new(&prefix).is_dir()); - assert_eq!(var(&out, "EESSI_USER_INSTALL"), prefix.to_str()); -} - -#[test] -fn the_default_user_prefix_is_home_eessi() { - let fake = Fake::new("2026.06", None); - let out = fake.run(&[]); - ok(&out); - assert!(fake.path("home/EESSI").is_dir()); -} - -#[test] -fn a_project_prefix_is_not_created() { - let fake = Fake::new("2026.06", None); - let project = fake.path("project"); - let out = fake.run(&[("EESSI_PROJECT_INSTALL", project.to_str().unwrap())]); - ok(&out); - assert!(!project.exists()); - assert_eq!(var(&out, "EESSI_USER_INSTALL"), None); -} - -#[test] -fn an_empty_site_install_is_not_a_user_prefix() { - let fake = Fake::new("2026.06", None); - let out = fake.run(&[("EESSI_SITE_INSTALL", "")]); - ok(&out); - assert!(!fake.path("home/EESSI").exists()); - assert_eq!(var(&out, "EESSI_USER_INSTALL"), None); - assert_eq!(var(&out, "EESSI_SITE_INSTALL"), Some("")); -} - -#[test] -fn an_empty_cvmfs_install_is_not_a_user_prefix() { - let fake = Fake::new("2026.06", None); - let out = fake.run(&[("EESSI_CVMFS_INSTALL", "")]); - ok(&out); - assert!(!fake.path("home/EESSI").exists()); - assert_eq!(var(&out, "EESSI_USER_INSTALL"), None); - assert_eq!(var(&out, "EESSI_CVMFS_INSTALL"), Some("")); -} - -#[test] -fn an_empty_site_install_with_a_user_prefix_is_refused() { - let fake = Fake::new("2026.06", None); - let out = fake.run(&[("EESSI_SITE_INSTALL", ""), ("EESSI_USER_INSTALL", "/x")]); - assert_eq!(out.status.code(), Some(3)); - assert!(!fake.path("home/EESSI").exists()); -} - -#[test] -fn two_prefixes_are_refused() { - let fake = Fake::new("2026.06", None); - let out = fake.run(&[ - ("EESSI_USER_INSTALL", "/x"), - ("EESSI_PROJECT_INSTALL", "/y"), - ]); - assert_eq!(out.status.code(), Some(3)); -} - -#[test] -fn a_missing_version_is_reported() { - let fake = Fake::new("2026.06", None); - let out = fake.run(&[("EESSI_VERSION", "2025.06")]); - assert_eq!(out.status.code(), Some(2)); - assert!(String::from_utf8_lossy(&out.stderr).contains("versions/2025.06/init")); -} diff --git a/tests/pypi_cran_extend.rs b/tests/pypi_cran_extend.rs index 2c55eb54..5896e16b 100644 --- a/tests/pypi_cran_extend.rs +++ b/tests/pypi_cran_extend.rs @@ -239,7 +239,10 @@ fn assert_eessi_cargo_isolation(text: &str) { && text.contains("${EESSI_EPREFIX:-") && text.contains("compat/linux/${_arch}}/usr/bin") && text.contains("link-arg=-B") - && text.contains("LINKER=${CC:-gcc}") + && text.contains("export LINKER=\"$CC\"") + && text.contains("tr -cd") + && !text.contains("LINKER=${CC:-gcc}") + && !text.contains("echo ${LIBRARY_PATH") && !text.contains("X86_64"), "cargo on EESSI must share one host-derived isolation prelude:\n{text}" ); diff --git a/tests/target_config.rs b/tests/target_config.rs index 02c482db..585df802 100644 --- a/tests/target_config.rs +++ b/tests/target_config.rs @@ -5,6 +5,8 @@ use eb_stack::target::{ use std::collections::BTreeMap; use std::process::Command; +include!("support/write_executable.rs"); + #[test] fn layered_target_config_composes_ssh_slurm_container_and_easybuild() { let base = TargetConfigLayer::from_toml_str( @@ -418,6 +420,125 @@ tmp_root = "/tmp" assert!(by_layer("runtime")["command"]["program"].is_string()); } +/// A stand-in EasyBuild command that prints `answer` and exits 0. +fn version_stub(dir: &std::path::Path, answer: &str) -> String { + let path = dir.join("eb-local"); + write_executable(&path, &format!("#!/bin/sh\nprintf '%s\\n' '{answer}'\n")).expect("stub"); + path.to_str().expect("utf-8 path").into() +} + +fn host_target(command: String, eessi_extend: Option<&str>) -> BuildTarget { + let mut environment = BTreeMap::new(); + if let Some(value) = eessi_extend { + environment.insert("EB_LOCAL_EESSI_EXTEND".into(), value.into()); + } + BuildTarget { + name: "eessi-extend-doctor".into(), + transport: TargetTransport::Local, + executor: TargetExecutor::Direct, + runtime: TargetRuntime::Host, + easybuild: EasyBuildWorkload { + command, + robot_paths: Vec::new(), + work_root: "/tmp".into(), + tmp_root: "/tmp".into(), + environment, + }, + } +} + +#[test] +fn doctor_fails_an_eb_local_that_answers_version_itself_under_extend_mode() { + let temp = tempfile::tempdir().expect("tempdir"); + let eb_local = version_stub(temp.path(), "eb-local 2.4.0 (x86_64-linux-musl)"); + let config = temp.path().join("targets.toml"); + std::fs::write( + &config, + format!( + r#" +schema_version = 1 +[[targets]] +name = "eessi-extend-old-eb-local" +[targets.transport] +kind = "local" +[targets.executor] +kind = "direct" +[targets.runtime] +kind = "host" +[targets.easybuild] +command = "{eb_local}" +work_root = "/tmp" +tmp_root = "/tmp" +[targets.easybuild.environment] +EB_LOCAL_EESSI_EXTEND = "1" +"# + ), + ) + .expect("config"); + let doctor = Command::new(env!("CARGO_BIN_EXE_eb-stack")) + .args([ + "target", + "doctor", + "--config", + config.to_str().unwrap(), + "--target", + "eessi-extend-old-eb-local", + ]) + .output() + .expect("target doctor"); + assert!( + !doctor.status.success(), + "an eb-local without extend mode must fail the doctor" + ); + let report: serde_json::Value = + serde_json::from_slice(&doctor.stdout).expect("doctor JSON on stdout"); + assert_eq!(report["ok"], false); + let checks = report["checks"].as_array().expect("checks"); + for check in checks.iter().filter(|check| check["layer"] != "easybuild") { + assert_eq!(check["success"], true, "{check}"); + assert!(check.get("reason").is_none(), "{check}"); + } + let easybuild = checks + .iter() + .find(|check| check["layer"] == "easybuild") + .expect("easybuild check"); + assert_eq!(easybuild["success"], false, "{easybuild}"); + assert_eq!(easybuild["exit_code"], 0, "{easybuild}"); + let reason = easybuild["reason"].as_str().unwrap_or_default(); + assert!( + reason.contains("EB_LOCAL_EESSI_EXTEND") && reason.contains("2.5.0"), + "{easybuild}" + ); +} + +#[test] +fn doctor_passes_an_eb_local_that_reaches_easybuild_under_extend_mode() { + let temp = tempfile::tempdir().expect("tempdir"); + let eb_local = version_stub( + temp.path(), + "Environment set up to use EESSI (2026.06), have fun!\n\ + This is EasyBuild 5.1.2 (framework: 5.1.2, easyblocks: 5.1.2) on host builder.", + ); + let report = doctor_target(&host_target(eb_local, Some("1"))).expect("doctor"); + assert!(report.ok(), "{report:?}"); + assert!(report.checks.iter().all(|check| check.reason.is_none())); +} + +#[test] +fn doctor_reads_the_extend_variable_as_eb_local_does() { + let temp = tempfile::tempdir().expect("tempdir"); + let eb_local = version_stub(temp.path(), "eb-local 2.4.0 (x86_64-linux-musl)"); + for eessi_extend in [None, Some(""), Some("0")] { + let report = doctor_target(&host_target(eb_local.clone(), eessi_extend)).expect("doctor"); + assert!( + report.ok(), + "EB_LOCAL_EESSI_EXTEND={eessi_extend:?} leaves extend mode off: {report:?}" + ); + } + let report = doctor_target(&host_target(eb_local, Some("yes"))).expect("doctor"); + assert!(!report.ok(), "{report:?}"); +} + #[test] fn public_target_examples_form_a_complete_layered_target() { let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); @@ -442,9 +563,14 @@ fn public_eessi_extend_target_routes_through_eessi_container() { let target = &targets[0]; assert_eq!(target.name, "eessi-extend-user"); assert!(matches!(target.runtime, TargetRuntime::Eessi { .. })); + assert_eq!(target.easybuild.command, "/usr/local/bin/eb-local"); assert_eq!( - target.easybuild.command, - "/usr/local/bin/eessi-extend-eb.sh" + target + .easybuild + .environment + .get("EB_LOCAL_EESSI_EXTEND") + .map(String::as_str), + Some("1") ); assert_eq!( target @@ -459,7 +585,9 @@ fn public_eessi_extend_target_routes_through_eessi_container() { let joined = command.args.join(" "); assert!(joined.contains("--mode exec"), "{joined}"); assert!(joined.contains("--access ro"), "{joined}"); - assert!(joined.contains("eessi-extend-eb.sh"), "{joined}"); + assert!(joined.contains("/usr/local/bin/eb-local"), "{joined}"); + assert!(joined.contains("EB_LOCAL_EESSI_EXTEND=1"), "{joined}"); + assert!(!joined.contains("eessi-extend-eb.sh"), "{joined}"); assert!(joined.contains("EESSI_USER_INSTALL="), "{joined}"); assert!(joined.contains("art.eb"), "{joined}"); } @@ -520,7 +648,7 @@ kind = "direct" kind = "host" [targets.easybuild] -command = "eessi-extend-eb.sh" +command = "eb-local" robot_paths = [] work_root = "/work/campaign" tmp_root = "/work/tmp"