this repo has no description
0
fork

Configure Feed

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

at main 63 lines 2.4 kB view raw
1(** query command: show detailed info for a package *) 2 3open Cmdliner 4module Layer = Day11_layer.Layer 5 6let show_layers_from_symlinks ~os_dir ~packages_dir ~pkg_str = 7 let symlinks = Day11_layer.Scan.list_package_symlinks 8 ~exclude:["blessed-build"; "blessed-docs"; "history.jsonl"] 9 packages_dir pkg_str in 10 if symlinks = [] then begin 11 Printf.printf "No layers for %s\n" pkg_str; 12 1 13 end else begin 14 Printf.printf "Layers for %s (%d):\n\n" pkg_str (List.length symlinks); 15 List.iter (fun (name, _target) -> 16 let layer = Layer.of_hash ~os_dir name in 17 match Day11_layer.Meta.load (Layer.meta_path layer) with 18 | Ok meta -> 19 let status = if meta.exit_status = 0 then "ok" 20 else if meta.failed_dep <> None then "cascade" 21 else "fail" in 22 Printf.printf " %s status=%s created=%s\n" 23 name status meta.created_at 24 | Error _ -> 25 Printf.printf " %s (no metadata)\n" name 26 ) symlinks; 27 0 28 end 29 30let run profile_name profile_dir package = 31 match Common.load_profile ~profile_dir ~name:profile_name with 32 | Error (`Msg e) -> Printf.eprintf "Error: %s\n%!" e; 1 33 | Ok (_profile, paths) -> 34 match Common.latest_snapshot_dir paths with 35 | None -> Printf.printf "No snapshots found\n"; 1 36 | Some snapshot_dir -> 37 let os_dir = paths.os_dir in 38 let packages_dir = Fpath.(snapshot_dir / "packages") in 39 let entries = Day11_lib.History.read ~packages_dir ~pkg_str:package in 40 if entries = [] then 41 (* Fall back to showing layers discovered via symlinks *) 42 show_layers_from_symlinks ~os_dir ~packages_dir ~pkg_str:package 43 else begin 44 Printf.printf "History for %s (%d entries):\n\n" package 45 (List.length entries); 46 List.iter (fun (e : Day11_lib.History.entry) -> 47 Printf.printf " %s run=%s hash=%s status=%s category=%s compiler=%s%s\n" 48 e.ts e.run (String.sub e.build_hash 0 (min 16 (String.length e.build_hash))) 49 e.status e.category e.compiler 50 (if e.blessed then " [blessed]" else "") 51 ) entries; 52 0 53 end 54 55let package_term = 56 Arg.(required & pos 0 (some string) None & info [] ~docv:"PACKAGE" 57 ~doc:"Package name (e.g. astring.0.8.5)") 58 59let cmd = 60 let info = Cmd.info "query" ~doc:"Show build history for a package" in 61 let term = Term.(const run $ Common.profile_term $ Common.profile_dir_term 62 $ package_term) in 63 Cmd.v info term