Monorepo management for opam overlays
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Regenerate opam-repo from monorepo before sync

The sync command was using stale URLs from the opam-repo instead of
the authoritative URLs from the monorepo's dune-project files. This
caused clone failures for repos where the opam-repo had outdated
dev-repo URLs (e.g., ocaml-peertube had git.recoil.org instead of
tangled.org).

Now sync regenerates opam-repo entries from the monorepo before
discovering packages, ensuring URLs are always up to date.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

+37 -3
+37 -3
lib/monopam.ml
··· 1435 1435 m "Failed to fetch from %s: %a" remote Git.pp_error e)) 1436 1436 verse_remotes 1437 1437 1438 + (* Helper to read file contents, returning None if file doesn't exist *) 1439 + let read_file_opt path = try Some (Eio.Path.load path) with Eio.Io _ -> None 1440 + 1441 + (* Regenerate opam-repo entries from monorepo dune-project files. 1442 + This ensures URLs in opam-repo match the monorepo before sync. *) 1443 + let regenerate_opam_repo ~fs ~config () = 1444 + let monorepo = Config.Paths.monorepo config in 1445 + let sources_path = Fpath.(monorepo / "sources.toml") in 1446 + let sources = 1447 + match Sources_registry.load ~fs sources_path with 1448 + | Ok s -> s 1449 + | Error _ -> Sources_registry.empty 1450 + in 1451 + match discover_packages_from_monorepo ~fs ~config ~sources () with 1452 + | Error _ -> () (* Skip on error *) 1453 + | Ok pkgs -> 1454 + let opam_repo = Config.Paths.opam_repo config in 1455 + let updated = ref 0 in 1456 + List.iter 1457 + (fun pkg -> 1458 + let pkg_dir = 1459 + Fpath.(opam_repo / "packages" / pkg.pkg_name / (pkg.pkg_name ^ ".dev")) 1460 + in 1461 + let dst_path = Eio.Path.(fs / Fpath.to_string pkg_dir / "opam") in 1462 + let dst_content = read_file_opt dst_path in 1463 + if Some pkg.opam_content <> dst_content then begin 1464 + let pkg_dir_eio = Eio.Path.(fs / Fpath.to_string pkg_dir) in 1465 + (try Eio.Path.mkdirs ~perm:0o755 pkg_dir_eio with Eio.Io _ -> ()); 1466 + Eio.Path.save ~create:(`Or_truncate 0o644) dst_path pkg.opam_content; 1467 + incr updated 1468 + end) 1469 + pkgs; 1470 + if !updated > 0 then 1471 + Log.info (fun m -> m "Regenerated %d opam-repo entries from monorepo" !updated) 1472 + 1438 1473 let sync ~proc ~fs ~config ?package ?(remote = false) ?(skip_push = false) 1439 1474 ?(skip_pull = false) () = 1440 1475 let fs_t = fs_typed fs in ··· 1457 1492 match ensure_monorepo_initialized ~proc ~fs:fs_t ~config with 1458 1493 | Error e -> Error e 1459 1494 | Ok () -> ( 1495 + (* Regenerate opam-repo from monorepo to ensure URLs are up to date *) 1496 + regenerate_opam_repo ~fs:(fs_t :> _ Eio.Path.t) ~config (); 1460 1497 match discover_packages ~fs:(fs_t :> _ Eio.Path.t) ~config () with 1461 1498 | Error e -> Error e 1462 1499 | Ok all_pkgs -> ··· 1764 1801 Fmt.pf ppf "Synced: %d, Unchanged: %d, Missing: %d, Orphaned: %d" 1765 1802 (List.length r.synced) (List.length r.unchanged) (List.length r.missing) 1766 1803 (List.length r.orphaned) 1767 - 1768 - (* Read file contents safely, returning None if file doesn't exist *) 1769 - let read_file_opt path = try Some (Eio.Path.load path) with Eio.Io _ -> None 1770 1804 1771 1805 (* List all package directories in opam-repo/packages/ *) 1772 1806 let list_opam_repo_packages ~fs ~config =