aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-05-16 14:55:15 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-05-17 12:52:15 -0700
commit0dc93f41c87256a1bab12975e98ebbe2f9426ffa (patch)
treebb5f64b59c777f00552efe9b4f9990b42ca69973
parent08b78ef52866754f93b977ebd73098047f54c49a (diff)
downloadconsfigurator-0dc93f41c87256a1bab12975e98ebbe2f9426ffa.tar.gz
use UIOP rather than dpkg(1) to compare prerequisite data versions
For both performance and portability reasons. Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--doc/data.rst2
-rw-r--r--src/util.lisp22
2 files changed, 8 insertions, 16 deletions
diff --git a/doc/data.rst b/doc/data.rst
index 47783b4..faba8a3 100644
--- a/doc/data.rst
+++ b/doc/data.rst
@@ -74,7 +74,7 @@ can't decrypt the store. If a prerequisite data source wants to effectively
bypass caching and provide fresh data every time Consfigurator deploys the
host, it can use ``GET-UNIVERSAL-TIME`` as its first function.
-Versions are compared using ``dpkg --compare-versions``.
+Versions are compared using ``UIOP:VERSION<`` and ``UIOP:VERSION<=``.
Security issues
---------------
diff --git a/src/util.lisp b/src/util.lisp
index cbc21c2..60653da 100644
--- a/src/util.lisp
+++ b/src/util.lisp
@@ -249,28 +249,20 @@ previous output."
;;;; Version numbers
+(defun number->string (x)
+ (etypecase x (string x) (number (format nil "~D" x))))
+
(defun version< (x y)
- (dpkg-version-compare x "<<" y))
+ (uiop:version< (number->string x) (number->string y)))
(defun version> (x y)
- (dpkg-version-compare x ">>" y))
+ (version< y x))
(defun version<= (x y)
- (dpkg-version-compare x "<=" y))
+ (uiop:version<= (number->string x) (number->string y)))
(defun version>= (x y)
- (dpkg-version-compare x ">=" y))
-
-(defun dpkg-version-compare (x r y)
- (zerop (nth-value 2 (run-program `("dpkg" "--compare-versions"
- ,(etypecase x
- (string x)
- (number (format nil "~A" x)))
- ,r
- ,(etypecase y
- (string y)
- (number (format nil "~A" y))))
- :ignore-error-status t))))
+ (version<= y x))
;;;; Encoding of strings to filenames