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

Do not use opam-installer to copy files #941

Merged
6 commits merged into from Jul 3, 2018
Merged

Do not use opam-installer to copy files #941

6 commits merged into from Jul 3, 2018

Conversation

ghost
Copy link

@ghost ghost commented Jul 2, 2018

opam is currently not mandatory to use dune, however one still needs the external opam-installer binary in order to run dune install or dune uninstall. This is annoying, especially since this tool is quite simple.

In order to make dune more self-contained, this PR reimplements dune install and dune uninstall without calling out to opam-installer.

@ghost ghost requested review from rgrinberg and emillon July 2, 2018 09:50
@ghost ghost added this to the 1.0.0 milestone Jul 2, 2018
bin/main.ml Outdated
Io.copy_file () ~src ~dst
~chmod:(match section with
| Libexec -> (fun x -> x lor 0o111)
| _ -> (fun x -> x))
Copy link
Collaborator

Choose a reason for hiding this comment

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

opam-installer will clear the executable bit in the other cases, so it should be something like x land 0o666. (I'd recommend extracting set_executable_bits and clear_executable_bits function as well)

Copy link
Author

Choose a reason for hiding this comment

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

thanks for the pointer, I realized we also need to add Lib_root and Libexec_root. I updated the code

; man = Path.relative destdir "man"
; lib = Path.relative libdir package
; libexec = Path.relative libdir package
; share = Path.relative destdir ("share/" ^ package)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it OK to concatenate paths like this? I guess package is normalized already (so it does not contain slashes or ".."), but also does it work on windows?

Copy link
Author

Choose a reason for hiding this comment

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

There might be an issue here. However we were doing the same before and we have had no issue so far. I guess we could add a few more constraints on package names

bin/main.ml Outdated
try
f ()
with Unix.Unix_error (e, _, _) ->
Format.fprintf err_ppf "@{<error>Error@}: %s@."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Out of curiosity, why is it not possible to print on stderr directly?

Copy link
Author

Choose a reason for hiding this comment

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

actually, yes it's possible. I didn't remember stderr was configured to interpret styles

Copy link
Member

Choose a reason for hiding this comment

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

Isn't this better to do it this way so that buffering is consistent?

Copy link
Author

Choose a reason for hiding this comment

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

This is a synchronous call so it's not an issue

@andreypopp
Copy link
Member

andreypopp commented Jul 2, 2018

Could it be made to use DESTDIR variable from the environment as the installation prefix?

@ghost
Copy link
Author

ghost commented Jul 2, 2018

we should do it in this PR if opam-installer currently does it. Otherwise in another PR

bin/main.ml Outdated
if what = "install" then begin
Printf.eprintf "Installing %s as %s\n%!"
(Path.to_string src)
(Path.to_string_maybe_quoted dst);
Copy link
Member

Choose a reason for hiding this comment

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

Just curious why we're printing paths differently here (not quoted vs maybe quoted)

Copy link
Author

Choose a reason for hiding this comment

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

Actually I didn't mean to print src as the lines are quite long already, it was just temporarily to debug something

bin/main.ml Outdated
files_deleted_in := Path.Set.add !files_deleted_in dir;
end;
Path.Set.to_list !files_deleted_in
|> List.rev
Copy link
Member

Choose a reason for hiding this comment

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

What's the significance of doing it in this order?

Copy link
Author

Choose a reason for hiding this comment

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

It is to make sure we delete sub-directories first. I added a comment

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
@ghost ghost merged commit e56fba9 into ocaml:master Jul 3, 2018
This pull request was closed.
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.

5 participants