[pkg] Resolve directory symlinks in fetched targets#13792
Conversation
df327f2 to
91d83ae
Compare
There was a problem hiding this comment.
Here is an example that I think causes a loop in the current algorithm:
/source/
dir_a/
link_to_b -> ../dir_b
dir_b/
link_to_a -> ../dir_a
Following this along we get an infinitely descending directory.
I think you will need to keep a set of resolved targets and check against it if you want to remember where you have been as to not repeat the resolution.
Another issue that I see is the multiple passes that are currently done, but we can improve this later once we have something that works correctly.
We also might need to add some validation that we don't escape the source directory, I don't think its a good idea to allow symlinks to / for example.
|
I just pushed work in progress to adress the latest comment about cycles. |
fe80747 to
5134ba5
Compare
5134ba5 to
b869da0
Compare
| This fails correctly | ||
| $ build_pkg bar 2>&1 | sanitize_pkg_digest bar.0.0.1 | tail -3 | ||
| Error: Unable to resolve symlink | ||
| _build/_private/default/.pkg/bar.0.0.1-DIGEST_HASH/source/dir_b/link_to_a/link_to_b, |
There was a problem hiding this comment.
CI isn't happy because it finds dir_a/link_to_b/link_to_a before the one I wrote in the test
|
Aside from the CI failures due to non-deterministic errors, the main code is ready for review. |
|
I haven't looked closely, but I think your changes might have made that test non-deterministic. |
c43ca48 to
6a8ab11
Compare
Alizter
left a comment
There was a problem hiding this comment.
Here are some problems I've observed:
-
There is a difference between local and tarball sources when it comes to directory symlinks. The tarball sources correctly resolve the contents wheras local sources silently discard them. I think rather than silently discarding them we should either raise a user error if this is something we wish not to support or support it. I would probably consider not supporting it.
-
Broken symlinks appear to be silently ignored. For example something stupid like a symlink to itself. We should probably error to the user in this case saying that we don't accept such symlinks.
| (* [raw_resolved] is a relative build path but it might contain indirections, | ||
| something like _build/foo/../bar | ||
| or _build/../outside *) | ||
| let canon_resolved = Path.of_string raw_resolved in |
There was a problem hiding this comment.
This only canonicalises relative paths and not absolute ones. I think Path.External.canonicalize_abs was the other way you did it.
There was a problem hiding this comment.
For some reason, raw_resolved is always a relative path, which is correctly canonicalized by Path.of_string
I ended up removing Path.External.canonicalize_abs anyway
|
Here are some of the issues we currently have: |
bc64415 to
71bc486
Compare
|
Update: we've looked further into this and it seems the desired behaviour in I've pushed a new version containing that deletion, along with a few WIP comments, I'm looking into them |
71bc486 to
7a3f5e6
Compare
|
Those OxCaml failures are real and are due to a new version of ppx_expect. It seems |
|
Annoyingly OxCaml is using ppx_expect v18, but v18 hasn't been released so we have a situation where the OxCaml version of the build is using a newer library that cannot overlap with the old version we have available. Luckily we can detect that and pass some compatibility flags to make it work. |
… source) Sort entries in fetch to guarantee determinism Remove the symlink resolution happening in pkg_rules as it's too complicated. The main change happening in fetch is still there. Signed-off-by: Ambre Austen Suhamy <ambre@tarides.com>
The big comment explaining everything was moved to fetch. Signed-off-by: Ambre Austen Suhamy <ambre@tarides.com>
Signed-off-by: Ambre Austen Suhamy <ambre@tarides.com>
Signed-off-by: Ambre Austen Suhamy <ambre@tarides.com>
Signed-off-by: Ambre Austen Suhamy <ambre@tarides.com>
…d function Signed-off-by: Ambre Austen Suhamy <ambre@tarides.com>
Remove 'seen' as cycle detection, is_descendant is enough Signed-off-by: Ambre Austen Suhamy <ambre@tarides.com>
Signed-off-by: Ambre Austen Suhamy <ambre@tarides.com>
Signed-off-by: Ali Caglayan <alizter@gmail.com>
ee52e3b to
12d733f
Compare
|
As #14382 looks like it's not going to get merged very quickly, I've rebased to exclude it, and inlined the changes into a local |
In ocaml#13792, we resolve directory symlinks in fetch targets. This commit extends the resolving to files too to enable caching for fetched sources. Signed-off-by: Puneeth Chaganti <punchagan@muse-amuse.in>
In ocaml#13792, we resolve directory symlinks in fetch targets. This commit extends the resolving to files too to enable caching for fetched sources. Signed-off-by: Puneeth Chaganti <punchagan@muse-amuse.in>
In ocaml#13792, we resolve directory symlinks in fetch targets. This commit extends the resolving to files too to enable caching for fetched sources. Signed-off-by: Puneeth Chaganti <punchagan@muse-amuse.in>
In ocaml#13792, we resolve directory symlinks in fetch targets. This commit extends the resolving to files too to enable caching for fetched sources. Signed-off-by: Puneeth Chaganti <punchagan@muse-amuse.in>
In ocaml#13792, we resolve directory symlinks in fetch targets. This commit extends the resolving to files too to enable caching for fetched sources. Signed-off-by: Puneeth Chaganti <punchagan@muse-amuse.in>
Housekeeping
This PR fixes the tests in #13393
#9873 will not be fixed, but still a significant step towards fixing #13678.
What this PR does
After fetching package sources, add a pass resolving directory symlinks. As they're not problematic at this stage, file symlinks are left as is. Broken symlinks are removed silently to preserve existing behaviour.
Note: both
portable_hardlinkandportable_symlinkwork backwards from what I initially understood, see #13791Done with the help of @Alizter, so thanks :)