Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495#!/bin/bashset -euo pipefail
cd "$(dirname "$0")/.."source Scripts/product.envsource Scripts/packaging-paths.shsource Scripts/version.shstructural_only=falseif [[ ${1:-} == --no-launch ]]; then structural_only=true; shift; fiif [[ $# -gt 1 ]]; then echo "Usage: $0 [--no-launch] [app]" >&2 exit 2fiapp=$(packaging_app_path "${1:-build/$PRODUCT_NAME.app}")Scripts/bundle-preflight.sh "$app"work=$(mktemp -d "${TMPDIR:-/tmp}/$PRODUCT_CASK-smoke.XXXXXX")pid=cleanup() { if [[ -n $pid ]]; then if kill -0 "$pid" 2>/dev/null; then if ! kill -KILL "$pid" 2>/dev/null && kill -0 "$pid" 2>/dev/null; then echo "Could not kill smoke process $pid." >&2 exit 1 fi fi wait "$pid" 2>/dev/null || true pid= fi rm -rf "$work"}trap cleanup EXITtrap 'exit 130' INTtrap 'exit 143' TERMcodesign --verify --strict --deep "$app"if ! codesign -dv "$app" > "$work/signature.log" 2>&1; then /bin/cat "$work/signature.log" >&2 exit 1fiif ! codesign -d --entitlements - --xml "$app" > "$work/entitlements.plist" 2> "$work/entitlements.log"; then /bin/cat "$work/entitlements.log" >&2 exit 1fiScripts/parcel-dev.sh check-bundle-signature "$work/signature.log" "$work/entitlements.plist"Scripts/parcel-dev.sh update-metadata check "$app/Contents/Info.plist"updates_enabled=$(/usr/libexec/PlistBuddy -c "Print :${PRODUCT_NAME}UpdatesEnabled" "$app/Contents/Info.plist")if [[ $updates_enabled == true ]]; then Scripts/parcel-dev.sh check-binaries "$app" "$PRODUCT_NAME" "$PWD"else Scripts/parcel-dev.sh check-binaries --sdk-only "$app" "$PRODUCT_NAME" "$PWD"fiframework="$app/Contents/Frameworks/Sparkle.framework"for component in Sparkle Autoupdate Updater.app XPCServices/Installer.xpc XPCServices/Downloader.xpc; do [[ -e $framework/Versions/B/$component ]] || { echo "Missing Sparkle component: $component" >&2; exit 1; } codesign --verify --strict "$framework/Versions/B/$component"donelipo "$framework/Versions/B/Sparkle" -verify_arch arm64 x86_64if ! otool -l "$app/Contents/MacOS/$PRODUCT_NAME" | grep -F '@executable_path/../Frameworks' > /dev/null; then echo 'The app cannot locate its embedded frameworks.' >&2; exit 1fiif [[ $structural_only == true ]]; then exit 0; fiditto "$app" "$work/$PRODUCT_NAME.app"codesign --verify --strict --deep "$work/$PRODUCT_NAME.app"
run_smoke() { local label=$1 log=$2 status=0 tick shift 2 DYLD_BIND_AT_LAUNCH=1 "$@" > "$log" 2>&1 & pid=$! for (( tick=0; tick<50; tick++ )); do if ! kill -0 "$pid" 2>/dev/null; then wait "$pid" 2>/dev/null || status=$? pid= if [[ $status != 0 ]]; then echo "The bundled $label failed (status $status):" >&2 /bin/cat "$log" >&2 return 1 fi return 0 fi sleep 0.1 done echo "The bundled $label timed out after 5 seconds:" >&2 /bin/cat "$log" >&2 return 1}run_smoke CLI "$work/version.log" "$work/$PRODUCT_NAME.app/Contents/Resources/bin/$PRODUCT_CLI" --versionif ! validate_version "$(<"$work/version.log")"; then echo 'The bundled CLI returned an invalid version:' >&2 /bin/cat "$work/version.log" >&2 exit 1fi
# dyld loads linked frameworks before main; bind eagerly without starting the app runtime.run_smoke app "$work/app.log" "$work/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME" --smoke