Improve OpenBSD probes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
diff --git a/unix/defs.lisp b/unix/defs.lisp
index f9f81a6..d567424 100644
--- a/unix/defs.lisp
+++ b/unix/defs.lisp
@@ -53,10 +53,10 @@
(eval-when (:compile-toplevel :load-toplevel :execute)
(defvar *cksum-legacy-algorithms*
- '(:cksum :sum :sysvsum))
+ '(:cksum))
(defvar *cksum-algorithms*
- `(:md4 :md5 :rmd160 :sha1 :sha224 :sha256 :sha384 :sha512
+ `(:md5 :rmd160 :sha1 :sha224 :sha256 :sha384 :sha512
,@*cksum-legacy-algorithms*)))
(defvar *probe-file-content-size-limit* 8192)
diff --git a/unix/openbsd.lisp b/unix/openbsd.lisp
index a44cbe1..c045ea1 100644
--- a/unix/openbsd.lisp
+++ b/unix/openbsd.lisp
@@ -22,33 +22,40 @@
(define-resource-class openbsd-pkg (pkg)
()
- ((probe-openbsd-pkg :properties (:name :version :flavors))))
+ ((probe-openbsd-pkg :properties (:versions))))
-(define-syntax pkg_info<1> (name version flavors)
- #~|\s*((?:[^-\s]+)(?:-[^-0-9\s][^-\s]*)*)-([0-9][^-\s]*)(-[^\s]+)?|
+(define-syntax pkg_info<1> (name version)
+ #~|\s*((?:[^-\s]+)(?:-[^-0-9\s][^-\s]*)*)-([0-9][^-\s]*-[^\s]+)?|
"Syntax for pkg_info(1) on OpenBSD"
- (values name version (re-matches #~|[^-]+| flavors)))
+ (values name (list version)))
(defgeneric probe-openbsd-pkg (resource os))
(defmethod probe-openbsd-pkg ((pkg openbsd-pkg) (os os-openbsd))
(let ((id (resource-id pkg)))
- (multiple-value-bind #1=(name version flavors)
- (iter (pkg_info<1> #1# in
+ (multiple-value-bind #1=(versions)
+ (iter (pkg_info<1> (name versions) in
(run "pkg_info | egrep ~A" (sh-quote (str "^" id "-"))))
(when (string= id name)
(return (values* #1#))))
(properties* #1#))))
+(defmethod merge-property-values ((pkg openbsd-pkg)
+ (property (eql :versions))
+ (old list)
+ (new list))
+ (sort (remove-duplicates (append old new))
+ #'string<))
+
(defmethod probe-installed-packages% ((host host) (os os-openbsd))
(with-host host
- (iter (pkg_info<1> #1=(name version flavors)
+ (iter (pkg_info<1> #1=(name versions flavors)
in (run "pkg_info"))
(for pkg = (resource 'openbsd-pkg name))
(add-probed-properties pkg (properties* #1#))
- (collect pkg))))
+ (adjoining pkg))))
-(defun probe-installed-packages (&optional (host *host*))
+(defun probe-installed-packages (&optional (host (current-host)))
(probe-installed-packages% host (host-os host)))
#+nil
@@ -58,7 +65,10 @@
(describe-probed (resource 'openbsd-pkg "emacs"))
#+nil
-(probe-installed-packages *localhost* (host-os *localhost*))
+(probe-installed-packages)
+
+#+nil
+(map nil #'describe-probed (probe-installed-packages))
#+nil
(run "pkg_info -q | grep emacs-")