[macOS] Fix COPY step on macOS 15 Sequoia (#884)

macOS build fails on Sequoia beta 2 and later (verified in public beta 3
as well) hosts during COPY step when copying files with the `restricted`
extended attribute set.

The problem appears to be due to the `-a` (archive) option, which is an
alias for `-RpP`. Of these, the `-p` option appears to be the source of
the problem. This flag attempts to preserve file metadata including
Access Control Lists and Extended Attributes. However, the `restricted`
extended attribute is not settable when System Integrity Protection
(SIP) is enabled, which it is by default.

This appears to be a change in the implementation of `cp` in macOS 15
Sequoia beta 2 and later. Previous versions would fail to copy the
attribute, but continue without failing. The current version appears to
fail if it cannot set any extended attribute.

Two alternatives to the previous `cp -af` step:
* Use `cp -Rf`. This succeeds but file metadata such as
  creation time, modification time, etc. are not preserved.
* Use `rsync -a`. rsync's -a flag also copies metadata but on a
  best-efforts basis and doesn't error out when it fails to set the
  restricted attribute.

Of the two, the latter more closely approximates the previous behaviour.

The `rm -rf` step can be replaced with `rsync`'s `--delete` option; with
the default `--delete-before` behaviour, this replicates the function of
the `rm -rf`.

Fixes: https://github.com/flutter/flutter/issues/152978

## Pre-launch Checklist

- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [X] I read the [Flutter Style Guide] _recently_, and have followed its
advice.
- [X] I signed the [CLA].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [X] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md
1 file changed
tree: 1a727d7e2145dd5e12b51eb379c431e9c0594271
  1. .github/
  2. build/
  3. build_overrides/
  4. tools/
  5. .clang-format
  6. .gitattributes
  7. .gitignore
  8. .gn
  9. AUTHORS
  10. BUILD.gn
  11. CODEOWNERS
  12. LICENSE
  13. README.md
README.md

OpenSSF Scorecard

buildroot

Build environment for the Flutter engine

This repository is used by the flutter/engine repository. For instructions on how to use it, see that repository's CONTRIBUTING.md file.

To update your checkout to use the latest buildroot, run gclient sync.

To submit patches to this buildroot repository, create a branch, push to that branch, then submit a PR on GitHub for that branch.

To point the engine to a new version of buildroot after your patch is merged, update the buildroot hash in the engine's DEPS file.