ocaml / opam

opam is a source-based package manager. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.
https://opam.ocaml.org
Other
1.21k stars 348 forks source link

new subcommand: opam admin migrate-extrafiles #5960

Open hannesm opened 1 month ago

hannesm commented 1 month ago

This subcommand allows to move all extra-files of an existing opam repository into extra-sources. The files are extracted into a specified local directory, and the opam files are edited in-place.

see #5811 for motivation

rjbou commented 1 month ago

Thanks for the PR! We'll look at it once opam 2.2 release is done

hannesm commented 1 month ago

For the future reviewer, a slightly modified piece (see https://github.com/hannesm/opam/compare/migrate...hannesm:opam:migrate-extra-files) was used for driving the rewrite for opam-repository (https://github.com/ocaml/opam-repository/pull/25960)

The main differences are:

So, it boils down to what to expect from such an automated migration, and whether there's need to have the result conveniently editable by people (or by scripts). Since some choices are hardcoded (such as the hash algorithm -- the tool has only ever been applied with SHA256 (and there are special code paths for "what if an MD5 is present" and "what to do if a SHA512 is present"), which is unlikely something you'd want to embed into the opam source tree.

About file naming, for deduplication reasons (and please note, there are other ways to achieve deduplication), the layout on the opam-source-archives repository is "patches/pkg-name/file1..N", i.e. not another subdirectory for pkg_version.