doom upgrade: delete straight if recipe changed
By deleting straight, the latest pinned version will be reinstalled on the second part of the 'doom upgrade' process. This is a clumsy fix for a catch 22 where using straight to update straight would break due to backwards incompatibilities (see #4950). This will do while we wait for the CLI rewrite.
This commit is contained in:
parent
d4dec35658
commit
48322af020
1 changed files with 26 additions and 3 deletions
|
@ -44,6 +44,16 @@ following shell commands:
|
||||||
(split-string stdout "\n" t)
|
(split-string stdout "\n" t)
|
||||||
(error "Failed to check working tree in %s" dir))))
|
(error "Failed to check working tree in %s" dir))))
|
||||||
|
|
||||||
|
(defun doom--get-straight-recipe ()
|
||||||
|
(with-temp-buffer
|
||||||
|
(insert-file-contents (doom-path doom-core-dir "packages.el"))
|
||||||
|
(when (re-search-forward "(package! straight" nil t)
|
||||||
|
(goto-char (match-beginning 0))
|
||||||
|
(let ((sexp (sexp-at-point)))
|
||||||
|
(plist-put sexp :recipe
|
||||||
|
(eval (plist-get sexp :recipe)
|
||||||
|
t))))))
|
||||||
|
|
||||||
|
|
||||||
(defun doom-cli-upgrade (&optional auto-accept-p force-p)
|
(defun doom-cli-upgrade (&optional auto-accept-p force-p)
|
||||||
"Upgrade Doom to the latest version non-destructively."
|
"Upgrade Doom to the latest version non-destructively."
|
||||||
|
@ -116,9 +126,22 @@ following shell commands:
|
||||||
(print! (start "Upgrading Doom Emacs..."))
|
(print! (start "Upgrading Doom Emacs..."))
|
||||||
(print-group!
|
(print-group!
|
||||||
(doom-clean-byte-compiled-files)
|
(doom-clean-byte-compiled-files)
|
||||||
(or (and (zerop (car (doom-call-process "git" "reset" "--hard" target-remote)))
|
(let ((straight-recipe (doom--get-straight-recipe)))
|
||||||
(equal (cdr (doom-call-process "git" "rev-parse" "HEAD")) new-rev))
|
(or (and (zerop (car (doom-call-process "git" "reset" "--hard" target-remote)))
|
||||||
(error "Failed to check out %s" (substring new-rev 0 10)))
|
(equal (cdr (doom-call-process "git" "rev-parse" "HEAD")) new-rev))
|
||||||
|
(error "Failed to check out %s" (substring new-rev 0 10)))
|
||||||
|
;; HACK It's messy to use straight to upgrade straight, due
|
||||||
|
;; to the potential for backwards incompatibility, so
|
||||||
|
;; we staticly check if Doom's `package!' declaration
|
||||||
|
;; for straight has changed. If it has, delete
|
||||||
|
;; straight so 'doom upgrade's second stage will
|
||||||
|
;; install the new version for us.
|
||||||
|
;;
|
||||||
|
;; Clumsy, but a better solution is in the works.
|
||||||
|
(unless (equal straight-recipe (doom--get-straight-recipe))
|
||||||
|
(print! (info "Preparing straight for an update"))
|
||||||
|
(delete-directory (doom-path straight-base-dir "straight/repos/straight.el")
|
||||||
|
'recursive)))
|
||||||
(print! (info "%s") (cdr result))
|
(print! (info "%s") (cdr result))
|
||||||
t))))))
|
t))))))
|
||||||
(ignore-errors
|
(ignore-errors
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue