{"action":"created","issue":{"url":"https://api.github.com/repos/ocaml/opam-repository/issues/5140","labels_url":"https://api.github.com/repos/ocaml/opam-repository/issues/5140/labels{/name}","comments_url":"https://api.github.com/repos/ocaml/opam-repository/issues/5140/comments","events_url":"https://api.github.com/repos/ocaml/opam-repository/issues/5140/events","html_url":"https://github.com/ocaml/opam-repository/pull/5140","id":116886800,"number":5140,"title":"bulk addition of 'ocamlbuild {build}' dependencies","user":{"login":"gasche","id":426238,"avatar_url":"https://avatars.githubusercontent.com/u/426238?v=3","gravatar_id":"","url":"https://api.github.com/users/gasche","html_url":"https://github.com/gasche","followers_url":"https://api.github.com/users/gasche/followers","following_url":"https://api.github.com/users/gasche/following{/other_user}","gists_url":"https://api.github.com/users/gasche/gists{/gist_id}","starred_url":"https://api.github.com/users/gasche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gasche/subscriptions","organizations_url":"https://api.github.com/users/gasche/orgs","repos_url":"https://api.github.com/users/gasche/repos","events_url":"https://api.github.com/users/gasche/events{/privacy}","received_events_url":"https://api.github.com/users/gasche/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2015-11-14T01:53:52Z","updated_at":"2015-11-20T15:29:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ocaml/opam-repository/pulls/5140","html_url":"https://github.com/ocaml/opam-repository/pull/5140","diff_url":"https://github.com/ocaml/opam-repository/pull/5140.diff","patch_url":"https://github.com/ocaml/opam-repository/pull/5140.patch"},"body":"I am experimenting with a script to edit opam-repository in bulk to add an [ocamlbuild](https://github.com/ocaml/opam-repository/tree/master/packages/ocamlbuild/) dependency to all packages that seem to depend on ocamlbuild, in the following sense:\r\n\r\n- they have a `_tags` file somewhere in the package archive; or,\r\n- they have a `myocamlbuild.ml` file somewhere in the package archive; or,\r\n- they have an `_oasis` file in the archive with the `BuildTools: ocamlbuild` line present; or,\r\n- they call `ocamlbuild` directly from the `build` command of their `opam` file\r\n\r\n(The context is that, as announced at the last OCaml Workshop in Vancouver, ocamlbuild should be eventually split from the standard definition. This means that adding the ocamlbuild dependency today will be a no-op, but it prevents scripts from breaking on an ocamlbuild-deprived compiler, or all ocamlbuild-using project packagers from having to edit their past and present `opam` package metadata manually.)\r\n\r\nThe script I wrote can be found at [gasche/opam:admin-scripts/add_ocamlbuild_dependency.ml](https://github.com/gasche/opam/blob/ocamlbuild-migration-script/admin-scripts/add_ocamlbuild_dependency.ml). It is heavily commented so that you can check it does what is described in this PR.\r\n\r\nRunning the script adds an `ocamlbuild` dependency to 2869 of the 4185 packages in the current opam-repository master.\r\n\r\nProgrammatically modifying `opam` files has the unfortunate side-effect that fields are re-ordered and some bracketing conventions changed, so the diff generated do not only contain the new dependency. In order to make the diff as easy to review as possible (that is: not very much, given its size), I have been careful to split changes in two commits, one just that just reformats the `opam` file without changing its semantics (but updates the version to 1.2, as I don't know whether older version support the output of the script's opam-serialization), and one that does add the dependency.\r\n\r\nIn the future, I think it could be useful to write an `opam fmt` script that would reformat `opam` files (by just reading and writing them again), with an `opam fmt --check` mode to verify that `opam fmt` would be a no-op, and run this `--check` on opam-repository pull requests to make sure that commiters have properly normalized their opam file before submission. This would make it easier to mix and review both human-written and bulk-generated changes.\r\n\r\n### Request for comment\r\n\r\nWould you be ready to merge such a pull-request?\r\n\r\nAre there any further change that we can make to the generating script to improve the proposed patch quality?\r\n\r\nThe current approach is to try to add as few `ocamlbuild` dependencies as necessary. Another would be to add it preemptively to all packages, and let packagers manually *remove* it when they deem it useful. This is guaranteed not to break programs, but it would result in some programs having stronger dependencies than necessary.\r\n\r\nAnother question is: what will happen for `./opam` files that are not in this public repository? Other repos are free to use my script to do their bulk-editing if it makes sense, but there are tons of `opam` files stored in upstream packages version control, and those would have to be modified manually. Maybe we should also provide a script to do this automatically, at the level of a single package (this would not be too hard by sharing code with the present script)."},"comment":{"url":"https://api.github.com/repos/ocaml/opam-repository/issues/comments/158432569","html_url":"https://github.com/ocaml/opam-repository/pull/5140#issuecomment-158432569","issue_url":"https://api.github.com/repos/ocaml/opam-repository/issues/5140","id":158432569,"user":{"login":"gasche","id":426238,"avatar_url":"https://avatars.githubusercontent.com/u/426238?v=3","gravatar_id":"","url":"https://api.github.com/users/gasche","html_url":"https://github.com/gasche","followers_url":"https://api.github.com/users/gasche/followers","following_url":"https://api.github.com/users/gasche/following{/other_user}","gists_url":"https://api.github.com/users/gasche/gists{/gist_id}","starred_url":"https://api.github.com/users/gasche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gasche/subscriptions","organizations_url":"https://api.github.com/users/gasche/orgs","repos_url":"https://api.github.com/users/gasche/repos","events_url":"https://api.github.com/users/gasche/events{/privacy}","received_events_url":"https://api.github.com/users/gasche/received_events","type":"User","site_admin":false},"created_at":"2015-11-20T15:29:44Z","updated_at":"2015-11-20T15:29:44Z","body":"My understanding is that normalization would happen whatever the opam version is, because OPAM printing will use a fixed order for the fields, so you'll see a normalization change whenever users didn't follow that order. (In my experience the OPAM fixed order is reasonable and can be argued to be an improvement.)\r\n\r\nI think there is no normalization tool that exists today, but I started working on one on the side (I'm at the level or reading Cmdliner documentation again because it's not that easy to bootstrap a project using it). You may be interested in my [design notes](https://annuel.framapad.org/p/opam-fmt) for the tool.\r\n"}}