Files
Chris Tate 1e1a58c6d5 fix(windows): auto-detect openssl.cnf for broken OPENSSLDIR builds (#183)
* fix(windows): auto-detect openssl.cnf to fix broken OPENSSLDIR on Windows

Some Windows OpenSSL builds (e.g. ShiningLight.OpenSSL.Dev) compile in a
non-existent OPENSSLDIR, causing "Can't open openssl.cnf" errors. Portless
now probes common install locations and injects OPENSSL_CONF into the
child-process environment when needed.

Also updates the error message to suggest winget install on Windows.

Fixes #181

* fix(windows-debug): add Git mingw64 bin to PATH in run.sh

OpenSSL ships inside Git's mingw64/bin directory, but run.sh only
included Git's cmd directory. Tests that invoke openssl failed with
ENOENT on the Windows debug instance.

* docs(skill): add Windows openssl install guidance to requirements
2026-04-01 18:42:05 -05:00

93 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
INSTANCE_FILE="$SCRIPT_DIR/.instance"
if [[ ! -f "$INSTANCE_FILE" ]]; then
echo "Error: No instance provisioned. Run ./scripts/windows-debug/provision.sh first."
exit 1
fi
if [[ $# -eq 0 ]]; then
echo "Usage: ./scripts/windows-debug/run.sh \"<powershell-command>\""
echo ""
echo "Examples:"
echo " ./scripts/windows-debug/run.sh \"cd C:\\portless && pnpm test\""
echo " ./scripts/windows-debug/run.sh \"Get-Content C:\\bootstrap.log\""
echo " ./scripts/windows-debug/run.sh \"cd C:\\portless && pnpm test:e2e\""
exit 1
fi
source "$INSTANCE_FILE"
export AWS_DEFAULT_REGION="$REGION"
COMMAND="$*"
PARAMS_FILE=$(mktemp)
trap "rm -f $PARAMS_FILE" EXIT
python3 -c '
import json, sys
path_setup = "$env:PATH = \"C:\\Program Files\\nodejs;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Git\\mingw64\\bin;C:\\Program Files\\OpenSSL-Win64\\bin;$env:PATH\""
cmd = path_setup + "\n" + sys.argv[1]
json.dump({"commands": [cmd]}, open(sys.argv[2], "w"))
' "$COMMAND" "$PARAMS_FILE"
COMMAND_ID=$(aws ssm send-command \
--instance-ids "$INSTANCE_ID" \
--document-name "AWS-RunPowerShellScript" \
--parameters "file://$PARAMS_FILE" \
--timeout-seconds 3600 \
--query "Command.CommandId" --output text)
echo "Command sent (ID: $COMMAND_ID). Waiting..." >&2
while true; do
RESULT=$(aws ssm get-command-invocation \
--command-id "$COMMAND_ID" \
--instance-id "$INSTANCE_ID" \
--output json 2>&1) || true
STATUS=$(echo "$RESULT" | python3 -c "
import sys, json
try:
print(json.loads(sys.stdin.read()).get('Status', 'Unknown'))
except:
print('Pending')
" 2>/dev/null)
case "$STATUS" in
Success)
echo "$RESULT" | python3 -c "
import sys, json
r = json.loads(sys.stdin.read())
out = r.get('StandardOutputContent', '').rstrip()
err = r.get('StandardErrorContent', '').rstrip()
if out:
print(out)
if err:
print(err, file=sys.stderr)
"
exit 0
;;
Failed|TimedOut|Cancelled)
echo "$RESULT" | python3 -c "
import sys, json
r = json.loads(sys.stdin.read())
out = r.get('StandardOutputContent', '').rstrip()
err = r.get('StandardErrorContent', '').rstrip()
if out:
print(out)
if err:
print(err, file=sys.stderr)
"
echo "Command $STATUS." >&2
exit 1
;;
*)
sleep 3
;;
esac
done