HCoop
/
hcoop
/
domtool2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7adeee3
)
Change method of determining whether a package is installed
author
Adam Chlipala
<adamc@hcoop.net>
Wed, 14 Nov 2007 00:05:49 +0000
(
00:05
+0000)
committer
Adam Chlipala
<adamc@hcoop.net>
Wed, 14 Nov 2007 00:05:49 +0000
(
00:05
+0000)
src/plugins/apt.sml
patch
|
blob
|
blame
|
history
diff --git
a/src/plugins/apt.sml
b/src/plugins/apt.sml
index
1c31fbd
..
d2517e9
100644
(file)
--- 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
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
end