@@ 11,7 11,8 @@
#:parse
#:?)
(:export #:make-package-info
- ))
+ #:package-info=)
+ )
(in-package #:skin.djha.zippm/resolve)
@@ 172,7 173,6 @@
matches
less-equal
less-than
- in-range
not-equal
equal-to)
cl-semver:version)
@@ 261,8 261,43 @@
(declare (ignore colon at open-paren close-paren))
(make-package-info name version (coerce location 'string) requirements)))
+(defun version-predicate= (a b)
+ (declare (type version-predicate a b))
+ (and
+ (eql (relation a) (relation b))
+ (cl-semver:version= (version a) (version b))))
+;; This does not test requirer equality, as that would cause an infinite loop,
+;; since it represents a cycle in the graph.
+(defun requirement= (a b)
+ (declare (type requirement a b))
+ (and
+ (eql (status a) (status b))
+ (string= (name a) (name b))
+ (every (lambda (x y)
+ (every (lambda (x y)
+ (version-predicate= x y))
+ x
+ y))
+ (spec a)
+ (spec b))))
+
+(defun package-info= (a b)
+ (declare (type package-info a b))
+ (and
+ (string= (name a) (name b))
+ (cl-semver:version= (version a) (version b))
+ (string= (location a) (location b))
+ (every (lambda (x y)
+ (every (lambda (u v)
+ (and (requirement= u v)
+ (eq (requirer u) a)
+ (eq (requirer v) b)))
+ x
+ y))
+ (requirements a)
+ (requirements b))))
#+(or)
(progn
@@ 272,8 307,6 @@
(parse 'version-requirement "foo>=1.2.3,<=2.0.0,=>1.5.0;><3.0.0,!=3.2.3")
)
-
-
#+(or)
@@ 295,7 328,6 @@
(parse 'version-requirement "for>=1.2.3,<=2.0.0,=>1.5.0;><3.0.0,!=3.2.3")
(parse 'version-requirement "baz>=1.2.3,<=2.0.0,=>1.5.0;><3.0.0,!=3.2.3"))))
-
(defun present (name &key spec)
(make-instance 'requirement :status :present :name name :spec spec))
@@ 303,6 335,55 @@
(make-instance 'requirement :status :absent :name name :spec spec))
+(defun version-passes (ver pred)
+ (declare (type cl-semver:semantic-version version)
+ (type version-predicate pred))
+ (case (relation pred)
+ (:greater-than (cl-semver:version> ver (version pred)))
+ (:greater-equal (cl-semver:version>= ver (version pred)))
+ (:equal-to (cl-semver:version= ver (version pred)))
+ (:not-equal (cl-semver:version/= ver (version pred)))
+ (:less-equal (cl-semver:version<= ver (version pred)))
+ (:less-than (cl-semver:version< ver (version pred)))
+ (:pess-greater (and
+ (cl-semver:version>= ver (version pred))
+ (cl-semver:make-semantic-version
+ :major
+ (1+ (cl-semver:version-major ver))
+ :minor 0
+ :patch 0)))))
+
+(defmethod fulfills ((requirement requirement) (package package-info))
+ (and
+ (eql (status requirement) :present)
+ (string= (name requirement) (name package))
+ (every (lambda (spec)
+ (some (lambda (predicate)
+ (cl-semver:satisfies? (version package) predicate))
+ spec))
+ (spec requirement))))
+
+
+ (with-slots (name version requirements) package
+ (if (string= (name requirement) name)
+ (every (lambda (spec)
+ (some (lambda (predicate)
+ (cl-semver:satisfies? version predicate))
+ spec))
+ (spec requirement))
+ nil)))
+ (let ((name (name package))
+ (version (version package))
+ (requirements (requirements package)))
+ (if (string= (name requirement) name)
+ (every (lambda (spec)
+ (some (lambda (predicate)
+ (cl-semver:satisfies? version predicate))
+ spec))
+ (spec requirement))
+ nil)))
+
+
(defgeneric fulfills (requirement package)
@@ 125,9 125,12 @@
(pio-string "seven-bros:1.2.3@/tmp/foo(adam>=1.2.3,<=1.9.7,!=1.5.0;><3.0.0|benjamin==89.1.0;==89.5.0;==94.1.0&!caleb|caleb>=5.0.0-alpha.3,<5.0.0&daniel)"))
(ok (string= (format nil "~A" pio)
pio-string))
+ (ok (resolve:package-info= (esrap:parse 'resolve::package-info pio-string)
+ pio))
(ok (string= (format nil "~A" (esrap:parse 'resolve::package-info pio-string))
- pio-string)))))
+ pio-string))
+(ok (