Commit 82e1e1537f4ec77aac35da2c135c48eb9c499006

Thomas de Grivel 2020-10-22T21:06:57

adams 0.3.2

diff --git a/Makefile b/Makefile
index 8a393a2..c507555 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 PACKAGE = adams
-VERSION = 0.3.1
+VERSION = 0.3.2
 RELEASE_DIR = ${PACKAGE}-${VERSION}
 RELEASE_TARBALL = ${PACKAGE}-${VERSION}.tar.gz
 RELEASE_DEPS_TARBALL = ${PACKAGE}-${VERSION}.deps.tar.gz
diff --git a/README.md b/README.md
index 80fef9a..c609274 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-Adams 0.3
-=========
+Adams 0.3.2
+===========
 
 Adams is a UNIX system administration tool written in Common Lisp.
 
@@ -8,12 +8,6 @@ You describe your systems (hosts) using resources having properties.
 The properties are then probed and synchronized by Adams using only
 `/bin/sh` on the remote host, and `/usr/bin/ssh` on the control host.
 
-More viable alternatives include
-[Ansible](https://www.ansible.com/),
-[Chef](https://www.chef.io/)
-and
-[Puppet](https://puppet.com/).
-
 
 Configuration example
 ---------------------
diff --git a/prepare-build.lisp b/prepare-build.lisp
index 8ae26a5..a94bd53 100644
--- a/prepare-build.lisp
+++ b/prepare-build.lisp
@@ -187,6 +187,7 @@
                (load-form `(load ,build-file)))
           (format t "~& ~A~%" sys) (force-output)
           (print load-form out)))
-      (fresh-line out))))
+      (fresh-line out)
+      (force-output out))))
 
 (write-build-systems-file :adams)
diff --git a/unix/openbsd.lisp b/unix/openbsd.lisp
index 3afd665..168c49a 100644
--- a/unix/openbsd.lisp
+++ b/unix/openbsd.lisp
@@ -32,7 +32,7 @@
 (define-resource-class openbsd-pkg (pkg)
   ()
   ((probe-openbsd-pkg :properties (:ensure :flavor :version)))
-  ((op-openbsd-pkg :properties (:ensure))))
+  ((op-openbsd-pkg :properties (:ensure :version))))
 
 (define-syntax pkg_info<1> (name version flavor installed)
   #~|\s*([^-\s]+(?:-[^-0-9\s][^-\s]+)*)-([0-9][^-\s]*)(?:-([^-\s]+))?( \(installed\))?|
@@ -49,11 +49,11 @@
   (let ((id (resource-id pkg))
         (ensure :absent))
     (with-openbsd-pkg-id (id-name id-version id-flavor) (list id)
-      ;(format t "~&id-name ~S id-flavor ~S~%" id-name id-flavor)
+      (format t "~&id-name ~S id-flavor ~S~%" id-name id-flavor)
       (multiple-value-bind (version flavor)
           (with-pkg_info<1> (name version flavor installed)
               (run "pkg_info | egrep " (sh-quote (str "^" id-name)))
-            ;(format t "~&name ~S version ~S flavor ~S installed ~S~%" name version flavor installed)
+            (format t "~&name ~S version ~S flavor ~S installed ~S~%" name version flavor installed)
             (when (and (string= id-name name)
                        (or (and (null id-flavor) (null flavor))
                            (and id-flavor flavor
@@ -64,34 +64,26 @@
               (return (values version flavor))))
         (return (properties* ensure version flavor))))))
 
-(defmethod merge-property-values ((pkg openbsd-pkg)
-                                  (property (eql :versions))
-                                  (old list)
-                                  (new list))
-  (sort (remove-duplicates (append old new))
-        #'string<))
-
 (defmethod match-specified-value ((res host)
                                   (property (eql :packages))
                                   (specified list)
                                   (probed list)
                                   (os os-openbsd))
-  (format t "~&match-specified-value specified ~S~%" specified)
-  (format t "~&match-specified-value probed ~S~%" probed)
-  (force-output)
-  (with-openbsd-pkg-id (name version flavor) specified
-    (unless (find name probed :test #'string=)
-      (return nil)))
+  (dolist (pkg-id specified)
+    (unless (find pkg-id probed :test #'string=)
+      (return-from match-specified-value nil)))
   t)
 
-(defmethod op-openbsd-pkg ((pkg openbsd-pkg) (os os-openbsd) &key ensure)
+(defmethod op-openbsd-pkg ((pkg openbsd-pkg) (os os-openbsd) &key ensure version)
   (with-openbsd-pkg-id (id-name id-version id-flavor) (list (resource-id pkg))
-    (when (and id-flavor (not id-version))
-      (probe pkg :version))
+    (setq version
+	  (or version
+	      id-version
+	      (progn (probe pkg :version)
+		     (get-probed pkg :version))))
     (let ((pkg-string (str id-name
-                           (when (or id-version id-flavor)
-                             `(#\- ,(or id-version
-                                        (get-probed pkg :version))))
+			   (when version
+                             `(#\- ,version))
                            (when id-flavor
                              `(#\- ,id-flavor)))))
       (cond
@@ -117,16 +109,17 @@
 
 (defmethod op-host-packages ((host host) (os os-openbsd) &key packages)
   (with-host host
-    (with-openbsd-pkg-id (name version flavor) packages
-      (let ((pkg (resource 'openbsd-pkg name
-                           :ensure :installed)))
-        (when version
-          (resource 'openbsd-pkg name
-                    :version version))
-        (when flavor
-          (resource 'openbsd-pkg name
-                    :flavor flavor))
-        (sync pkg)))))
+    (dolist (pkg-id packages)
+      (with-openbsd-pkg-id (name version flavor) (list pkg-id)
+	(let ((pkg (resource 'openbsd-pkg pkg-id
+                             :ensure :installed)))
+          (when version
+            (resource 'openbsd-pkg pkg-id
+                      :version version))
+          (when flavor
+            (resource 'openbsd-pkg pkg-id
+                      :flavor flavor))
+          (sync pkg))))))
 
 #+nil
 (clear-resources)