diff --git a/core/core-configuration-layer.el b/core/core-configuration-layer.el index 3028f5ec1..190b4025c 100644 --- a/core/core-configuration-layer.el +++ b/core/core-configuration-layer.el @@ -205,6 +205,16 @@ cache folder.") (add-to-list 'package-archives '("marmalade" . "https://marmalade-repo.org/packages/"))))) +(defun configuration-layer//install-quelpa () + "Install `quelpa'." + (setq quelpa-verbose init-file-debug + quelpa-dir (concat spacemacs-cache-directory "quelpa/") + quelpa-build-dir (expand-file-name "build" quelpa-dir) + quelpa-persistent-cache-file (expand-file-name "cache" quelpa-dir) + quelpa-update-melpa-p nil) + (configuration-layer/load-or-install-protected-package 'package-build) + (configuration-layer/load-or-install-protected-package 'quelpa)) + (defun configuration-layer//resolve-package-archives (archives) "Resolve HTTP handlers for each archive in ARCHIVES and return a list of all reachable ones. @@ -972,6 +982,7 @@ path." (if layer "package" "dependency") pkg-name (if layer (format "@%S" layer) "") installed-count noinst-count) t) + (spacemacs//redisplay) (unless (package-installed-p pkg-name) (condition-case-unless-debug err (cond @@ -987,7 +998,8 @@ path." (configuration-layer//increment-error-count) (spacemacs-buffer/append (format (concat "\nAn error occurred while installing %s " - "(error: %s)\n") pkg-name err))))))) + "(error: %s)\n") pkg-name err)) + (spacemacs//redisplay)))))) (defun configuration-layer//lazy-install-p (layer-name) "Return non nil if the layer with LAYER-NAME should be lazy installed." @@ -1033,6 +1045,8 @@ path." (defun configuration-layer//install-packages (packages) "Install PACKAGES which are not lazy installed." (interactive) + ;; ensure we have quelpa available first + (configuration-layer//install-quelpa) (let* ((noinst-pkg-names (configuration-layer//get-uninstalled-packages (mapcar 'car (object-assoc-list :name packages)))) @@ -1045,11 +1059,11 @@ path." noinst-count)) (configuration-layer/retrieve-package-archives) (setq installed-count 0) + (spacemacs//redisplay) (dolist (pkg-name noinst-pkg-names) (setq installed-count (1+ installed-count)) (configuration-layer//install-package - (object-assoc pkg-name :name configuration-layer--packages)) - (spacemacs//redisplay)) + (object-assoc pkg-name :name configuration-layer--packages))) (spacemacs-buffer/append "\n")))) (defun configuration-layer//install-from-elpa (pkg-name) @@ -1663,6 +1677,41 @@ to select one." (configuration-layer//insert-lazy-install-form layer-name (car x) (cdr x)))))) +(defun configuration-layer/load-or-install-protected-package + (pkg &optional log file-to-load) + "Load PKG package, and protect it against being deleted as an orphan. +See `configuration-layer/load-or-install-package' for more information." + (push pkg configuration-layer--protected-packages) + (configuration-layer/load-or-install-package pkg log file-to-load)) + +(defun configuration-layer/load-or-install-package + (pkg &optional log file-to-load) + "Load PKG package. PKG will be installed if it is not already installed. +Whenever the initial require fails the absolute path to the package +directory is returned. +If LOG is non-nil a message is displayed in spacemacs-buffer-mode buffer. +FILE-TO-LOAD is an explicit file to load after the installation." + (let ((warning-minimum-level :error)) + (unless (require pkg nil 'noerror) + ;; not installed, we try to initialize package.el only if required to + ;; precious seconds during boot time + (require 'cl) + (let ((pkg-elpa-dir (spacemacs//get-package-directory pkg))) + (if pkg-elpa-dir + (add-to-list 'load-path pkg-elpa-dir) + ;; install the package + (when log + (spacemacs-buffer/append + (format "(Bootstrap) Installing %s...\n" pkg)) + (spacemacs//redisplay)) + (configuration-layer/retrieve-package-archives 'quiet) + (package-install pkg) + (setq pkg-elpa-dir (spacemacs//get-package-directory pkg))) + (require pkg nil 'noerror) + (when file-to-load + (load-file (concat pkg-elpa-dir file-to-load))) + pkg-elpa-dir)))) + (defun configuration-layer//increment-error-count () "Increment the error counter." (if configuration-layer-error-count diff --git a/core/core-funcs.el b/core/core-funcs.el index 745e49dbf..9b741f24a 100644 --- a/core/core-funcs.el +++ b/core/core-funcs.el @@ -25,39 +25,6 @@ ;; ns is returned instead of mac on Emacs 25+ (memq (window-system) '(mac ns))) -(defun spacemacs/load-or-install-protected-package (pkg &optional log file-to-load) - "Load PKG package, and protect it against being deleted as an orphan. -See `spacemacs/load-or-install-package' for more information." - (push pkg configuration-layer--protected-packages) - (spacemacs/load-or-install-package pkg log file-to-load)) - -(defun spacemacs/load-or-install-package (pkg &optional log file-to-load) - "Load PKG package. PKG will be installed if it is not already installed. -Whenever the initial require fails the absolute path to the package -directory is returned. -If LOG is non-nil a message is displayed in spacemacs-buffer-mode buffer. -FILE-TO-LOAD is an explicit file to load after the installation." - (let ((warning-minimum-level :error)) - (unless (require pkg nil 'noerror) - ;; not installed, we try to initialize package.el only if required to - ;; precious seconds during boot time - (require 'cl) - (let ((pkg-elpa-dir (spacemacs//get-package-directory pkg))) - (if pkg-elpa-dir - (add-to-list 'load-path pkg-elpa-dir) - ;; install the package - (when log - (spacemacs-buffer/append - (format "(Bootstrap) Installing %s...\n" pkg)) - (spacemacs//redisplay)) - (configuration-layer/retrieve-package-archives 'quiet) - (package-install pkg) - (setq pkg-elpa-dir (spacemacs//get-package-directory pkg))) - (require pkg nil 'noerror) - (when file-to-load - (load-file (concat pkg-elpa-dir file-to-load))) - pkg-elpa-dir)))) - (defun spacemacs//get-package-directory (pkg) "Return the directory of PKG. Return nil if not found." (let ((elpa-dir (file-name-as-directory package-user-dir))) diff --git a/core/core-spacemacs.el b/core/core-spacemacs.el index b482751c3..87e9a545b 100644 --- a/core/core-spacemacs.el +++ b/core/core-spacemacs.el @@ -139,7 +139,7 @@ (spacemacs-buffer/set-mode-line "Dotfile wizard installer") (spacemacs//redisplay) (when (dotspacemacs/install 'with-wizard) - (dotspacemacs/sync-configuration-layers '(16))))) + (configuration-layer/sync)))) (defun spacemacs/display-and-copy-version () "Echo the current spacemacs version and copy it." diff --git a/core/core-themes-support.el b/core/core-themes-support.el index 069e95a0b..d15afa19e 100644 --- a/core/core-themes-support.el +++ b/core/core-themes-support.el @@ -195,7 +195,7 @@ package name does not match theme name + `-theme' suffix.") (eq 'zonokai-red theme) (eq 'solarized-light theme) (eq 'solarized-dark theme)) - (spacemacs/load-or-install-package 'dash)) + (configuration-layer/load-or-install-package 'dash)) ;; Unless Emacs stock themes (unless (or (memq theme (custom-available-themes)) (eq 'default theme)) @@ -203,7 +203,7 @@ package name does not match theme name + `-theme' suffix.") ;; themes with explicitly declared package names ((assq theme spacemacs-theme-name-to-package) (let* ((pkg (spacemacs//get-theme-package theme)) - (pkg-dir (spacemacs/load-or-install-package pkg))) + (pkg-dir (configuration-layer/load-or-install-package pkg))) (when (or (eq 'moe-light theme) (eq 'moe-dark theme)) (load-file (concat pkg-dir "moe-light-theme.el")) @@ -215,7 +215,7 @@ package name does not match theme name + `-theme' suffix.") ;; if not we will handle the special themes as we get issues ;; in the tracker. (let ((pkg (spacemacs//get-theme-package theme))) - (spacemacs/load-or-install-package pkg)))))) + (configuration-layer/load-or-install-package pkg)))))) ('error (setq theme 'default) (display-warning 'spacemacs diff --git a/layers/+distribution/spacemacs-bootstrap/packages.el b/layers/+distribution/spacemacs-bootstrap/packages.el index 48bf39d59..59623cd0a 100644 --- a/layers/+distribution/spacemacs-bootstrap/packages.el +++ b/layers/+distribution/spacemacs-bootstrap/packages.el @@ -17,8 +17,6 @@ (evil :step bootstrap) (f :step bootstrap) (hydra :step bootstrap) - (package-build :step bootstrap) - (quelpa :step bootstrap) (s :step bootstrap) (use-package :step bootstrap) (which-key :step bootstrap) @@ -212,14 +210,6 @@ (setq hydra-key-doc-function 'spacemacs//hydra-key-doc-function hydra-head-format "[%s] ")) -(defun spacemacs-bootstrap/init-quelpa () - (setq quelpa-verbose init-file-debug - quelpa-dir (concat spacemacs-cache-directory "quelpa/") - quelpa-build-dir (expand-file-name "build" quelpa-dir) - quelpa-persistent-cache-file (expand-file-name "cache" quelpa-dir) - quelpa-update-melpa-p nil) - (require 'quelpa)) - (defun spacemacs-bootstrap/init-use-package () (require 'use-package) (setq use-package-verbose init-file-debug