Fix update error when a distant package is unavailable
Instead of error, show a warning that the unavailable package(s) were skipped. This should handle situations were a package is temporarily unavailable from MELPA (or other sources).
This commit is contained in:
parent
a4fd6407b2
commit
b4c10a4749
1 changed files with 22 additions and 1 deletions
|
@ -14,6 +14,7 @@
|
||||||
;;
|
;;
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
|
(require 'cl-lib)
|
||||||
(require 'eieio)
|
(require 'eieio)
|
||||||
(require 'package)
|
(require 'package)
|
||||||
(require 'ht)
|
(require 'ht)
|
||||||
|
@ -124,6 +125,9 @@
|
||||||
(defvar configuration-layer--used-distant-packages '()
|
(defvar configuration-layer--used-distant-packages '()
|
||||||
"A list of all distant packages that are effectively used.")
|
"A list of all distant packages that are effectively used.")
|
||||||
|
|
||||||
|
(defvar configuration-layer--skipped-packages nil
|
||||||
|
"A list of all packages that were skipped during last update attempt.")
|
||||||
|
|
||||||
(defvar configuration-layer-error-count nil
|
(defvar configuration-layer-error-count nil
|
||||||
"Non nil indicates the number of errors occurred during the
|
"Non nil indicates the number of errors occurred during the
|
||||||
installation of initialization.")
|
installation of initialization.")
|
||||||
|
@ -704,7 +708,10 @@ path."
|
||||||
(configuration-layer//get-latest-package-version-string
|
(configuration-layer//get-latest-package-version-string
|
||||||
pkg-name)))
|
pkg-name)))
|
||||||
;; (message "%s: %s > %s ?" pkg-name cur-version new-version)
|
;; (message "%s: %s > %s ?" pkg-name cur-version new-version)
|
||||||
(version< cur-version new-version))))
|
(if new-version
|
||||||
|
(version< cur-version new-version)
|
||||||
|
(cl-pushnew pkg-name configuration-layer--skipped-packages :test #'eq)
|
||||||
|
nil))))
|
||||||
|
|
||||||
(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."
|
||||||
|
@ -808,10 +815,12 @@ If called with a prefix argument ALWAYS-UPDATE, assume yes to update."
|
||||||
"--> fetching new package repository indexes...\n")
|
"--> fetching new package repository indexes...\n")
|
||||||
(spacemacs//redisplay)
|
(spacemacs//redisplay)
|
||||||
(package-refresh-contents)
|
(package-refresh-contents)
|
||||||
|
(setq configuration-layer--skipped-packages nil)
|
||||||
(let* ((update-packages
|
(let* ((update-packages
|
||||||
(configuration-layer//get-packages-to-update
|
(configuration-layer//get-packages-to-update
|
||||||
(mapcar 'car (object-assoc-list
|
(mapcar 'car (object-assoc-list
|
||||||
:name configuration-layer--used-distant-packages))))
|
:name configuration-layer--used-distant-packages))))
|
||||||
|
(skipped-count (length configuration-layer--skipped-packages))
|
||||||
(date (format-time-string "%y-%m-%d_%H.%M.%S"))
|
(date (format-time-string "%y-%m-%d_%H.%M.%S"))
|
||||||
(rollback-dir (expand-file-name
|
(rollback-dir (expand-file-name
|
||||||
(concat configuration-layer-rollback-directory
|
(concat configuration-layer-rollback-directory
|
||||||
|
@ -819,10 +828,22 @@ If called with a prefix argument ALWAYS-UPDATE, assume yes to update."
|
||||||
(upgrade-count (length update-packages))
|
(upgrade-count (length update-packages))
|
||||||
(upgraded-count 0)
|
(upgraded-count 0)
|
||||||
(update-packages-alist))
|
(update-packages-alist))
|
||||||
|
(when configuration-layer--skipped-packages
|
||||||
|
(spacemacs-buffer/append
|
||||||
|
(format (concat "--> Warning: cannot update %s package(s), possibly due"
|
||||||
|
" to a temporary network problem: %s\n")
|
||||||
|
skipped-count
|
||||||
|
(mapconcat #'symbol-name
|
||||||
|
configuration-layer--skipped-packages
|
||||||
|
" "))))
|
||||||
;; (message "packages to udpate: %s" update-packages)
|
;; (message "packages to udpate: %s" update-packages)
|
||||||
(if (> upgrade-count 0)
|
(if (> upgrade-count 0)
|
||||||
(if (and (not always-update)
|
(if (and (not always-update)
|
||||||
(not (yes-or-no-p (format (concat "%s package(s) to update, "
|
(not (yes-or-no-p (format (concat "%s package(s) to update, "
|
||||||
|
(if (> skipped-count 0)
|
||||||
|
(format "%s package(s) skipped, "
|
||||||
|
skipped-count)
|
||||||
|
"")
|
||||||
"do you want to continue ? ")
|
"do you want to continue ? ")
|
||||||
upgrade-count))))
|
upgrade-count))))
|
||||||
(spacemacs-buffer/append
|
(spacemacs-buffer/append
|
||||||
|
|
Reference in a new issue