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鈥檒l 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 PR in Progress in Opam 2.1.x via automation May 17, 2021
@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
@dra27 dra27 moved this from PR in Progress to PR To review in Opam 2.1.x May 17, 2021
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;

Opam 2.1.x automation moved this from PR To review to PR Finalised May 19, 2021
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
@rjbou rjbou moved this from PR Finalised to PR To review in Opam 2.1.x May 19, 2021
@dra27 dra27 moved this from PR To review to PR Finalised in Opam 2.1.x May 21, 2021
@dra27 dra27 moved this from PR Finalised to PR To review in Opam 2.1.x May 21, 2021
@dra27 dra27 closed this May 25, 2021
Opam 2.1.x automation moved this from PR To review to Done May 25, 2021
@dra27 dra27 reopened this May 25, 2021
Opam 2.1.x automation moved this from Done to PR in Progress May 25, 2021
@rjbou rjbou moved this from PR in Progress to PR To review in Opam 2.1.x May 25, 2021
@rjbou rjbou moved this from PR To review to PR Finalised in Opam 2.1.x May 27, 2021
@rjbou rjbou merged commit fd1e55e into ocaml:master May 28, 2021
Opam 2.1.x automation moved this from PR Finalised to Done 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
Opam 2.1.x
  
Done
Development

Successfully merging this pull request may close these issues.

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