From 4ce504d1a1691f762a1c48091e6f5e61b7c5b545 Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Tue, 1 Apr 2025 09:48:06 -0500 Subject: [PATCH] Fix `rsync` on macOS 15.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 15.4's `rsync` has a bug that requires the src to have write permissions. We normally shouldn't do this as it modifies the Bazel output base, so we limit this to only macOS 15.4 (as it’s fixed in 15.5). Also fixes a slight bug in the `patch_dsym` function. Signed-off-by: Brentley Jones --- .../bazel_integration_files/copy_dsyms.sh | 21 +++++++++++++++---- .../bazel_integration_files/copy_outputs.sh | 7 +++++++ .../templates/incremental_installer.sh | 7 +++++++ .../internal/templates/legacy_installer.sh | 7 +++++++ 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/xcodeproj/internal/bazel_integration_files/copy_dsyms.sh b/xcodeproj/internal/bazel_integration_files/copy_dsyms.sh index bae55b36fb..ea589c0ebc 100644 --- a/xcodeproj/internal/bazel_integration_files/copy_dsyms.sh +++ b/xcodeproj/internal/bazel_integration_files/copy_dsyms.sh @@ -3,9 +3,14 @@ set -euo pipefail function patch_dsym() { - readonly dsym_name="$1" - readonly binary_name="${dsym_name%%.*}" - readonly binary_path="${dsym_name}/Contents/Resources/DWARF/${binary_name}" + local dsym_name="$1" + + shopt -s extglob + local binary_name="${dsym_name%.dSYM}" + binary_name="${binary_name%@(.app|.appex|.bundle|.dext|.kext|.framework|.pluginkit|.systemextension|.xctest|.xpc)}" + shopt +s extglob + + local binary_path="${dsym_name}/Contents/Resources/DWARF/${binary_name}" if [[ ! -f "$binary_path" ]]; then echo "dSYM DWARF ${binary_path} does not exist." \ @@ -13,8 +18,8 @@ function patch_dsym() { return 1 fi + local dwarf_uuid dwarf_uuid=$(dwarfdump --uuid "${binary_path}" | cut -d ' ' -f 2) - readonly dwarf_uuid if [[ -z "${dwarf_uuid// /}" ]]; then echo "Failed to get dSYM uuid." \ "Skip dSYM patch." @@ -44,6 +49,14 @@ EOF if [[ -n "${BAZEL_OUTPUTS_DSYM:-}" ]]; then cd "${BAZEL_OUT%/*}" + if [[ $(sw_vers -productVersion | cut -d '.' -f 1-2) == "15.4" ]]; then + # 15.4's `rsync` has a bug that requires the src to have write permissions. + # We normally shouldn't do this as it modifies the bazel output base, so we + # limit this to only macOS 15.4. + # shellcheck disable=SC2046 + chmod -R +w $(xargs -n1 <<< "$BAZEL_OUTPUTS_DSYM") + fi + # shellcheck disable=SC2046 rsync \ --copy-links \ diff --git a/xcodeproj/internal/bazel_integration_files/copy_outputs.sh b/xcodeproj/internal/bazel_integration_files/copy_outputs.sh index e847cf0e27..1603b6f9aa 100755 --- a/xcodeproj/internal/bazel_integration_files/copy_outputs.sh +++ b/xcodeproj/internal/bazel_integration_files/copy_outputs.sh @@ -30,6 +30,13 @@ if [[ "$ACTION" != indexbuild ]]; then # rpaths to work ln -sfh "$PWD/$BAZEL_OUTPUTS_PRODUCT_BASENAME" "$TARGET_BUILD_DIR/$PRODUCT_NAME" else + if [[ $(sw_vers -productVersion | cut -d '.' -f 1-2) == "15.4" ]]; then + # 15.4's `rsync` has a bug that requires the src to have write + # permissions. We normally shouldn't do this as it modifies the bazel + # output base, so we limit this to only macOS 15.4. + chmod -R +w "$BAZEL_OUTPUTS_PRODUCT_BASENAME" + fi + # Product is a bundle rsync \ --copy-links \ diff --git a/xcodeproj/internal/templates/incremental_installer.sh b/xcodeproj/internal/templates/incremental_installer.sh index 2746d7d28a..64f30ccb12 100644 --- a/xcodeproj/internal/templates/incremental_installer.sh +++ b/xcodeproj/internal/templates/incremental_installer.sh @@ -74,6 +74,13 @@ dest_dir="$(dirname "${dest}")" # Copy over `xcschemes` readonly dest_xcschemes="$dest/xcshareddata/xcschemes" +if [[ $(sw_vers -productVersion | cut -d '.' -f 1-2) == "15.4" ]]; then + # 15.4's `rsync` has a bug that requires the src to have write permissions. + # We normally shouldn't do this as it modifies the bazel output base, so we + # limit this to only macOS 15.4. + chmod -R +w "$src_xcschemes" +fi + mkdir -p "$dest_xcschemes" rsync \ --archive \ diff --git a/xcodeproj/internal/templates/legacy_installer.sh b/xcodeproj/internal/templates/legacy_installer.sh index fd2f96d0f6..01bd05a5fa 100644 --- a/xcodeproj/internal/templates/legacy_installer.sh +++ b/xcodeproj/internal/templates/legacy_installer.sh @@ -136,6 +136,13 @@ fi # Sync over the project, changing the permissions to be writable +if [[ $(sw_vers -productVersion | cut -d '.' -f 1-2) == "15.4" ]]; then + # 15.4's `rsync` has a bug that requires the src to have write permissions. + # We normally shouldn't do this as it modifies the bazel output base, so we + # limit this to only macOS 15.4. + chmod -R +w "$src" +fi + # Don't touch project.xcworkspace as that will make Xcode prompt rsync \ --archive \