:group 'package
:version "24.1")
-(defun package-version-split (string)
- "Split a package string into a version list."
- (mapcar 'string-to-int (split-string string "[.]")))
-
(defconst package--builtins-base
;; We use package-version split here to make sure to pick up the
;; minor version.
- `((emacs . [,(package-version-split emacs-version) nil
+ `((emacs . [,(version-to-list emacs-version) nil
"GNU Emacs"])
- (package . [,(package-version-split package-el-version)
+ (package . [,(version-to-list package-el-version)
nil "Simple package system for GNU Emacs"]))
"Packages which are always built-in.")
"Turn a list of version numbers into a version string."
(mapconcat 'int-to-string l "."))
-(defun package--version-first-nonzero (l)
- (while (and l (= (car l) 0))
- (setq l (cdr l)))
- (if l (car l) 0))
-
-(defun package-version-compare (v1 v2 fun)
- "Compare two version lists according to FUN.
-FUN can be <, <=, =, >, >=, or /=."
- (while (and v1 v2 (= (car v1) (car v2)))
- (setq v1 (cdr v1)
- v2 (cdr v2)))
- (if v1
- (if v2
- ;; Both not null; we know the cars are not =.
- (funcall fun (car v1) (car v2))
- ;; V1 not null, V2 null.
- (funcall fun (package--version-first-nonzero v1) 0))
- (if v2
- ;; V1 null, V2 not null.
- (funcall fun 0 (package--version-first-nonzero v2))
- ;; Both null.
- (funcall fun 0 0))))
-
(defun package-strip-version (dirname)
"Strip the version from a combined package name and version.
E.g., if given \"quux-23.0\", will return \"quux\""
((eq force t)
t)
((stringp force) ; held
- (package-version-compare (package-version-split version)
- (package-version-split force)
- '=))
+ (version-list-= (version-to-list version)
+ (version-to-list force)))
(t
(error "Invalid element in `package-load-list'")))
(package-load-descriptor dir subdir))))))))
(defun package--built-in (package version)
"Return true if the package is built-in to Emacs."
(let ((elt (assq package package--builtins)))
- (and elt
- (package-version-compare (package-desc-vers (cdr elt)) version '=))))
+ (and elt (version-list-= (package-desc-vers (cdr elt)) version))))
;; FIXME: return a reason instead?
(defun package-activate (package version)
(req-list (package-desc-reqs (cdr pkg-desc)))
;; If the package was never activated, do it now.
(keep-going (or (not (memq package package-activated-list))
- (package-version-compare this-version version '>))))
+ (version-list-< version this-version))))
(while (and req-list keep-going)
(let* ((req (car req-list))
(req-name (car req))
;; can also get here if the requested package was already
;; activated. Return non-nil in the latter case.
(and (memq package package-activated-list)
- (package-version-compare this-version version '>=))))))
+ (version-list-<= version this-version))))))
(defun package-mark-obsolete (package pkg-vec)
"Put package on the obsolete list, if not already there."
Each requirement is of the form (OTHER-PACKAGE \"VERSION\")."
(let* ((name (intern name-str))
(pkg-desc (assq name package-alist))
- (new-version (package-version-split version-string))
+ (new-version (version-to-list version-string))
(new-pkg-desc
(cons name
(vector new-version
(mapcar
(lambda (elt)
(list (car elt)
- (package-version-split (car (cdr elt)))))
+ (version-to-list (car (cdr elt)))))
requirements)
docstring))))
;; Only redefine a package if the redefinition is newer.
(if (or (not pkg-desc)
- (package-version-compare new-version
- (package-desc-vers (cdr pkg-desc))
- '>))
+ (version-list-< (package-desc-vers (cdr pkg-desc))
+ new-version))
(progn
(when pkg-desc
;; Remove old package and declare it obsolete.
;; You can have two packages with the same version, for instance
;; one in the system package directory and one in your private
;; directory. We just let the first one win.
- (unless (package-version-compare new-version
- (package-desc-vers (cdr pkg-desc))
- '=)
+ (unless (version-list-= new-version
+ (package-desc-vers (cdr pkg-desc)))
;; The package is born obsolete.
(package-mark-obsolete (car new-pkg-desc) (cdr new-pkg-desc))))))
(defun package-installed-p (package &optional min-version)
(let ((pkg-desc (assq package package-alist)))
(and pkg-desc
- (package-version-compare min-version
- (package-desc-vers (cdr pkg-desc))
- '<=))))
+ (version-list-<= min-version
+ (package-desc-vers (cdr pkg-desc))))))
(defun package-compute-transaction (result requirements)
(dolist (elt requirements)
(symbol-name next-pkg)))
((null (stringp hold))
(error "Invalid element in `package-load-list'"))
- ((package-version-compare next-version
- (package-version-split hold)
- '>)
+ ((version-list-< (version-to-list hold) next-version)
(error "Package '%s' held at version %s, \
but version %s required"
(symbol-name next-pkg) hold
(unless pkg-desc
(error "Package '%s' is not available for installation"
(symbol-name next-pkg)))
- (unless (package-version-compare (package-desc-vers (cdr pkg-desc))
- next-version
- '>=)
+ (unless (version-list-<= next-version
+ (package-desc-vers (cdr pkg-desc)))
(error
"Need package '%s' with version %s, but only %s is available"
(symbol-name next-pkg) (package-version-join next-version)
;; Version 1 of 'builtin-packages' is a list where the car is
;; a split emacs version and the cdr is an alist suitable for
;; package--builtins.
- (let ((our-version (package-version-split emacs-version))
+ (let ((our-version (version-to-list emacs-version))
(result package--builtins-base))
(setq package--builtins
(dolist (elt builtins result)
- (if (package-version-compare our-version (car elt) '>=)
+ (if (version-list-<= (car elt) our-version)
(setq result (append (cdr elt) result)))))))))
(defun package-read-archive-contents (archive)
(vconcat (cdr package) (vector archive))))
(existing-package (cdr (assq name package-archive-contents))))
(when (or (not existing-package)
- (package-version-compare version
- (aref existing-package 0) '>))
+ (version-list-< (aref existing-package 0) version))
(add-to-list 'package-archive-contents entry))))
(defun package-download-transaction (transaction)
(mapcar
(lambda (elt)
(list (car elt)
- (package-version-split (car (cdr elt)))))
+ (version-to-list (car (cdr elt)))))
requires))
(set-text-properties 0 (length file-name) nil file-name)
(set-text-properties 0 (length pkg-version) nil pkg-version)
(mapcar
(lambda (elt)
(list (car elt)
- (package-version-split (car (cdr elt)))))
+ (version-to-list (car (cdr elt)))))
requires))
(vector pkg-name requires docstring version-string readme))))
(cond ((stringp (cadr hold))
"held")
((and (setq builtin (assq name package--builtins))
- (package-version-compare
+ (version-list-=
(package-desc-vers (cdr builtin))
- (package-desc-vers desc)
- '=))
+ (package-desc-vers desc)))
"built-in")
(t "installed"))
(package-desc-doc desc)
hold (assq name package-load-list))
(unless (and hold (stringp (cadr hold))
(package-installed-p
- name (package-version-split (cadr hold))))
+ name (version-to-list (cadr hold))))
(setq info-list
(package-list-maybe-add name
(package-desc-vers desc)