Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173#!/bin/bashset -euo pipefailcd "$(dirname "$0")/../.."unset BASH_ENVsource Scripts/product.envsource Scripts/version.shroot=$PWDif [[ -z ${PARCEL_DEV_BINARY:-} ]]; then PARCEL_DEV_BINARY=$(Scripts/parcel-dev.sh --path)fiPARCEL_DEV_BINARY=$(realpath "$PARCEL_DEV_BINARY")export PARCEL_DEV_BINARYoriginal_path=$PATHwork=$(mktemp -d "${TMPDIR:-/tmp}/$PRODUCT_CASK-safety.XXXXXX")trap 'rm -rf "$work"' EXITcount=0check() { if ! "$@"; then printf 'Packaging safety test failed: %s\n' "$*" >&2; exit 1; fi count=$((count + 1))}fails() { if "$@" > "$work/failure.log" 2>&1; then printf 'Expected failure: %s\n' "$*" >&2; return 1; fi}for version in 0.1.0 12.34.56 1.2.3-beta 1.2.3-beta.2 1.2.3+build.42 1.2.3-rc.1+build-42; do check validate_version "$version"donefor version in '' 1 1.2 1.2.3.4 letters '1.2.3 bad' $'1.2.3\n1.2.3' $'1.2.3\n' $'1.2.3\r' $'1.2.3\t' $'1.2.3\033' '1.2.3-' '1.2.3+' '1.2.3-β' '1.2.3+../bad'; do check fails validate_version "$version" check fails env PARCEL_VERSION="$version" PARCEL_SIGN_IDENTITY=- Scripts/bundle.sh check fails env PARCEL_VERSION="$version" Scripts/release.sh --dry-run check fails Scripts/launch.sh --dry-run --version "$version" check fails env GITHUB_ACTIONS=true GITHUB_EVENT_NAME=push GITHUB_REF_TYPE=tag \ GITHUB_REPOSITORY="$PRODUCT_GITHUB_REPO" GITHUB_REF_NAME="v$version" \ GITHUB_REF="refs/tags/v$version" GITHUB_RUN_NUMBER=1 Scripts/ci-release.sh preflightdonecheck /bin/bash Scripts/version.sh version 1.2.3-beta.1+build.42check /bin/bash Scripts/version.sh release 1.2.3 42check /bin/bash Scripts/version.sh build 42check fails /bin/bash Scripts/version.sh unknowncheck fails /bin/bash Scripts/version.sh release 1.2.3check fails /bin/bash Scripts/version.sh version $'1.2.3\n'for version in 0.1.0 12.34.56; do check validate_ordered_version "$version" check /bin/bash Scripts/version.sh ordered-version "$version"donefor version in '' 1 1.2 1.2.3.4 1.2.3-beta 1.2.3+build.42 $'1.2.3\n'; do check fails validate_ordered_version "$version" check fails /bin/bash Scripts/version.sh ordered-version "$version"donecheck fails validate_ordered_versioncheck fails validate_ordered_version 1.2.3 extrafor number in 1 42; do check validate_positive_build_number "$number" check /bin/bash Scripts/version.sh positive-build "$number"donefor number in '' 0 001 1.2 $'42\n'; do check fails validate_positive_build_number "$number" check fails /bin/bash Scripts/version.sh positive-build "$number"donecheck fails validate_positive_build_numbercheck fails validate_positive_build_number 42 extrafor number in 0 1 42 001; do check validate_build_number "$number"; donefor number in '' 1.2 letters '1 2' $'1\n2' $'1\n' $'1\r' $'1\t'; do check fails validate_build_number "$number" check fails env PARCEL_BUILD_NUMBER="$number" PARCEL_SIGN_IDENTITY=- Scripts/bundle.sh check fails env PARCEL_BUILD_NUMBER="$number" Scripts/release.sh --dry-rundonemkdir -p "$work/project/Scripts" "$work/project/build/$PRODUCT_NAME.app/Contents/Frameworks/Sample.framework/Versions/B" "$work/allowed" "$work/bin"cp Scripts/product.env Scripts/packaging-paths.sh Scripts/parcel-dev.sh "$work/project/Scripts/"app="$work/project/build/$PRODUCT_NAME.app"ditto Sources/ParcelUI/Resources/AppIcons "$app/Contents/Resources/Parcel_ParcelUI.bundle/Contents/Resources"framework="$app/Contents/Frameworks/Sample.framework"printf 'framework\n' > "$framework/Versions/B/Sample"ln -s B "$framework/Versions/Current"ln -s Versions/Current/Sample "$framework/Sample"check Scripts/bundle-preflight.sh "$app"ln -s "$framework/Versions/B/Sample" "$app/Contents/absolute"ln -s ../../../outside "$app/Contents/escaping"mkfifo "$app/Contents/pipe"Scripts/parcel-dev.sh packaging-socket-fixture "$work/s" "$app/Contents/socket"check fails Scripts/bundle-preflight.sh "$app"for path in absolute escaping pipe socket; do check grep -Fq "Contents/$path" "$work/failure.log"; donecheck grep -Fq 'absolute symlink' "$work/failure.log"check grep -Fq 'symlink escapes' "$work/failure.log"rm "$app/Contents/absolute" "$app/Contents/escaping" "$app/Contents/pipe" "$app/Contents/socket"ln -s missing "$app/Contents/dangling"check fails Scripts/bundle-preflight.sh "$app"rm "$app/Contents/dangling"ln -s cycle-link "$app/Contents/cycle-link"check fails Scripts/bundle-preflight.sh "$app"rm "$app/Contents/cycle-link"check Scripts/bundle-preflight.sh "$app"check fails Scripts/bundle-preflight.shcd "$work/project"source Scripts/packaging-paths.shcheck test "$(packaging_app_path "$app")" = "$(realpath "$app")"mkdir build/Wrong.appcheck fails packaging_app_path build/Wrong.appcheck fails "$root/Scripts/dmg.sh" "$PWD/build/Wrong.app" "$TMPDIR/wrong-name.dmg"check fails "$root/Scripts/check-bundle.sh" "$PWD/build/Wrong.app"ln -s Wrong.app build/Alias.appcheck fails packaging_app_path build/Alias.appTMPDIR=$(realpath "$work/allowed")export TMPDIRcheck test "$(packaging_output_path build/new/deep/image.dmg)" = "$(realpath .)/build/new/deep/image.dmg"check test "$(packaging_output_path "$TMPDIR/image.dmg")" = "$TMPDIR/image.dmg"check fails packaging_output_path "$work/outside/image.dmg"check test ! -e "$work/outside"ln -s "$work" build/outsidecheck fails packaging_output_path build/outside/image.dmgcheck fails packaging_output_path build/outside/missing/image.dmgprintf 'existing\n' > build/existing.dmgcheck fails packaging_output_path build/existing.dmgln -s "$work/missing" build/dangling.dmgcheck fails packaging_output_path build/dangling.dmgmv build actual-buildln -s actual-build buildcheck fails packaging_build_directorycheck fails packaging_app_path "$app"check fails packaging_output_path "$TMPDIR/image.dmg"rm buildmv actual-build buildmkdir -p "$app/Contents/MacOS" "$app/Contents/Resources/bin"printf 'app\n' > "$app/Contents/MacOS/$PRODUCT_NAME"printf 'cli\n' > "$app/Contents/Resources/bin/$PRODUCT_CLI"cat > "$work/bin/xcrun" <<'STUB'#!/bin/bash[[ $* == --show-sdk-version ]] || exit 1printf '26.2\n'STUBcat > "$work/bin/otool" <<'STUB'#!/bin/bashset -euo pipefail[[ $1 == -l && -f $2 ]]for architecture in arm64 x86_64; do printf '%s (architecture %s):\nLoad command 0\n cmd LC_BUILD_VERSION\n cmdsize 32\n platform 1\n minos %s\n sdk %s\n ntools 1\n' "$2" "$architecture" "${TEST_MINOS:-15.0}" "${TEST_SDK:-26.2}"doneSTUBchmod +x "$work/bin/"*export PATH="$work/bin:$PATH"check "$root/Scripts/parcel-dev.sh" check-binaries "$app" "$PRODUCT_NAME" "$PWD"check fails env TEST_MINOS=14.0 "$root/Scripts/parcel-dev.sh" check-binaries "$app" "$PRODUCT_NAME" "$PWD"check fails env TEST_SDK=15.0 "$root/Scripts/parcel-dev.sh" check-binaries "$app" "$PRODUCT_NAME" "$PWD"for binary in "$app/Contents/MacOS/$PRODUCT_NAME" "$app/Contents/Resources/bin/$PRODUCT_CLI"; do printf 'diagnostic %s/Sources/example.swift\n' "$PWD" >> "$binary" check fails "$root/Scripts/parcel-dev.sh" check-binaries "$app" "$PRODUCT_NAME" "$PWD" check grep -Fq "${binary#"$app/"}" "$work/failure.log" printf 'binary\n' > "$binary"doneprintf 'int main(void) { return 0; }\n' > "$PWD/source.c"check /usr/bin/clang -g -mmacosx-version-min=15.0 -Wl,-rpath,"$PWD/build/frameworks" \ -Wl,-rpath,@executable_path/../Frameworks "$PWD/source.c" -o "$app/Contents/MacOS/$PRODUCT_NAME"check fails env PATH="$original_path" "$root/Scripts/parcel-dev.sh" check-binaries "$app" "$PRODUCT_NAME" "$PWD"mv "$app/Contents/MacOS/$PRODUCT_NAME.dSYM" "$work/diagnostics.dSYM"check env PATH="$original_path" "$root/Scripts/parcel-dev.sh" strip-binary-paths "$app/Contents/MacOS/$PRODUCT_NAME" "$PWD"check env PATH="$original_path" "$root/Scripts/parcel-dev.sh" check-binaries "$app" "$PRODUCT_NAME" "$PWD"/usr/bin/otool -l "$app/Contents/MacOS/$PRODUCT_NAME" > "$work/loader-paths.log"check grep -Fq '@executable_path/../Frameworks' "$work/loader-paths.log"check fails grep -Fq "$PWD" "$work/loader-paths.log"mkdir -p "$work/staged" "$work/published-parent"printf 'first\n' > "$work/staged/marker"check "$root/Scripts/parcel-dev.sh" install-bundle "$work/staged" "$work/published-parent/$PRODUCT_NAME.app"check test ! -e "$work/staged"mkdir "$work/staged"printf 'second\n' > "$work/staged/marker"check "$root/Scripts/parcel-dev.sh" install-bundle "$work/staged" "$work/published-parent/$PRODUCT_NAME.app"check grep -q second "$work/published-parent/$PRODUCT_NAME.app/marker"check grep -q first "$work/staged/marker"ln -s "$work/published-parent/$PRODUCT_NAME.app" "$work/link.app"check fails "$root/Scripts/parcel-dev.sh" install-bundle "$work/staged" "$work/link.app"check test -L "$work/link.app"printf 'Packaging safety checks passed: %s\n' "$count"