From a378e68834840e0a2f856837532ca23ba8dba07c Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Wed, 14 Nov 2007 00:05:49 +0000 Subject: [PATCH 1/1] Change method of determining whether a package is installed --- src/plugins/apt.sml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 -- 2.20.1