New update method

- backup the packages to be updated
- then delete them
- the user restart emacs and spacemacs will install the last version

Fixes some update errors related to byte-compilation like the one
which affected the powerline (void variable left)

This commit also adds some page break for clarity
This commit is contained in:
syl20bnr 2015-04-02 22:23:16 -04:00
parent 61dce32ad6
commit 5f7579867a
3 changed files with 13 additions and 18 deletions

View File

@ -449,6 +449,7 @@ If PRE is non nil then `layer-pre-extensions' is read instead of
(defun configuration-layer/update-packages ()
"Upgrade elpa packages"
(interactive)
(spacemacs/insert-page-break)
(spacemacs/append-to-buffer
"\nUpdating Spacemacs... (for now only ELPA packages are updated)\n")
(spacemacs/append-to-buffer
@ -472,7 +473,7 @@ If PRE is non nil then `layer-pre-extensions' is read instead of
"Packages update has been cancelled.\n")
;; backup the package directory and construct an alist
;; variable to be cached for easy update and rollback
(spacemacs/replace-last-line-of-buffer
(spacemacs/append-to-buffer
"--> performing backup of package(s) to update...\n" t)
(spacemacs//redisplay)
(dolist (pkg update-packages)
@ -491,25 +492,14 @@ If PRE is non nil then `layer-pre-extensions' is read instead of
(dolist (pkg update-packages)
(setq upgraded-count (1+ upgraded-count))
(spacemacs/replace-last-line-of-buffer
(format "--> updating package %s... [%s/%s]"
(format "--> preparing update of package %s... [%s/%s]"
pkg upgraded-count upgrade-count) t)
(spacemacs//redisplay)
(configuration-layer//package-delete pkg)
(condition-case err (package-install pkg)
('error
(message (format
(concat "An error occurred during the update of "
"this package %s, retrying one more time...")
err))
(package-install pkg)))
(when (version< emacs-version "24.3.50")
;; explicitly force activation
(setq package-activated-list (delq pkg package-activated-list))
(configuration-layer//activate-package pkg)))
(configuration-layer//package-delete pkg))
(spacemacs/append-to-buffer
(format "\n--> %s packages updated.\n" upgraded-count))
(format "\n--> %s package(s) to be updated.\n" upgraded-count))
(spacemacs/append-to-buffer
"\nEmacs has to be restarted for the changes to take effect.\n")
"\nEmacs has to be restarted to actually install the new packages.\n")
(spacemacs//redisplay))
(spacemacs/append-to-buffer "--> All packages are up to date.\n")
(spacemacs//redisplay))))
@ -539,6 +529,7 @@ to select one."
(when candidates
(ido-completing-read "Rollback slots (most recent are first): "
candidates))))))
(spacemacs/insert-page-break)
(if (not slot)
(message "No rollback slot available.")
(string-match "^\\(.+?\\)\s.*$" slot)

View File

@ -112,6 +112,10 @@ buffer, right justified."
"Display MSG in message prepended with '(Spacemacs)'."
(message "(Spacemacs) %s" (apply 'format msg args)))
(defun spacemacs/insert-page-break ()
"Insert a page break line in spacemacs buffer."
(spacemacs/append-to-buffer "\n \n\n"))
(defun spacemacs/append-to-buffer (msg &optional messagebuf)
"Append MSG to spacemacs buffer. If MESSAGEBUF is not nil then MSG is
also written in message buffer."
@ -195,7 +199,7 @@ buffer, right justified."
(list-separator "\n\n"))
(goto-char (point-max))
(page-break-lines-mode)
(spacemacs/append-to-buffer "\n \n\n")
(spacemacs/insert-page-break)
(mapc (lambda (el)
(cond
((eq el 'recents)

View File

@ -348,7 +348,7 @@ version and the NEW version."
;; (vc-mode vc-mode)
;; " " mode-line-modes mode-line-misc-info mode-line-end-spaces
(spacemacs/set-mode-line
(format (concat "%s errors at startup! "
(format (concat "%s error(s) at startup! "
"Spacemacs may not be able to operate properly.")
configuration-layer-error-count))
(force-mode-line-update))