From f49960c3fe60e7b363ca07ac80aa201eab8dd8b3 Mon Sep 17 00:00:00 2001 From: Blake Friedman Date: Mon, 15 Apr 2024 09:57:19 -0700 Subject: [PATCH] Fix: OSS builds can accidentally using coreutils cp (#44097) Summary: There are two places where we use a feature specific to the system version of 'cp', the: -X Do not copy Extended Attributes (EAs) or resource forks. This feature isn't available in GNU's cp, which is commonly installed on macOS using: brew install coreutils && brew link coreutils We can avoid the problem alltogether by being specific about the path of the system cp. Changelog: [General][Fixed] don't break script phase and codegen when coreutils installed on macOS Differential Revision: D56143216 --- packages/react-native-codegen/scripts/oss/build.sh | 7 ++++--- .../scripts/react_native_pods_utils/script_phases.sh | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/react-native-codegen/scripts/oss/build.sh b/packages/react-native-codegen/scripts/oss/build.sh index 215911a34588d4..84daf5dea68fde 100755 --- a/packages/react-native-codegen/scripts/oss/build.sh +++ b/packages/react-native-codegen/scripts/oss/build.sh @@ -29,9 +29,10 @@ EDEN_SAFE_MV="mv" if [ -x "$(command -v eden)" ]; then pushd "$THIS_DIR" - # Detect if we are in an EdenFS checkout + # Detect if we are in an EdenFS checkout, but be sure to use /bin/cp + # incase users have GNU coreutils installed which is incompatible with -X if [[ "$OSTYPE" == "darwin"* ]] && eden info; then - EDEN_SAFE_MV="cp -R -X" + EDEN_SAFE_MV="/bin/cp -R -X" fi popd >/dev/null @@ -60,7 +61,7 @@ else if [ "$OSTYPE" = "msys" ] || [ "$OSTYPE" = "cygwin" ]; then tar cf - --exclude='*.lock' "$CODEGEN_DIR" | (cd "$TMP_DIR" && tar xvf - ); else - cp -R "$CODEGEN_DIR/." "$TMP_DIR"; + /bin/cp -R "$CODEGEN_DIR/." "$TMP_DIR"; fi pushd "$TMP_DIR" >/dev/null diff --git a/packages/react-native/scripts/react_native_pods_utils/script_phases.sh b/packages/react-native/scripts/react_native_pods_utils/script_phases.sh index a35272c580b166..92325f1ad078f4 100755 --- a/packages/react-native/scripts/react_native_pods_utils/script_phases.sh +++ b/packages/react-native/scripts/react_native_pods_utils/script_phases.sh @@ -104,7 +104,7 @@ moveOutputs () { mkdir -p "$RCT_SCRIPT_OUTPUT_DIR" # Copy all output to output_dir - cp -R -X "$TEMP_OUTPUT_DIR/." "$RCT_SCRIPT_OUTPUT_DIR" || exit 1 + /bin/cp -R -X "$TEMP_OUTPUT_DIR/." "$RCT_SCRIPT_OUTPUT_DIR" || exit 1 echo "$LIBRARY_NAME output has been written to $RCT_SCRIPT_OUTPUT_DIR:" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1 ls -1 "$RCT_SCRIPT_OUTPUT_DIR" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1 }