feat(pkg): interpret %{pkg-self:build-id} variable#13312
Conversation
According to [1] and [2], `build-id` is a SHA256 hash identifying the precise package version with all its dependencies. Consumers of this variable, such as the process.sh script in [3], use this to identify specific packages in existing opam switches. In [3] this is used to find an already-built relocatable OCaml compiler. In dune we wish to re-use [3] for choosing the relocatable compiler, therefore we need to substitute the value with something that will not be picked up as a hash from an existing opam valuation of build-id. We don't support build-id of things other than pkg-self and that's fine for now because we don't have any need to at the moment. For now we choose a magic number that is easily recognizable in case anything needs to be debugged. [1] https://github.com/ocaml/opam/blob/master/src/state/opamPackageVar.ml [2] https://github.com/ocaml/opam/wiki/Spec-for-Extended-package-specific-variables [3] https://github.com/dra27/opam-repository/tree/relocatable Signed-off-by: Ali Caglayan <alizter@gmail.com>
| @@ -1,5 +1,7 @@ | |||
| Here we test the translation and implementation of opam package variables. | |||
|
|
|||
| CR-soon Alizter: The numbers here are pointless since we have line numbers. | |||
There was a problem hiding this comment.
I will address this point in a follow-up PR.
|
To me it seems odd that we fake a The issue is that if there's another user of |
Packages can put Patching the other repo is also not an option. We are consuming the repo and modifying it to meet our needs simply creates more work for both sides. Picking a dummy value, with the knowledge that we didn't pick anything before and rejected it allows us to build more packages than before. The hack in the third party repo is simply as a demo. Opam will intend to use something similar. The exact details of the implementation haven't settled yet, but its clear for now that build-id will need to be interpreted. |
The problem is that a faithful implementation of this variable would break dune's caching. Dune relies on digesting the contents of packages and their build instructions to avoid recompilation. Any sort of "unique" build identifier will break that. |
According to [1] and [2],
build-idis a SHA256 hash identifying the precise package version with all its dependencies.Consumers of this variable, such as the process.sh script in [3], use this to identify specific packages in existing opam switches. In [3] this is used to find an already-built relocatable OCaml compiler.
In dune we wish to re-use [3] for choosing the relocatable compiler, therefore we need to substitute the value with something that will not be picked up as a hash from an existing opam valuation of build-id.
For now we choose a magic number that is easily recognizable in case anything needs to be debugged.
[1] https://github.com/ocaml/opam/blob/master/src/state/opamPackageVar.ml
[2] https://github.com/ocaml/opam/wiki/Spec-for-Extended-package-specific-variables
[3] https://github.com/dra27/opam-repository/tree/relocatable
Addressing relevant concern in: