Thicket data repository for the EEG
at main 3.6 kB view raw
1{ 2 "id": "https://www.tunbury.org/2025/03/31/opam-post-deps", 3 "title": "Installation order for opam packages", 4 "link": "https://www.tunbury.org/2025/03/31/opam-post-deps/", 5 "updated": "2025-03-31T00:00:00", 6 "published": "2025-03-31T00:00:00", 7 "summary": "Previously, I discussed the installation order for a simple directed acyclic graph without any cycles. However, opam packages include post dependencies. Rather than package A depending upon B where B would be installed first, post dependencies require X to be installed after Y. The post dependencies only occur in a small number of core OCaml packages. They are quite often empty and exist to direct the solver. Up until now, I had been using a base layer with an opam switch containing the base compiler and, therefore, did not need to deal with any post dependencies.", 8 "content": "<p>Previously, I discussed the installation order for a simple directed acyclic graph without any cycles. However, <code>opam</code> packages include <em>post</em> dependencies. Rather than package A depending upon B where B would be installed first, <em>post</em> dependencies require X to be installed after Y. The <em>post</em> dependencies only occur in a small number of core OCaml packages. They are quite often empty and exist to direct the solver. Up until now, I had been using a base layer with an opam switch containing the base compiler and, therefore, did not need to deal with any <em>post</em> dependencies.</p>\n\n<p>Here is the graph of <a href=\"https://www.tunbury.org/images/0install.2.18-with-post-with-colour.pdf\">0install</a> with <em>post</em> dependencies coloured in red.</p>\n\n<p>Removing the <em>post</em> dependencies gives an unsatisfying graph with orphaned dependencies. <a href=\"https://www.tunbury.org/images/0install.2.18-without-post.pdf\">0install without post</a>. Note <code>base-nnp.base</code> and <code>base-effects.base</code>. However, this graph can be used to produce a linear installation order. The orphaned packages can be removed with a recursive search.</p>\n\n<p>When opam wants to decide the installation order, it uses OCamlgraph’s topological sort capability.</p>\n\n<blockquote>\n <p>This functor provides functions which allow iterating over a graph in topological order. Cycles in graphs are allowed. Specification is the following: If vertex [x] is visited before vertex [y] then either there is a path from [x] to [y], or there is no path from [y] to [x]. In the particular case of a DAG, this simplifies to: if there is an edge from [x] to [y], then [x] is visited before [y].</p>\n</blockquote>\n\n<p>The description of <code>fold</code> is particularly interesting as the order for cycles is unspecified.</p>\n\n<blockquote>\n <p>[fold action g seed] allows iterating over the graph [g] in topological order. [action node accu] is called repeatedly, where [node] is the node being visited, and [accu] is the result of the [action]’s previous invocation, if any, and [seed] otherwise. If [g] contains cycles, the order is unspecified inside the cycles and every node in the cycles will be presented exactly once</p>\n</blockquote>\n\n<p>In my testing, the installation order matches the order used by opam within the variation allowed above.</p>\n\n<p>Layers can be built up using the intersection of packages installed so far and the required dependencies.</p>", 9 "content_type": "html", 10 "author": { 11 "name": "Mark Elvers", 12 "email": "mark.elvers@tunbury.org", 13 "uri": null 14 }, 15 "categories": [ 16 "opam", 17 "tunbury.org" 18 ], 19 "source": "https://www.tunbury.org/atom.xml" 20}