|
| 1 | +#!/bin/sh |
| 2 | +set -eu |
| 3 | + |
| 4 | +REPO_DIR="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)" |
| 5 | +PKG_PATH="" |
| 6 | +REQUIRE_SIGNED="0" |
| 7 | + |
| 8 | +if [ "$#" -gt 2 ]; then |
| 9 | + echo "Too many arguments. Usage: $0 [--signed] <package>" >&2 |
| 10 | + exit 1 |
| 11 | +fi |
| 12 | + |
| 13 | +if [ "$#" -ge 1 ]; then |
| 14 | + if [ "$1" = "--signed" ]; then |
| 15 | + REQUIRE_SIGNED="1" |
| 16 | + PKG_PATH="${2:-}" |
| 17 | + else |
| 18 | + PKG_PATH="$1" |
| 19 | + fi |
| 20 | +fi |
| 21 | + |
| 22 | +if [ -z "$PKG_PATH" ]; then |
| 23 | + PKG_PATH="$(cd "$REPO_DIR" && find dist -maxdepth 1 -name 'DevStackMenu-*.pkg' -type f | sort | head -n 1 || true)" |
| 24 | +fi |
| 25 | + |
| 26 | +if [ -z "$PKG_PATH" ] || [ ! -f "$PKG_PATH" ]; then |
| 27 | + echo "Package not found. Provide a path: ./Scripts/release-smoke-install.sh dist/DevStackMenu-...pkg" >&2 |
| 28 | + exit 1 |
| 29 | +fi |
| 30 | + |
| 31 | +TMP_DIR="$(mktemp -d)" |
| 32 | +TMP_LOG="$TMP_DIR/release-install.log" |
| 33 | +TMP_PAYLOAD="$TMP_DIR/payload.txt" |
| 34 | +TMP_HELP="$TMP_DIR/dx-help.txt" |
| 35 | +TMP_HELP_ERR="$TMP_DIR/dx-help.err" |
| 36 | +trap 'rm -rf "$TMP_DIR"' EXIT |
| 37 | + |
| 38 | +printf 'Using package: %s\n' "$PKG_PATH" |
| 39 | +"$REPO_DIR/Scripts/verify-package.sh" "$PKG_PATH" "$REQUIRE_SIGNED" |
| 40 | + |
| 41 | +printf 'Inspecting payload paths:\n' |
| 42 | +pkgutil --payload-files "$PKG_PATH" | sort > "$TMP_PAYLOAD" |
| 43 | +cat "$TMP_PAYLOAD" |
| 44 | +printf '\n' |
| 45 | + |
| 46 | +if [ "$REQUIRE_SIGNED" = "1" ] && ! pkgutil --check-signature "$PKG_PATH" >/dev/null 2>&1; then |
| 47 | + echo "Package signature is required but missing." >&2 |
| 48 | + exit 1 |
| 49 | +fi |
| 50 | + |
| 51 | +printf 'Installing package (requires sudo)...\n' |
| 52 | +if [ "$(id -u)" -eq 0 ]; then |
| 53 | + installer -pkg "$PKG_PATH" -target / | tee "$TMP_LOG" |
| 54 | +else |
| 55 | + sudo installer -pkg "$PKG_PATH" -target / | tee "$TMP_LOG" |
| 56 | +fi |
| 57 | + |
| 58 | +printf 'Verifying installed artifacts...\n' |
| 59 | +if [ ! -x /usr/local/bin/dx ]; then |
| 60 | + echo "dx missing in /usr/local/bin" >&2 |
| 61 | + exit 1 |
| 62 | +fi |
| 63 | + |
| 64 | +if [ ! -d "/Applications/DevStackMenu.app" ]; then |
| 65 | + echo "DevStackMenu.app missing in /Applications" >&2 |
| 66 | + exit 1 |
| 67 | +fi |
| 68 | + |
| 69 | +if [ ! -d "/Applications/Import Compose To DX.app" ]; then |
| 70 | + echo "Import Compose To DX.app missing in /Applications" >&2 |
| 71 | + exit 1 |
| 72 | +fi |
| 73 | + |
| 74 | +if /usr/local/bin/dx --help >"$TMP_HELP" 2>"$TMP_HELP_ERR"; then |
| 75 | + printf 'dx status: ' |
| 76 | + /usr/local/bin/dx status |
| 77 | +else |
| 78 | + echo "dx failed to run" >&2 |
| 79 | + cat "$TMP_HELP_ERR" |
| 80 | + exit 1 |
| 81 | +fi |
| 82 | + |
| 83 | +if command -v dx >/dev/null 2>&1; then |
| 84 | + printf 'dx path from PATH: %s\n' "$(command -v dx)" |
| 85 | +else |
| 86 | + printf 'dx is not on current PATH. Binary is at /usr/local/bin/dx\n' |
| 87 | + printf 'You can add it for this shell with: export PATH="/usr/local/bin:$PATH"\n' |
| 88 | +fi |
| 89 | + |
| 90 | +printf '\nSmoke install passed.\n' |
| 91 | +printf 'To clean artifacts: sudo rm -rf /Applications/DevStackMenu.app /Applications/Import\\ Compose\\ To\\ DX.app /usr/local/bin/dx\n' |
0 commit comments