#!/usr/bin/env bash set -euo pipefail version="${HOLOLAKE_VERSION:-0.1.5}" target="x86_64-pc-windows-msvc" repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$repo_root" if [[ "$(uname -s)" != "Linux" ]]; then echo "This cross-build entrypoint is intended for the JD Linux build node." >&2 exit 2 fi if command -v apt-get >/dev/null 2>&1; then apt_prefix=() if [[ "$(id -u)" -ne 0 ]]; then apt_prefix=(sudo); fi "${apt_prefix[@]}" apt-get update "${apt_prefix[@]}" apt-get install -y clang curl lld llvm nsis build-essential pkg-config libssl-dev fi command -v node >/dev/null || { echo "Node.js is required." >&2; exit 2; } export PATH="$HOME/.cargo/bin:$PATH" if ! command -v cargo >/dev/null 2>&1; then command -v curl >/dev/null || { echo "curl is required to install Rust." >&2; exit 2; } export RUSTUP_DIST_SERVER="${RUSTUP_DIST_SERVER:-https://rsproxy.cn}" export RUSTUP_UPDATE_ROOT="${RUSTUP_UPDATE_ROOT:-https://rsproxy.cn/rustup}" curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal fi export CARGO_HOME="${CARGO_HOME:-$HOME/.cargo-jd}" mkdir -p "$CARGO_HOME" cp scripts/cargo-config-jd.toml "$CARGO_HOME/config.toml" export PATH="$CARGO_HOME/bin:$HOME/.cargo/bin:$PATH" if ! command -v corepack >/dev/null 2>&1; then npm install --global corepack fi corepack enable 2>/dev/null || true corepack prepare pnpm@10.25.0 --activate rustup target add "$target" command -v cargo-xwin >/dev/null || cargo install cargo-xwin --locked pnpm install --frozen-lockfile pnpm tauri build --runner cargo-xwin --target "$target" --bundles nsis bundle_dir="src-tauri/target/$target/release/bundle/nsis" installer="$(find "$bundle_dir" -maxdepth 1 -type f -name '*-setup.exe' -print -quit)" [[ -n "$installer" ]] || { echo "No NSIS installer was produced." >&2; exit 1; } [[ "$(basename "$installer")" == *"$version"* ]] || { echo "Installer filename does not contain version $version: $installer" >&2; exit 1; } node scripts/verify-internal-package-content.mjs dist sha256sum "$installer" > "$installer.sha256" echo "$installer"