Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[et] Fix path canonicalization #52274

Merged
merged 1 commit into from
Apr 20, 2024

Conversation

cbracken
Copy link
Member

Previously we were getting the enclosing directory path of the et tool (via the dirname builtin), then canonicalising the path by resolving symlinks. This doesn't work if the et on the path is itself a symlink. For example, if a user created a symlink et in a concrete directory at ~/.local/bin:

~/.local/bin/et -> ~/src/flutter/engines/src/flutter/bin/et

first we'd compute the dirname of the script:

~/.local/bin

then we'd resolve symlinks:

~/.local/bin

and incorrectly assume that was the engine directory.

Instead, we now resolve symlinks, then compute the enclosing directory.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

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

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Previously we were getting the enclosing directory path of the `et` tool
(via the `dirname` builtin), then canonicalising the path by resolving
symlinks. This doesn't work if the `et` on the path is itself a symlink.
For example, if a user created a symlink `et` in a concrete directory
at `~/.local/bin`:

```
~/.local/bin/et -> ~/src/flutter/engines/src/flutter/bin/et
```
first we'd compute the dirname of the script:
```
~/.local/bin
```
then we'd resolve symlinks:
```
~/.local/bin
```
and incorrectly assume that was the engine directory.

Instead, we now resolve symlinks, then compute the enclosing directory.
@cbracken cbracken force-pushed the et-fix-path-canonicalisation branch from ee78ee8 to 59f5b1a Compare April 19, 2024 22:05
@cbracken cbracken merged commit 5b2241e into flutter:main Apr 20, 2024
24 checks passed
@cbracken cbracken deleted the et-fix-path-canonicalisation branch April 20, 2024 00:24
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 20, 2024
johnmccutchan pushed a commit that referenced this pull request Apr 20, 2024
In order to canonicalise paths, previously we were doing an iterative
computation to resolve symlinks to a canonical path, directory by
directory. This was because on macOS and other BSDs, readlink doesn't
support the `-f` (follow symlinks) option. However, macOS and other
BSD-based systems *do* bundle the `realpath` utility, which resolves
symlinks.

This patch is stacked on top of #52274 and is the second commit
(dec38dd).

## 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 and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [ ] I added new tests to check the change I am making or feature I am
adding, or the PR is [test-exempt]. See [testing the engine] for
instructions on writing and running engine tests.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I signed the [CLA].
- [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/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Apr 20, 2024
…147099)

flutter/engine@3db86b3...6f4d753

2024-04-20 [email protected] Roll Skia from 1910252ea26a to 514d7fc627b3 (6 revisions) (flutter/engine#52277)
2024-04-20 [email protected] [et] Fix path canonicalization (flutter/engine#52274)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
gilnobrega pushed a commit to gilnobrega/flutter that referenced this pull request Apr 22, 2024
…lutter#147099)

flutter/engine@3db86b3...6f4d753

2024-04-20 [email protected] Roll Skia from 1910252ea26a to 514d7fc627b3 (6 revisions) (flutter/engine#52277)
2024-04-20 [email protected] [et] Fix path canonicalization (flutter/engine#52274)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@zanderso
Copy link
Member

You could test this change in the scenario you describe by adding a test to https://github.com/flutter/engine/blob/main/tools/engine_tool/test/entry_point_test.dart that creates such a symlink.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants