diff --git a/scripts/lipo b/scripts/lipo index a8c4226..12bd686 100755 --- a/scripts/lipo +++ b/scripts/lipo @@ -1,19 +1,22 @@ -#!/bin/sh +#!/bin/bash +# Precision shim for lipo to handle read-only frameworks from Nix store. +# See: https://github.com/NixOS/nixpkgs/issues/405066 -echo "LIPO SHIM: $@" >&2 +# If the upstream issue is fixed and the file is already writable, +# this script will still work gracefully. for arg in "$@"; do - case "$arg" in - */*.framework/*) - fw_dir="${arg%.framework/*}.framework" - echo "LIPO SHIM: chmod $fw_dir" >&2 - chmod -R u+w "$fw_dir" 2>/dev/null - ;; - *.lipo) - echo "LIPO SHIM: chmod $(dirname "$arg")" >&2 - chmod u+w "$(dirname "$arg")" 2>/dev/null - ;; - esac + # Check if we are acting on a Flutter binary within a framework + if [[ "$arg" == *"Flutter.framework/Flutter" || "$arg" == *"FlutterMacOS.framework/FlutterMacOS" ]]; then + # Identify the framework directory + FW_DIR=$(echo "$arg" | sed 's|/Flutter$||; s|/FlutterMacOS$||') + + if [ -d "$FW_DIR" ]; then + # Make the framework and its contents writable + chmod -R +w "$FW_DIR" 2>/dev/null + fi + fi done +# Pass through to the real lipo tool exec /usr/bin/lipo "$@" \ No newline at end of file