#!/usr/bin/env bash # Platform-authored stand-in for the captured install-tool.sh, passed to the captured helpers as INSTALL_TOOL. It has the same call shape # (`require-installed-tool.sh TOOL DEST_DIR`) but never downloads: the tool must already be baked into the source-tools image, and a # missing or non-executable tool fails the run. It only links the baked tool into DEST_DIR where the helper expects to find it. # env: SOURCE_TOOLS_DIR the image's tool directory (default /opt/source-tools; tests point it at a fixture) set -eu tool=${1:-} dest=${2:-} [ -n "$tool" ] && [ -n "$dest" ] || { echo "require-installed-tool: usage: TOOL DEST_DIR" >&2; exit 2; } root=${SOURCE_TOOLS_DIR:-/opt/source-tools} mkdir -p -- "$dest" case "$tool" in actionlint|shellcheck|yq|jq|envsubst) [ -x "$root/bin/$tool" ] || { echo "require-installed-tool: $tool is not installed at $root/bin/$tool; this runtime does not download tools" >&2; exit 1; } ln -s "$root/bin/$tool" "$dest/$tool" ;; bats) # install-tool.sh bats leaves DEST/bin/bats; the helper puts DEST/bin on PATH. [ -x "$root/bats/bin/bats" ] || { echo "require-installed-tool: bats is not installed at $root/bats/bin/bats; this runtime does not download tools" >&2; exit 1; } mkdir -p -- "$dest/bin" ln -s "$root/bats/bin/bats" "$dest/bin/bats" ;; *) echo "require-installed-tool: '$tool' is not part of the source-tools image" >&2 exit 1 ;; esac