You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

45 lines
1.2 KiB

;;
if Array.length Sys.argv <> 2 then (
Format.printf "usage: %s <package name>@." Sys.argv.(0);
exit 1
)
let pkg = Sys.argv.(1)
let chan =
Unix.open_process_in ("opam list -a --color=never -s")
let _ =
try
while true do
(* one pkg *)
let line = input_line chan in
(* the last version of this pkg *)
let last_ver =
input_line
(Unix.open_process_in
("opam show --color=never " ^ line ^ " -f version"))
in
let chan' =
Unix.open_process_in
( "opam list --color=never --required-by " ^ line ^ "." ^ last_ver
^ " -s" )
in
let seen = ref false in
try
while true do
(* one dep of this pkg *)
let line' = input_line chan' in
(* if pkg is here, then this pkg still depends on pkg *)
if line' = pkg then (
seen := true;
try Unix.kill (Unix.process_in_pid chan') Sys.sigkill with Sys_error _ -> ();
raise_notrace End_of_file
)
done
with End_of_file -> begin
ignore(Unix.close_process_in chan');
if not !seen then print_endline line;
end
done
with End_of_file -> ()