Commit d26a91d557bf48da3242c042436b0e9af1e0bb99

Thomas de Grivel 2018-07-04T04:39:48

wip debian pkg

diff --git a/unix/debian.lisp b/unix/debian.lisp
index 1864cb7..0d77726 100644
--- a/unix/debian.lisp
+++ b/unix/debian.lisp
@@ -22,13 +22,26 @@
 
 (define-resource-class debian-pkg (pkg)
   ()
-  ((probe-apt-pkg :properties (:versions))))
+  ((probe-debian-pkg :properties (:versions))))
 
 (define-syntax apt<8>-list (name release version arch tags)
   #~|([^/\s]+)(?:/([^\s]*))?\s+([^\s]+)\s+([^\s]+)(?:\s+\[([^\]]+)\])?|
   "Syntax for apt(8) list on Linux Debian"
   (values name release version arch (cl-ppcre:split "," tags)))
 
+(defmethod probe-debian-pkg ((pkg debian-pkg) (os os-linux-debian))
+  (let ((id (resource-id pkg))
+        (ensure :absent))
+    (multiple-value-bind #1=(release version arch tags)
+        (with-apt<8>-list (name . #1#)
+            (run "apt list | grep " id)
+          (declare (type string name))
+          (when (string= id name)
+            (when (find "installed" (the list tags))
+              (setf ensure :installed))
+            (return (values* #1#))))
+      (properties* (ensure . #1#)))))
+
 (defmethod probe-host-packages ((host host) (os os-linux-debian))
   (with-host host
     (let ((packages))