Files
nixpkgs/pkgs/development/compilers/flutter/versions/3_44/patches/fix-ios-build-xcode-backend-sh.patch
2026-06-14 23:23:14 +08:00

40 lines
1.2 KiB
Diff

Fix iOS build issue with NixOS/nixpkgs flutter
This patch cleans up xcode_backend.sh to use the FLUTTER_ROOT
environment variable directly, avoiding symlink traversal issues.
--- a/packages/flutter_tools/bin/xcode_backend.sh
+++ b/packages/flutter_tools/bin/xcode_backend.sh
@@ -10,27 +10,8 @@
#
# -------------------------------------------------------------------------- #
-# exit on error, or usage of unset var
-set -euo pipefail
+# Run `dart ./xcode_backend.dart` with the dart from $FLUTTER_ROOT.
+dart="${FLUTTER_ROOT}/bin/dart"
+xcode_backend_dart="${BASH_SOURCE[0]%.sh}.dart"
+exec "${dart}" "${xcode_backend_dart}" "$@" "ios"
-# Needed because if it is set, cd may print the path it changed to.
-unset CDPATH
-
-function follow_links() (
- cd -P -- "$(dirname -- "$1")"
- file="$PWD/$(basename -- "$1")"
- while [[ -h "$file" ]]; do
- cd -P -- "$(dirname -- "$file")"
- file="$(readlink -- "$file")"
- cd -P -- "$(dirname -- "$file")"
- file="$PWD/$(basename -- "$file")"
- done
- echo "$file"
-)
-
-PROG_NAME="$(follow_links "${BASH_SOURCE[0]}")"
-BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
-FLUTTER_ROOT="$BIN_DIR/../../.."
-DART="$FLUTTER_ROOT/bin/dart"
-
-"$DART" "$BIN_DIR/xcode_backend.dart" "$@" "ios"