day11/build: extract opam knowledge from Run_in_layers via Oci_spec.t
The user-facing change is on Oci_spec: it now exposes a type t
representing a spec template, parameterized only by the rootfs path.
make returns t, and to_yojson / write take ~root to instantiate.
This separates "what container do I want" (known up-front) from
"where is the rootfs" (only known after the host-side mount step).
That separation lets Run_in_layers.run lose all of its hardcoded
opam-isms:
- No more container_env with HOME=/home/opam
- No more ~cwd:"/home/opam" / ~hostname:"builder" / ~network:true
- No more bash-wrapping of cmd:string into argv
- No more ~mounts parameter
The function now takes an Oci_spec.t directly and just calls
Oci_spec.write ~root:(Fpath.to_string merged) after mounting the
overlay. Its imports are now strictly Day11_container, Day11_layer,
Day11_exec — no Day11_opam_layer reference, no /home/opam mention.
The only thing still tying Run_in_layers to day11_build is the
Types.build_env reference.
Build_layer absorbed the opam-flavoured spec construction into a
new opam_build_spec helper (cwd /home/opam, env with HOME, network
on, bash-wrapped argv) and constructs the spec internally before
calling Run_in_layers.run. From the caller's perspective
Build_layer.build's signature is unchanged.
The doc-pipeline callers in generate.ml are unchanged: they still
go through Build_layer.build with a custom strategy, and the
opam-flavoured defaults happen to be exactly what odoc tools expect
(they live at /home/opam/doc-tools/bin/...).
Test files that used Oci_spec.make ~root:... and Oci_spec.write
were updated for the new template / instantiate split. The unit
tests that inspected the JSON pipe make_basic_spec () through a
small spec_to_json helper.
12 test suites green. End-to-end smoke build of logs.0.10.0 still
works; layer.json's timing record now reports a single prep_upper
phase instead of separate dump_state and chown entries (since
those moved out of Run_in_layers and into a Build_layer prep_upper
callback in an earlier commit on this same series).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>