X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/7adeee333409df08a82fafc8b1629e56d47c09c1..a378e68834840e0a2f856837532ca23ba8dba07c:/src/plugins/apt.sml diff --git a/src/plugins/apt.sml b/src/plugins/apt.sml index 1c31fbd..d2517e9 100644 --- a/src/plugins/apt.sml +++ b/src/plugins/apt.sml @@ -25,6 +25,20 @@ fun validName s = CharVector.all (fn ch => Char.isAlphaNum ch orelse ch = #"_" o fun installed name = validName name - andalso OS.Process.isSuccess (OS.Process.system ("/usr/bin/dpkg -p " ^ name ^ " >/dev/null 2>/dev/null")) + andalso let + val proc = Unix.execute ("/usr/bin/apt-cache", ["policy", name]) + val inf = Unix.textInstreamOf proc + + val _ = TextIO.inputLine inf + in + (case TextIO.inputLine inf of + NONE => false + | SOME line => + case String.tokens Char.isSpace line of + [_, "(none)"] => false + | [_, _] => true + | _ => false) + before ignore (Unix.reap proc) + end end