core: install and uninstall package from package-alist
Consult the archive only when the user actually update the packages. Fixes #2956
This commit is contained in:
parent
dad786bc8d
commit
3f18a09560
|
@ -658,15 +658,18 @@ path."
|
||||||
"to add a recipe for it in alist %S.")
|
"to add a recipe for it in alist %S.")
|
||||||
pkg-name recipes-var))))
|
pkg-name recipes-var))))
|
||||||
|
|
||||||
(defun configuration-layer//filter-packages-with-deps (pkg-names filter)
|
(defun configuration-layer//filter-packages-with-deps
|
||||||
|
(pkg-names filter &optional use-archive)
|
||||||
"Return a filtered PACKAGES list where each elements satisfies FILTER."
|
"Return a filtered PACKAGES list where each elements satisfies FILTER."
|
||||||
(when pkg-names
|
(when pkg-names
|
||||||
(let (result)
|
(let (result)
|
||||||
(dolist (pkg-name pkg-names)
|
(dolist (pkg-name pkg-names)
|
||||||
;; recursively check dependencies
|
;; recursively check dependencies
|
||||||
(let* ((deps
|
(let* ((deps
|
||||||
(configuration-layer//get-package-deps-from-archive
|
(if use-archive
|
||||||
pkg-name))
|
(configuration-layer//get-package-deps-from-archive
|
||||||
|
pkg-name)
|
||||||
|
(configuration-layer//get-package-deps-from-alist pkg-name)))
|
||||||
(install-deps
|
(install-deps
|
||||||
(when deps (configuration-layer//filter-packages-with-deps
|
(when deps (configuration-layer//filter-packages-with-deps
|
||||||
(mapcar 'car deps) filter))))
|
(mapcar 'car deps) filter))))
|
||||||
|
@ -717,7 +720,7 @@ path."
|
||||||
(defun configuration-layer//get-packages-to-update (pkg-names)
|
(defun configuration-layer//get-packages-to-update (pkg-names)
|
||||||
"Return a filtered list of PKG-NAMES to update."
|
"Return a filtered list of PKG-NAMES to update."
|
||||||
(configuration-layer//filter-packages-with-deps
|
(configuration-layer//filter-packages-with-deps
|
||||||
pkg-names 'configuration-layer//new-version-available-p))
|
pkg-names 'configuration-layer//new-version-available-p 'use-archive))
|
||||||
|
|
||||||
(defun configuration-layer//configure-packages (packages)
|
(defun configuration-layer//configure-packages (packages)
|
||||||
"Configure all passed PACKAGES honoring the steps order."
|
"Configure all passed PACKAGES honoring the steps order."
|
||||||
|
@ -979,12 +982,12 @@ to select one."
|
||||||
"Return the path for LAYER symbol."
|
"Return the path for LAYER symbol."
|
||||||
(ht-get configuration-layer-paths layer))
|
(ht-get configuration-layer-paths layer))
|
||||||
|
|
||||||
(defun configuration-layer//get-all-packages-dependencies ()
|
(defun configuration-layer//get-packages-dependencies ()
|
||||||
"Returns dependencies hash map for all packages in `package-alist'."
|
"Returns dependencies hash map for all packages in `package-alist'."
|
||||||
(let ((result (make-hash-table :size 512)))
|
(let ((result (make-hash-table :size 512)))
|
||||||
(dolist (pkg package-alist)
|
(dolist (pkg package-alist)
|
||||||
(let* ((pkg-sym (car pkg))
|
(let* ((pkg-sym (car pkg))
|
||||||
(deps (configuration-layer//get-package-dependencies pkg-sym)))
|
(deps (configuration-layer//get-package-deps-from-alist pkg-sym)))
|
||||||
(dolist (dep deps)
|
(dolist (dep deps)
|
||||||
(let* ((dep-sym (car dep))
|
(let* ((dep-sym (car dep))
|
||||||
(value (ht-get result dep-sym)))
|
(value (ht-get result dep-sym)))
|
||||||
|
@ -1038,12 +1041,13 @@ to select one."
|
||||||
(expand-file-name (concat elpa-dir pkg-dir-name))))
|
(expand-file-name (concat elpa-dir pkg-dir-name))))
|
||||||
(t (package-desc-dir (cadr pkg-desc))))))
|
(t (package-desc-dir (cadr pkg-desc))))))
|
||||||
|
|
||||||
(defun configuration-layer//get-package-dependencies (pkg-name)
|
(defun configuration-layer//get-package-deps-from-alist (pkg-name)
|
||||||
"Return the dependencies alist for package with name PKG-NAME."
|
"Return the dependencies alist for package with name PKG-NAME."
|
||||||
(let ((pkg-desc (assq pkg-name package-alist)))
|
(let ((pkg-desc (assq pkg-name package-alist)))
|
||||||
(cond
|
(when pkg-desc
|
||||||
((version< emacs-version "24.3.50") (aref (cdr pkg-desc) 1))
|
(cond
|
||||||
(t (package-desc-reqs (cadr pkg-desc))))))
|
((version< emacs-version "24.3.50") (aref (cdr pkg-desc) 1))
|
||||||
|
(t (package-desc-reqs (cadr pkg-desc)))))))
|
||||||
|
|
||||||
(defun configuration-layer//get-package-deps-from-archive (pkg-name)
|
(defun configuration-layer//get-package-deps-from-archive (pkg-name)
|
||||||
"Return the dependencies alist for a PKG-NAME from the archive data."
|
"Return the dependencies alist for a PKG-NAME from the archive data."
|
||||||
|
@ -1113,7 +1117,7 @@ Returns the filtered list."
|
||||||
(defun configuration-layer/delete-orphan-packages (packages)
|
(defun configuration-layer/delete-orphan-packages (packages)
|
||||||
"Delete PACKAGES if they are orphan."
|
"Delete PACKAGES if they are orphan."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((dependencies (configuration-layer//get-all-packages-dependencies))
|
(let* ((dependencies (configuration-layer//get-packages-dependencies))
|
||||||
(implicit-packages (configuration-layer//get-implicit-packages
|
(implicit-packages (configuration-layer//get-implicit-packages
|
||||||
configuration-layer--used-distant-packages))
|
configuration-layer--used-distant-packages))
|
||||||
(orphans (configuration-layer//filter-used-themes
|
(orphans (configuration-layer//filter-used-themes
|
||||||
|
|
Loading…
Reference in a new issue