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