Keep the tool definition data-oriented
The toolchain starts with one pinned tool. ShellCheck's script owns the release version, host asset name, checksum, upstream URL, and path of the executable inside the archive.
The script still runs installation phases, so it is executable rather than purely declarative. Its tool-specific surface is nevertheless data-oriented: reusable download, verification, extraction, and placement mechanics stay in the sourced helper.
toolchain/tools/install-shellcheck.sh:9-28
14 focused lines
Install the pinned ShellCheck build
Run the installer with an explicit prefix, then inspect the installed version. The replay omits curl's progress meter.
Reject an unspecified destination
The shared helper enables fail-fast shell behavior and requires TOOLCHAIN_INSTALL_PREFIX as it is sourced. The ${NAME:?message} expansion stops before any directory is created when the caller has not selected a destination.
Making the boundary explicit lets Make provide the repository-local prefix later, while tests and direct runs can safely choose a temporary tree.
toolchain/tools/lib/install.sh:27-41
12 focused lines
Fail before choosing a destination
Run the tool script without an install prefix. Dash reports both the calling script and the sourced line where expansion stops.
Download and verify in a staging area
The first fetch creates a temporary directory inside the install prefix and registers cleanup traps. The stable bin directory is not the download destination.
After curl succeeds, the helper computes the staged file's SHA-256 value with sha256sum -c. A mismatch aborts before extraction or publication can trust the bytes.
toolchain/tools/lib/install.sh:110-163
18 focused lines
Publish the complete executable last
Only after fetch, verification, and extraction does install_bin validate the staged executable and create the destination directory.
The staging directory lives on the same filesystem as bin, so the final mv can publish the completed executable by rename instead of writing the stable path incrementally.
toolchain/tools/lib/install.sh:181-203
16 focused lines