From 0dc93f41c87256a1bab12975e98ebbe2f9426ffa Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 16 May 2021 14:55:15 -0700 Subject: use UIOP rather than dpkg(1) to compare prerequisite data versions For both performance and portability reasons. Signed-off-by: Sean Whitton --- doc/data.rst | 2 +- src/util.lisp | 22 +++++++--------------- 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 -- cgit v1.2.3