Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to copying on symlink-less MSYS2 #4817

Merged
merged 2 commits into from
Apr 29, 2022

Conversation

jonahbeckford
Copy link
Contributor

Splitting up #4813:

For 92397ac ("Allow MSYS2 to prefer copying over symlinking") I think the code duplication can be reduced if is_cygwin_variant and is_msys2_variant are merged into a single function get_windows_executable_variant : string -> [ Native | Cygwin of [Cygwin | Msys2] | Tainted of [Cygwin | Msys2] ]. The old is_cygwin_variant and the new is_msys2_variant can then be defined in terms of that function. While it's being added, it would be good to thread the tainting support through to OpamSystem.install (the point of CygLinked is to warn for the situation where you've accidentally linked with a Cygwin or MSYS2 compiled DLL which usually implies bindings are wrong somewhere). I was initially confused by the title of the commit, as we must definitely prefer symlinking over copying (if it's available and works), vs requiring symlinking (I completely agree with you that requiring developer mode is an unacceptable barrier), but I think that the actual rsync change works correctly if native symlinking is enabled. The longer-term plan for this (I say longer, it's possible this'll happen in 2.2 or 2.3) is to use ocaml-tar and implement the cp command directly. Cygwin/MSYS2' cp and tar commands are somewhat belligerently staying portable where symlinks are concerned - Windows symlinks do not require the file to exist, what they do require is for the type of the target to be known, which cp does (trivially) and tar can (slightly less-trivially). The only thing which is very hard to copy reliably is a dangling/broken symlink. However, I think your rsync solution is a very good stop-gap!

For continuity this initial PR is as-is from the original PR, except the new title and a change in the commit description:

Default MSYS2 installations "support" symlinking by copying. This
commit adds a two-phase rsync (copy first without symlinks, then
copy symlinks) so the MSYS2 copying behavior works.

@kit-ty-kate kit-ty-kate requested a review from dra27 August 30, 2021 18:04
@kit-ty-kate kit-ty-kate added this to PR in progress in Opam 2.2.0 via automation Aug 30, 2021
@kit-ty-kate kit-ty-kate added this to the 2.2.0~alpha milestone Aug 30, 2021
@jonahbeckford
Copy link
Contributor Author

  1. Switched to get_windows_executable_variant.
  2. I kept is_cygwin_variant and marked it deprecated. It is not used in any current ocaml/opam code but perhaps packages outside of Opam rely on it.

Copy link
Member

@dra27 dra27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update to this - sorry for the number of comments, though most of them are in fact reverts!

Consider Ubuntu and Debian: most of the time we can just treat as Debian in terms of handling and then very occasionally we care that it's specifically Ubuntu. I think the Msys2/Cygwin API should be the same - most of the time we simply need to know that it's Cygwin-like and we can call that Cygwin. Then only the specific place where you want some handling that's just for Msys2 do we actually match on that. It makes the diff smaller too 🙂

I haven't fleshed out the change to OpamSystem.default_install_warning - I think there should be Msys2-specific messages for that.

src/core/opamProcess.ml Outdated Show resolved Hide resolved
src/core/opamProcess.ml Outdated Show resolved Hide resolved
src/core/opamStd.ml Outdated Show resolved Hide resolved
src/core/opamStd.ml Outdated Show resolved Hide resolved
src/core/opamStd.ml Outdated Show resolved Hide resolved
src/core/opamStd.mli Outdated Show resolved Hide resolved
src/core/opamStd.mli Outdated Show resolved Hide resolved
src/core/opamStd.mli Outdated Show resolved Hide resolved
src/core/opamSystem.ml Outdated Show resolved Hide resolved
src/core/opamSystem.ml Outdated Show resolved Hide resolved
@jonahbeckford
Copy link
Contributor Author

The suggested changes were made.

@rjbou rjbou requested a review from dra27 December 8, 2021 16:44
@dra27 dra27 force-pushed the feature-rsync-copy-fallback branch from 574eed1 to d53534a Compare March 23, 2022 14:56
Copy link
Member

@dra27 dra27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay approving this (and thanks to @rjbou for rebasing it!). Thanks for this - the rsync support will either get extended to the Cygwin-side at some point or the whole thing will get replaced with Windows-aware OCaml versions but, in the meantime, this is a great stability improvement!

@dra27
Copy link
Member

dra27 commented Mar 23, 2022

(it still needs to run through CI, which is presently suffering from another GitHub outage...)

@rjbou rjbou moved this from PR in progress to PR to review in Opam 2.2.0 Mar 23, 2022
@dra27 dra27 force-pushed the feature-rsync-copy-fallback branch from d53534a to 49fb10d Compare April 28, 2022 10:08
@rjbou rjbou moved this from PR to review to PR finalised (merge with CI) in Opam 2.2.0 Apr 28, 2022
jonahbeckford and others added 2 commits April 29, 2022 11:57
Default MSYS2 installations "support" symlinking by copying. This
commit adds a two-phase rsync (copy first without symlinks, then
copy symlinks) so the MSYS2 copying behavior works.
@dra27 dra27 force-pushed the feature-rsync-copy-fallback branch from 49fb10d to ae4b5ec Compare April 29, 2022 10:57
@kit-ty-kate
Copy link
Member

Thanks a lot!

@kit-ty-kate kit-ty-kate merged commit 848a9c1 into ocaml:master Apr 29, 2022
Opam 2.2.0 automation moved this from PR finalised (merge with CI) to Done Apr 29, 2022
@jonahbeckford jonahbeckford deleted the feature-rsync-copy-fallback branch May 3, 2022 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Opam 2.2.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants