Files
fleetforge/infrastructure/installer/build-msi.sh
T

45 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DOCKER_IMAGE="fleetforge-wixl"
AGENT_BIN="${1:?Usage: $0 <agent-binary> <config-json> <version> <output.msi>}"
CONFIG_JSON="${2:?Usage: $0 <agent-binary> <config-json> <version> <output.msi>}"
VERSION="${3:?Usage: $0 <agent-binary> <config-json> <version> <output.msi>}"
OUTPUT="${4:?Usage: $0 <agent-binary> <config-json> <version> <output.msi>}"
if [ ! -f "$AGENT_BIN" ]; then
echo "Error: Agent binary not found: $AGENT_BIN" >&2
exit 1
fi
if [ ! -f "$CONFIG_JSON" ]; then
echo "Error: Config file not found: $CONFIG_JSON" >&2
exit 1
fi
if ! docker image inspect "$DOCKER_IMAGE" >/dev/null 2>&1; then
echo "Building wixl Docker image..."
docker build -t "$DOCKER_IMAGE" "$SCRIPT_DIR"
fi
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
cp "$AGENT_BIN" "$TMPDIR/forge-agent.exe"
cp "$CONFIG_JSON" "$TMPDIR/config.json"
sed "s/__VERSION__/$VERSION/g" "$SCRIPT_DIR/agent.wxs" > "$TMPDIR/agent.wxs"
echo "Compiling MSI with wixl..."
docker run --rm \
-v "$TMPDIR:/work" \
"$DOCKER_IMAGE" \
wixl -o /work/output.msi \
-D "AgentBinaryPath=/work/forge-agent.exe" \
-D "ConfigFilePath=/work/config.json" \
/work/agent.wxs
cp "$TMPDIR/output.msi" "$OUTPUT"
echo "MSI generated: $OUTPUT ($(du -h "$OUTPUT" | cut -f1))"