Skip to content

Commit

Permalink
Fix: OSS builds can accidentally using coreutils cp (#44097)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #44097

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

Reviewed By: cipolleschi

Differential Revision: D56143216

fbshipit-source-id: f1c1ef9ea2f01614d6d89c4e9eedf43113deb80c
  • Loading branch information
blakef authored and Titozzz committed Jul 22, 2024
1 parent f996422 commit 141778d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions packages/react-native-codegen/scripts/oss/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 141778d

Please sign in to comment.