Function: package-vc-install-dependencies
package-vc-install-dependencies is a byte-compiled function defined in
package-vc.el.gz.
Signature
(package-vc-install-dependencies REQUIREMENTS)
Documentation
Install missing dependencies, and return missing ones.
The return value will be nil if everything was found, or a list of (NAME VERSION) pairs of all packages that couldn't be found.
REQUIREMENTS should be a list of additional requirements; each element in this list should have the form (PACKAGE VERSION-LIST), where PACKAGE is a package name and VERSION-LIST is the required version of that package.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/package-vc.el.gz
(defun package-vc-install-dependencies (requirements)
"Install missing dependencies, and return missing ones.
The return value will be nil if everything was found, or a list
of (NAME VERSION) pairs of all packages that couldn't be found.
REQUIREMENTS should be a list of additional requirements; each
element in this list should have the form (PACKAGE VERSION-LIST),
where PACKAGE is a package name and VERSION-LIST is the required
version of that package."
(let ((to-install '()) (missing '()))
(cl-labels ((search (pkg)
"Attempt to find all dependencies for PKG."
(cond
((assq (car pkg) to-install)) ;inhibit cycles
((package-installed-p (car pkg)))
((let* ((pac package-archive-contents)
(desc (cadr (assoc (car pkg) pac))))
(if desc
(let ((reqs (package-desc-reqs desc)))
(push desc to-install)
(mapc #'search reqs))
(push pkg missing))))))
(version-order (a b)
"Predicate to sort packages in order."
(version-list-<
(package-desc-version b)
(package-desc-version a)))
(duplicate-p (a b)
"Are A and B the same package?"
(eq (package-desc-name a) (package-desc-name b)))
(depends-on-p (target package)
"Does PACKAGE depend on TARGET?"
(or (eq target package)
(let* ((pac package-archive-contents)
(desc (cadr (assoc package pac))))
(and desc (seq-some
(apply-partially #'depends-on-p target)
(mapcar #'car (package-desc-reqs desc)))))))
(dependent-order (a b)
(let ((desc-a (package-desc-name a))
(desc-b (package-desc-name b)))
(depends-on-p desc-a desc-b))))
(mapc #'search requirements)
(cl-callf sort to-install #'version-order)
(cl-callf seq-uniq to-install #'duplicate-p)
(cl-callf sort to-install #'dependent-order))
(mapc #'package-install-from-archive to-install)
missing))