#!/usr/bin/env bash # Assemble dist/windows-x86_64/ and dist/cst-agent-VERSION-windows-x86_64.zip # from the cross build (build-win-tui, else build-win; CST_WIN_BUILD=DIR # picks another, e.g. build-msys2) and busybox-w32. set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" # shellcheck source=lib_release.sh . "$ROOT/scripts/lib_release.sh" REL="$ROOT/dist/windows-x86_64" if [[ -n "${CST_WIN_BUILD:-}" ]]; then EXE="$ROOT/$CST_WIN_BUILD/cst-agent.exe" else EXE="$ROOT/build-win-tui/cst-agent.exe" [[ -f "$EXE" ]] || EXE="$ROOT/build-win/cst-agent.exe" fi BB="$ROOT/third_party/busybox/busybox.exe" [[ -f "$EXE" ]] || { echo "no cst-agent.exe; build first" >&2; exit 1; } [[ -f "$BB" ]] || { echo "no busybox.exe; scripts/build_third_party_mingw.sh busybox-w32" >&2; exit 1; } ver="$(cst_version)" strip="${MINGW_HOST-x86_64-w64-mingw32}" strip="${strip:+$strip-}strip" command -v "$strip" >/dev/null || strip=strip # MSYS2: unprefixed rm -rf "$REL" mkdir -p "$REL" cp -f "$EXE" "$REL/cst-agent.exe" "$strip" "$REL/cst-agent.exe" cp -f "$BB" "$REL/busybox.exe" cp -f "$ROOT/third_party/busybox/LICENSE.busybox" "$REL/" cp -f "$ROOT/docs/README-windows.md" "$REL/README.md" cp -f "$ROOT/scripts/windows/cst-agent-update.cmd" "$ROOT/scripts/install_windows.ps1" "$REL/" echo "$ver" >"$REL/VERSION" zip="$ROOT/dist/cst-agent-$ver-windows-x86_64.zip" rm -f "$zip" (cd "$ROOT/dist" && zip -qr "$zip" windows-x86_64) cst_sha256_write "$zip" ls -la "$REL" echo "$zip" # NSIS installer from the same folder (CST_REQUIRE_NSIS=1: fail without makensis). setup="$ROOT/dist/cst-agent-$ver-windows-x86_64-setup.exe" if command -v makensis >/dev/null; then rm -f "$setup" makensis -V2 -WX -INPUTCHARSET UTF8 -DVERSION="$ver" -DSRCDIR="$REL" \ -DOUTFILE="$setup" "$ROOT/scripts/windows/cst-agent.nsi" cst_sha256_write "$setup" echo "$setup" elif [[ "${CST_REQUIRE_NSIS:-0}" == 1 ]]; then echo "makensis not found" >&2 exit 1 else echo "makensis not found; skipping the installer" >&2 fi