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

Fix installation order when processing .install files #4667

Merged
merged 6 commits into from
May 28, 2021

Conversation

dra27
Copy link
Member

@dra27 dra27 commented May 17, 2021

#4657 exposed no fewer than 3 bugs! 🐛

  • OpamSystem.install doesn't the file permissions correctly if the file already exists (since open_out_gen only uses the mode if it actually creates the file). The first commit here fixes that and also the case of a symlink being overwritten which is handled by OpamSystem.copy_file but wasn't being handled by OpamSystem.install.
  • opam-devel.install installs a file called opam twice to lib/opam-devel (fixed in Fix opam-devel.install #4664)
  • The updates in Make install faster by not scanning the whole switch when no install field is present #4494 changed the order in which sections were processed - the second commit here reverses (excuse pun!) that slip

NB List.flatten blows the stack w.r.t. the number of lists (which is fundamentally small) and the length of the longest sub-list - this would already blow the stack in an earlier List.map call, so I convinced myself that a crazy opam .install file with gazillions of entries is already exploding.

@dra27 dra27 requested review from AltGr and kit-ty-kate May 17, 2021 16:26
@dra27 dra27 added this to the 2.1.0~rc milestone May 17, 2021
@dra27 dra27 linked an issue May 17, 2021 that may be closed by this pull request
Copy link
Member

@AltGr AltGr left a comment

Choose a reason for hiding this comment

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

Seems good! See my comment on interrogations about special cases for #4494 though.

in
let () =
try if Unix.((lstat dst).st_kind <> S_REG) then
remove_file dst
Copy link
Member

Choose a reason for hiding this comment

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

This is the right behaviour, but now I am wondering what happens if a package overwrites a directory installed by another package with a file 🤔
It shouldn't be worse than just overriding files, and since this DirTrack is done outside of this, it should correctly detect the deleted files; but this has consequences with #4494, since that only handles lists of files expected to be installed: it should also track anything below in case it encounters a directory right ?

That seems pretty minor, though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure what happens at the higher level, but OpamSystem.install will fail if the destination is a directory?

Copy link
Collaborator

@rjbou rjbou May 25, 2021

Choose a reason for hiding this comment

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

Several kind of files are written in the install process:

  • the pkg.config file that is package specific by name
  • the files in .install file that are written in prefix/pkg/xxx
  • the misc files in .install that need confirmation from user to be installed, as they are absolute paths

Other install/copy are done via install field commands not opam instructions

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure what happens at the higher level, but OpamSystem.install will fail if the destination is a directory?

indeed, it is the first check

let install ?(warning=default_install_warning) ?exec src dst =
  if Sys.is_directory src then
    internal_error "Cannot install %s: it is a directory." src;
  if (try Sys.is_directory dst with Sys_error _ -> false) then
    internal_error "Cannot install to %s: it is a directory." dst;

Copy link
Member

@kit-ty-kate kit-ty-kate left a comment

Choose a reason for hiding this comment

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

My original PR in #4494 was significantly changed so none of this is my code (this also explains why i didn't see these issues sooner) and I can't really review it properly, but from afar it looks ok.

@rjbou rjbou self-requested a review May 19, 2021 12:16
@dra27 dra27 force-pushed the 4494-regression branch from c7ecc5d to fac0cc5 Compare May 24, 2021 20:51
@dra27 dra27 closed this May 25, 2021
@dra27 dra27 reopened this May 25, 2021
@dra27 dra27 force-pushed the 4494-regression branch from e68f928 to 8bb48be Compare May 26, 2021 10:43
@dra27 dra27 force-pushed the 4494-regression branch from 8bb48be to 22d98df Compare May 27, 2021 10:00
@rjbou rjbou merged commit fd1e55e into ocaml:master May 28, 2021
@dra27 dra27 deleted the 4494-regression branch June 7, 2021 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[master] opam-devel does not install the opam binary anymore
4 participants