fix binary wrappers being skipped
This commit is contained in:
parent
d0cc80109e
commit
5de8e62e66
1 changed files with 24 additions and 3 deletions
27
bin/main.ml
27
bin/main.ml
|
|
@ -159,6 +159,26 @@ let elf_scan path needles =
|
|||
List.iter (fun n -> Hashtbl.replace found n true) needles);
|
||||
found
|
||||
|
||||
let nix_wrapper_target path =
|
||||
try
|
||||
let real = Unix.realpath path in
|
||||
let ic = open_in_bin real in
|
||||
let n = in_channel_length ic in
|
||||
if n > 65536 then (close_in ic; None)
|
||||
else begin
|
||||
let s = Bytes.create n in
|
||||
really_input ic s 0 n; close_in ic;
|
||||
let s = Bytes.to_string s in
|
||||
if not (contains_str s "makeCWrapper") then None
|
||||
else
|
||||
let re = Str.regexp "/nix/store/[a-z0-9]+-[^' \n\r\x00]+/bin/[a-zA-Z0-9._-]+" in
|
||||
try ignore (Str.search_forward re s 0);
|
||||
let target = Str.matched_string s in
|
||||
if Sys.file_exists target then Some target else None
|
||||
with Not_found -> None
|
||||
end
|
||||
with _ -> None
|
||||
|
||||
let skip_name name =
|
||||
String.length name = 0 || name = "-" || name.[0] = '.'
|
||||
|| String.starts_with ~prefix:"lib" name
|
||||
|
|
@ -177,9 +197,10 @@ let classify_binary bindir name =
|
|||
else if is_script path then Try_help
|
||||
else
|
||||
let scan = elf_scan path ["-h"; "completion"] in
|
||||
if not (Hashtbl.mem scan "-h") then Skip
|
||||
else if Hashtbl.mem scan "completion" then Try_native_and_help
|
||||
else Try_help
|
||||
if Hashtbl.mem scan "completion" then Try_native_and_help
|
||||
else if Hashtbl.mem scan "-h" then Try_help
|
||||
else if nix_wrapper_target path <> None then Try_help
|
||||
else Skip
|
||||
|
||||
let num_cores () =
|
||||
try
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue