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

Deal with Windows path conventions (backslashes, .exe, etc.) #3350

Merged
merged 6 commits into from
Jun 27, 2019

Conversation

dra27
Copy link
Member

@dra27 dra27 commented May 10, 2018

And the last portion of #3260 split off.

This borrows parts of #3346 and #3348 but also contains at least bit which needs further discussion.

Further comment to follow.

@dra27
Copy link
Member Author

dra27 commented Jun 10, 2018

The two commits about installation add useful warnings and shims to allow programs to be installed correctly (which should be becoming less common with Dune, etc. anyway).

The problem part is the variable interpolation. This is indeed arising from files mentioned in substs fields (that's where the one above came from). The problem here is that substs command is blind to what it's actually doing. Thoughts?

let base' =
{base with c = OpamFilename.Base.add_extension base.c "exe"} in
if OpamFilename.exists (OpamFilename.create build_dir base'.c) then begin
OpamConsole.warning "Added .exe to %s; .install file should be fixed" (OpamFilename.Base.to_string base.c);
Copy link
Member

Choose a reason for hiding this comment

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

It's best in general to avoid displaying messages that only make sense to developpers/packagers to the end users, unless they have a clear way to report; but I am not sure how best to do this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps also noting that the package maintainer should be informed?

@dra27
Copy link
Member Author

dra27 commented Jun 14, 2018

I had some thoughts on the substs problem:

  • Adding a predicate/flag to the substs command to either enable or disable escaping
  • Possibly changing the default to be with escaping of backslashes ... but I haven't checked uses in opam-repository to see whether that would break existing packages (but it's probably too late to do that)
  • Instead of relying on just opam-version being the first line, instead see if the file parses as an opam file and enable the heuristic then (that seems a much better idea)

@dra27
Copy link
Member Author

dra27 commented Jun 24, 2019

Refactored the interface for the warnings and altered so that running with --strict turns these warnings into errors - see this AppVeyor log

Identifies Windows executables, DLLs and Unix shell scripts based on
their content. This provides a primitive for identifying package
installation problems (installing executable without .exe extension,
expecting a #! script to work, etc.)

Signed-off-by: David Allsopp <david.allsopp@metastack.com>
The install command doesn't make sense for Windows. OpamSystem.install
altered to use copying instead and also various checks added to guard
against package errors. In particular, .exe is automatically added to
executables (with a warning) if exec is true and warnings are displayed
if Cygwin-linked files or Unix shell-scripts are installed.

Signed-off-by: David Allsopp <david.allsopp@metastack.com>
As with opam-installer, if a file cannot be found the .exe version is
attempted. If this is found, then the file is installed using a .exe
extension. A warning advising that the package should be fixed is also
displayed!

Signed-off-by: David Allsopp <david.allsopp@metastack.com>
Windows paths will routinely contain backslash characters, meaning that
opam's variable interpolation (OpamFilter.expand_interpolations_in_file)
will not work if the method is used to generate .config files.

The function now attempts to process the file using opam-file-format. If
this is successful, then variables expansions which occur inside quoted
and triple-quoted strings will have backslash and double-quote
characters escaped.

Thus, if the lib variable is C:\OPAM\system\lib then the following .in
file:

opam-version: "2.0"
variables {
  lib: "%{lib}%/ocaml"
  broken: %{lib}%
}

expands to:

opam-version: "2.0"
variables {
  lib: "C:\\OPAM\\system\\lib/ocaml"
  broken: C:\OPAM\system\lib
}

Signed-off-by: David Allsopp <david.allsopp@metastack.com>
@AltGr AltGr merged commit 5df7a6b into ocaml:master Jun 27, 2019
@dra27 dra27 deleted the windows-filenames branch June 27, 2019 09:37
@dra27 dra27 mentioned this pull request Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants