Skip to content

Do not use opam-installer to copy files - #941

Merged
6 commits merged into
masterfrom
unknown repository
Jul 3, 2018
Merged

6 commits merged into
masterfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Jul 2, 2018

Copy link
Copy Markdown

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 emillon and rgrinberg July 2, 2018 09:50
@ghost ghost added this to the 1.0.0 milestone Jul 2, 2018
Comment thread bin/main.ml Outdated
Io.copy_file () ~src ~dst
~chmod:(match section with
| Libexec -> (fun x -> x lor 0o111)
| _ -> (fun x -> x))

Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread src/install.ml
; man = Path.relative destdir "man"
; lib = Path.relative libdir package
; libexec = Path.relative libdir package
; share = Path.relative destdir ("share/" ^ package)

Copy link
Copy Markdown
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
Copy Markdown
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

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

andreypopp commented Jul 2, 2018 •

Copy link
Copy Markdown
Member

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

@ghost

ghost commented Jul 2, 2018

Copy link
Copy Markdown
Author

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

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

Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread bin/main.ml
files_deleted_in := Path.Set.add !files_deleted_in dir;
end;
Path.Set.to_list !files_deleted_in
|> List.rev

Copy link
Copy Markdown
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
Copy Markdown
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 <[email protected]>
Signed-off-by: Jeremie Dimino <[email protected]>
Signed-off-by: Jeremie Dimino <[email protected]>
@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