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: support package pinning via http+tar #11446

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

maiste
Copy link
Collaborator

@maiste maiste commented Feb 5, 2025

This PR reduces the gap between opam and dune package management functionnalities. It allows users to ping a tar file (gz or bz) using http (and https) protocol.

Closes #10121

Copy link
Collaborator

@Leonidas-from-XIV Leonidas-from-XIV left a comment

Choose a reason for hiding this comment

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

Thanks. The ZIP file changes can be added in a separate PR if you want, but I think that it would be useful to support it given it is a rather common format, especially on Windows.

bin/pkg/pkg_common.ml Outdated Show resolved Hide resolved
src/dune_pkg/mount.ml Outdated Show resolved Hide resolved
src/dune_pkg/opamUrl0.ml Show resolved Hide resolved
src/dune_pkg/opamUrl0.ml Outdated Show resolved Hide resolved
src/dune_pkg/opamUrl0.ml Outdated Show resolved Hide resolved
src/dune_pkg/source.ml Outdated Show resolved Hide resolved
test/blackbox-tests/test-cases/pkg/pin-depends.t Outdated Show resolved Hide resolved
src/dune_pkg/opamUrl0.mli Show resolved Hide resolved
test/blackbox-tests/test-cases/pkg/pin-depends.t Outdated Show resolved Hide resolved
@maiste maiste force-pushed the fix/pinning-10121-bis branch from 2182db3 to 5992d48 Compare February 6, 2025 16:07
@Leonidas-from-XIV
Copy link
Collaborator

@maiste I've looked into the describe.t failure and when I run it locally the issue does not happen, so it seems like that might be another CI failure.

@@ -23,6 +23,29 @@ let of_opam_url loc url =
>>| User_error.ok_exn
in
Git rev
| `Tar ->
let dir = Path.Build.(L.relative root [ "_fetch"; "url" ]) |> Path.build in
Copy link
Member

Choose a reason for hiding this comment

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

Why do we put this into _fetch? Is this to attempt to make the build system to use this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, exactly. Is there a better to do it?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think there's a way to do this at the moment. Whatever you write here will be removed by dune anyway. Might as well use a temp dir.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I try to respect the structure for Dune so it doesn't have to redo the work twice. Isn't it supposed to consider it?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think that will work. Dune writes a metadata file describing its state of the workspace local cache. If you didn't update this file, it will just delete what you have put in there.

raise (User_error.E message)
| Ok output ->
let target =
let file_digest = Digest.file (Path.to_string output) |> Digest.to_hex in
Copy link
Member

Choose a reason for hiding this comment

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

Path.to_string |> Digest.file |> Digest.to_hex

@@ -46,3 +46,14 @@ let extract ~archive ~target =
Path.rename target_in_temp target;
Ok ()
;;

let load_or_untar ~target ~archive =
match Path.exists target with
Copy link
Member

Choose a reason for hiding this comment

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

What if the tar file is updated remotely?

Copy link
Member

Choose a reason for hiding this comment

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

I still don't understand the point of this check

Copy link
Member

@rgrinberg rgrinberg left a comment

Choose a reason for hiding this comment

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

Do we plan to support tarballs on the file system?

@maiste
Copy link
Collaborator Author

maiste commented Feb 10, 2025

Do we plan to support tarballs on the file system?

No, we expect people to untar directory themselves on the file system and point to the path. I don't think it is worth adding the machinery for this as there is already one for file://.

What if the tar file is updated remotely?

If the file is updated remotely:

  • you will have to re-run dune pkg lock if you clean the _build or,
  • it will keep using the version in the _build without updating it.

I don't think we have a proper when to address it. If we checked on every run, people would have to download the tar file every time they run dune build. In the current configuration, people will have a checksum error if they do dune clean && dune build which is the equivalent of the behavior (good or bad, idk) with opam: you have to run opam reinstall to get the changes.

I would expect people to want to be aware when the checksum change, but having to explicitly state when they want to synchronize the checksum. It would prevent them from downloading tar they don't expect to change.

@rgrinberg
Copy link
Member

I think we should re-download the tarball and construct the checksum every time we run dune pkg lock. This is consistent with how we treat all other sources that lack a checksum. Anything else will be bound to create confusion that will have to be solved by reminding everyone to do the equivalent of opam update.

You could still avoid re-downloading if you use curl with the correct e-tag incantations.

@maiste
Copy link
Collaborator Author

maiste commented Feb 11, 2025

I agree with you, and this is what happens in the current situation. If you run dune pkg lock, it will download the tar and update the checksum. What I meant is that it is not going to change if you run dune build and the file changed remotely.

Regarding the etag, @Leonidas-from-XIV suggested this. However, many of the packages on opam-repository live in GitHub Release and from the requests I tried with curl, it does not seem to provide an ETag header. It is still an optimization we can do later.

@rgrinberg
Copy link
Member

Okay, thanks. Is there a test that demonstrates that subsequent dune pkg lock re-download it? We should have one.

@maiste
Copy link
Collaborator Author

maiste commented Feb 11, 2025

I'm rewriting my test to show the behavior. It should be ready for a next review round by the end of the day 👍

maiste and others added 8 commits February 11, 2025 13:57
Signed-off-by: Etienne Marais <[email protected]>
Co-authored-by: ArthurW <[email protected]>
Signed-off-by: Etienne Marais <[email protected]>
Co-authored-by: Marek Kubica <[email protected]>
Signed-off-by: Etienne Marais <[email protected]>
Signed-off-by: Etienne Marais <[email protected]>
Signed-off-by: Etienne Marais <[email protected]>
Signed-off-by: Etienne Marais <[email protected]>
@maiste maiste force-pushed the fix/pinning-10121-bis branch from 5992d48 to 6a41320 Compare February 11, 2025 13:19
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.

Support pinning packages with an archive url
3 participants